Fix postgres-decoderbufs build against PostgreSQL 19.#34
Closed
devrimgunduz wants to merge 1 commit into
Closed
Conversation
PG19 introduced several source-incompatible changes that this patch
addresses in src/decoderbufs.c:
1. `AssertVariableIsOfType` was renamed to `StaticAssertVariableIsOfType`
(upstream commit "Rename AssertVariableIsOfType to
StaticAssertVariableIsOfType"). The old name no longer exists, so
_PG_output_plugin_init() originally failed with an
implicit-declaration error.
However, simply switching to StaticAssertVariableIsOfType() trades
that error for a new one: PG19's c.h defines that macro in terms of
the bare `typeof` keyword, which only exists under a GNU C dialect
or C23 -- it is not available under strict `-std=c11`/`-std=c17`,
which is the dialect PGXS's own CFLAGS select on this build. So the
upstream macro itself fails to compile here ("unknown type name
'typeof'"), independent of anything in decoderbufs.
Fixed by performing the same compile-time type check ourselves on
PG19+, using the double-underscored `__typeof__` GNU extension
(which, unlike bare `typeof`, remains available in strict-ANSI
modes on both gcc and clang) together with c.h's own
`StaticAssertDecl` and `__builtin_types_compatible_p`. This check is
purely a compile-time sanity check with no effect on behavior, so it
is simply skipped (via an inner #if) on any toolchain lacking the
builtin, rather than trying to fail the build.
2. `VARATT_IS_EXTERNAL_ONDISK()` now takes a `const void *` instead of
silently accepting a `Datum`. tuple_to_tuple_msg() was passing the
raw Datum (`origval`), which is an integer type on this platform,
causing "makes pointer from integer without a cast". Fixed by
wrapping the argument with DatumGetPointer(), which is correct and
a no-op change on all supported PG versions.
3. `ReorderBufferTXN` no longer has an `xact_time` member. Upstream
commit "Make some use of anonymous unions [reorderbuffer xact_time]"
turned the `xact_time` union into an anonymous union embedded
directly in ReorderBufferTXN, so `commit_time` (as well as
`prepare_time` / `abort_time`) is once again accessed directly as
txn->commit_time, the same way it was before PG15 introduced the
named `xact_time` union. This affected pg_decode_begin_txn(),
pg_decode_commit_txn(), and pg_decode_change(). Fixed by adding a
`PG_VERSION_NUM >= 190000` branch that uses txn->commit_time
directly, while keeping the txn->xact_time.commit_time path for
PG15-PG18 and the pre-PG15 txn->commit_time path unchanged.
No behavioral changes for PG15-PG18 or earlier; this is purely a
compatibility fix so the extension builds on PG19 as well.
|
❌ Developer Certificate of Origin (DCO) check failed. Hi @devrimgunduz, please sign off all commits with: If pull request commits are not signed off, the pull request cannot be merged. For more information about why this is required, please see our blog about contribution requirement changes. |
Author
|
Will submit another one |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PG19 introduced several source-incompatible changes that this patch addresses in src/decoderbufs.c:
AssertVariableIsOfTypewas renamed toStaticAssertVariableIsOfType(upstream commit "Rename AssertVariableIsOfType to StaticAssertVariableIsOfType"). The old name no longer exists, so _PG_output_plugin_init() originally failed with an implicit-declaration error.However, simply switching to StaticAssertVariableIsOfType() trades that error for a new one: PG19's c.h defines that macro in terms of the bare
typeofkeyword, which only exists under a GNU C dialect or C23 -- it is not available under strict-std=c11/-std=c17, which is the dialect PGXS's own CFLAGS select on this build. So the upstream macro itself fails to compile here ("unknown type name 'typeof'"), independent of anything in decoderbufs.Fixed by performing the same compile-time type check ourselves on PG19+, using the double-underscored
__typeof__GNU extension (which, unlike baretypeof, remains available in strict-ANSI modes on both gcc and clang) together with c.h's ownStaticAssertDecland__builtin_types_compatible_p. This check is purely a compile-time sanity check with no effect on behavior, so it is simply skipped (via an inner #if) on any toolchain lacking the builtin, rather than trying to fail the build.VARATT_IS_EXTERNAL_ONDISK()now takes aconst void *instead of silently accepting aDatum. tuple_to_tuple_msg() was passing the raw Datum (origval), which is an integer type on this platform, causing "makes pointer from integer without a cast". Fixed by wrapping the argument with DatumGetPointer(), which is correct and a no-op change on all supported PG versions.ReorderBufferTXNno longer has anxact_timemember. Upstream commit "Make some use of anonymous unions [reorderbuffer xact_time]" turned thexact_timeunion into an anonymous union embedded directly in ReorderBufferTXN, socommit_time(as well asprepare_time/abort_time) is once again accessed directly as txn->commit_time, the same way it was before PG15 introduced the namedxact_timeunion. This affected pg_decode_begin_txn(), pg_decode_commit_txn(), and pg_decode_change(). Fixed by adding aPG_VERSION_NUM >= 190000branch that uses txn->commit_time directly, while keeping the txn->xact_time.commit_time path for PG15-PG18 and the pre-PG15 txn->commit_time path unchanged.No behavioral changes for PG15-PG18 or earlier; this is purely a compatibility fix so the extension builds on PG19 as well.
Hacked by Claude, tested by me.
Per pgdg-packaging/pgdg-rpms#213