Re: Rename of triggers for partitioned tables
Zhihong Yu <zyu@yugabyte.com>
From: Zhihong Yu <zyu@yugabyte.com>
To: Arne Roland <A.Roland@index.de>, PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2021-06-28T19:22:17Z
Lists: pgsql-hackers
On Mon, Jun 28, 2021 at 11:45 AM Arne Roland <A.Roland@index.de> wrote: > Hi, > > *From:* Zhihong Yu <zyu@yugabyte.com> > *Sent:* Monday, June 28, 2021 15:28 > *Subject:* Re: Rename of triggers for partitioned tables > > > - void *arg) > > +callbackForRenameTrigger(char *relname, Oid relid) > > > > Since this method is only called by RangeVarCallbackForRenameTrigger(), > it seems the method can be folded into RangeVarCallbackForRenameTrigger. > > that seems obvious. I have no idea why I didn't do that. > > > + * renametrig - changes the name of a trigger on a possibly > partitioned relation recurisvely > > ... > > +renametrigHelper(RenameStmt *stmt, Oid tgoid, Oid relid) > > > > Comment doesn't match the name of method. I think it is better to use _ > instead of camel case. > > The other functions in this file seem to be in mixed case (camel case with > lower first character). I don't have a strong point either way, but the > consistency seems to be worth it to me. > > > -renametrig(RenameStmt *stmt) > > +renameonlytrig(RenameStmt *stmt, Relation tgrel, Oid relid, Oid > tgparent) > > > > Would renametrig_unlocked be better name for the method ? > > I think the name renametrig_unlocked might be confusing. I am not sure my > name is good. But upon calling this function everything is locked already > and stays locked. So unlocked seems a confusing name to me. > renameOnlyOneTriggerWithoutAccountingForChildrenWhereAllLocksAreAquiredAlready > sadly isn't very concise anymore. Do you have another idea? > > > strcmp(stmt->subname, NameStr(trigform->tgname)) can be saved in a > variable since it is used after the if statement. > > It's always needed later. I did miss it due to the short circuiting > expression. Thanks! > > > + tgrel = table_open(TriggerRelationId, RowExclusiveLock); > > ... > > + ReleaseSysCache(tuple); /* We are still holding the > > + * AccessExclusiveLock. */ > > > > The lock mode in comment doesn't seem to match the lock taken. > > I made the comment slightly more verbose. I hope it's clear now. > > Thank you very much for the feedback! I attached a new version of the > patch based on your suggestions. > > Regards > Arne > > Adding mailing list.
Commits
-
Remove newly added useless assertion check
- 21b3aa9c8faf 15.0 landed
-
Make ALTER TRIGGER RENAME consistent for partitioned tables
- 80ba4bb38353 15.0 landed
-
Fix pg_dump for disabled triggers on partitioned tables
- ccfc3cbb341a 11.13 cited
-
Preserve firing-on state when cloning row triggers to partitions
- fed35bd4a650 11.13 cited
-
Fix ALTER TABLE .. ENABLE/DISABLE TRIGGER recursion
- bbb927b4db9b 14.0 cited
-
Record parents of triggers
- b9b408c48724 13.0 cited
-
Allow FOR EACH ROW triggers on partitioned tables
- 86f575948c77 11.0 cited