Skip to content

Add PostgreSQL 19 support - #58

Open
devrimgunduz wants to merge 1 commit into
ossc-db:masterfrom
devrimgunduz:master
Open

Add PostgreSQL 19 support#58
devrimgunduz wants to merge 1 commit into
ossc-db:masterfrom
devrimgunduz:master

Conversation

@devrimgunduz

Copy link
Copy Markdown
Contributor

Changelog:

  • pgsp_token_types.h: Add a PG19 branch (PG_VERSION_NUM < 200000) for the hand-maintained core-scanner token enum. Values were not guessed: they were extracted from a bison-generated gram.h built from the actual PostgreSQL 19beta1 gram.y (CURRENT_CATALOG et al. stayed the same; FALSE_P/LOCALTIME/LOCALTIMESTAMP/NULL_P/TRUE_P shifted up because new keywords were inserted ahead of them in the grammar). This fixes the "#error This version of PostgeSQL is not supported" and the resulting cascade of ~20 "undeclared identifier" errors in pgsp_json.c (Op, SCONST, IDENT, FCONST, BCONST, XCONST, ICONST, NULL_P, TRUE_P, FALSE_P, CURRENT_*, LOCALTIME[STAMP]).

  • pgsp_json.c: Guard the yyextra.escape_string_warning = false; assignment to PG_VERSION_NUM < 190000. The field was removed from core_yy_extra_type in PG19's scanner cleanup, so it no longer exists to assign to; the warning it used to silence isn't emitted by the core scanner in PG19 either, so simply skipping the assignment is correct.

  • pgsp_explain.c (report_triggers): PG19 split per-trigger EXPLAIN ANALYZE timing out of the general Instrumentation struct into a new TriggerInstrumentation struct (upstream commit "instrumentation: Separate trigger logic from other uses"). ri_TrigInstrument is now an array of TriggerInstrumentation, exposing firing counts via ->firings and timing via ->instr.total (an instr_time, not a bare double). Added a PG_VERSION_NUM >= 190000 branch that mirrors upstream explain.c's report_triggers(): reads tginstr->firings/tginstr->instr.total instead of instr->ntuples/instr->total, and drops the manual InstrEndLoop() call that's no longer needed/applicable for triggers in PG19. This fixes the "incompatible pointer types", "no member named 'ntuples'", and "invalid operands to binary expression" errors.

  • pg_store_plans.c:

    • Add missing #include "access/htup_details.h" and #include "utils/tuplestore.h". PG19's funcapi.h/executor headers no longer pull these in transitively, so heap_form_tuple(), tuplestore_begin_heap(), and tuplestore_putvalues() were showing up as implicit-function-declaration errors even though the functions themselves are unchanged.
    • ShmemInitHash(): PG19 collapsed the old (init_size, max_size) pair into a single nelems argument (4-arg signature instead of 5-arg). Since pg_store_plans already always passed store_size for both arguments, this is a mechanical drop of the duplicate argument, version-gated on PG_VERSION_NUM >= 190000.
    • pgsp_ExecutorStart()/pgsp_ExecutorEnd(): PG19 removed QueryDesc->totaltime entirely and reworked top-of-query instrumentation around QueryDesc->query_instr / query_instr_options, managed by the core executor instead of by extensions calling InstrAlloc()/ InstrEndLoop() by hand (mirrors the same change already made in contrib/pg_stat_statements and contrib/auto_explain upstream). Added a PG_VERSION_NUM >= 190000 branch that requests INSTRUMENT_ALL via query_instr_options before the executor starts, and reads timing/buffer usage back out of queryDesc->query_instr in ExecutorEnd using INSTR_TIME_GET_DOUBLE(). The pre-19 code path (totaltime/InstrAlloc/ InstrEndLoop) is preserved unchanged for older versions.

Hacked by Claude, tested by me. So please double check the patch.

Per: pgdg-packaging/pgdg-rpms#213

- pgsp_token_types.h: Add a PG19 branch (PG_VERSION_NUM < 200000) for the
  hand-maintained core-scanner token enum. Values were not guessed: they
  were extracted from a bison-generated gram.h built from the actual
  PostgreSQL 19beta1 gram.y (CURRENT_CATALOG et al. stayed the same;
  FALSE_P/LOCALTIME/LOCALTIMESTAMP/NULL_P/TRUE_P shifted up because new
  keywords were inserted ahead of them in the grammar). This fixes the
  "#error This version of PostgeSQL is not supported" and the resulting
  cascade of ~20 "undeclared identifier" errors in pgsp_json.c
  (Op, SCONST, IDENT, FCONST, BCONST, XCONST, ICONST, NULL_P, TRUE_P,
  FALSE_P, CURRENT_*, LOCALTIME[STAMP]).

- pgsp_json.c: Guard the `yyextra.escape_string_warning = false;` assignment
  to PG_VERSION_NUM < 190000. The field was removed from core_yy_extra_type
  in PG19's scanner cleanup, so it no longer exists to assign to; the
  warning it used to silence isn't emitted by the core scanner in PG19
  either, so simply skipping the assignment is correct.

- pgsp_explain.c (report_triggers): PG19 split per-trigger EXPLAIN ANALYZE
  timing out of the general Instrumentation struct into a new
  TriggerInstrumentation struct (upstream commit "instrumentation: Separate
  trigger logic from other uses"). ri_TrigInstrument is now an array of
  TriggerInstrumentation, exposing firing counts via ->firings and timing
  via ->instr.total (an instr_time, not a bare double). Added a
  PG_VERSION_NUM >= 190000 branch that mirrors upstream explain.c's
  report_triggers(): reads tginstr->firings/tginstr->instr.total instead of
  instr->ntuples/instr->total, and drops the manual InstrEndLoop() call
  that's no longer needed/applicable for triggers in PG19. This fixes the
  "incompatible pointer types", "no member named 'ntuples'", and "invalid
  operands to binary expression" errors.

- pg_store_plans.c:
  * Add missing #include "access/htup_details.h" and
    #include "utils/tuplestore.h". PG19's funcapi.h/executor headers no
    longer pull these in transitively, so heap_form_tuple(),
    tuplestore_begin_heap(), and tuplestore_putvalues() were showing up as
    implicit-function-declaration errors even though the functions
    themselves are unchanged.
  * ShmemInitHash(): PG19 collapsed the old (init_size, max_size) pair into
    a single `nelems` argument (4-arg signature instead of 5-arg). Since
    pg_store_plans already always passed store_size for both arguments,
    this is a mechanical drop of the duplicate argument, version-gated on
    PG_VERSION_NUM >= 190000.
  * pgsp_ExecutorStart()/pgsp_ExecutorEnd(): PG19 removed
    QueryDesc->totaltime entirely and reworked top-of-query instrumentation
    around QueryDesc->query_instr / query_instr_options, managed by the
    core executor instead of by extensions calling InstrAlloc()/
    InstrEndLoop() by hand (mirrors the same change already made in
    contrib/pg_stat_statements and contrib/auto_explain upstream). Added a
    PG_VERSION_NUM >= 190000 branch that requests INSTRUMENT_ALL via
    query_instr_options before the executor starts, and reads timing/buffer
    usage back out of queryDesc->query_instr in ExecutorEnd using
    INSTR_TIME_GET_DOUBLE(). The pre-19 code path (totaltime/InstrAlloc/
    InstrEndLoop) is preserved unchanged for older versions.

Hacked by Claude, tested by me.
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