public inbox for [email protected]  
help / color / mirror / Atom feed
From: Artur Zakirov <[email protected]>
To: Álvaro Herrera <[email protected]>
Cc: Postgres hackers <[email protected]>
Subject: Re: Order of InvokeObjectPostAlterHook within ATExecSetNotNull
Date: Wed, 18 Mar 2026 17:55:25 +0100
Message-ID: <CAKNkYnzAKjibTv4HVPxY4FgPp7W0cX2zToo+DjUF93CLMMq6Sg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAKNkYnxUPCJk-3Xe0A3rmCC8B8V8kqVJbYMVN6ySGpjs_qd7dQ@mail.gmail.com>
	<[email protected]>

On Wed, 18 Mar 2026 at 17:34, Álvaro Herrera <[email protected]> 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


Attachments:

  [application/octet-stream] object_access_hook_attnotnull_order_18.patch (786B, 2-object_access_hook_attnotnull_order_18.patch)
  download | inline diff:
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index dd2b4a51076..9b0aad95a0a 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8050,12 +8050,12 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
 	ccon = linitial(cooked);
 	ObjectAddressSet(address, ConstraintRelationId, ccon->conoid);
 
-	InvokeObjectPostAlterHook(RelationRelationId,
-							  RelationGetRelid(rel), attnum);
-
 	/* Mark pg_attribute.attnotnull for the column and queue validation */
 	set_attnotnull(wqueue, rel, attnum, true, true);
 
+	InvokeObjectPostAlterHook(RelationRelationId,
+							  RelationGetRelid(rel), attnum);
+
 	/*
 	 * Recurse to propagate the constraint to children that don't have one.
 	 */


  [application/octet-stream] object_access_hook_attnotnull_order.patch (786B, 3-object_access_hook_attnotnull_order.patch)
  download | inline diff:
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 67e42e5df29..a5ac38578f6 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8137,12 +8137,12 @@ ATExecSetNotNull(List **wqueue, Relation rel, char *conName, char *colName,
 	ccon = linitial(cooked);
 	ObjectAddressSet(address, ConstraintRelationId, ccon->conoid);
 
-	InvokeObjectPostAlterHook(RelationRelationId,
-							  RelationGetRelid(rel), attnum);
-
 	/* Mark pg_attribute.attnotnull for the column and queue validation */
 	set_attnotnull(wqueue, rel, attnum, true, true);
 
+	InvokeObjectPostAlterHook(RelationRelationId,
+							  RelationGetRelid(rel), attnum);
+
 	/*
 	 * Recurse to propagate the constraint to children that don't have one.
 	 */


view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Order of InvokeObjectPostAlterHook within ATExecSetNotNull
  In-Reply-To: <CAKNkYnzAKjibTv4HVPxY4FgPp7W0cX2zToo+DjUF93CLMMq6Sg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox