Skip to content

With plugins_require_parse, refuse string function bodies and DO blocks while a table is listed in table access - #37

Merged
artem-pplx merged 7 commits into
mainfrom
artem-pplx/table-access-string-bodies
Nov 19, 2026
Merged

artem-pplx merged 7 commits into
mainfrom
artem-pplx/table-access-string-bodies

Conversation

@artem-pplx

@artem-pplx artem-pplx commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Table access checks the tables a statement names. A function body given as a string (CREATE FUNCTION ... LANGUAGE sql AS $$ SELECT ... FROM t $$, or plpgsql, or any other language) is opaque to the parser. A function created this way can read a table listed in table access (pools.<pool>.plugins.table_access.tables) that table access never saw, and later calls to it name only the function. DO blocks and string-bodied CREATE PROCEDURE don't parse at all, and the unparsed-query check only looks for listed names in their text, which a body can build at run time.

Policy

On a pool with plugins_require_parse, while any table is listed in table access, no string body reaches the server. Table access refuses a parsed CREATE FUNCTION or CREATE PROCEDURE with a string body, and unparsed DO, CREATE FUNCTION and CREATE PROCEDURE are refused too. The guarantee holds only in strict mode: the pool sets plugins_require_parse, or a process-wide plugin is registered, which makes pgcat require parsing on every pool. Otherwise, when the pool flag is off and no process-wide plugin is registered, built-in table access checks names only, as on main: parsed or not, a string body is forwarded, because an unparsed DO block or CREATE FUNCTION (one with COST or ROWS) would be forwarded anyway. Either way, functions that run SQL given as text (query_to_xml, dblink) aren't refused.

  • With plugins_require_parse, table access refuses CREATE [OR REPLACE] FUNCTION and CREATE PROCEDURE unless the body is SQL it can read. That means RETURN expr or BEGIN ATOMIC ... END for a function, and BEGIN ATOMIC ... END for a procedure. String bodies (AS '...', AS $$...$$, with or without a link symbol, in any language) are refused, and so is any body form the parser adds later. The 42501 message is permission for a function body given as a string denied.
  • With plugins_require_parse, an unparsed query is refused while any table is listed in table access or gated by a configured plugin, if one of its statements starts with DO or CREATE [OR REPLACE] FUNCTION|PROCEDURE. This follows the existing rule for unparsed VACUUM.
    • Statements are found with the tokenizer, so a keyword inside a string or comment doesn't count. The tokenizer reads the text as written, since dollar-quote tags are case-sensitive. Text without do, function or procedure (in any case) isn't tokenized, since keywords can't be escaped. Text with one of them that can't be tokenized is refused.
    • The tokenizer reads the lines after COPY ... FROM STDIN; as the COPY's data, but the server runs them as statements, since COPY data comes in messages of its own. So that data is tokenized again and put back after the rest of the ; line, and a statement that starts on that line and goes on in the data is read whole. Data ended by a \. line, which the server can read as part of a comment or string, is refused. So is a query with more than four such COPYs, which keeps the cost linear.
    • The tokenizer reads strings as Postgres does with standard_conforming_strings = on. A session that turns that off can make pgcat and the server end a string in different places. That affects every name check, not just this one, and is left for a separate change.
  • A body given as SQL (BEGIN ATOMIC ... END, RETURN expr) is parsed, so it's allowed and checked by the tables it names, with or without plugins_require_parse.
  • The parsed refusal covers the tables listed in table access. A configured plugin sees a parsed string-bodied function like any other statement, and refuses it itself if its tables need that. The unparsed refusal covers every plugin's gated tables, because unparsed statements reach no plugin. Pools that set identity_tenant_parameter are covered either way: its tenant guard already refuses every DO and CREATE [OR REPLACE] FUNCTION|PROCEDURE, parsed or not.

Alternatives, if this is too strict for strict-mode pools that create functions:

  • Check string bodies by text: refuse a body only if it names a listed table, as the unparsed-query check does. This allows most migrations, but a body can build a name ('secr' || 'ets') and pass.
  • Parse LANGUAGE sql bodies and check them like BEGIN ATOMIC bodies, refusing other languages and bodies that don't parse. This is precise for SQL functions but still refuses plpgsql.

