Обсуждение: Order of InvokeObjectPostAlterHook within ATExecSetNotNull
Hello hackers! The commit 14e87ff added pg_constraint rows for not-null [1]. The consequence of the patch is that it changed the order of InvokeObjectPostAlterHook() call and update of "attnotnull" field in the catalog. Before the update was before the call of the hook [2]. And now "attnotnull" is updated after the call of InvokeObjectPostAlterHook() [3]. This is a noticeable change to extensions which use "object_access_hook" since they see a bit of stale information about the attribute. Is this an intended behavior or rather a bug? 1 - https://postgr.es/m/202408310358.sdhumtyuy2ht@alvherre.pgsql 2 - https://github.com/postgres/postgres/blob/REL_17_9/src/backend/commands/tablecmds.c#L7818 3 - https://github.com/postgres/postgres/blob/REL_18_1/src/backend/commands/tablecmds.c#L8043-L8047 -- Kind regards, Artur
On 2026-Mar-18, Artur Zakirov wrote: > Hello hackers! > > The commit 14e87ff added pg_constraint rows for not-null [1]. The > consequence of the patch is that it changed the order of > InvokeObjectPostAlterHook() call and update of "attnotnull" field in > the catalog. Before the update was before the call of the hook [2]. > And now "attnotnull" is updated after the call of > InvokeObjectPostAlterHook() [3]. > > This is a noticeable change to extensions which use > "object_access_hook" since they see a bit of stale information about > the attribute. > > Is this an intended behavior or rather a bug? This was not intentional. Want to submit a patch? -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
On Wed, 18 Mar 2026 at 17:34, Álvaro Herrera <alvherre@kurilemu.de> wrote: > > > > Is this an intended behavior or rather a bug? > > This was not intentional. Want to submit a patch? > > -- > Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ Thank you for the quick response. Sure, I attached the patch for the main branch and for REL_18_STABLE just in case, although the main patch also should apply to REL_18_STABLE. I think we might need to backpatch it to PG 18 too where the change was introduced. -- Kind regards, Artur
Вложения
On 2026-Mar-18, Artur Zakirov wrote: > Thank you for the quick response. Sure, I attached the patch for the > main branch and for REL_18_STABLE just in case, although the main > patch also should apply to REL_18_STABLE. > I think we might need to backpatch it to PG 18 too where the change > was introduced. Thanks, this is clearly my mistake -- pushed to both branches. (I didn't use the patch you sent for 18, just the one for master, which I then cherry-picked into 18. I would say that it's not necessary to submit a version specific to a branch when the one for master cherry-picks cleanly.) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/