Skip to content

Commit c9f5368

Browse files
committed
Define compatible version for InitResultRelInfo routine
1 parent b19f72c commit c9f5368

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed

src/include/compat/pg_compat.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
/*
7272
* DefineRelation()
7373
*
74-
* for v10 set NULL on 'queryString' parameter as it uses only under vanilla
74+
* for v10 set NULL into 'queryString' argument as it's used only under vanilla
7575
* partition creating
7676
*/
7777
#if PG_VERSION_NUM >= 100000
@@ -172,6 +172,25 @@ extern void create_plain_partial_paths(PlannerInfo *root,
172172
#endif
173173

174174

175+
/*
176+
* InitResultRelInfo
177+
*
178+
* for v10 set NULL into 'partition_root' argument to specify that result
179+
* relation is not vanilla partition
180+
*/
181+
#if PG_VERSION_NUM >= 100000
182+
#define InitResultRelInfoCompat(resultRelInfo, resultRelationDesc, \
183+
resultRelationIndex, instrument_options) \
184+
InitResultRelInfo((resultRelInfo), (resultRelationDesc), \
185+
(resultRelationIndex), NULL, (instrument_options))
186+
#elif PG_VERSION_NUM >= 90500
187+
#define InitResultRelInfoCompat(resultRelInfo, resultRelationDesc, \
188+
resultRelationIndex, instrument_options) \
189+
InitResultRelInfo((resultRelInfo), (resultRelationDesc), \
190+
(resultRelationIndex), (instrument_options))
191+
#endif
192+
193+
175194
/*
176195
* make_result()
177196
*/

src/partition_filter.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* ------------------------------------------------------------------------
99
*/
1010

11+
#include "compat/pg_compat.h"
1112
#include "init.h"
1213
#include "nodes_common.h"
1314
#include "pathman.h"
@@ -295,18 +296,10 @@ scan_result_parts_storage(Oid partid, ResultPartsStorage *parts_storage)
295296
if (!parts_storage->saved_rel_info)
296297
elog(ERROR, "ResultPartsStorage contains no saved_rel_info");
297298

298-
#if PG_VERSION_NUM >= 100000
299-
InitResultRelInfo(child_result_rel_info,
300-
child_rel,
301-
child_rte_idx,
302-
parent_rel,
303-
parts_storage->estate->es_instrument);
304-
#else
305-
InitResultRelInfo(child_result_rel_info,
306-
child_rel,
307-
child_rte_idx,
308-
parts_storage->estate->es_instrument);
309-
#endif
299+
InitResultRelInfoCompat(child_result_rel_info,
300+
child_rel,
301+
child_rte_idx,
302+
parts_storage->estate->es_instrument);
310303

311304
if (parts_storage->command_type != CMD_DELETE)
312305
ExecOpenIndices(child_result_rel_info, parts_storage->speculative_inserts);

src/utility_stmt_hooking.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
#include "compat/debug_compat_features.h"
15+
#include "compat/pg_compat.h"
1516
#include "init.h"
1617
#include "utility_stmt_hooking.h"
1718
#include "partition_filter.h"
@@ -561,18 +562,10 @@ PathmanCopyFrom(CopyState cstate, Relation parent_rel,
561562
tupDesc = RelationGetDescr(parent_rel);
562563

563564
parent_result_rel = makeNode(ResultRelInfo);
564-
#if PG_VERSION_NUM >= 100000
565-
InitResultRelInfo(parent_result_rel,
566-
parent_rel,
567-
1, /* dummy rangetable index */
568-
NULL,
569-
0);
570-
#else
571-
InitResultRelInfo(parent_result_rel,
572-
parent_rel,
573-
1, /* dummy rangetable index */
574-
0);
575-
#endif
565+
InitResultRelInfoCompat(parent_result_rel,
566+
parent_rel,
567+
1, /* dummy rangetable index */
568+
0);
576569
ExecOpenIndices(parent_result_rel, false);
577570

578571
estate->es_result_relations = parent_result_rel;

0 commit comments

Comments
 (0)