($INBOX_DIR/description missing)help / color / mirror / Atom feed
[PATCH v9 8/8] pg_dump: partitioned index depend on its partitions 93+ messages / 4 participants [nested] [flat]
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v10 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 88a68a4697..aaf955458c 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -18153,6 +18153,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -18164,9 +18167,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx), false); parentTblId = get_partition_parent(RelationGetRelid(partedTbl), false); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --mvpLiMfbWzRoNl4x-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --O5XBE6gyVG5Rl6Rj-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8687e9a97c..865ab6c2e9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17493,6 +17493,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17504,9 +17507,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index b0f02bc1f6..2a7d9b463c 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --FsscpQKzF/jJk6ya-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 559fa1d2e5..eb56890311 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17497,6 +17497,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17508,9 +17511,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --fmvA4kSBHQVZhkR6-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions @ 2020-11-25 23:34 Justin Pryzby <[email protected]> 0 siblings, 0 replies; 93+ messages in thread From: Justin Pryzby @ 2020-11-25 23:34 UTC (permalink / raw) This is required for restoring clustered parent index, which is marked INVALID until indexes have been built on all its child tables, and it's prohibited to CLUSTER ON an INVALID index See also: 8cff4f5348d075e063100071013f00a900c32b0f --- src/backend/commands/tablecmds.c | 6 +++--- src/bin/pg_dump/common.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 420991e315..a478c13990 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -17521,6 +17521,9 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) table_close(idxRel, RowExclusiveLock); } + /* make sure we see the validation we just did */ + CommandCounterIncrement(); + /* * If this index is in turn a partition of a larger index, validating it * might cause the parent to become valid also. Try that. @@ -17532,9 +17535,6 @@ validatePartitionedIndex(Relation partedIdx, Relation partedTbl) Relation parentIdx, parentTbl; - /* make sure we see the validation we just did */ - CommandCounterIncrement(); - parentIdxId = get_partition_parent(RelationGetRelid(partedIdx)); parentTblId = get_partition_parent(RelationGetRelid(partedTbl)); parentIdx = relation_open(parentIdxId, AccessExclusiveLock); diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index 1a261a5545..cdfba058fc 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -429,6 +429,12 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) attachinfo[k].parentIdx = parentidx; attachinfo[k].partitionIdx = index; + /* + * We want dependencies from parent to partition (so that the + * partition index is created first) + */ + addObjectDependency(&parentidx->dobj, index->dobj.dumpId); + /* * We must state the DO_INDEX_ATTACH object's dependencies * explicitly, since it will not match anything in pg_depend. @@ -446,6 +452,8 @@ flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables) */ addObjectDependency(&attachinfo[k].dobj, index->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, parentidx->dobj.dumpId); + // addObjectDependency(&parentidx->dobj, attachinfo[k].dobj.dumpId); + addObjectDependency(&attachinfo[k].dobj, index->indextable->dobj.dumpId); addObjectDependency(&attachinfo[k].dobj, -- 2.17.0 --AA9g+nFNFPYNJKiL-- ^ permalink raw reply [nested|flat] 93+ messages in thread
* "command cannot affect row a second time" in INSERT ... ON CONFLICT @ 2024-10-31 13:20 Karthik Ramanathan <[email protected]> 0 siblings, 2 replies; 93+ messages in thread From: Karthik Ramanathan @ 2024-10-31 13:20 UTC (permalink / raw) To: pgsql-hackers Hello hackers, I am looking to better understand the applicability of the error message "command cannot affect row a second time". Consider the following table and data: CREATE TABLE ioc (i int, UNIQUE(i)); INSERT INTO ioc VALUES (1); The following two queries produce different errors: *Query 1* postgres=# INSERT INTO ioc VALUES (1), (20) ON CONFLICT (i) DO UPDATE SET i = 20; ERROR: 21000: ON CONFLICT DO UPDATE command cannot affect row a second time HINT: Ensure that no rows proposed for insertion within the same command have duplicate constrained values. *Query 2* postgres=# INSERT INTO ioc VALUES (20), (1) ON CONFLICT (i) DO UPDATE SET i = 20; ERROR: 23505: duplicate key value violates unique constraint "ioc_i_key" DETAIL: Key (i)=(20) already exists. INSERT ... ON CONFLICT does not support deferrable unique constraints, and so the two errors appear to be logically equivalent. However, the MERGE command which does support deferring unique constraints, consistently produces the duplicate key violation for similar queries [1] but also raises "command cannot affect row a second time" in other scenarios as demonstrated by regress tests in merge.sql. Naively, it seems to me that attempting to take a tuple lock on both: 1. The conflicting tuple (i = 1 in the second tuple in Query 2) as well as 2. The tuple it updates into (i = 20 in the second tuple in Query 2) (which may or may not exist) in ExecOnConflictUpdate could yield a consistent error message in both scenarios but it offers no real functional gains. 1. Is there a different reason the two queries produce a different error? 2. Is there a better way to think about the "command cannot affect row a second time"? Appreciate any guidance. Thanks. Warm regards, Karthik Ramanathan [1] MERGE command example CREATE TABLE source (sid INT); CREATE TABLE target (tid INT, UNIQUE (tid)); INSERT INTO target VALUES (1); *Query 1a* postgres=# INSERT INTO source VALUES (20), (1); postgres=# MERGE INTO target t USING source AS s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET tid = 20 WHEN NOT MATCHED THEN INSERT VALUES (s.sid); ERROR: 23505: duplicate key value violates unique constraint "target_tid_key" DETAIL: Key (tid)=(20) already exists. *Query 1b* postgres=# INSERT INTO source VALUES (1), (20); postgres=# MERGE INTO target t USING source AS s ON t.tid = s.sid WHEN MATCHED THEN UPDATE SET tid = 20 WHEN NOT MATCHED THEN INSERT VALUES (s.sid); ERROR: 23505: duplicate key value violates unique constraint "target_tid_key" DETAIL: Key (tid)=(20) already exists. ^ permalink raw reply [nested|flat] 93+ messages in thread
* Re: "command cannot affect row a second time" in INSERT ... ON CONFLICT @ 2024-10-31 17:21 Aleksander Alekseev <[email protected]> parent: Karthik Ramanathan <[email protected]> 1 sibling, 0 replies; 93+ messages in thread From: Aleksander Alekseev @ 2024-10-31 17:21 UTC (permalink / raw) To: pgsql-hackers; +Cc: Karthik Ramanathan <[email protected]> Hi Karthik, > I am looking to better understand the applicability of the error message "command cannot affect row a second time". > > Consider the following table and data: > CREATE TABLE ioc (i int, UNIQUE(i)); > INSERT INTO ioc VALUES (1); > > The following two queries produce different errors: > Query 1 > postgres=# INSERT INTO ioc VALUES (1), (20) ON CONFLICT (i) DO UPDATE SET i = 20; > ERROR: 21000: ON CONFLICT DO UPDATE command cannot affect row a second time > HINT: Ensure that no rows proposed for insertion within the same command have duplicate constrained values. > > Query 2 > postgres=# INSERT INTO ioc VALUES (20), (1) ON CONFLICT (i) DO UPDATE SET i = 20; > ERROR: 23505: duplicate key value violates unique constraint "ioc_i_key" > DETAIL: Key (i)=(20) already exists. Not sure if it will answer your question *entirely* but you will find a bit more detail about "cannot affect row a second time" in the discussion [1]. This error has nothing to do with unique constraints, so I think you trigger one of two errors depending on the order of inserted rows and the content of your table. This being said, I didn't investigate your scenario in much detail. [1]: https://www.postgresql.org/message-id/flat/CAJ7c6TPQJNFETz9H_qPpA3x7ybz2D1QMDtBku_iK33gT3UR34Q%40mai... -- Best regards, Aleksander Alekseev ^ permalink raw reply [nested|flat] 93+ messages in thread
* Re: "command cannot affect row a second time" in INSERT ... ON CONFLICT @ 2024-10-31 17:41 David G. Johnston <[email protected]> parent: Karthik Ramanathan <[email protected]> 1 sibling, 0 replies; 93+ messages in thread From: David G. Johnston @ 2024-10-31 17:41 UTC (permalink / raw) To: Karthik Ramanathan <[email protected]>; +Cc: pgsql-hackers On Thu, Oct 31, 2024 at 9:52 AM Karthik Ramanathan < [email protected]> wrote: > I am looking to better understand the applicability of the error message > "command cannot affect row a second time". > > Consider the following table and data: > CREATE TABLE ioc (i int, UNIQUE(i)); > INSERT INTO ioc VALUES (1); > > The following two queries produce different errors: > *Query 1* > postgres=# INSERT INTO ioc VALUES (1), (20) ON CONFLICT (i) DO UPDATE SET > i = 20; > ERROR: 21000: ON CONFLICT DO UPDATE command cannot affect row a second > time > HINT: Ensure that no rows proposed for insertion within the same command > have duplicate constrained values. > Right, id 1 exists, you insert id 1 again, that row becomes id 20, then you attempt to insert id 20 again, which conflicts, and the system attempts to update the 1-become-20 row to 20 but fails to perform the update since that now-existing row was already modified in this statement (it was inserted). You don't get a duplicate key error because the second modification condition is more general and thus triggers first. I.e., that error has to happen regardless of whether a duplicate key error condition was going to happen or not (e.g., you could have done something like "set i = i * 20" - not tested) > *Query 2* > postgres=# INSERT INTO ioc VALUES (20), (1) ON CONFLICT (i) DO UPDATE SET > i = 20; > ERROR: 23505: duplicate key value violates unique constraint "ioc_i_key" > DETAIL: Key (i)=(20) already exists. > Here the insertion of id 20 happens just fine, then inserting id 1 conflicts, the existing row with id 1 gets updated to id 20 which results in a duplicate key violation. > 1. Is there a different reason the two queries produce a different error? > First error condition wins. Multiple modification gets tested first, before checking whether the outcome of a modification would result in a duplicate. 2. Is there a better way to think about the "command cannot affect row a > second time"? Appreciate any guidance. Thanks. > > A row inserted or updated in a statement cannot be subsequently modified in that same statement. I don't actually understand how you are presently thinking about this... Apparently the algorithm for merge is able to avoid impacting the same row twice and thus if the underlying DML is going to produce a duplicate key violation that is what you will see. I hesitate to claim you'd never see a multi-update scenario but do find it reasonable that it would be less prone to it. David J. ^ permalink raw reply [nested|flat] 93+ messages in thread
end of thread, other threads:[~2024-10-31 17:41 UTC | newest] Thread overview: 93+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v10 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v6 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v8 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v9 8/8] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2020-11-25 23:34 [PATCH v7 7/7] pg_dump: partitioned index depend on its partitions Justin Pryzby <[email protected]> 2024-10-31 13:20 "command cannot affect row a second time" in INSERT ... ON CONFLICT Karthik Ramanathan <[email protected]> 2024-10-31 17:21 ` Re: "command cannot affect row a second time" in INSERT ... ON CONFLICT Aleksander Alekseev <[email protected]> 2024-10-31 17:41 ` Re: "command cannot affect row a second time" in INSERT ... ON CONFLICT David G. Johnston <[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