Change

  • table_access.rs: has_string_body, applied to nested statements as well, and a refusal that applies when the router requires parsing (QueryRouter::plugins_require_parse). It comes after the VACUUM of every table check, and allows only the body forms listed above.
  • query_router.rs: runs_string_body, used by might_touch_gated while any plugin gates a table, which runs only with plugins_require_parse. A word check comes before tokenizing. Unterminated COPY ... FROM STDIN data is tokenized again, and each statement's first four keywords are matched without allocating.
  • configured_tests.rs: with plugins_require_parse, a table-scoped configured plugin now refuses the unparsed DO block that builds a listed name. Without the setting it still forwards it. A query_to_xml call that builds the name is still forwarded, which pins that limitation.
  • CONFIG.md and docs/plugin-registration.md state the strict-mode guarantee, that built-in table access checks names only when the pool flag is off and no process-wide plugin is registered, and that configured plugins handle parsed string bodies for their own tables. Both say which inline COPY ... FROM STDIN data is refused, and docs/plugin-registration.md says the unparsed string-body rule applies while gated_tables is non-empty.

Impact

Strict pools (plugins_require_parse, or any pool while a process-wide plugin is registered) whose table access lists a table can no longer create functions or procedures with string bodies through pgcat. Strict pools where table access or a configured plugin gates any table refuse unparsed DO, CREATE FUNCTION and CREATE PROCEDURE. This newly affects pools that forwarded them under a table-scoped plugin; existing blanket refusals are unchanged. Migrations that need them must run against the server directly or use BEGIN ATOMIC bodies. Other pools behave as on main.

This PR is independent of #35 in behavior but conflicts in table_access.rs (the use sqlparser::ast list and the helper functions after granted()). Whichever lands second should change "a function body given as a string" in #35's "names inside strings" list, in both the module doc and docs/plugin-registration.md. It should say that the body is refused with plugins_require_parse (this rule) and unread without it.

Tested locally: cargo test --lib (395 passed). These tests carry most of the coverage:

  • test_string_function_bodies_are_refused_with_plugins_require_parse: a strict router refuses every string body, AS $$ SELECT count(*) FROM secrets $$ included. A router without the setting allows them, and both refuse a BEGIN ATOMIC/RETURN body that names secrets.
  • test_parsed_string_bodies_are_refused_only_with_plugins_require_parse: the same, through the router's plugin path, with secrets still listed after plugins_require_parse is turned off. With the pool flag off, a string body that names no listed table is forwarded with no plugin registered and refused once an allow-only process-wide plugin is registered.
  • test_only_sql_function_bodies_are_read: a hand-built procedure body As(..) and a missing function body are refused in strict mode.
  • test_unparsed_string_bodies_are_rejected_while_a_table_is_gated: CREATE FUNCTION ... COST 1 doesn't parse, is refused with plugins_require_parse, and is forwarded without it. Untokenizable text is refused only if it has one of the words. A DO, CREATE FUNCTION or CREATE PROCEDURE after COPY ... FROM STDIN; is refused. That covers one split across the ; line and the data, data ended by \. inside a comment, and five nested COPYs. COPY do_log FROM STDIN;\nSELECT 1 and four nested COPYs are forwarded. A DO block between strings with mixed-case dollar-quote tags ($a$ ... $A$ ... $a$) is refused.
  • unparsed_queries_are_refused_unless_the_plugin_is_table_scoped

Negative controls:

  • Making the parsed refusal ignore plugins_require_parse (the earlier behavior) fails the first two tests.
  • Removing the word check before tokenizing fails the fourth.
  • Restoring the previous runs_string_body fails the fourth at the first COPY case. Re-checking the COPY data on its own, without putting it back after the ; line, fails it at the split CREATE FUNCTION case. Tokenizing the lowercased text fails it at the mixed-case tag case. Setting COPY_DATA_READS to 3 fails it at the four nested COPYs.
  • Making the parsed refusal read the pool's flag instead of QueryRouter::plugins_require_parse fails the second at the process-wide plugin case.
  • Restoring the previous has_string_body fails the third.
  • Making the unparsed refusal ignore plugins_require_parse fails the fourth and fifth.

cargo fmt --check is clean, and cargo clippy --lib reports nothing in the changed code. In CI, the test job passes on this head: 395 + 4 Rust tests, and 297 Python tests passed with 14 xfailed.

Created with Perplexity

A function or procedure body given as a string, and a DO block, is code the
parser doesn't read, so table access can't see the tables it names. While
table access blocks any table, it refuses CREATE FUNCTION with a string body.
DO and string-bodied CREATE PROCEDURE don't parse; with
plugins_require_parse, an unparsed query holding one is refused while any
table is gated, as an unparsed VACUUM is. Bodies given as SQL (BEGIN ATOMIC,
RETURN) are parsed and checked as before.

Co-authored-by: Perplexity <noreply@perplexity.ai>

@artem-pplx artem-pplx left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at d94ff3de: not clear. One blocker and one design decision for the author.

Pass 1 of 2. This PR changes a security check, so a second reviewer on a different model will review the same head once the blocker is resolved.

Code. It does what it says for the statements it sees, and the tests hold up: each new or changed assert fails with the fix reverted.

Blocker. The docs and the description say a string-bodied CREATE FUNCTION is refused whenever a table is blocked. Without plugins_require_parse, a CREATE FUNCTION ... COST 1 AS $$...$$ (unparsed) or a DO block that creates the function is forwarded, so that's not a guarantee. Details are inline at docs/plugin-registration.md:220-225.

Design question (the author decides).

  • Under plugins_require_parse, the PR closes a real gap. DO $$ BEGIN EXECUTE '... secr' || 'ets'; END $$ and string-bodied functions could read a blocked table, and nothing caught them. This matches the existing strict-mode VACUUM rule.
  • Without it, the always-on parsed refusal costs a lot for little protection. It breaks every migration that creates a plpgsql or SQL function with a quoted body (updated_at/audit trigger functions in Rails, Django, Flyway, Liquibase, Alembic and Prisma; pg_dump restores), and it's bypassed with COST 1 or a DO wrapper.
  • Recommendation: apply the parsed refusal only when plugins_require_parse is on. Then strict mode means one thing, refusing code pgcat can't read, and other pools keep today's name-based guarantee, documented as such.
    • Per-pool scope (any blocked table refuses all string bodies) follows from the body being opaque, so it's justified.
    • A text check of bodies isn't a security rule, as the description itself notes.
    • Parsing LANGUAGE sql bodies is a good follow-up for strict-mode compatibility.
  • Either way, other built-ins also run SQL given as text and stay open in both modes. Don't describe the policy as "no string body can reach a blocked table": SELECT query_to_xml('select * from secrets', true, false, '') parses and is allowed, and ts_stat and dblink behave the same way.

Nonblocking (inline). standard_conforming_strings = off makes the tokenizer and the server lex strings differently. Also: make has_string_body fail closed, a cheap prefilter before tokenizing, CONFIG.md wording, the documented-limitation test, and one question about the gated set.

Description (nonblocking apart from the blocker text):

  1. Quoted: "while any table is blocked on a pool, no function body given as a string is accepted." Suggested: "while any table is blocked on a pool, table access refuses a parsed CREATE FUNCTION with a string body. With plugins_require_parse, unparsed DO, CREATE FUNCTION and CREATE PROCEDURE are refused too, so no string body reaches the server. Without it, a DO block or a CREATE FUNCTION the parser can't read is still forwarded."
  2. Quoted: "This PR is independent of #35. If #35 lands first, its module-doc sentence ... should then point to this rule." git merge-tree reports a content conflict with #35 in src/plugins/table_access.rs (the use sqlparser::ast::Ellipsis list, and the found chain in run()). docs/plugin-registration.md merges cleanly but contradicts itself: #35's bullet says string function bodies "aren't read", and this one says they're refused. Suggested: "This PR is independent of #35 in behavior but conflicts in table_access.rs. Whichever lands second should drop 'a function body given as a string' from #35's 'names inside strings' list, in both the module doc and docs/plugin-registration.md, and point to this rule."
  3. Title, optional: "Refuse string function bodies, and with plugins_require_parse DO blocks, while a table is blocked".
  4. The receipt "cargo test --lib (393 passed)" and the 42501 code are accurate.

