agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v5 07/12] consistent language: to which
15+ messages / 6 participants
[nested] [flat]

* [PATCH v5 07/12] consistent language: to which
@ 2019-05-21 00:02  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Justin Pryzby @ 2019-05-21 00:02 UTC (permalink / raw)

XXX: should have trailing period in tables?
---
 doc/src/sgml/monitoring.sgml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index cba36c0..df5df62 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -602,12 +602,12 @@ postgres   27093  0.0  0.0  30096  2752 ?        Ss   11:34   0:00 postgres: ser
     <row>
      <entry><structfield>datid</structfield></entry>
      <entry><type>oid</type></entry>
-     <entry>OID of the database this backend is connected to</entry>
+     <entry>OID of the database to which this backend is connected</entry>
     </row>
     <row>
      <entry><structfield>datname</structfield></entry>
      <entry><type>name</type></entry>
-     <entry>Name of the database this backend is connected to</entry>
+     <entry>Name of the database to which this backend is connected</entry>
     </row>
     <row>
      <entry><structfield>pid</structfield></entry>
@@ -2099,7 +2099,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
      <entry><type>text</type></entry>
      <entry>
       Host of the <productname>PostgreSQL</productname> instance
-      this WAL receiver is connected to. This can be a host name,
+      to which this WAL receiver is connected. This can be a host name,
       an IP address, or a directory path if the connection is via
       Unix socket.  (The path case can be distinguished because it
       will always be an absolute path, beginning with <literal>/</literal>.)
@@ -2110,7 +2110,7 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
      <entry><type>integer</type></entry>
      <entry>
       Port number of the <productname>PostgreSQL</productname> instance
-      this WAL receiver is connected to.
+      to which this WAL receiver is connected.
      </entry>
     </row>
     <row>
@@ -3375,7 +3375,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
      <row>
       <entry><literal><function>pg_stat_get_backend_dbid(integer)</function></literal></entry>
       <entry><type>oid</type></entry>
-      <entry>OID of the database this backend is connected to</entry>
+      <entry>OID of the database to which this backend is connected</entry>
      </row>
 
      <row>
-- 
2.7.4


--FkmkrVfFsRoUs1wW
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
 filename="v5-0008-Consistent-language-contains.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v14 1/2] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e28335915..7c3bfde571 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--6opfqulj2xnxqhkn
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v14-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v16 1/3] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e28335915..7c3bfde571 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--arayebouu3vhq6bx
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v16-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v15 1/2] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e28335915..7c3bfde571 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--icqk4nrzalktuh5g
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v15-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e08ca1c68..7234cb3da6 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--u5bqxbslpyv5rwih
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v17-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e08ca1c68..7234cb3da6 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--u5bqxbslpyv5rwih
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v17-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v15 1/2] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e28335915..7c3bfde571 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--icqk4nrzalktuh5g
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v15-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v13 1/2] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8a08463c2b..b5a99b4edc 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4788,19 +4788,28 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.  XXX does this cause other problems?
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--57gotikuhuh4be5c
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v13-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid
@ 2023-07-12 16:57  Alvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Alvaro Herrera @ 2023-07-12 16:57 UTC (permalink / raw)

---
 src/backend/utils/cache/relcache.c | 34 ++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 8e08ca1c68..7234cb3da6 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4789,19 +4789,41 @@ RelationGetIndexList(Relation relation)
 		result = lappend_oid(result, index->indexrelid);
 
 		/*
-		 * Invalid, non-unique, non-immediate or predicate indexes aren't
-		 * interesting for either oid indexes or replication identity indexes,
-		 * so don't check them.
+		 * Non-unique, non-immediate or predicate indexes aren't interesting
+		 * for either oid indexes or replication identity indexes, so don't
+		 * check them.
 		 */
-		if (!index->indisvalid || !index->indisunique ||
+		if (!index->indisunique ||
 			!index->indimmediate ||
 			!heap_attisnull(htup, Anum_pg_index_indpred, NULL))
 			continue;
 
-		/* remember primary key index if any */
-		if (index->indisprimary)
+		/*
+		 * Remember primary key index, if any.  We do this only if the index
+		 * is valid; but if the table is partitioned, then we do it even if
+		 * it's invalid.
+		 *
+		 * The reason for returning invalid primary keys for foreign tables is
+		 * because of pg_dump of NOT NULL constraints, and the fact that PKs
+		 * remain marked invalid until the partitions' PKs are attached to it.
+		 * If we make rd_pkindex invalid, then the attnotnull flag is reset
+		 * after the PK is created, which causes the ALTER INDEX ATTACH
+		 * PARTITION to fail with 'column ... is not marked NOT NULL'.  With
+		 * this, dropconstraint_internal() will believe that the columns must
+		 * not have attnotnull reset, so the PKs-on-partitions can be attached
+		 * correctly, until finally the PK-on-parent is marked valid.
+		 *
+		 * Also, this doesn't harm anything, because rd_pkindex is not a
+		 * "real" index anyway, but a RELKIND_PARTITIONED_INDEX.
+		 */
+		if (index->indisprimary &&
+			(index->indisvalid ||
+			 relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE))
 			pkeyIndex = index->indexrelid;
 
+		if (!index->indisvalid)
+			continue;
+
 		/* remember explicitly chosen replica index */
 		if (index->indisreplident)
 			candidateIndex = index->indexrelid;
-- 
2.39.2


--u5bqxbslpyv5rwih
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v17-0002-Add-pg_constraint-rows-for-NOT-NULL-constraints.patch"



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v3a] edit comments and stuff
@ 2026-01-05 14:26  Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Álvaro Herrera @ 2026-01-05 14:26 UTC (permalink / raw)

