Use new catalog modification wrappers

PostgreSQL 10 removes the ability to directly call CatalogUpdateIndexes
in favor of new CatalogTupleUpdate and CatalogTupleInsert calls, which
do this for us.
pull/1439/head
Jason Petersen 2017-04-19 21:29:35 -06:00
parent cf7bfdb22b
commit fdfcbaeb2a
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
6 changed files with 58 additions and 5 deletions

View File

@ -3027,8 +3027,12 @@ PostProcessUtility(Node *parsetree)
indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
indexForm->indisvalid = true;
#if (PG_VERSION_NUM >= 100000)
CatalogTupleUpdate(pg_index, &indexTuple->t_self, indexTuple);
#else
simple_heap_update(pg_index, &indexTuple->t_self, indexTuple);
CatalogUpdateIndexes(pg_index, indexTuple);
#endif
/* clean up; index now marked valid, but ROLLBACK will mark invalid */
heap_freetuple(indexTuple);

View File

@ -794,8 +794,12 @@ InsertShardRow(Oid relationId, uint64 shardId, char storageType,
tupleDescriptor = RelationGetDescr(pgDistShard);
heapTuple = heap_form_tuple(tupleDescriptor, values, isNulls);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleInsert(pgDistShard, heapTuple);
#else
simple_heap_insert(pgDistShard, heapTuple);
CatalogUpdateIndexes(pgDistShard, heapTuple);
#endif
/* invalidate previous cache entry and close relation */
CitusInvalidateRelcacheByRelid(relationId);
@ -842,8 +846,12 @@ InsertShardPlacementRow(uint64 shardId, uint64 placementId,
tupleDescriptor = RelationGetDescr(pgDistShardPlacement);
heapTuple = heap_form_tuple(tupleDescriptor, values, isNulls);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleInsert(pgDistShardPlacement, heapTuple);
#else
simple_heap_insert(pgDistShardPlacement, heapTuple);
CatalogUpdateIndexes(pgDistShardPlacement, heapTuple);
#endif
CitusInvalidateRelcacheByShardId(shardId);
@ -898,8 +906,13 @@ InsertIntoPgDistPartition(Oid relationId, char distributionMethod,
newTuple = heap_form_tuple(RelationGetDescr(pgDistPartition), newValues, newNulls);
/* finally insert tuple, build index entries & register cache invalidation */
#if (PG_VERSION_NUM >= 100000)
CatalogTupleInsert(pgDistPartition, newTuple);
#else
simple_heap_insert(pgDistPartition, newTuple);
CatalogUpdateIndexes(pgDistPartition, newTuple);
#endif
CitusInvalidateRelcacheByRelid(relationId);
RecordDistributedRelationDependencies(relationId, (Node *) distributionColumn);
@ -1150,9 +1163,13 @@ UpdateShardPlacementState(uint64 placementId, char shardState)
replace[Anum_pg_dist_shard_placement_shardstate - 1] = true;
heapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isnull, replace);
simple_heap_update(pgDistShardPlacement, &heapTuple->t_self, heapTuple);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleUpdate(pgDistShardPlacement, &heapTuple->t_self, heapTuple);
#else
simple_heap_update(pgDistShardPlacement, &heapTuple->t_self, heapTuple);
CatalogUpdateIndexes(pgDistShardPlacement, heapTuple);
#endif
shardId = DatumGetInt64(heap_getattr(heapTuple,
Anum_pg_dist_shard_placement_shardid,
@ -1217,9 +1234,13 @@ UpdateColocationGroupReplicationFactor(uint32 colocationId, int replicationFacto
replace[Anum_pg_dist_colocation_replicationfactor - 1] = true;
newHeapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isnull, replace);
simple_heap_update(pgDistColocation, &newHeapTuple->t_self, newHeapTuple);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleUpdate(pgDistColocation, &newHeapTuple->t_self, newHeapTuple);
#else
simple_heap_update(pgDistColocation, &newHeapTuple->t_self, newHeapTuple);
CatalogUpdateIndexes(pgDistColocation, newHeapTuple);
#endif
CommandCounterIncrement();

View File

@ -812,9 +812,13 @@ MarkNodeHasMetadata(char *nodeName, int32 nodePort, bool hasMetadata)
replace[Anum_pg_dist_node_hasmetadata - 1] = true;
heapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isnull, replace);
simple_heap_update(pgDistNode, &heapTuple->t_self, heapTuple);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleUpdate(pgDistNode, &heapTuple->t_self, heapTuple);
#else
simple_heap_update(pgDistNode, &heapTuple->t_self, heapTuple);
CatalogUpdateIndexes(pgDistNode, heapTuple);
#endif
CitusInvalidateRelcacheByRelid(DistNodeRelationId());

View File

@ -100,8 +100,13 @@ LogTransactionRecord(int groupId, char *transactionName)
tupleDescriptor = RelationGetDescr(pgDistTransaction);
heapTuple = heap_form_tuple(tupleDescriptor, values, isNulls);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleInsert(pgDistTransaction, heapTuple);
#else
simple_heap_insert(pgDistTransaction, heapTuple);
CatalogUpdateIndexes(pgDistTransaction, heapTuple);
#endif
CommandCounterIncrement();
/* close relation and invalidate previous cache entry */

View File

@ -477,8 +477,12 @@ CreateColocationGroup(int shardCount, int replicationFactor, Oid distributionCol
tupleDescriptor = RelationGetDescr(pgDistColocation);
heapTuple = heap_form_tuple(tupleDescriptor, values, isNulls);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleInsert(pgDistColocation, heapTuple);
#else
simple_heap_insert(pgDistColocation, heapTuple);
CatalogUpdateIndexes(pgDistColocation, heapTuple);
#endif
/* increment the counter so that next command can see the row */
CommandCounterIncrement();
@ -648,9 +652,15 @@ UpdateRelationColocationGroup(Oid distributedRelationId, uint32 colocationId)
replace[Anum_pg_dist_partition_colocationid - 1] = true;
heapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isNull, replace);
simple_heap_update(pgDistPartition, &heapTuple->t_self, heapTuple);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleUpdate(pgDistPartition, &heapTuple->t_self, heapTuple);
#else
simple_heap_update(pgDistPartition, &heapTuple->t_self, heapTuple);
CatalogUpdateIndexes(pgDistPartition, heapTuple);
#endif
CitusInvalidateRelcacheByRelid(distributedRelationId);
CommandCounterIncrement();

View File

@ -625,9 +625,14 @@ SetNodeState(char *nodeName, int32 nodePort, bool isActive)
replace[Anum_pg_dist_node_isactive - 1] = true;
heapTuple = heap_modify_tuple(heapTuple, tupleDescriptor, values, isnull, replace);
simple_heap_update(pgDistNode, &heapTuple->t_self, heapTuple);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleUpdate(pgDistNode, &heapTuple->t_self, heapTuple);
#else
simple_heap_update(pgDistNode, &heapTuple->t_self, heapTuple);
CatalogUpdateIndexes(pgDistNode, heapTuple);
#endif
CitusInvalidateRelcacheByRelid(DistNodeRelationId());
CommandCounterIncrement();
@ -868,8 +873,12 @@ InsertNodeRow(int nodeid, char *nodeName, int32 nodePort, uint32 groupId, char *
tupleDescriptor = RelationGetDescr(pgDistNode);
heapTuple = heap_form_tuple(tupleDescriptor, values, isNulls);
#if (PG_VERSION_NUM >= 100000)
CatalogTupleInsert(pgDistNode, heapTuple);
#else
simple_heap_insert(pgDistNode, heapTuple);
CatalogUpdateIndexes(pgDistNode, heapTuple);
#endif
/* close relation and invalidate previous cache entry */
heap_close(pgDistNode, AccessExclusiveLock);