What ran:

  • cargo +stable test --lib at this head: 393 passed, after forcing a rebuild of a stale shared target.
  • A negative control: reverting both checks fails all three new or changed tests.
  • cargo fmt --check is clean.
  • Probes of runs_string_body, parsing and tokenizing.
  • Limits: no Postgres server was run, and clippy wasn't run.

Reviewer: Claude Opus, High effort, pass 1 of 2. Comment-only.

Created with Perplexity

Comment thread docs/plugin-registration.md Resolved
Comment thread src/query_router.rs Resolved
Comment thread src/plugins/table_access.rs Resolved
Comment thread src/query_router.rs Resolved
Comment thread CONFIG.md Resolved
Comment thread src/plugins/table_access.rs Resolved

Copy link
Copy Markdown
Collaborator Author

Follow-ups outside this PR's scope (from pass 1 at d94ff3de):

  1. standard_conforming_strings. sqlparser always lexes as if the setting is on. A session that turns it off can make pgcat's parse differ from the server's, which affects every name check, not just this PR's. Consider refusing changes to it on gated pools (see the inline comment at query_router.rs:115-116).
  2. Built-ins that run SQL given as text. query_to_xml, query_to_xmlschema, query_to_xml_and_xmlschema, ts_stat and dblink* get past table access when parsed (confirmed for query_to_xml). Gate them by function name, or document them.
  3. Parse LANGUAGE sql string bodies. Checking them like BEGIN ATOMIC bodies would make most SQL-function migrations work again in strict mode.
  4. Reuse the new statement finder. first_word(...) == "vacuum" could use it for consistency. It isn't needed for safety, since VACUUM can't run in a multi-statement simple query.

Created with Perplexity

artem-pplx and others added 2 commits November 18, 2026 20:47
Table access refuses a string-bodied CREATE FUNCTION only when the parser
reads it. Without plugins_require_parse, a DO block or a CREATE FUNCTION with
an option the parser can't read (COST, ROWS) is forwarded, so the docs and
CONFIG.md now say the refusal is a guarantee only with that setting. A router
test pins it: those statements don't parse, and they're refused with the
setting and forwarded without it, even when the body names a gated table.

has_string_body now fails closed: any CREATE FUNCTION or CREATE PROCEDURE
whose body isn't RETURN or BEGIN ATOMIC, or that has none, counts as
unread, so a body form a later parser version gives isn't allowed unread.

The table-scoped test keeps a forwarded example of SQL that builds a name,
and CONFIG.md mentions the refusal of text that can't be tokenized.

Co-authored-by: Perplexity <noreply@perplexity.ai>
Co-authored-by: Perplexity <noreply@perplexity.ai>
@artem-pplx artem-pplx changed the title Refuse string function bodies and DO blocks while a table is blocked Refuse string function bodies, and with plugins_require_parse DO blocks, while a table is listed in table access Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Delta d94ff3de..dbe0190a: the docs blocker is resolved. The PR isn't cleared yet. It's waiting on the author's policy decision and then the final pass.

  • Docs blocker. docs/plugin-registration.md and CONFIG.md now say the refusal is a guarantee only with plugins_require_parse. They also state that DO, a string-bodied CREATE PROCEDURE, and CREATE FUNCTION ... COST/ROWS are forwarded without it, and that query_to_xml is never refused. The new router test pins the boundary: CREATE FUNCTION ... COST 1 AS $$ SELECT count(*) FROM secrets $$ doesn't parse, is refused with the setting, and is forwarded without it.
  • has_string_body fails closed. Only RETURN/BEGIN ATOMIC function bodies and BEGIN ATOMIC procedure bodies count as read. Any other parsed form, or no body, is refused. test_only_sql_function_bodies_are_read builds the unreadable shapes by hand and asserts the refusal.
  • CONFIG.md. The tokenize-failure line is added.
  • Built name. builds_the_name_elsewhere (an unparsed query_to_xml with a built name) is pinned as forwarded, so the documented limitation has a test.
  • Overlap note with Check every table name a statement gives, and route SELECT INTO to the primary #35. It now names the import list, the helper region and the docs contradiction.
  • Accepted as follow-ups, with replies on those threads: standard_conforming_strings, and the tokenize prefilter (pending the decision). The author also answered the gated-set question.

