Skip to content

Commit 8e56751

Browse files
anandgupta42claude
andcommitted
fix(analyst): deny the advisory-unlock functions in sql_check predicate_effect
pg_advisory_unlock, pg_advisory_unlock_shared and pg_advisory_unlock_all release session-level locks held by the pooled connection, and a read-only rollback does not undo that. The denylist now covers every pg_advisory_* / pg_try_advisory_* function; regression cases added for the three unlock variants. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent c566efc commit 8e56751

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/opencode/src/altimate/tools/sql-check.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export function readSql(sql: string, dialect?: string): string {
187187
body,
188188
) ||
189189
/\bREPLACE\b(?!\s*\()/i.test(body) ||
190-
/\b(nextval|setval|set_config|load_extension|writefile|dblink|dblink_exec|dblink_send_query|dblink_connect|dblink_connect_u|lo_import|lo_export|lo_create|lo_unlink|lo_put|pg_write_file|pg_append_file|pg_file_write|pg_file_rename|pg_file_unlink|pg_logical_emit_message|pg_(?:try_)?advisory_(?:xact_)?lock\w*|pg_terminate_backend|pg_cancel_backend|pg_promote|pg_reload_conf)\s*\(/i.test(
190+
/\b(nextval|setval|set_config|load_extension|writefile|dblink|dblink_exec|dblink_send_query|dblink_connect|dblink_connect_u|lo_import|lo_export|lo_create|lo_unlink|lo_put|pg_write_file|pg_append_file|pg_file_write|pg_file_rename|pg_file_unlink|pg_logical_emit_message|pg_(?:try_)?advisory_\w*|pg_terminate_backend|pg_cancel_backend|pg_promote|pg_reload_conf)\s*\(/i.test(
191191
functions,
192192
)
193193
) {

‎packages/opencode/test/altimate/sql-check-postgres.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ describe("predicate_effect with mocked Postgres", () => {
9999
"pg_advisory_xact_lock_shared",
100100
"pg_try_advisory_xact_lock",
101101
"pg_try_advisory_xact_lock_shared",
102+
"pg_advisory_unlock",
103+
"pg_advisory_unlock_shared",
104+
"pg_advisory_unlock_all",
102105
].map((name): [string, string[]] => [
103106
"advisory-lock",
104107
[`${name}(1)`, `PG_CATALOG.${name.toUpperCase()}(1, 2)`, `pg_catalog."${name}" /* lock */ (1)`],

0 commit comments

Comments
 (0)