Repository navigation
Description
Missing feature
Protected read-only queries: declare capabilities.read_only_queries: true and implement the optional execute_read_only_query RPC, so a saved connection with Read-only mode enabled keeps working.
Plugin version
v1.0.0-rc.14 (.tabularium declares readonly: false and no read_only_queries, and the plugin source has no execute_read_only_query handler as of current main)
Tabularis app version
0.33.1 (affects the build from TabularisDB/tabularis#1625, which removes the built-in PostgreSQL driver)
Additional context
Behavior change. The built-in PostgreSQL driver supported the per-connection Read-only mode: its queries ran with database-enforced write protection. A saved postgres connection with read_only = true therefore opened and ran reads.
Tabularis#1625 force-migrates saved postgres connections to postgresql. After that, the host's validate_support check refuses the connection before it is even tested, because the driver declares neither readonly nor read_only_queries:
This driver does not support protected read-only queries. Update the plugin or disable read-only mode in the connection settings.
So every read-only PostgreSQL connection stops opening after the upgrade, and the only way to use it again is to turn the protection off. The host deliberately never clears read_only itself, and it never falls back to execute_query for a protected call, so this has to be solved in the plugin.
What is needed (plugin side).
- Set
capabilities.read_only_queries: truein.tabularium. - Implement
execute_read_only_query. It has the same request and response shape asexecute_query(a bareQueryResult). See Optional protected read-only queries in the Tabularisplugins/PLUGIN_GUIDE.md. - Enforce protection in the database, not by keyword filtering. The host's SQL preflight cannot see side effects in stored functions, so the plugin must make the session unable to write even for calls that look like reads, for example
SET TRANSACTION READ ONLY/BEGIN READ ONLYon the pinned connection (ordefault_transaction_read_only = onfor that session). If protection cannot be enabled, return an error. - Restore or discard the physical connection on every success, error and cancellation path, so protection never leaks to a writable user of the same pool.
- Honor
ConnectionParams.read_onlyin connection testing and metadata discovery too. The host omits the savedstartup_scriptwhile it is on, and plugin initialization and metadata calls must not write.
Related contract notes.
- The host never retries a failed protected call through
execute_query. - Read-only batches are preflighted in full, then each statement uses the protected RPC independently; transaction/session-control statements are refused.
- Visual EXPLAIN stays unavailable in read-only mode, as for any plugin.
Suggested acceptance criteria.
- A write (
INSERT,UPDATE,DELETE, DDL, and a function call that writes) sent throughexecute_read_only_queryfails in the database and changes nothing. - A read through it succeeds, with paging parameters honored like
execute_query. - After a protected call fails or is cancelled, the next writable call on the same pool can write.
- A connection saved with
read_only = trueopens and lists schemas and tables.
Related. Found while reviewing TabularisDB/tabularis#1625 (CodeRabbit finding on lib.rs). Until this lands, read-only PostgreSQL connections cannot be opened after the built-in driver is removed.
Activity
fix: close review findings on protected read-only queries (#202)
test: exercise protected read-only queries over TLS, sockets and PgBo…
fix: close second-round review findings on protected read-only queries (
feat: add protected read-only queries (#202) (#205)