Still open: the policy itself. The parsed refusal is still unconditional at this head. Once the author decides, a fresh pass on a different model will review that head.

Reviewer: Claude Opus, High effort, delta check of the changed hunks. I didn't rerun the tests; CI on this head is green, and the author's negative controls are reported in the PR. Comment-only.

Created with Perplexity

Without plugins_require_parse, an unparsed DO block or CREATE FUNCTION
is forwarded anyway, so refusing the parsed ones guarded nothing there.
Table access now refuses a parsed string body only on pools that set
it, and checks names only on the others, as before. Text that can't be
tokenized is only read as a possible DO block or function if it has one
of those words, which also skips tokenizing most long queries.

Co-authored-by: Perplexity <noreply@perplexity.ai>
@artem-pplx artem-pplx changed the title Refuse string function bodies, and with plugins_require_parse DO blocks, while a table is listed in table access With plugins_require_parse, refuse string function bodies and DO blocks while a table is listed in table access Nov 18, 2026

@artem-pplx artem-pplx left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at 01e57dc: not clear yet. There's one blocker.

  • Blocker: runs_string_body misses DO / CREATE FUNCTION / CREATE PROCEDURE placed after COPY ... FROM STDIN; (inline on src/query_router.rs).

Option (a) is sound: TableAccess::run refuses parsed string bodies only when plugins_require_parse() is set, and has_string_body now fails closed. Negative controls confirm the tests check both modes: forcing the condition always on fails 2 tests, and forcing it off fails 3. The title and description match the head, apart from the blocker. There are three nonblocking inline notes. A pre-existing tokenizer follow-up goes in a separate comment.

Evidence: cargo +stable test --lib gives 395 passed, cargo +stable fmt --check is clean, and CI is 10/10 green. Probe tests and a PostgreSQL 18 wire check confirmed the blocker. Integration harnesses against a live deployment weren't run.

Review passes: Claude Opus 5.5 High (initial and delta), then a fresh Gemini 4 Carbon High final. This is the final pass that found the blocker. After the fix I'll run a delta and a new independent final on the new head.

Created with Perplexity

Comment thread src/query_router.rs Resolved
Comment thread src/query_router.rs Resolved
Comment thread src/query_router.rs Resolved
Comment thread docs/plugin-registration.md Resolved
The tokenizer reads the lines after `COPY ... FROM STDIN;` as the COPY's
data, so a DO or a string-bodied CREATE FUNCTION or PROCEDURE on them
wasn't seen, though the server runs them as statements. The data is now
tokenized again and put back after the rest of the `;` line, so a
statement that starts there and goes on in the data is read whole. Data
ended by a `\.` line, which the server can read as part of a comment, is
refused, and so is a query with more than four of these COPYs.

The statement check matches keywords instead of lowercased strings, the
prefilter comment says what the prefilter skips, and the plugin docs say
the string-body rule applies while gated_tables is non-empty.

Co-authored-by: Perplexity <noreply@perplexity.ai>

@artem-pplx artem-pplx left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at d62fb0e: not clear yet. There is one new blocker, and it is not in the COPY change.

  • The COPY FROM STDIN blocker is fixed. I checked the splice against sqlparser 0.64's capture_copy_data. Unterminated data runs to the end of the input, so there's at most one such capture and it's last in the source. The rest-of-line tokens come from next_token, which never produces CopyData. Retokenizing the data with a fresh tracker either finds statements or a nested capture, which the loop handles, and the bound keeps the cost linear. I also probed a few cases at this head with a scratch test, and each was refused: a multi-line comment on the ; line, COPY a FROM STDIN; COPY b FROM\nSTDIN; DO ..., and a nested COPY with DO on the same data line.
  • Blocker: runs_string_body gets the lowercased query, and dollar-quote tags are case-sensitive, so mixed-case tags can hide a DO block (inline at src/query_router.rs:2136).
  • Nonblocking: the docs paragraph doesn't mention the inline-COPY refusals (inline).

The title and description match this head.

Evidence: CI is green on d62fb0e (10/10). I ran the 46 query_router lib tests locally, plus a scratch test (not committed) and one query against PostgreSQL 18.6. I didn't rerun the full suite. Review: Claude Opus 5.5, High effort, delta pass. The fresh GPT-6.2 Astra High final will run on the head that fixes the blocker.

Created with Perplexity

Comment thread src/query_router.rs Resolved
Comment thread docs/plugin-registration.md Resolved
might_touch_gated lowercased the query before it looked for DO and
CREATE FUNCTION or PROCEDURE statements. Dollar-quote tags are
case-sensitive, so the tokenizer could end a `$a$` string at `$A$`, read
a later DO block as part of a string, and forward it. runs_string_body
now gets the text as written; its keyword and substring checks already
ignore case.

CONFIG.md and the plugin docs also say that inline COPY FROM STDIN data
ending with a `\.` line, or nesting more than four COPYs, is refused.

Co-authored-by: Perplexity <noreply@perplexity.ai>

@artem-pplx artem-pplx left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at c7e5cd2: not clear. The only blocker is wording in the docs and description; the enforcement is sound.

  • The dollar-tag fix is verified. runs_string_body(original) is in place, the case is a refused body, and it passes as both simple query and Parse.
  • The COPY repair holds against sqlparser 0.64's capture code. The final pass covered LF, CR and CRLF, an empty tail, multi-line strings and comments on the ; line, two COPYs on one line, and the 4/5 boundary.
  • Blocker: CONFIG.md and the plugin-registration docs say the refusal follows the pool's plugins_require_parse, but a registered process-wide plugin also turns it on (inline at CONFIG.md:419-422). The description has the same issue (top-level comment).
  • Nonblocking: the COPY clause needs the word qualifier, and the depth test should use literals (inline).

Evidence: CI 10/10 green. cargo test --lib passed locally (395). The final pass ran focused and scratch tests plus a constant mutation (4 to 3). Passes on this head: Claude Opus 5.5 High (delta) and GPT-6.2 Astra High (fresh independent final). Once a head fixes only this wording, I'll check it with a docs-only delta.

Created with Perplexity

Comment thread CONFIG.md Resolved
Comment thread docs/plugin-registration.md Resolved
Comment thread src/query_router.rs Resolved

Copy link
Copy Markdown
Collaborator Author

Description: two rollout statements don't match this head (blocker-level, wording only)

  1. Policy: "The guarantee holds only in that strict mode. On a pool without plugins_require_parse, table access checks names only, as on main"

    A registered process-wide plugin also makes the mode strict, through QueryRouter::plugins_require_parse(). Replacement:

    The guarantee holds only in strict mode: the pool sets plugins_require_parse, or a process-wide plugin is registered, which makes pgcat require parsing on every pool. Otherwise table access checks names only, as on main

  2. Impact: "Pools without plugins_require_parse, and pools whose table access lists no table, behave as on main."

    Two cases differ from main. A process-wide plugin plus a listed table refuses parsed string bodies even with the pool flag false. And on a strict pool whose table access lists no table, a configured plugin's gated tables still make unparsed DO, CREATE FUNCTION and CREATE PROCEDURE refused, as configured_tests.rs:773-778 asserts. Replacement:

    Strict pools (plugins_require_parse, or any pool while a process-wide plugin is registered) whose table access lists a table can no longer create functions or procedures with string bodies through pgcat. Strict pools where table access or a configured plugin gates any table can no longer run unparsed DO, CREATE FUNCTION or CREATE PROCEDURE. Migrations that need them must run against the server directly or use BEGIN ATOMIC bodies. Other pools behave as on main.

The title is fine.

Created with Perplexity

The refusal follows the effective plugins_require_parse, which a
registered process-wide plugin turns on for every pool. CONFIG.md and the
plugin docs now say so. Their COPY clause also says it applies only to
text with one of the three words.

