From 0a4231c3bc092f2902c8916f22b8571e97af8c18 Mon Sep 17 00:00:00 2001 From: "Joshua D. Drake" Date: Fri, 28 Aug 2026 15:07:53 -0600 Subject: [PATCH 1/2] test: refuse blank counters, and order the scan premise before them (#753) Found by running the removal proof I owed for #822 and did not do. #822 added two `scan_lines == 1` premises. I demonstrated the MECHANISM on a different query and never reddened the premises themselves, which is the shape this suite exists to catch. Doing it properly with `pgcolumnar.enable_custom_scan = off` reddens them at `got [0] want [1]`, so they are not vacuous. But it exposed a real defect. With no columnar scan in the plan every counter is an empty string, and `check "" ""` PASSES: -- a (the documented column): of groups read PASS the documented narrow query reads every chunk group That check reported success having compared one blank with another. A check that passes on nothing is worse than no check, and it would have stayed hidden because the mutation that produces it is not one the suite ever ran. Two changes. The scan-node premise now runs BEFORE anything reads a counter, rather than inside the cost block. Every counter in this suite is read out of a columnar scan's EXPLAIN output and does not exist without one, so that premise guards the whole suite and not just the two checks that happened to follow it. Two premises now refuse blanks explicitly: one for the group counters and one for the two costs. They print what they actually got, so a failure says `doc=/ sel=/` rather than leaving the reader to infer emptiness from a strange comparison. Removal proof, `pgcolumnar.enable_custom_scan = off`: before this commit check 1 PASSES on blanks, suite fails on other checks after 3 premises FAIL naming the cause, 11 checks run Stock is 11 of 11, up from 9. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_017Y7gXubmW8DDDZPZNPXJHm --- test/doc_parallel_premise.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/test/doc_parallel_premise.sh b/test/doc_parallel_premise.sh index 5ffb17b..8cf7c12 100755 --- a/test/doc_parallel_premise.sh +++ b/test/doc_parallel_premise.sh @@ -114,8 +114,23 @@ serial_cost() { | grep -oE 'cost=[0-9.]+\.\.[0-9.]+' | sed 's/.*\.\.//' | head -1 } +# The scan-node premise comes FIRST, because every counter below is read out of +# a columnar scan's EXPLAIN output and does not exist without one. +for _c in "$doc_col" sel; do + check "premise: the $_c plan is exactly one columnar scan node" \ + "$(scan_lines "$_c")" "1" +done + doc_read=$(read_groups "$doc_col"); doc_tot=$(total_groups "$doc_col") sel_read=$(read_groups sel); sel_tot=$(total_groups sel) + +# A counter that was not printed is an EMPTY string, and `check "" ""` PASSES. +# That is not hypothetical: with pgcolumnar.enable_custom_scan=off the plan is a +# seq scan, every counter below is blank, and check 1 passed comparing one blank +# with another. A check that passes on nothing is worse than no check. +check "premise: the group counters were read, not blank" \ + "$([ -n "$doc_read" ] && [ -n "$doc_tot" ] && [ -n "$sel_read" ] && [ -n "$sel_tot" ] \ + && echo yes || echo "doc=$doc_read/$doc_tot sel=$sel_read/$sel_tot")" "yes" echo "-- $doc_col (the documented column): $doc_read of $doc_tot groups read" echo "-- sel (stored in order): $sel_read of $sel_tot groups read" @@ -141,11 +156,9 @@ check "the documented column is not the one stored in order" \ # Exact rather than bounded: reading more groups must cost more. A bound here # would need calibrating and the direction does not. if [ "$doc_col" != "sel" ]; then - for _c in "$doc_col" sel; do - check "premise: the $_c plan is exactly one columnar scan node" \ - "$(scan_lines "$_c")" "1" - done dc=$(serial_cost "$doc_col"); sc=$(serial_cost sel) + check "premise: both costs were extracted, not blank" \ + "$([ -n "$dc" ] && [ -n "$sc" ] && echo yes || echo "dc=$dc sc=$sc")" "yes" echo "-- serial cost: $doc_col $dc, sel $sc" check "and the documented column is costed above the ordered one" \ "$(awk -v a="$dc" -v b="$sc" 'BEGIN { print (a > b) ? "yes" : "no (" a " vs " b ")" }')" "yes" From 3a1f8e876458171b61aeda1a4b8f429312299636 Mon Sep 17 00:00:00 2001 From: "Joshua D. Drake" Date: Fri, 28 Aug 2026 15:17:19 -0600 Subject: [PATCH 2/2] test: let the group-counter check defend itself, not lean on a premise Review suggestion from #823. Defaults that cannot collide, so blank-versus-blank fails on its own rather than relying on the premise above it to catch first: "${doc_read:-}" "${doc_tot:-}" Under enable_custom_scan=off the check now reports FAIL the documented narrow query reads every chunk group: got [] want [] where before it printed PASS having compared one blank with another. The premises stay, because they name the cause; this makes the check independent of them. Suggested by OffgridwithJD. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_017Y7gXubmW8DDDZPZNPXJHm --- test/doc_parallel_premise.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/doc_parallel_premise.sh b/test/doc_parallel_premise.sh index 8cf7c12..e3611eb 100755 --- a/test/doc_parallel_premise.sh +++ b/test/doc_parallel_premise.sh @@ -137,8 +137,12 @@ echo "-- sel (stored in order): $sel_read of $sel_tot groups read" # --- 1. the defect this suite exists for ------------------------------------ # The published speedup numbers were taken with every group read. If the page's # query prunes, the numbers beside it describe a different amount of work. +# Defaults that CANNOT collide, so blank-versus-blank fails on its own rather +# than relying on the premise above to catch it. `check "" ""` passes, so a check +# fed by two extracted values must never be able to compare one blank with +# another. check "the documented narrow query reads every chunk group" \ - "$doc_read" "$doc_tot" + "${doc_read:-}" "${doc_tot:-}" # --- 2. the contrast the page now documents is real ------------------------- check "and filtering the ordered column instead prunes some away" \