Skip to content

PGSQL 17/18 prohibits function json() but allows "json"() - #22

Open
andreimerlescu wants to merge 1 commit into
Graphicle-AI:mainfrom
andreimerlescu:bugfix/pg17-json-func
Open

andreimerlescu wants to merge 1 commit into
Graphicle-AI:mainfrom
andreimerlescu:bugfix/pg17-json-func

Conversation

@andreimerlescu

Copy link
Copy Markdown
Contributor

What this changes

Graphicle can't create a PostgreSQL store on PostgreSQL 17 or newer:

graphicle: Storage operation failed: syntax error at or near "json"

functions.sql uses json as a name in three places: the function
json(doc text), and the json column both json_each functions return.
Since PostgreSQL 17, JSON is a keyword that can't name a function,
parameter or returned column unquoted (Appendix C).
On 16 it could, so 16 works. Ubuntu 26.04 ships 18.

This quotes all three ("json"). The names are unchanged, so queries that
read the column don't change. No other name in the file collides with a
keyword of PostgreSQL 18.

CI doesn't set GRAPHICLE_DATABASE_URL, so the PostgreSQL tests are
skipped there. A follow-up could add a PostgreSQL 16 and 18 service job.

How you tested it

  • PostgreSQL 18 (Homebrew), GRAPHICLE_DATABASE_URL set:
    cargo test --locked --test it postgres_store: 8 of 8 pass; 6 of 8 fail
    with the error above without the json_each part of the fix.
  • PostgreSQL 16.15: the patched functions.sql loads, and json_each
    and "json"() return what they did before.
~/.cargo/bin/cargo +1.95.0 test --locked --test it postgres_store
running 8 tests
test postgres_store::a_sqlite_only_folder_is_refused_by_read_only_opens_too ... ok
test postgres_store::an_import_refuses_a_store_that_needs_a_newer_reader ... ok
test postgres_store::an_import_refuses_to_replace_a_store_whose_copy_is_still_running ... ok
test postgres_store::an_import_refuses_a_column_this_version_does_not_know ... ok
test postgres_store::an_unfinished_store_of_unknown_origin_names_both_commands_and_is_replaced ... ok
test postgres_store::a_restore_stopped_before_its_load_committed_is_refused ... ok
test postgres_store::an_import_stopped_before_its_copy_committed_is_refused_and_replaced ... ok
test postgres_store::an_empty_store_file_is_refused_never_filled_and_replaced_by_an_import ... ok

test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 548 filtered out; finished in 8.93s

I ran a benchmark against a host with 12 GiB of RAM on 2.2GHz CPUs that performed at:

replaying 6 tools (a starting mix (no usage yet)) against 43 projects, 20s per level, target: 95% within 2s

AGENTS    CALLS  ERRORS       P50       P95  CALLS/S
     1      348       0       9ms     201ms     17.4
     2      505       0      12ms     775ms     25.2
     4     1034       0      15ms     714ms     51.7
     8     1877       0      20ms     710ms     93.8
    16     2285       0      31ms     850ms    114.2
    32     2375       0     123ms     907ms    118.8
    64     2044       0     371ms    1.278s    102.2

Checklist

  • Every commit is signed off (git commit -s), as the
    Developer Certificate of Origin asks
    (CONTRIBUTING.md).
  • Tests and docs are updated where the behaviour changed. (Docs already
    say "PostgreSQL 16 or newer"; the existing PostgreSQL tests cover it.)
  • If a Cargo.lock changed, I ran cargo deny check in that crate and
    refreshed its licence page, as CONTRIBUTING.md describes. (No change.)
  • Code taken or ported from another project is permissively licensed and
    credited in the crate's NOTICE.md. (None.)
  • If I changed a benchmark number or a claim in the docs, it links to its
    evidence in docs/benchmarks.md. (None.)

Signed-off-by: Andrei Merlescu <andrei+github@merlescu.net>

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.

1 participant