The depth test uses the documented 4 and 5, and a new case pins that a
registered process-wide plugin makes table access refuse a parsed string
body on a pool without plugins_require_parse.

Co-authored-by: Perplexity <noreply@perplexity.ai>

Copy link
Copy Markdown
Collaborator Author

Re the description comment: both statements now use your replacement wording. The Policy section defines strict mode as the pool setting plugins_require_parse or a registered process-wide plugin. Impact lists both differences from main: process-wide plugins, and configured plugins' gated tables on strict pools. The test and negative-control lists also cover the new process-wide case and the literal 4/5 depth check. The head is 3ea9be8, which changes only tests and docs.

Created with Perplexity

@artem-pplx artem-pplx left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict at 3ea9be8: clear.

  • The blocker from c7e5cd2 is resolved: CONFIG.md, the plugin-registration docs and the body's Policy/Impact now describe strict mode as the pool flag or a registered process-wide plugin, including configured plugins' gated tables.
  • The non-test code is byte-identical to c7e5cd2: both src/ hunks are inside mod test. So the enforcement clearance from that head carries over: the COPY FROM STDIN repair, original-case tokenization and the prefilter.
  • The new test pins the effective-flag rule: with the pool flag false, a string body is allowed with an empty registry and refused with an allow-only registered plugin. The depth test now pins the documented four allowed and five refused.
  • Two small optional wording edits to the description are in a separate comment, along with a ledger of follow-ups.

Evidence: CI 10/10 green. Locally, the two string-body tests pass at this head, and cargo test --lib (395) passed at c7e5cd2 with the same runtime code. Passes on this head: Claude Opus 5.5 High (delta) and a fresh GPT-6.2 Astra High (bounded delta, second model). Before that: GPT-6.2 Astra High (independent final) at c7e5cd2, Gemini 4 Carbon High (final) at 01e57dc, and Claude Opus 5.5 High (pass 1 and deltas).

Created with Perplexity

Copy link
Copy Markdown
Collaborator Author

Description: optional precision edits (nonblocking)

  1. Impact: "Strict pools where table access or a configured plugin gates any table can no longer run unparsed DO, CREATE FUNCTION or CREATE PROCEDURE." With a registered process-wide plugin, every unparsed query was already refused on main, so "no longer" overstates the change there. Suggested wording:

    Strict pools where table access or a configured plugin gates any table refuse unparsed DO, CREATE FUNCTION and CREATE PROCEDURE. This newly affects pools that forwarded them under a table-scoped plugin; existing blanket refusals are unchanged.

  2. Change, table_access.rs bullet and elsewhere: any remaining "pools without plugins_require_parse check names only" reads like a pool-flag-only rule. Suggested wording: "built-in table access checks names only when the pool flag is off and no process-wide plugin is registered."

The title is accurate.

Created with Perplexity

Copy link
Copy Markdown
Collaborator Author

Review ledger (follow-ups outside this PR's scope; none block it)

  • Tokenizer parity with the server lexer (follow-up, in progress separately). runs_string_body and the name checks rely on sqlparser tokenizing the way Postgres lexes. Known gaps that exist on main as well as here are handled in a separate change. The standard_conforming_strings = off case is one of them; it's documented in the PR body as left for that change, so I've resolved its thread with that disposition.
  • Work bound for long unparsed text (hardening). COPY_DATA_READS bounds the number of tokenizer passes, not the size of the first token vector. An unparsed query longer than query_parser_max_length is still tokenized once in full when it contains one of the three words. A byte cap before tokenizing (refusing above it while a table is gated) would bound memory as well. This is optional, and no throughput or memory test was run.
  • sqlparser upgrades. The COPY handling depends on sqlparser 0.64's CopyData capture (payload before the ;, rest-of-line after it). Keep the after_copy assertions when you bump sqlparser; they fail if that layout changes.

Disposition: recorded once. I won't reopen this review for these items.

Created with Perplexity

@artem-pplx
artem-pplx marked this pull request as ready for review November 19, 2026 06:20
@artem-pplx
artem-pplx merged commit 9c40703 into main Nov 19, 2026
10 checks passed
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.

2 participants