---
 src/backend/utils/sort/tuplesort.c     |   2 +-
 src/include/executor/instrument_node.h | 146 ++++++++++++-------------
 src/include/utils/tuplesort.h          |  15 ---
 3 files changed, 73 insertions(+), 90 deletions(-)

diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 473d31188b8..9e4cd816137 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -200,7 +200,7 @@ struct Tuplesortstate
 	int64		maxSpace;		/* maximum amount of space occupied among sort
 								 * of groups, either in-memory or on-disk */
 	bool		isMaxSpaceDisk; /* true when maxSpace is value for on-disk
-								 * space, false when its value for in-memory
+								 * space, false when it's value for in-memory
 								 * space */
 	TupSortStatus maxSpaceStatus;	/* sort status when maxSpace was reached */
 	LogicalTapeSet *tapeset;	/* logtape.c object for tapes in a temp file */
diff --git a/src/include/executor/instrument_node.h b/src/include/executor/instrument_node.h
index 75520008c36..49627eb4a27 100644
--- a/src/include/executor/instrument_node.h
+++ b/src/include/executor/instrument_node.h
@@ -1,8 +1,12 @@
 /*-------------------------------------------------------------------------
  *
  * instrument_node.h
- *	  Definitions for node-specific instrumentation
+ *	  Definitions for node-specific support for parallel query instrumentation
  *
+ * These structs purposely contain no pointers because they are copied
+ * across processes during parallel query execution.  Each worker copies its
+ * individual information into the container struct at executor shutdown time,
+ * to allow the leader to display the information in EXPLAIN ANALYZE.
  *
  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
@@ -15,32 +19,30 @@
 #define INSTRUMENT_NODE_H
 
 
-
 /* ---------------------
- * per-worker aggregate information
+ *	Instrumentation information for aggregate function execution
  * ---------------------
  */
 typedef struct AggregateInstrumentation
 {
-	Size	hash_mem_peak; /* peak hash table memory usage */
-	uint64	hash_disk_used; /*kB of disk space used */
-	int		hash_batches_used; /* batches used during entire execution */
+	Size		hash_mem_peak;	/* peak hash table memory usage */
+	uint64		hash_disk_used; /* kB of disk space used */
+	int			hash_batches_used;	/* batches used during entire execution */
 } AggregateInstrumentation;
 
