Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4dba331

Browse files
committed
Fix CommandCounterIncrement in partition-related DDL
It makes sense to do the CCIs in the places that do catalog updates, rather than before the places that error out because the former ones fail to do it. In particular, it looks like StorePartitionBound() and IndexSetParentIndex() ought to make their own CCIs. Per review comments from Peter Eisentraut for row-level triggers on partitioned tables. Discussion: https://postgr.es/m/20171229225319.ajltgss2ojkfd3kp@alvherre.pgsql
1 parent 467963c commit 4dba331

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

src/backend/catalog/heap.c

+3
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,9 @@ StorePartitionBound(Relation rel, Relation parent, PartitionBoundSpec *bound)
32983298
heap_freetuple(newtuple);
32993299
heap_close(classRel, RowExclusiveLock);
33003300

3301+
/* Make update visible */
3302+
CommandCounterIncrement();
3303+
33013304
/*
33023305
* The partition constraint for the default partition depends on the
33033306
* partition bounds of every other partition, so we must invalidate the

src/backend/commands/indexcmds.c

+3
Original file line numberDiff line numberDiff line change
@@ -2512,5 +2512,8 @@ IndexSetParentIndex(Relation partitionIdx, Oid parentOid)
25122512

25132513
recordDependencyOn(&partIdx, &partitionTbl, DEPENDENCY_AUTO);
25142514
}
2515+
2516+
/* make our updates visible */
2517+
CommandCounterIncrement();
25152518
}
25162519
}

src/backend/commands/tablecmds.c

-9
Original file line numberDiff line numberDiff line change
@@ -864,13 +864,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
864864
update_default_partition_oid(RelationGetRelid(parent), relationId);
865865

866866
heap_close(parent, NoLock);
867-
868-
/*
869-
* The code that follows may also update the pg_class tuple to update
870-
* relnumchecks, so bump up the command counter to avoid the "already
871-
* updated by self" error.
872-
*/
873-
CommandCounterIncrement();
874867
}
875868

876869
/*
@@ -14585,8 +14578,6 @@ ATExecAttachPartitionIdx(List **wqueue, Relation parentIdx, RangeVar *name)
1458514578

1458614579
pfree(attmap);
1458714580

14588-
CommandCounterIncrement();
14589-
1459014581
validatePartitionedIndex(parentIdx, parentTbl);
1459114582
}
1459214583

0 commit comments

Comments
 (0)