Skip to content

Add PostgreSQL 18 and 19 support to sqlite_fdw#118

Open
devrimgunduz wants to merge 1 commit into
pgspider:masterfrom
devrimgunduz:master
Open

Add PostgreSQL 18 and 19 support to sqlite_fdw#118
devrimgunduz wants to merge 1 commit into
pgspider:masterfrom
devrimgunduz:master

Conversation

@devrimgunduz

Copy link
Copy Markdown

Fixes all build failures and warnings against PostgreSQL 18 and 19 while preserving full compatibility with PG13 through PG17.

connection.c — PostgreSQL 18 and 19
utils/hsearch.h and utils/tuplestore.h are no longer pulled in
transitively in recent PostgreSQL versions. Add them explicitly and
unconditionally so that HASHCTL, HASH_SEQ_STATUS, hash_create(),
hash_search(), hash_seq_init(), hash_seq_search(), HASH_ELEM,
HASH_BLOBS, HASH_ENTER and tuplestore_putvalues() are visible.

deparse.c — PostgreSQL 19
Three headers dropped from the transitive include chain by PG19's
IWYU cleanup pass; add them explicitly (unconditionally):
catalog/pg_type.h — all *OID and *ARRAYOID type constants
access/htup_details.h — GETSTRUCT()
access/transam.h — FirstGenbkiObjectId

deparse.c — PostgreSQL 18 and 19
PathKey.pk_strategy (int, btree StrategyNumber) was replaced by
pk_cmptype (CompareType) in PG18. The lookup function changed from
get_opfamily_member() to get_opfamily_member_for_cmptype().
BTLessStrategyNumber comparisons use COMPARE_LT instead.
All guarded by #if PG_VERSION_NUM >= 180000. Affects:
sqlite_is_foreign_pathkey() and sqlite_append_order_by_clause().

deparse.c — all versions (warning fix)
Remove dead pindex variable (AttrNumber) from sqlite_deparse_insert()
and sqlite_deparse_update(). The variable was only ever incremented,
never read; SQLite uses unnumbered '?' placeholders.

sqlite_fdw.c — PostgreSQL 19
access/htup_details.h is no longer transitively included for
sqlite_fdw.c in PG19, making SizeofHeapTupleHeader undeclared.
Add the header explicitly (unconditionally; safe on all PG versions).

sqlite_fdw.c — PostgreSQL 19
In PG19, PlanState.instrument changed type from Instrumentation * to
NodeInstrumentation *. The Instrumentation base struct no longer
carries tuplecount (that field moved to NodeInstrumentation). Use
NodeInstrumentation * under #if PG_VERSION_NUM >= 190000 in
sqliteIterateDirectModify(), leaving PG13–18 behaviour unchanged.

sqlite_fdw.c — PostgreSQL 18
create_foreignscan_path(), create_foreign_join_path() and
create_foreign_upper_path() each gained "int disabled_nodes" between
"rows" and "startup_cost". Pass 0 at all ten call sites under a
#if PG_VERSION_NUM >= 180000 guard.
cost_sort() gained "int input_disabled_nodes" between "pathkeys" and
"input_cost". Pass 0 at the one call site under the same guard.
ExplainPropertyText(), ExplainPropertyInteger() and the ExplainState
struct were split into commands/explain_format.h and
commands/explain_state.h; include both for PG18+.

sqlite_fdw.c — all versions (warning fix)
Remove dead variable i (int) from sqliteExecForeignUpdate(); it was
only incremented, never read.

sqlite_query.c — PostgreSQL 19
VARDATA() and SET_VARSIZE() became strict-typed static inline
functions in PG19 requiring a pointer argument. Wrap the raw Datum
value_datum with DatumGetPointer() at both call sites in
sqlite_convert_to_pg(). DatumGetPointer() is a safe portable cast
on all supported PG versions.

Coded by Claude, tested by me.

Per pgdg-packaging/pgdg-rpms#213

Fixes all build failures and warnings against PostgreSQL 18 and 19
while preserving full compatibility with PG13 through PG17.

connection.c — PostgreSQL 18 and 19
  utils/hsearch.h and utils/tuplestore.h are no longer pulled in
  transitively in recent PostgreSQL versions.  Add them explicitly and
  unconditionally so that HASHCTL, HASH_SEQ_STATUS, hash_create(),
  hash_search(), hash_seq_init(), hash_seq_search(), HASH_ELEM,
  HASH_BLOBS, HASH_ENTER and tuplestore_putvalues() are visible.

deparse.c — PostgreSQL 19
  Three headers dropped from the transitive include chain by PG19's
  IWYU cleanup pass; add them explicitly (unconditionally):
    catalog/pg_type.h    — all *OID and *ARRAYOID type constants
    access/htup_details.h — GETSTRUCT()
    access/transam.h     — FirstGenbkiObjectId

deparse.c — PostgreSQL 18 and 19
  PathKey.pk_strategy (int, btree StrategyNumber) was replaced by
  pk_cmptype (CompareType) in PG18.  The lookup function changed from
  get_opfamily_member() to get_opfamily_member_for_cmptype().
  BTLessStrategyNumber comparisons use COMPARE_LT instead.
  All guarded by #if PG_VERSION_NUM >= 180000.  Affects:
  sqlite_is_foreign_pathkey() and sqlite_append_order_by_clause().

deparse.c — all versions (warning fix)
  Remove dead pindex variable (AttrNumber) from sqlite_deparse_insert()
  and sqlite_deparse_update().  The variable was only ever incremented,
  never read; SQLite uses unnumbered '?' placeholders.

sqlite_fdw.c — PostgreSQL 19
  access/htup_details.h is no longer transitively included for
  sqlite_fdw.c in PG19, making SizeofHeapTupleHeader undeclared.
  Add the header explicitly (unconditionally; safe on all PG versions).

sqlite_fdw.c — PostgreSQL 19
  In PG19, PlanState.instrument changed type from Instrumentation * to
  NodeInstrumentation *.  The Instrumentation base struct no longer
  carries tuplecount (that field moved to NodeInstrumentation).  Use
  NodeInstrumentation * under #if PG_VERSION_NUM >= 190000 in
  sqliteIterateDirectModify(), leaving PG13–18 behaviour unchanged.

sqlite_fdw.c — PostgreSQL 18
  create_foreignscan_path(), create_foreign_join_path() and
  create_foreign_upper_path() each gained "int disabled_nodes" between
  "rows" and "startup_cost".  Pass 0 at all ten call sites under a
  #if PG_VERSION_NUM >= 180000 guard.
  cost_sort() gained "int input_disabled_nodes" between "pathkeys" and
  "input_cost".  Pass 0 at the one call site under the same guard.
  ExplainPropertyText(), ExplainPropertyInteger() and the ExplainState
  struct were split into commands/explain_format.h and
  commands/explain_state.h; include both for PG18+.

sqlite_fdw.c — all versions (warning fix)
  Remove dead variable i (int) from sqliteExecForeignUpdate(); it was
  only incremented, never read.

sqlite_query.c — PostgreSQL 19
  VARDATA() and SET_VARSIZE() became strict-typed static inline
  functions in PG19 requiring a pointer argument.  Wrap the raw Datum
  value_datum with DatumGetPointer() at both call sites in
  sqlite_convert_to_pg().  DatumGetPointer() is a safe portable cast
  on all supported PG versions.

Coded by Claude, tested by me.

Per pgdg-packaging/pgdg-rpms#213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant