PG17 regress sanity: Fix test diffs in columnar schedule

pull/7767/head
Colm McHugh 2024-11-25 14:41:07 +00:00
parent c396ce60a0
commit 80658d1783
6 changed files with 75 additions and 17 deletions

View File

@ -977,6 +977,7 @@ DETAIL: unparameterized; 1 clauses pushed down
(1 row) (1 row)
SET hash_mem_multiplier = 1.0; SET hash_mem_multiplier = 1.0;
SELECT public.explain_with_pg16_subplan_format($Q$
EXPLAIN (analyze on, costs off, timing off, summary off) EXPLAIN (analyze on, costs off, timing off, summary off)
SELECT sum(a) FROM pushdown_test where SELECT sum(a) FROM pushdown_test where
( (
@ -989,13 +990,18 @@ SELECT sum(a) FROM pushdown_test where
) )
or or
(a > 200000-2010); (a > 200000-2010);
$Q$) as "QUERY PLAN";
NOTICE: columnar planner: adding CustomScan path for pushdown_test NOTICE: columnar planner: adding CustomScan path for pushdown_test
DETAIL: unparameterized; 0 clauses pushed down DETAIL: unparameterized; 0 clauses pushed down
CONTEXT: PL/pgSQL function explain_with_pg16_subplan_format(text) line XX at FOR over EXECUTE statement
NOTICE: columnar planner: cannot push down clause: must match 'Var <op> Expr' or 'Expr <op> Var' NOTICE: columnar planner: cannot push down clause: must match 'Var <op> Expr' or 'Expr <op> Var'
HINT: Var must only reference this rel, and Expr must not reference this rel HINT: Var must only reference this rel, and Expr must not reference this rel
CONTEXT: PL/pgSQL function explain_with_pg16_subplan_format(text) line XX at FOR over EXECUTE statement
NOTICE: columnar planner: cannot push down clause: must not contain a subplan NOTICE: columnar planner: cannot push down clause: must not contain a subplan
CONTEXT: PL/pgSQL function explain_with_pg16_subplan_format(text) line XX at FOR over EXECUTE statement
NOTICE: columnar planner: adding CustomScan path for pushdown_test NOTICE: columnar planner: adding CustomScan path for pushdown_test
DETAIL: unparameterized; 1 clauses pushed down DETAIL: unparameterized; 1 clauses pushed down
CONTEXT: PL/pgSQL function explain_with_pg16_subplan_format(text) line XX at FOR over EXECUTE statement
QUERY PLAN QUERY PLAN
--------------------------------------------------------------------- ---------------------------------------------------------------------
Aggregate (actual rows=1 loops=1) Aggregate (actual rows=1 loops=1)
@ -1092,14 +1098,14 @@ BEGIN;
END; END;
EXPLAIN (analyze on, costs off, timing off, summary off) EXPLAIN (analyze on, costs off, timing off, summary off)
SELECT id FROM pushdown_test WHERE country IN ('USA', 'BR', 'ZW'); SELECT id FROM pushdown_test WHERE country IN ('USA', 'BR', 'ZW');
QUERY PLAN QUERY PLAN
--------------------------------------------------------------------- ---------------------------------------------------------------------
Custom Scan (ColumnarScan) on pushdown_test (actual rows=3 loops=1) Custom Scan (ColumnarScan) on pushdown_test (actual rows=3 loops=1)
Filter: (country = ANY ('{USA,BR,ZW}'::text[])) Filter: (country = ANY ('{USA,BR,ZW}'::text[]))
Rows Removed by Filter: 1 Rows Removed by Filter: 1
Columnar Projected Columns: id, country Columnar Projected Columns: id, country
Columnar Chunk Group Filters: (country = ANY ('{USA,BR,ZW}'::text[])) Columnar Chunk Group Filters: (country = ANY ('{USA,BR,ZW}'::text[]))
Columnar Chunk Groups Removed by Filter: 2 Columnar Chunk Groups Removed by Filter: 2
(6 rows) (6 rows)
SELECT id FROM pushdown_test WHERE country IN ('USA', 'BR', 'ZW'); SELECT id FROM pushdown_test WHERE country IN ('USA', 'BR', 'ZW');

View File

@ -290,27 +290,28 @@ BEGIN;
(16 rows) (16 rows)
ROLLBACK; ROLLBACK;
-- Force nested loop join to ensure the next query has a
-- consistent plan across pg versions
set enable_hashjoin to 0;
set enable_mergejoin to 0;
-- use custom scan -- use custom scan
EXPLAIN (COSTS OFF) WITH w AS (SELECT * FROM full_correlated) EXPLAIN (COSTS OFF) WITH w AS (SELECT * FROM full_correlated)
SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d
WHERE w2.a = 123; WHERE w2.a = 123;
QUERY PLAN QUERY PLAN
--------------------------------------------------------------------- ---------------------------------------------------------------------
Merge Join Nested Loop
Merge Cond: (w2.d = w1.a) Join Filter: (w1.a = w2.d)
CTE w CTE w
-> Custom Scan (ColumnarScan) on full_correlated -> Custom Scan (ColumnarScan) on full_correlated
Columnar Projected Columns: a, b, c, d Columnar Projected Columns: a, b, c, d
-> Sort -> CTE Scan on w w2
Sort Key: w2.d Filter: (a = 123)
-> CTE Scan on w w2 -> CTE Scan on w w1
Filter: (a = 123) (8 rows)
-> Materialize
-> Sort
Sort Key: w1.a
-> CTE Scan on w w1
(13 rows)
reset enable_hashjoin;
reset enable_mergejoin;
-- use index -- use index
EXPLAIN (COSTS OFF) WITH w AS NOT MATERIALIZED (SELECT * FROM full_correlated) EXPLAIN (COSTS OFF) WITH w AS NOT MATERIALIZED (SELECT * FROM full_correlated)
SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d

