Skip to content

Commit c436b29

Browse files
author
Maksim Milyutin
committed
Combine simple_heap_update and CatalogUpdateIndexes routines in pg version 9.6 and below into one routine CatalogTupleUpdate as it is in pg10
1 parent d056e02 commit c436b29

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

src/compat/pg_compat.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
/*
3838
* CatalogIndexInsert is the copy of static prototype having the same name from
3939
* src/backend/catalog/indexing.c
40-
*
41-
* CatalogUpdateIndexes
4240
*/
4341
#if PG_VERSION_NUM >= 100000
4442
#include "catalog/index.h"
@@ -119,10 +117,6 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
119117

120118
ExecDropSingleTupleTableSlot(slot);
121119
}
122-
void
123-
CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple)
124-
{
125-
}
126120
#endif
127121

128122

src/include/compat/pg_compat.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,23 @@
6969

7070

7171
/*
72-
* CatalogIndexInsert
73-
* CatalogUpdateIndexes
72+
* CatalogIndexInsert()
7473
*/
7574
#if PG_VERSION_NUM >= 100000
7675
#include "catalog/indexing.h"
7776
void CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple);
78-
void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple);
77+
#endif
78+
79+
80+
/*
81+
* CatalogTupleUpdate()
82+
*/
83+
#if PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 100000
84+
#define CatalogTupleUpdate(heapRel, updTid, heapTuple) \
85+
do { \
86+
simple_heap_update((heapRel), (updTid), (heapTuple)); \
87+
CatalogUpdateIndexes((heapRel), (heapTuple)); \
88+
} while (0)
7989
#endif
8090

8191

src/partition_creation.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -981,11 +981,8 @@ postprocess_child_table_and_atts(Oid parent_relid, Oid partition_relid)
981981
/* Build new tuple with parent's ACL */
982982
htup = heap_modify_tuple(htup, pg_class_desc, values, nulls, replaces);
983983

984-
/* Update child's tuple */
985-
simple_heap_update(pg_class_rel, &iptr, htup);
986-
987-
/* Don't forget to update indexes */
988-
CatalogUpdateIndexes(pg_class_rel, htup);
984+
/* Update child's tuple with related indexes */
985+
CatalogTupleUpdate(pg_class_rel, &iptr, htup);
989986
}
990987

991988
systable_endscan(scan);
@@ -1085,11 +1082,8 @@ postprocess_child_table_and_atts(Oid parent_relid, Oid partition_relid)
10851082
subhtup = heap_modify_tuple(subhtup, pg_attribute_desc,
10861083
values, nulls, replaces);
10871084

1088-
/* Update child's tuple */
1089-
simple_heap_update(pg_attribute_rel, &iptr, subhtup);
1090-
1091-
/* Don't forget to update indexes */
1092-
CatalogUpdateIndexes(pg_attribute_rel, subhtup);
1085+
/* Update child's tuple and related indexes */
1086+
CatalogTupleUpdate(pg_attribute_rel, &iptr, subhtup);
10931087
}
10941088

10951089
systable_endscan(subscan);

0 commit comments

Comments
 (0)