Skip to content

fix: fall back to proisagg/proiswindow on PostgreSQL < 11 in get_routines (#88) - #110

Merged
aesslinger merged 1 commit into
mainfrom
fix/88-pg10-routines-fallback
Sep 16, 2026
Merged

aesslinger merged 1 commit into
mainfrom
fix/88-pg10-routines-fallback

Conversation

@aesslinger

Copy link
Copy Markdown
Collaborator

Summary

  • get_routines hardcoded the PG 11+ query referencing pg_proc.prokind unconditionally. prokind was introduced in PostgreSQL 11, replacing the boolean columns proisagg/proiswindow; on 9.x/10, referencing it fails at parse time (SQLSTATE 42703, column "prokind" does not exist).
  • The builtin driver queries current_setting('server_version_num') first and branches on >= 110000; ported that exactly, extracting the query-selection logic into a pure routine_query_for_version(server_version_num) function so it's unit-testable without a live server.

Fixes #88.

Test plan

  • TDD: added metadata_tests.rs (4 tests covering both branches and the exact 110000 boundary). Confirmed the pre-PG11 tests fail against a simulated pre-fix implementation (the old hardcoded modern-only query) before restoring the real fix.
  • cargo test --lib — 325 passed
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • Verified live against a real PostgreSQL 10.21 instance (podman postgres:10), not just simulated:
    • Confirmed prokind genuinely does not exist on that server — reproduced the exact SQLSTATE 42703 error from the issue via raw psql
    • Confirmed the pre-fix binary fails with that identical error against the real PG10 server
    • Confirmed the post-fix binary succeeds, correctly listing a real function as FUNCTION and correctly excluding a real aggregate (via the legacy proisagg filter) — the one part of this fix that's impossible to verify without an actual pre-PG11 server, since a mock/unit test can't reproduce PostgreSQL's own catalog behavior
    • Confirmed the modern branch still works unchanged against the existing PG16 live-test database

…ines (#88)

get_routines hardcoded the PG 11+ query that references pg_proc.prokind
unconditionally. prokind was introduced in PostgreSQL 11, replacing the
boolean columns proisagg/proiswindow; on 9.x/10, referencing it fails at
parse time (SQLSTATE 42703, "column \"prokind\" does not exist"). The
builtin driver queries current_setting('server_version_num') first and
branches on >= 110000; this repo's version had no such check.

Ported the version branch exactly, extracting the query-selection logic
into a pure routine_query_for_version(server_version_num) function so
it's unit-testable without a live server.

TDD: added metadata_tests.rs (4 tests covering both branches and the
exact 110000 boundary). Confirmed the new pre-PG11 tests fail against a
simulated pre-fix implementation (the old hardcoded modern-only query)
before restoring the real fix.

Verified live against a real PostgreSQL 10.21 instance (podman
postgres:10): confirmed "prokind" genuinely does not exist on that
server (reproducing the exact SQLSTATE 42703 error from the issue),
then confirmed the pre-fix binary fails with that identical error
against the real PG10 server while the post-fix binary succeeds --
correctly listing a real function as FUNCTION and correctly EXCLUDING a
real aggregate (via the legacy proisagg filter), which is the one part
of this fix impossible to verify without an actual pre-PG11 server.
Also verified the modern branch still works unchanged against the
existing PG16 live-test database.
@aesslinger aesslinger added the prerelease:rc Version suggestion targets a release candidate label Sep 16, 2026
@github-actions

Copy link
Copy Markdown

Version suggestion

Based on this PR's title (fix) and the prerelease:rc label:

Current 1.0.0-rc.3
Suggested next tag v1.0.0-rc.4

This is informational only — no tag or release is created automatically yet.

1 similar comment
@github-actions

Copy link
Copy Markdown

Version suggestion

Based on this PR's title (fix) and the prerelease:rc label:

Current 1.0.0-rc.3
Suggested next tag v1.0.0-rc.4

This is informational only — no tag or release is created automatically yet.

@aesslinger aesslinger self-assigned this Sep 16, 2026
@aesslinger
aesslinger merged commit fbc6474 into main Sep 16, 2026
14 checks passed
@aesslinger
aesslinger deleted the fix/88-pg10-routines-fallback branch September 16, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prerelease:rc Version suggestion targets a release candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_routines hardcodes the PG 11+ query (fails on PostgreSQL 10 with "column prokind does not exist")

1 participant