Fix CREATE DATABASE/DROP DATABASE pipeline error; bump CI postgres to 17 - #102
Closed
Magisus wants to merge 3 commits into
Closed
Fix CREATE DATABASE/DROP DATABASE pipeline error; bump CI postgres to 17#102Magisus wants to merge 3 commits into
Magisus wants to merge 3 commits into
Conversation
Align the CI test database with the Postgres version PE actually ships, rather than an older release. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…atement create-db! and drop-db! (and several tests) ran their SQL through clojure.java.jdbc's execute!, which always issues statements via a PreparedStatement and, for create-db!'s multi-role branch, combined GRANT/CREATE DATABASE/REVOKE into one semicolon-joined string. Postgres now rejects CREATE DATABASE and DROP DATABASE when they arrive this way, reporting "cannot be executed within a pipeline" (enforced as of Postgres 11.19/12.14/13.10/14.7/15.2, since running these commands without waiting for a prior command's result could previously leave the database in an inconsistent state if an earlier command failed). Add execute-unpiped!, a small helper that runs each SQL string as its own plain, unbatched java.sql.Statement on a single connection, and use it for create-db! and drop-db!. Update the tests that issued CREATE/DROP DATABASE directly via jdbc/execute! to go through create-db!/drop-db! instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… owner CREATE DATABASE ... OWNER other_role requires the connecting role to be able to SET ROLE to other_role. Postgres 16 split that ability out of plain role membership into its own SET privilege (pg_has_role's MEMBER type now only means "some form of membership exists", regardless of whether SET ROLE will work). Postgres 16 also changed CREATEROLE semantics so creating a role only grants the creator an ADMIN-only, SET-false membership over it automatically - enough to satisfy the old MEMBER check, but not enough to actually SET ROLE to it. create-db!'s pre-check therefore incorrectly concluded the caller could already act as the target owner, skipped the temporary GRANT, and then failed to CREATE DATABASE with "must be able to SET ROLE" on Postgres 16+. Add a version-aware can-set-role? check (SET privilege on 16+, MEMBER before) and include "WITH SET TRUE" on the temporary GRANT on 16+, where that clause is available. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Author
|
Closing — same repo-mismatch issue as #101: PE builds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
create-db!-test/drop-db!-testerror withPSQLException: CREATE DATABASE cannot be executed within a pipeline.clojure.java.jdbc/execute!always issues SQL through aPreparedStatement(extended query protocol), andcreate-db!'s multi-role branch additionally combinedGRANT/CREATE DATABASE/REVOKEinto one semicolon-joined string. Postgres now rejectsCREATE DATABASE/DROP DATABASEissued this way — enforced as of Postgres 11.19/12.14/13.10/14.7/15.2 (see https://www.postgresql.org/message-id/841565.1677254194@sss.pgh.pa.us).execute-unpiped!, which runs each SQL string as its own plain, unbatchedjava.sql.Statementon a single connection, and used it increate-db!/drop-db!. Updated the handful of tests that issuedCREATE/DROP DATABASEdirectly viajdbc/execute!to go throughcreate-db!/drop-db!instead.Test plan
lein check— no new warnings/errors from the changed codeclj-kondo --linton changed files — no new warningslein test :allagainst Postgres 17) — verifyingcreate-db!-test/drop-db!-testnow pass🤖 Generated with Claude Code