Skip to content

Fix keyword token numbers for PostgreSQL 18, and the regression tests on PostgreSQL 15-17 - #61

Open
devrimgunduz wants to merge 1 commit into
ossc-db:masterfrom
devrimgunduz:pg18-token-numbers
Open

devrimgunduz wants to merge 1 commit into
ossc-db:masterfrom
devrimgunduz:pg18-token-numbers

Conversation

@devrimgunduz

Copy link
Copy Markdown
Contributor

Fixes #60.

Problem

With 1.10, make installcheck only passes on PostgreSQL 18. On PostgreSQL 15, 16 and 17 both tests fail:

  • convert: expected/convert.out expects NULL, TRUE, FALSE and LOCALTIMESTAMP to be kept in the normalized output, but normalize_expr() replaces them with ?, as it always did.
  • store: expected/store.out has the Disabled: false lines that only PostgreSQL 18's EXPLAIN prints.

The convert difference comes from PostgreSQL 18 support (c03e976): pgsp_token_types.h reuses the PostgreSQL 17 token numbers for PostgreSQL 18, but five of them changed in PostgreSQL 18's gram.h. So on PostgreSQL 18 the IS_CONST check no longer matches these keywords, they are not masked, and the expected file was updated to that output.

token header (PG17/18 block) PG17 gram.h PG18 gram.h
FALSE_P 418 418 419
LOCALTIME 512 512 513
LOCALTIMESTAMP 513 513 514
NULL_P 552 552 553
TRUE_P 708 708 710

The gram.h values are from running bison on gram.y of the 17.11 and 18.6 tarballs. The other tokens in the enum are unchanged.

Changes

  • pgsp_token_types.h: keep the existing block for PostgreSQL 17 and add one with the PostgreSQL 18 values.
  • expected/convert.out: restore the two masked lines, as they were before c03e976. One file now matches all versions.
  • expected/store_1.out: new alternative output for PostgreSQL 17 and older, without the Disabled lines.

Compatibility

On PostgreSQL 18, these keywords are masked again in the normalized plan, as on older versions. Plans that differ only in such constants are treated as the same plan again, so plan ids of affected plans change compared to 1.10 on PostgreSQL 18.

Tests

1.10 plus this change, make installcheck with shared_preload_libraries = 'pg_store_plans,pg_stat_statements': both tests pass on PostgreSQL 15.19, 16.15, 17.11 and 18.6, on Rocky Linux 8 and Fedora 44.

Note: #58 (PostgreSQL 19 support) adds another block to the same place in pgsp_token_types.h; I will rebase whichever is merged second.

… on older versions

pgsp_token_types.h reused the PostgreSQL 17 token numbers for
PostgreSQL 18, but five of them changed in PostgreSQL 18's gram.h
(FALSE_P, LOCALTIME, LOCALTIMESTAMP, NULL_P, TRUE_P). normalize_expr()
therefore no longer replaced NULL, TRUE, FALSE, LOCALTIME and
LOCALTIMESTAMP with '?' on PostgreSQL 18. Add a separate block with the
PostgreSQL 18 values.

expected/convert.out was changed to the unmasked output when PostgreSQL
18 support was added, which made the convert test fail on older versions.
Restore the masked output; it is now the same on all versions.

Add expected/store_1.out for PostgreSQL 17 and older, where EXPLAIN does
not print the "Disabled" property.

Per ossc-db#60

This branch has not been deployed

No deployments
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.

convert regression test fails on vanilla PostgreSQL 16/17 (and on PG18 when keyword token numbers are in sync with the server)

1 participant