View File

@ -585,3 +585,23 @@ BEGIN
RETURN NEXT; RETURN NEXT;
END LOOP; END LOOP;
END; $$ language plpgsql; END; $$ language plpgsql;
-- This function formats EXPLAIN output to conform to how pg <= 16 EXPLAIN
-- shows ANY <subquery> in an expression the pg version >= 17. When 17 is
-- the minimum supported pgversion this function can be retired. The commit
-- that changed how ANY <subquery> exrpressions appear in EXPLAIN is:
-- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=fd0398fcb
CREATE OR REPLACE FUNCTION explain_with_pg16_subplan_format(explain_command text, out query_plan text)
RETURNS SETOF TEXT AS $$
DECLARE
pgversion int = 0;
BEGIN
pgversion = substring(version(), '\d+')::int ;
FOR query_plan IN execute explain_command LOOP
IF pgversion >= 17 THEN
IF query_plan ~ 'SubPlan \d+\).col' THEN
query_plan = regexp_replace(query_plan, '\(ANY \(\w+ = \(SubPlan (\d+)\).col1\)\)', '(SubPlan \1)', 'g');
END IF;
END IF;
RETURN NEXT;
END LOOP;
END; $$ language plpgsql;

View File

@ -415,6 +415,7 @@ SELECT sum(a) FROM pushdown_test where (a > random() and a <= 2000) or (a > 2000
SELECT sum(a) FROM pushdown_test where (a > random() and a <= 2000) or (a > 200000-1010); SELECT sum(a) FROM pushdown_test where (a > random() and a <= 2000) or (a > 200000-1010);
SET hash_mem_multiplier = 1.0; SET hash_mem_multiplier = 1.0;
SELECT public.explain_with_pg16_subplan_format($Q$
EXPLAIN (analyze on, costs off, timing off, summary off) EXPLAIN (analyze on, costs off, timing off, summary off)
SELECT sum(a) FROM pushdown_test where SELECT sum(a) FROM pushdown_test where
( (
@ -427,6 +428,7 @@ SELECT sum(a) FROM pushdown_test where
) )
or or
(a > 200000-2010); (a > 200000-2010);
$Q$) as "QUERY PLAN";
RESET hash_mem_multiplier; RESET hash_mem_multiplier;
SELECT sum(a) FROM pushdown_test where SELECT sum(a) FROM pushdown_test where
( (

View File

@ -181,11 +181,19 @@ BEGIN;
WHERE ct_1.a < 3000; WHERE ct_1.a < 3000;
ROLLBACK; ROLLBACK;
-- Force nested loop join to ensure the next query has a
-- consistent plan across pg versions
set enable_hashjoin to 0;
set enable_mergejoin to 0;
-- use custom scan -- use custom scan
EXPLAIN (COSTS OFF) WITH w AS (SELECT * FROM full_correlated) EXPLAIN (COSTS OFF) WITH w AS (SELECT * FROM full_correlated)
SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d
WHERE w2.a = 123; WHERE w2.a = 123;
reset enable_hashjoin;
reset enable_mergejoin;
-- use index -- use index
EXPLAIN (COSTS OFF) WITH w AS NOT MATERIALIZED (SELECT * FROM full_correlated) EXPLAIN (COSTS OFF) WITH w AS NOT MATERIALIZED (SELECT * FROM full_correlated)
SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d SELECT * FROM w AS w1 JOIN w AS w2 ON w1.a = w2.d

View File

@ -611,3 +611,24 @@ BEGIN
RETURN NEXT; RETURN NEXT;
END LOOP; END LOOP;
END; $$ language plpgsql; END; $$ language plpgsql;
-- This function formats EXPLAIN output to conform to how pg <= 16 EXPLAIN
-- shows ANY <subquery> in an expression the pg version >= 17. When 17 is
-- the minimum supported pgversion this function can be retired. The commit
-- that changed how ANY <subquery> exrpressions appear in EXPLAIN is:
-- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=fd0398fcb
CREATE OR REPLACE FUNCTION explain_with_pg16_subplan_format(explain_command text, out query_plan text)
RETURNS SETOF TEXT AS $$
DECLARE
pgversion int = 0;
BEGIN
pgversion = substring(version(), '\d+')::int ;
FOR query_plan IN execute explain_command LOOP
IF pgversion >= 17 THEN
IF query_plan ~ 'SubPlan \d+\).col' THEN
query_plan = regexp_replace(query_plan, '\(ANY \(\w+ = \(SubPlan (\d+)\).col1\)\)', '(SubPlan \1)', 'g');
END IF;
END IF;
RETURN NEXT;
END LOOP;
END; $$ language plpgsql;