Skip to content

Commit

Permalink
Fixed compatibility with PG 17.
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonin Houska committed Jul 13, 2024
1 parent 1d1777f commit 0bb37b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions concurrent.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,11 @@ plugin_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
HeapTuple newtuple;

newtuple = change->data.tp.newtuple != NULL ?
#if PG_VERSION_NUM >= 170000
change->data.tp.newtuple : NULL;
#else
&change->data.tp.newtuple->tuple : NULL;
#endif

/*
* Identity checks in the main function should have made this
Expand All @@ -692,9 +696,17 @@ plugin_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
newtuple;

oldtuple = change->data.tp.oldtuple != NULL ?
#if PG_VERSION_NUM >= 170000
change->data.tp.oldtuple : NULL;
#else
&change->data.tp.oldtuple->tuple : NULL;
#endif
newtuple = change->data.tp.newtuple != NULL ?
#if PG_VERSION_NUM >= 170000
change->data.tp.newtuple : NULL;
#else
&change->data.tp.newtuple->tuple : NULL;
#endif

if (newtuple == NULL)
elog(ERROR, "Incomplete update info.");
Expand All @@ -710,7 +722,11 @@ plugin_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
HeapTuple oldtuple;

oldtuple = change->data.tp.oldtuple ?
#if PG_VERSION_NUM >= 170000
change->data.tp.oldtuple : NULL;
#else
&change->data.tp.oldtuple->tuple : NULL;
#endif

if (oldtuple == NULL)
elog(ERROR, "Incomplete delete info.");
Expand Down
10 changes: 10 additions & 0 deletions pg_squeeze.c
Original file line number Diff line number Diff line change
Expand Up @@ -2820,6 +2820,14 @@ build_transient_indexes(Relation rel_dst, Relation rel_src,
opclassOptions,
#endif
indoptions,
#if PG_VERSION_NUM >= 170000
/*
* stattargets not needed for the transient
* index, the value of the source index
* will remain (we only swap the storage).
*/
NULL,
#endif
PointerGetDatum(reloptions),
flags, /* flags */
0, /* constr_flags */
Expand Down Expand Up @@ -3251,8 +3259,10 @@ swap_relation_files(Oid r1, Oid r2)

table_close(relRelation, RowExclusiveLock);

#if PG_VERSION_NUM < 170000
RelationCloseSmgrByOid(r1);
RelationCloseSmgrByOid(r2);
#endif
}

/*
Expand Down
4 changes: 3 additions & 1 deletion worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,9 @@ create_replication_slots(int nslots, MemoryContext mcxt)
snprintf(name, NAMEDATALEN, REPL_SLOT_PREFIX "%u_%u", MyDatabaseId,
slot_nr);

#if PG_VERSION_NUM >= 140000
#if PG_VERSION_NUM >= 170000
ReplicationSlotCreate(name, true, RS_PERSISTENT, false, false, false);
#elif PG_VERSION_NUM >= 140000
ReplicationSlotCreate(name, true, RS_PERSISTENT, false);
#else
ReplicationSlotCreate(name, true, RS_PERSISTENT);
Expand Down

0 comments on commit 0bb37b2

Please sign in to comment.