Skip to content

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

Description

@aesslinger

Summary

get_routines runs the PG 11+ prokind query unconditionally. The built-in driver checks server_version_num and falls back to a pre-PG-11 query that uses proisagg/proiswindow. On PostgreSQL 10.x (and older), the plugin's query fails with SQLSTATE 42703 column "prokind" does not exist.

Builtin behavior (upstream main)

src-tauri/src/drivers/postgres/mod.rs::get_routines:

let server_version_num: i32 = query_one(
    &pool,
    "SELECT current_setting('server_version_num')::int4 AS v", &[],
).await?.try_get("v").unwrap_or(0);

let query = if server_version_num >= 110000 {
    // PG 11+: SELECT proname, prokind … AND prokind IN ('f', 'p')
} else {
    // Pre-11: SELECT proname, 'f'::"char" AS prokind … AND NOT proisagg AND NOT proiswindow
};

Plugin behavior (this repo)

src/handlers/metadata.rs:665 — hardcoded single query with a comment:

// PG 11+ uses prokind; older versions use proisagg/proiswindow flags.
// CI runs PG 16, so we use the modern query.
let query = r#"
    SELECT proname, prokind
    FROM pg_proc
    WHERE pronamespace = … AND prokind IN ('f', 'p')
    ORDER BY proname
"#;

No version check, no fallback.

Impact

  • Severity: Low-Medium. PostgreSQL 10 is EOL (Nov 2022), but the built-in driver explicitly supports it and this is a trivial port. A user on a legacy PG server sees get_routines return a -32603 error (and the routine browser fails to load) instead of a routine list.
  • Not caught by the parity suite (CI runs PG 16 only).

Fix

Port the version branch: query current_setting('server_version_num')::int4, pick the query by >= 110000, run it. Add a test (the version-branch selection is unit-testable by testing both query strings; the live behavior on PG 10 would need a PG 10 container, likely #[ignore]).

Related

  • Builtin reference: TabularisDB/tabularis drivers/postgres/mod.rs::get_routines (the server_version_num branch).
  • Related upstream issue: TabularisDB/tabularis#375 ("Schema introspection fails on PostgreSQL < 11 (column 'prokind' does not exist)") — same root cause on the builtin side, already fixed there.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcapability-gapA builtin-only feature this plugin doesn't yet support

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions