Skip to content

Commit f01f988

Browse files
committed
fix compatibility issues for postgres 10
1 parent 55639f9 commit f01f988

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/partition_creation.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
#include "utils/syscache.h"
4848
#include "utils/typcache.h"
4949

50+
#if PG_VERSION_NUM >= 100000
51+
#include "utils/regproc.h"
52+
#endif
5053

5154
static Oid spawn_partitions_val(Oid parent_relid,
5255
const Bound *range_bound_min,
@@ -1955,18 +1958,29 @@ drop_single_update_trigger_internal(Oid relid,
19551958
* To avoid warning message about missing trigger we check it beforehand.
19561959
* and quit if it doesn't
19571960
*/
1961+
#if PG_VERSION_NUM >= 100000
1962+
address = get_object_address(OBJECT_TRIGGER,
1963+
(Node *) namelist,
1964+
&relation,
1965+
AccessExclusiveLock,
1966+
true);
1967+
#else
19581968
address = get_object_address(OBJECT_TRIGGER,
19591969
namelist, NIL,
19601970
&relation,
19611971
AccessExclusiveLock,
19621972
true);
1973+
#endif
1974+
19631975
if (!OidIsValid(address.objectId))
19641976
return;
19651977

19661978
/* Actually remove trigger */
19671979
n->removeType = OBJECT_TRIGGER;
19681980
n->objects = list_make1(namelist);
1981+
#if PG_VERSION_NUM < 100000
19691982
n->arguments = NIL;
1983+
#endif
19701984
n->behavior = DROP_RESTRICT; /* default behavior */
19711985
n->missing_ok = true;
19721986
n->concurrent = false;

src/partition_filter.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ select_partition_for_insert(ExprContext *econtext, ExprState *expr_state,
436436
int nparts;
437437
bool isnull;
438438
Datum value;
439+
Oid parent = PrelParentRelid(prel);
439440

440441
/* Execute expression */
441442
value = ExecEvalExprCompat(expr_state, econtext, &isnull,
@@ -453,11 +454,11 @@ select_partition_for_insert(ExprContext *econtext, ExprState *expr_state,
453454
elog(ERROR, ERR_PART_ATTR_MULTIPLE);
454455
else if (nparts == 0)
455456
{
456-
selected_partid = create_partitions_for_value(PrelParentRelid(prel),
457+
selected_partid = create_partitions_for_value(parent,
457458
value, prel->ev_type);
458459

459460
/* get_pathman_relation_info() will refresh this entry */
460-
invalidate_pathman_relation_info(PrelParentRelid(prel), NULL);
461+
invalidate_pathman_relation_info(parent, NULL);
461462
}
462463
else selected_partid = parts[0];
463464

@@ -469,15 +470,15 @@ select_partition_for_insert(ExprContext *econtext, ExprState *expr_state,
469470
if (rri_holder == NULL)
470471
{
471472
/* get_pathman_relation_info() will refresh this entry */
472-
invalidate_pathman_relation_info(PrelParentRelid(prel), NULL);
473+
invalidate_pathman_relation_info(parent, NULL);
473474

474475
/* Get a fresh PartRelationInfo */
475-
prel = get_pathman_relation_info(PrelParentRelid(prel));
476+
prel = get_pathman_relation_info(parent);
476477

477478
/* Paranoid check (all partitions have vanished) */
478479
if (!prel)
479480
elog(ERROR, "table \"%s\" is not partitioned",
480-
get_rel_name_or_relid(PrelParentRelid(prel)));
481+
get_rel_name_or_relid(parent));
481482
}
482483
/* If partition has subpartitions */
483484
else if (rri_holder->has_subpartitions)

src/pl_funcs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,10 @@ is_tuple_convertible(PG_FUNCTION_ARGS)
671671
map = convert_tuples_by_name(RelationGetDescr(rel1),
672672
RelationGetDescr(rel2),
673673
ERR_PART_DESC_CONVERT);
674-
/* Now free map */
675-
pfree(map);
674+
675+
/* Now free map. Note that map can be NULL if conversion isn't needed */
676+
if (map)
677+
pfree(map);
676678
}
677679
PG_CATCH();
678680
{

0 commit comments

Comments
 (0)