Skip to content

Commit c67665d

Browse files
Parenthesize chunk retention CASE expressions in PL/pgSQL IF guards (#99)
Database bootstrap currently fails with PostgreSQL 42601 at Original(10355): the first unparenthesized CASE in a PL/pgSQL IF exposes its internal THEN as the end of the IF condition. Parenthesize that CASE and the identical later map guard expression. Preserve both 512 MiB capacity checks, state-dependent 256 KiB/1 MiB reserves, error messages and every other migration byte. Exact original source-offset and whole-file inverse proofs plus whitespace and unchanged-tree checks pass. The cancelled native run has no completed test summary; this candidate has not executed SQL or native tests.
1 parent 7706e8f commit c67665d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/jupiter/migration/m20261008_000300_chunk_map_retention.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ BEGIN
152152
IF TG_OP='DELETE' OR TG_OP='TRUNCATE' THEN
153153
RAISE EXCEPTION 'chunk receipt generations and collection history are retained';
154154
END IF;
155-
IF mst2_chunk_retention_bytes()+CASE WHEN NEW.state IN ('DELETING','APPLIED') THEN 262144 ELSE 1048576 END>536870912 THEN
155+
IF mst2_chunk_retention_bytes()+(CASE WHEN NEW.state IN ('DELETING','APPLIED') THEN 262144 ELSE 1048576 END)>536870912 THEN
156156
RAISE EXCEPTION 'chunk receipt mutation lacks actual durable byte headroom';
157157
END IF;
158158
IF TG_OP='UPDATE' AND (NEW.receipt_key IS DISTINCT FROM OLD.receipt_key OR NEW.source_id IS DISTINCT FROM OLD.source_id
@@ -244,7 +244,7 @@ BEGIN
244244
IF NOT permitted THEN RAISE EXCEPTION 'map lifetime deletion lacks exact reader-free collection claim'; END IF;
245245
RETURN OLD;
246246
END IF;
247-
IF mst2_chunk_retention_bytes()+CASE WHEN NEW.state='DELETING' THEN 262144 ELSE 1048576 END>536870912 THEN
247+
IF mst2_chunk_retention_bytes()+(CASE WHEN NEW.state='DELETING' THEN 262144 ELSE 1048576 END)>536870912 THEN
248248
RAISE EXCEPTION 'chunk map lifetime mutation lacks actual durable byte headroom';
249249
END IF;
250250
IF TG_OP='UPDATE' AND (NEW.map_id IS DISTINCT FROM OLD.map_id OR NEW.generation IS DISTINCT FROM OLD.generation

0 commit comments

Comments
 (0)