-/* ----------------
- *    Shared memory container for per-worker aggregate information
- * ----------------
+/*
+ * Shared memory container for per-worker aggregate information
  */
 typedef struct SharedAggInfo
 {
-	int	num_workers;
+	int			num_workers;
 	AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedAggInfo;
-/*
- * Struct for statistics maintained by amgettuple and amgetbitmap
- *
- * Note: IndexScanInstrumentation can't contain any pointers, since it is
- * copied into a SharedIndexScanInstrumentation during parallel scans
+
+
+/* ---------------------
+ *	Instrumentation information for indexscans (amgettuple and amgetbitmap)
+ * ---------------------
  */
 typedef struct IndexScanInstrumentation
 {
@@ -49,7 +51,7 @@ typedef struct IndexScanInstrumentation
 } IndexScanInstrumentation;
 
 /*
- * Struct for every worker's IndexScanInstrumentation, stored in shared memory
+ * Shared memory container for per-worker information
  */
 typedef struct SharedIndexScanInstrumentation
 {
@@ -57,11 +59,13 @@ typedef struct SharedIndexScanInstrumentation
 	IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedIndexScanInstrumentation;
 
-/*
- *	 BitmapHeapScanInstrumentation information
+
+/* ---------------------
+ *	Instrumentation information for bitmap heap scans
  *
  *		exact_pages		   total number of exact pages retrieved
  *		lossy_pages		   total number of lossy pages retrieved
+ * ---------------------
  */
 typedef struct BitmapHeapScanInstrumentation
 {
@@ -70,11 +74,7 @@ typedef struct BitmapHeapScanInstrumentation
 } BitmapHeapScanInstrumentation;
 
 /*
- *	 Instrumentation data for a parallel bitmap heap scan.
- *
- * A shared memory struct that each parallel worker copies its
- * BitmapHeapScanInstrumentation information into at executor shutdown to
- * allow the leader to display the information in EXPLAIN ANALYZE.
+ * Shared memory container for per-worker information
  */
 typedef struct SharedBitmapHeapInstrumentation
 {
@@ -83,25 +83,27 @@ typedef struct SharedBitmapHeapInstrumentation
 } SharedBitmapHeapInstrumentation;
 
 
+/* ---------------------
+ *	Instrumentation information for Memoize
+ * ---------------------
+ */
 typedef struct MemoizeInstrumentation
 {
-	uint64 cache_hits;		/* number of rescans where we've found the
-							 * scan parameters values to be cached */
-	uint64 cache_misses;	/* number of rescans where we've not found the
-							 * scan parameters values to be cached */
-	uint64 cache_evictions;	/* number of cache entries removed due to
-							 * the need to free memory */
-	uint64 cache_overflows;	/* number of times we've had to bypass the
-							 * cache when filling it due to not being
-							 * able to free enough space to store the
-							 * current scan's tuples */
-	uint64	mem_peak;		/* peak memory usage in bytes */
-
+	uint64		cache_hits;		/* number of rescans where we've found the
+								 * scan parameters values to be cached */
+	uint64		cache_misses;	/* number of rescans where we've not found the
+								 * scan parameters values to be cached */
+	uint64		cache_evictions;	/* number of cache entries removed due to
+									 * the need to free memory */
+	uint64		cache_overflows;	/* number of times we've had to bypass the
+									 * cache when filling it due to not being
+									 * able to free enough space to store the
+									 * current scan's tuples */
+	uint64		mem_peak;		/* peak memory usage in bytes */
 } MemoizeInstrumentation;
 
-/* ----------------
- *  Shared memory container for per-worker memoize information
- *  ----------------
+/*
+ * Shared memory container for per-worker memoize information
  */
 typedef struct SharedMemoizeInfo
 {
@@ -110,27 +112,25 @@ typedef struct SharedMemoizeInfo
 } SharedMemoizeInfo;
 
 
-/*
- * Data structures for reporting sort statistics.  Note that
- * TuplesortInstrumentation can't contain any pointers because we
- * sometimes put it in shared memory.
- *
- * The parallel-sort infrastructure relies on having a zero TuplesortMethod
- * to indicate that a worker never did anything, so we assign zero to
- * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
- * OR'ed together to represent a situation where different workers used
- * different methods, so we need a separate bit for each one.  Keep the
- * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
+/* ---------------------
+ *	Instrumentation information for Sorts.
+ * ---------------------
  */
 
-#define NUM_TUPLESORTMETHODS 4
-
 typedef enum
 {
 	SORT_SPACE_TYPE_DISK,
 	SORT_SPACE_TYPE_MEMORY,
 } TuplesortSpaceType;
 
+/*
+ * The parallel-sort infrastructure relies on having a zero TuplesortMethod
+ * to indicate that a worker never did anything, so we assign zero to
+ * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
+ * OR'ed together to represent a situation where different workers used
+ * different methods, so we need a separate bit for each one.  Keep the
+ * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
+ */
 typedef enum
 {
 	SORT_TYPE_STILL_IN_PROGRESS = 0,
@@ -139,40 +139,40 @@ typedef enum
 	SORT_TYPE_EXTERNAL_SORT = 1 << 2,
 	SORT_TYPE_EXTERNAL_MERGE = 1 << 3
 } TuplesortMethod;
+#define NUM_TUPLESORTMETHODS 4
 
 typedef struct TuplesortInstrumentation
 {
-	TuplesortMethod sortMethod;		/* sort algorithm used */
+	TuplesortMethod sortMethod; /* sort algorithm used */
 	TuplesortSpaceType spaceType;	/* type of space spaceUsed represents */
-	int64       spaceUsed;			/* space consumption, in kB */
+	int64		spaceUsed;		/* space consumption, in kB */
 } TuplesortInstrumentation;
 
-/* ----------------
- *  Shared memory container for per-worker sort information
- *  ----------------
+/*
+ * Shared memory container for per-worker sort information
  */
 typedef struct SharedSortInfo
 {
-	int num_workers;
+	int			num_workers;
 	TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedSortInfo;
 
-/* ----------------
- *   Values displayed by EXPLAIN ANALYZE
- * ----------------
+
+/* ---------------------
+ *   Instrumentation information for nodeHash.c
+ * ---------------------
  */
 typedef struct HashInstrumentation
 {
-	int		nbuckets;			/* number of buckets at end of execution */
-	int		nbuckets_original;	/* planned number of buckets */
-	int		nbatch;				/* number of batches at end of execution */
-	int		nbatch_original;	/* planned number of batches */
-	Size	space_peak;			/* peak memory usage in bytes */
+	int			nbuckets;		/* number of buckets at end of execution */
+	int			nbuckets_original;	/* planned number of buckets */
+	int			nbatch;			/* number of batches at end of execution */
+	int			nbatch_original;	/* planned number of batches */
+	Size		space_peak;		/* peak memory usage in bytes */
 } HashInstrumentation;
 
-/* ----------------
- *   Shared memory container for per-worker hash information
- * ----------------
+/*
+ * Shared memory container for per-worker information
  */
 typedef struct SharedHashInfo
 {
@@ -180,9 +180,10 @@ typedef struct SharedHashInfo
 	HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedHashInfo;
 
-/* ----------------
+
+/* ---------------------
  *   Instrumentation information for IncrementalSort
- * ----------------
+ * ---------------------
  */
 typedef struct IncrementalSortGroupInfo
 {
@@ -200,10 +201,7 @@ typedef struct IncrementalSortInfo
 	IncrementalSortGroupInfo prefixsortGroupInfo;
 } IncrementalSortInfo;
 
-/* ----------------
- *   Shared memory container for per-worker incremental sort information
- * ----------------
- */
+/* Shared memory container for per-worker incremental sort information */
 typedef struct SharedIncrementalSortInfo
 {
 	int			num_workers;
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index a7e867f36b8..943a2b7dc93 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -62,21 +62,6 @@ typedef struct SortCoordinateData
 
 typedef struct SortCoordinateData *SortCoordinate;
 
-/*
- * Data structures for reporting sort statistics.  Note that
- * TuplesortInstrumentation can't contain any pointers because we
- * sometimes put it in shared memory.
- *
- * The parallel-sort infrastructure relies on having a zero TuplesortMethod
- * to indicate that a worker never did anything, so we assign zero to
- * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
- * OR'ed together to represent a situation where different workers used
- * different methods, so we need a separate bit for each one.  Keep the
- * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
- */
-
-#define NUM_TUPLESORTMETHODS 4
-
 /* Bitwise option flags for tuple sorts */
 #define TUPLESORT_NONE					0
 
-- 
2.47.3


--xs5il3t73pzvzpq7--





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* [PATCH v3a] edit comments and stuff
@ 2026-01-05 14:26  Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Álvaro Herrera @ 2026-01-05 14:26 UTC (permalink / raw)

---
 src/backend/utils/sort/tuplesort.c     |   2 +-
 src/include/executor/instrument_node.h | 146 ++++++++++++-------------
 src/include/utils/tuplesort.h          |  15 ---
 3 files changed, 73 insertions(+), 90 deletions(-)

diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 473d31188b8..9e4cd816137 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -200,7 +200,7 @@ struct Tuplesortstate
 	int64		maxSpace;		/* maximum amount of space occupied among sort
 								 * of groups, either in-memory or on-disk */
 	bool		isMaxSpaceDisk; /* true when maxSpace is value for on-disk
-								 * space, false when its value for in-memory
+								 * space, false when it's value for in-memory
 								 * space */
 	TupSortStatus maxSpaceStatus;	/* sort status when maxSpace was reached */
 	LogicalTapeSet *tapeset;	/* logtape.c object for tapes in a temp file */
diff --git a/src/include/executor/instrument_node.h b/src/include/executor/instrument_node.h
index 75520008c36..49627eb4a27 100644
--- a/src/include/executor/instrument_node.h
+++ b/src/include/executor/instrument_node.h
@@ -1,8 +1,12 @@
 /*-------------------------------------------------------------------------
  *
  * instrument_node.h
- *	  Definitions for node-specific instrumentation
+ *	  Definitions for node-specific support for parallel query instrumentation
  *
+ * These structs purposely contain no pointers because they are copied
+ * across processes during parallel query execution.  Each worker copies its
+ * individual information into the container struct at executor shutdown time,
+ * to allow the leader to display the information in EXPLAIN ANALYZE.
  *
  * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
@@ -15,32 +19,30 @@
 #define INSTRUMENT_NODE_H
 
 
-
 /* ---------------------
- * per-worker aggregate information
+ *	Instrumentation information for aggregate function execution
  * ---------------------
  */
 typedef struct AggregateInstrumentation
 {
-	Size	hash_mem_peak; /* peak hash table memory usage */
-	uint64	hash_disk_used; /*kB of disk space used */
-	int		hash_batches_used; /* batches used during entire execution */
+	Size		hash_mem_peak;	/* peak hash table memory usage */
+	uint64		hash_disk_used; /* kB of disk space used */
+	int			hash_batches_used;	/* batches used during entire execution */
 } AggregateInstrumentation;
 
-/* ----------------
- *    Shared memory container for per-worker aggregate information
- * ----------------
+/*
+ * Shared memory container for per-worker aggregate information
  */
 typedef struct SharedAggInfo
 {
-	int	num_workers;
+	int			num_workers;
 	AggregateInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedAggInfo;
-/*
- * Struct for statistics maintained by amgettuple and amgetbitmap
- *
- * Note: IndexScanInstrumentation can't contain any pointers, since it is
- * copied into a SharedIndexScanInstrumentation during parallel scans
+
+
+/* ---------------------
+ *	Instrumentation information for indexscans (amgettuple and amgetbitmap)
+ * ---------------------
  */
 typedef struct IndexScanInstrumentation
 {
@@ -49,7 +51,7 @@ typedef struct IndexScanInstrumentation
 } IndexScanInstrumentation;
 
 /*
- * Struct for every worker's IndexScanInstrumentation, stored in shared memory
+ * Shared memory container for per-worker information
  */
 typedef struct SharedIndexScanInstrumentation
 {
@@ -57,11 +59,13 @@ typedef struct SharedIndexScanInstrumentation
 	IndexScanInstrumentation winstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedIndexScanInstrumentation;
 
-/*
- *	 BitmapHeapScanInstrumentation information
+
+/* ---------------------
+ *	Instrumentation information for bitmap heap scans
  *
  *		exact_pages		   total number of exact pages retrieved
  *		lossy_pages		   total number of lossy pages retrieved
+ * ---------------------
  */
 typedef struct BitmapHeapScanInstrumentation
 {
@@ -70,11 +74,7 @@ typedef struct BitmapHeapScanInstrumentation
 } BitmapHeapScanInstrumentation;
 
 /*
- *	 Instrumentation data for a parallel bitmap heap scan.
- *
- * A shared memory struct that each parallel worker copies its
- * BitmapHeapScanInstrumentation information into at executor shutdown to
- * allow the leader to display the information in EXPLAIN ANALYZE.
+ * Shared memory container for per-worker information
  */
 typedef struct SharedBitmapHeapInstrumentation
 {
@@ -83,25 +83,27 @@ typedef struct SharedBitmapHeapInstrumentation
 } SharedBitmapHeapInstrumentation;
 
 
+/* ---------------------
+ *	Instrumentation information for Memoize
+ * ---------------------
+ */
 typedef struct MemoizeInstrumentation
 {
-	uint64 cache_hits;		/* number of rescans where we've found the
-							 * scan parameters values to be cached */
-	uint64 cache_misses;	/* number of rescans where we've not found the
-							 * scan parameters values to be cached */
-	uint64 cache_evictions;	/* number of cache entries removed due to
-							 * the need to free memory */
-	uint64 cache_overflows;	/* number of times we've had to bypass the
-							 * cache when filling it due to not being
-							 * able to free enough space to store the
-							 * current scan's tuples */
-	uint64	mem_peak;		/* peak memory usage in bytes */
-
+	uint64		cache_hits;		/* number of rescans where we've found the
+								 * scan parameters values to be cached */
+	uint64		cache_misses;	/* number of rescans where we've not found the
+								 * scan parameters values to be cached */
+	uint64		cache_evictions;	/* number of cache entries removed due to
+									 * the need to free memory */
+	uint64		cache_overflows;	/* number of times we've had to bypass the
+									 * cache when filling it due to not being
+									 * able to free enough space to store the
+									 * current scan's tuples */
+	uint64		mem_peak;		/* peak memory usage in bytes */
 } MemoizeInstrumentation;
 
-/* ----------------
- *  Shared memory container for per-worker memoize information
- *  ----------------
+/*
+ * Shared memory container for per-worker memoize information
  */
 typedef struct SharedMemoizeInfo
 {
@@ -110,27 +112,25 @@ typedef struct SharedMemoizeInfo
 } SharedMemoizeInfo;
 
 
-/*
- * Data structures for reporting sort statistics.  Note that
- * TuplesortInstrumentation can't contain any pointers because we
- * sometimes put it in shared memory.
- *
- * The parallel-sort infrastructure relies on having a zero TuplesortMethod
- * to indicate that a worker never did anything, so we assign zero to
- * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
- * OR'ed together to represent a situation where different workers used
- * different methods, so we need a separate bit for each one.  Keep the
- * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
+/* ---------------------
+ *	Instrumentation information for Sorts.
+ * ---------------------
  */
 
-#define NUM_TUPLESORTMETHODS 4
-
 typedef enum
 {
 	SORT_SPACE_TYPE_DISK,
 	SORT_SPACE_TYPE_MEMORY,
 } TuplesortSpaceType;
 
+/*
+ * The parallel-sort infrastructure relies on having a zero TuplesortMethod
+ * to indicate that a worker never did anything, so we assign zero to
+ * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
+ * OR'ed together to represent a situation where different workers used
+ * different methods, so we need a separate bit for each one.  Keep the
+ * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
+ */
 typedef enum
 {
 	SORT_TYPE_STILL_IN_PROGRESS = 0,
@@ -139,40 +139,40 @@ typedef enum
 	SORT_TYPE_EXTERNAL_SORT = 1 << 2,
 	SORT_TYPE_EXTERNAL_MERGE = 1 << 3
 } TuplesortMethod;
+#define NUM_TUPLESORTMETHODS 4
 
 typedef struct TuplesortInstrumentation
 {
-	TuplesortMethod sortMethod;		/* sort algorithm used */
+	TuplesortMethod sortMethod; /* sort algorithm used */
 	TuplesortSpaceType spaceType;	/* type of space spaceUsed represents */
-	int64       spaceUsed;			/* space consumption, in kB */
+	int64		spaceUsed;		/* space consumption, in kB */
 } TuplesortInstrumentation;
 
-/* ----------------
- *  Shared memory container for per-worker sort information
- *  ----------------
+/*
+ * Shared memory container for per-worker sort information
  */
 typedef struct SharedSortInfo
 {
-	int num_workers;
+	int			num_workers;
 	TuplesortInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedSortInfo;
 
-/* ----------------
- *   Values displayed by EXPLAIN ANALYZE
- * ----------------
+
+/* ---------------------
+ *   Instrumentation information for nodeHash.c
+ * ---------------------
  */
 typedef struct HashInstrumentation
 {
-	int		nbuckets;			/* number of buckets at end of execution */
-	int		nbuckets_original;	/* planned number of buckets */
-	int		nbatch;				/* number of batches at end of execution */
-	int		nbatch_original;	/* planned number of batches */
-	Size	space_peak;			/* peak memory usage in bytes */
+	int			nbuckets;		/* number of buckets at end of execution */
+	int			nbuckets_original;	/* planned number of buckets */
+	int			nbatch;			/* number of batches at end of execution */
+	int			nbatch_original;	/* planned number of batches */
+	Size		space_peak;		/* peak memory usage in bytes */
 } HashInstrumentation;
 
-/* ----------------
- *   Shared memory container for per-worker hash information
- * ----------------
+/*
+ * Shared memory container for per-worker information
  */
 typedef struct SharedHashInfo
 {
@@ -180,9 +180,10 @@ typedef struct SharedHashInfo
 	HashInstrumentation hinstrument[FLEXIBLE_ARRAY_MEMBER];
 } SharedHashInfo;
 
-/* ----------------
+
+/* ---------------------
  *   Instrumentation information for IncrementalSort
- * ----------------
+ * ---------------------
  */
 typedef struct IncrementalSortGroupInfo
 {
@@ -200,10 +201,7 @@ typedef struct IncrementalSortInfo
 	IncrementalSortGroupInfo prefixsortGroupInfo;
 } IncrementalSortInfo;
 
-/* ----------------
- *   Shared memory container for per-worker incremental sort information
- * ----------------
- */
+/* Shared memory container for per-worker incremental sort information */
 typedef struct SharedIncrementalSortInfo
 {
 	int			num_workers;
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index a7e867f36b8..943a2b7dc93 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -62,21 +62,6 @@ typedef struct SortCoordinateData
 
 typedef struct SortCoordinateData *SortCoordinate;
 
-/*
- * Data structures for reporting sort statistics.  Note that
- * TuplesortInstrumentation can't contain any pointers because we
- * sometimes put it in shared memory.
- *
- * The parallel-sort infrastructure relies on having a zero TuplesortMethod
- * to indicate that a worker never did anything, so we assign zero to
- * SORT_TYPE_STILL_IN_PROGRESS.  The other values of this enum can be
- * OR'ed together to represent a situation where different workers used
- * different methods, so we need a separate bit for each one.  Keep the
- * NUM_TUPLESORTMETHODS constant in sync with the number of bits!
- */
-
-#define NUM_TUPLESORTMETHODS 4
-
 /* Bitwise option flags for tuple sorts */
 #define TUPLESORT_NONE					0
 
-- 
2.47.3


--xs5il3t73pzvzpq7--





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: pg_createsubscriber --dry-run logging concerns
@ 2026-06-29 13:56  Peter Eisentraut <[email protected]>
  0 siblings, 2 replies; 15+ messages in thread

From: Peter Eisentraut @ 2026-06-29 13:56 UTC (permalink / raw)
  To: Peter Smith <[email protected]>; Álvaro Herrera <[email protected]>; +Cc: Chao Li <[email protected]>; Euler Taveira <[email protected]>; [email protected] <[email protected]>; PostgreSQL Hackers <[email protected]>

On 18.11.25 22:35, Peter Smith wrote:
> On Wed, Nov 19, 2025 at 2:39 AM Álvaro Herrera <[email protected]> wrote:
>>
>> On 2025-Nov-12, Peter Smith wrote:
>>
>>> It is tempting to implement a "--silent" mode, but if I did that, I
>>> would then feel obliged to document and test it. I don't want to go
>>> further down this rabbit hole for what was originally supposed to be
>>> trivial logging.
>>
>> Yeah, I understand.
>>
>>> So, I am calling it quits for this 0001 patch.
>>>
>>> Perhaps it's still of some use to push changes for everything except
>>> the pg_resetwal? Or if you prefer to just abandon the whole patch,
>>> that is OK too. Thanks for trying.
>>
>> Got it.  I pushed it for the other programs and marked the CF entry as
>> committed -- thanks for the patches and the discussion.
> 
> Thanks for pushing!

I have a follow-up for this.  Earlier in this thread it was asked to 
combine the dry-run info message into one string with a newline.  But I 
think this doesn't really fit the message style guidelines.  I suggest 
to use a primary plus detail style here too.  How about the attached patch?

From 09e5fcedec79fceb024e4d02980d8c0a09805c62 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 7 May 2026 11:14:10 +0200
Subject: [PATCH] Split dry-run messages into primary and detail

---
 src/bin/pg_archivecleanup/pg_archivecleanup.c | 6 ++++--
 src/bin/pg_basebackup/pg_createsubscriber.c   | 6 ++++--
 src/bin/pg_combinebackup/pg_combinebackup.c   | 6 ++++--
 src/bin/pg_rewind/pg_rewind.c                 | 6 ++++--
 src/bin/scripts/vacuumdb.c                    | 6 ++++--
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c
index ab686b4748c..3492dab64d7 100644
--- a/src/bin/pg_archivecleanup/pg_archivecleanup.c
+++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c
@@ -376,8 +376,10 @@ main(int argc, char **argv)
 	}
 
 	if (dryrun)
-		pg_log_info("Executing in dry-run mode.\n"
-					"No files will be removed.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("No files will be removed.");
+	}
 
 	/*
 	 * Check archive exists and other initialization if required.
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 4d705778454..0a9b11184f5 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -2514,8 +2514,10 @@ main(int argc, char **argv)
 	}
 
 	if (dry_run)
-		pg_log_info("Executing in dry-run mode.\n"
-					"The target directory will not be modified.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("The target directory will not be modified.");
+	}
 
 	pg_log_info("validating publisher connection string");
 	pub_base_conninfo = get_base_conninfo(opt.pub_conninfo_str,
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c
index d13bf63eb1e..767b8b9e499 100644
--- a/src/bin/pg_combinebackup/pg_combinebackup.c
+++ b/src/bin/pg_combinebackup/pg_combinebackup.c
@@ -243,8 +243,10 @@ main(int argc, char *argv[])
 		opt.manifest_checksums = CHECKSUM_TYPE_NONE;
 
 	if (opt.dry_run)
-		pg_log_info("Executing in dry-run mode.\n"
-					"The target directory will not be modified.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("The target directory will not be modified.");
+	}
 
 	/* Check that the platform supports the requested copy method. */
 	if (opt.copy_method == COPY_METHOD_CLONE)
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 9d745d4b25b..2e86fd158d0 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -302,8 +302,10 @@ main(int argc, char **argv)
 
 	/* Ok, we have all the options and we're ready to start. */
 	if (dry_run)
-		pg_log_info("Executing in dry-run mode.\n"
-					"The target directory will not be modified.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("The target directory will not be modified.");
+	}
 
 	/* First, connect to remote server. */
 	if (connstr_source)
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index ccc7f88a291..f8158ca6a78 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -308,8 +308,10 @@ main(int argc, char *argv[])
 				 "missing-stats-only", "analyze-only", "analyze-in-stages");
 
 	if (vacopts.dry_run && !vacopts.quiet)
-		pg_log_info("Executing in dry-run mode.\n"
-					"No commands will be sent to the server.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("No commands will be sent to the server.");
+	}
 
 	ret = vacuuming_main(&cparams, dbname, maintenance_db, &vacopts,
 						 &objects, tbl_count,
-- 
2.54.0



Attachments:

  [text/plain] 0001-Split-dry-run-messages-into-primary-and-detail.patch (3.7K, ../../[email protected]/2-0001-Split-dry-run-messages-into-primary-and-detail.patch)
  download | inline diff:
From 09e5fcedec79fceb024e4d02980d8c0a09805c62 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
Date: Thu, 7 May 2026 11:14:10 +0200
Subject: [PATCH] Split dry-run messages into primary and detail

---
 src/bin/pg_archivecleanup/pg_archivecleanup.c | 6 ++++--
 src/bin/pg_basebackup/pg_createsubscriber.c   | 6 ++++--
 src/bin/pg_combinebackup/pg_combinebackup.c   | 6 ++++--
 src/bin/pg_rewind/pg_rewind.c                 | 6 ++++--
 src/bin/scripts/vacuumdb.c                    | 6 ++++--
 5 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c
index ab686b4748c..3492dab64d7 100644
--- a/src/bin/pg_archivecleanup/pg_archivecleanup.c
+++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c
@@ -376,8 +376,10 @@ main(int argc, char **argv)
 	}
 
 	if (dryrun)
-		pg_log_info("Executing in dry-run mode.\n"
-					"No files will be removed.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("No files will be removed.");
+	}
 
 	/*
 	 * Check archive exists and other initialization if required.
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index 4d705778454..0a9b11184f5 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -2514,8 +2514,10 @@ main(int argc, char **argv)
 	}
 
 	if (dry_run)
-		pg_log_info("Executing in dry-run mode.\n"
-					"The target directory will not be modified.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("The target directory will not be modified.");
+	}
 
 	pg_log_info("validating publisher connection string");
 	pub_base_conninfo = get_base_conninfo(opt.pub_conninfo_str,
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c
index d13bf63eb1e..767b8b9e499 100644
--- a/src/bin/pg_combinebackup/pg_combinebackup.c
+++ b/src/bin/pg_combinebackup/pg_combinebackup.c
@@ -243,8 +243,10 @@ main(int argc, char *argv[])
 		opt.manifest_checksums = CHECKSUM_TYPE_NONE;
 
 	if (opt.dry_run)
-		pg_log_info("Executing in dry-run mode.\n"
-					"The target directory will not be modified.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("The target directory will not be modified.");
+	}
 
 	/* Check that the platform supports the requested copy method. */
 	if (opt.copy_method == COPY_METHOD_CLONE)
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 9d745d4b25b..2e86fd158d0 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -302,8 +302,10 @@ main(int argc, char **argv)
 
 	/* Ok, we have all the options and we're ready to start. */
 	if (dry_run)
-		pg_log_info("Executing in dry-run mode.\n"
-					"The target directory will not be modified.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("The target directory will not be modified.");
+	}
 
 	/* First, connect to remote server. */
 	if (connstr_source)
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index ccc7f88a291..f8158ca6a78 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -308,8 +308,10 @@ main(int argc, char *argv[])
 				 "missing-stats-only", "analyze-only", "analyze-in-stages");
 
 	if (vacopts.dry_run && !vacopts.quiet)
-		pg_log_info("Executing in dry-run mode.\n"
-					"No commands will be sent to the server.");
+	{
+		pg_log_info("executing in dry-run mode");
+		pg_log_info_detail("No commands will be sent to the server.");
+	}
 
 	ret = vacuuming_main(&cparams, dbname, maintenance_db, &vacopts,
 						 &objects, tbl_count,
-- 
2.54.0



^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: pg_createsubscriber --dry-run logging concerns
@ 2026-06-29 20:14  Euler Taveira <[email protected]>
  parent: Peter Eisentraut <[email protected]>
  1 sibling, 1 reply; 15+ messages in thread

From: Euler Taveira @ 2026-06-29 20:14 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Peter Smith <[email protected]>; Álvaro Herrera <[email protected]>; +Cc: Chao Li <[email protected]>; [email protected] <[email protected]>; PostgreSQL Hackers <[email protected]>

On Mon, Jun 29, 2026, at 10:56 AM, Peter Eisentraut wrote:
>
> I have a follow-up for this.  Earlier in this thread it was asked to 
> combine the dry-run info message into one string with a newline.  But I 
> think this doesn't really fit the message style guidelines.  I suggest 
> to use a primary plus detail style here too.  How about the attached patch?
>

LGTM.


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: pg_createsubscriber --dry-run logging concerns
@ 2026-06-29 20:21  Peter Smith <[email protected]>
  parent: Euler Taveira <[email protected]>
  0 siblings, 0 replies; 15+ messages in thread

From: Peter Smith @ 2026-06-29 20:21 UTC (permalink / raw)
  To: Euler Taveira <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Álvaro Herrera <[email protected]>; Chao Li <[email protected]>; [email protected] <[email protected]>; PostgreSQL Hackers <[email protected]>

On Tue, Jun 30, 2026 at 8:15 AM Euler Taveira <[email protected]> wrote:
>
> On Mon, Jun 29, 2026, at 10:56 AM, Peter Eisentraut wrote:
> >
> > I have a follow-up for this.  Earlier in this thread it was asked to
> > combine the dry-run info message into one string with a newline.  But I
> > think this doesn't really fit the message style guidelines.  I suggest
> > to use a primary plus detail style here too.  How about the attached patch?
> >
>
> LGTM.
>

Ditto.

======
Kind Regards,
Peter Smith.
Fujitsu Australia





^ permalink  raw  reply  [nested|flat] 15+ messages in thread

* Re: pg_createsubscriber --dry-run logging concerns
@ 2026-06-29 21:13  Álvaro Herrera <[email protected]>
  parent: Peter Eisentraut <[email protected]>
  1 sibling, 0 replies; 15+ messages in thread

From: Álvaro Herrera @ 2026-06-29 21:13 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; Peter Smith <[email protected]>; +Cc: Chao Li <[email protected]>; Euler Taveira <[email protected]>; [email protected] <[email protected]>; L. pgsql-hackers <[email protected]>

On 2026-06-29, Peter Eisentraut wrote:

> I have a follow-up for this.  Earlier in this thread it was asked to 
> combine the dry-run info message into one string with a newline.  But I 
> think this doesn't really fit the message style guidelines.  I suggest 
> to use a primary plus detail style here too.  How about the attached patch?

Yeah, that works for me.  It makes me wonder what was I thinking when I requested that newline.

-- 
Álvaro Herrera





^ permalink  raw  reply  [nested|flat] 15+ messages in thread


end of thread, other threads:[~2026-06-29 21:13 UTC | newest]

Thread overview: 15+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 00:02 [PATCH v5 07/12] consistent language: to which Justin Pryzby <[email protected]>
2023-07-12 16:57 [PATCH v16 1/3] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v15 1/2] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v13 1/2] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v15 1/2] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v17 1/3] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2023-07-12 16:57 [PATCH v14 1/2] Remember PK oid for partitioned tables even when it's invalid Alvaro Herrera <[email protected]>
2026-01-05 14:26 [PATCH v3a] edit comments and stuff Álvaro Herrera <[email protected]>
2026-01-05 14:26 [PATCH v3a] edit comments and stuff Álvaro Herrera <[email protected]>
2026-06-29 13:56 Re: pg_createsubscriber --dry-run logging concerns Peter Eisentraut <[email protected]>
2026-06-29 20:14 ` Re: pg_createsubscriber --dry-run logging concerns Euler Taveira <[email protected]>
2026-06-29 20:21   ` Re: pg_createsubscriber --dry-run logging concerns Peter Smith <[email protected]>
2026-06-29 21:13 ` Re: pg_createsubscriber --dry-run logging concerns Álvaro Herrera <[email protected]>

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