Handles EXPLAIN output diffs in PG15: extra arrows&result lines

To handle extra "->" arrows resulting from extra Result lines
in explain outputs, we add the following explain method to
multi_test_helpers.sql file

- plan_without_arrows() is added for cases where we want the
whole explain output without arrows and without Result lines
naisila/failure_pg15
naisila 2022-08-19 14:46:51 +03:00
parent 3787c0511d
commit d37eb176db
4 changed files with 35 additions and 2 deletions

View File

@ -264,17 +264,21 @@ EXPLAIN (analyze on, costs off, timing off, summary off)
Columnar Projected Columns: a
(9 rows)
SELECT plan_without_arrows($Q$
EXPLAIN (costs off, timing off, summary off)
SELECT y, * FROM another_columnar_table;
QUERY PLAN
$Q$);
plan_without_arrows
---------------------------------------------------------------------
Custom Scan (ColumnarScan) on another_columnar_table
Columnar Projected Columns: x, y
(2 rows)
SELECT plan_without_arrows($Q$
EXPLAIN (costs off, timing off, summary off)
SELECT *, x FROM another_columnar_table;
QUERY PLAN
$Q$);
plan_without_arrows
---------------------------------------------------------------------
Custom Scan (ColumnarScan) on another_columnar_table
Columnar Projected Columns: x, y

View File

@ -81,6 +81,18 @@ BEGIN
RETURN NEXT;
END LOOP;
END; $$ language plpgsql;
-- Create a function to remove arrows from the explain plan
CREATE OR REPLACE FUNCTION plan_without_arrows(explain_command text, out query_plan text)
RETURNS SETOF TEXT AS $$
BEGIN
FOR query_plan IN execute explain_command LOOP
IF (query_plan LIKE '%-> Result%' OR query_plan = 'Result') THEN
CONTINUE;
END IF;
query_plan := regexp_replace(query_plan, '( )*-> (.*)', '\2', 'g');
RETURN NEXT;
END LOOP;
END; $$ language plpgsql;
-- helper function that returns true if output of given explain has "is not null" (case in-sensitive)
CREATE OR REPLACE FUNCTION explain_has_is_not_null(explain_command text)
RETURNS BOOLEAN AS $$

View File

@ -130,11 +130,15 @@ INSERT INTO another_columnar_table SELECT generate_series(0,5);
EXPLAIN (analyze on, costs off, timing off, summary off)
SELECT a, y FROM multi_column_chunk_filtering, another_columnar_table WHERE x > 1;
SELECT plan_without_arrows($Q$
EXPLAIN (costs off, timing off, summary off)
SELECT y, * FROM another_columnar_table;
$Q$);
SELECT plan_without_arrows($Q$
EXPLAIN (costs off, timing off, summary off)
SELECT *, x FROM another_columnar_table;
$Q$);
EXPLAIN (costs off, timing off, summary off)
SELECT y, another_columnar_table FROM another_columnar_table;

View File

@ -88,6 +88,19 @@ BEGIN
END LOOP;
END; $$ language plpgsql;
-- Create a function to remove arrows from the explain plan
CREATE OR REPLACE FUNCTION plan_without_arrows(explain_command text, out query_plan text)
RETURNS SETOF TEXT AS $$
BEGIN
FOR query_plan IN execute explain_command LOOP
IF (query_plan LIKE '%-> Result%' OR query_plan = 'Result') THEN
CONTINUE;
END IF;
query_plan := regexp_replace(query_plan, '( )*-> (.*)', '\2', 'g');
RETURN NEXT;
END LOOP;
END; $$ language plpgsql;
-- helper function that returns true if output of given explain has "is not null" (case in-sensitive)
CREATE OR REPLACE FUNCTION explain_has_is_not_null(explain_command text)
RETURNS BOOLEAN AS $$