From 60291343cf55f8c948bc7879d632597929abce5b Mon Sep 17 00:00:00 2001 From: Anthonin Bonnefoy Date: Fri, 30 Aug 2024 10:04:20 +0200 Subject: [PATCH] Add PG17 to test matrix and make tests compatible with PG17 --- Makefile | 16 ++++++++++++--- expected/nested.out | 27 ++++++++++++------------- expected/planstate_subplans.out | 2 +- expected/subxact.out | 7 ++----- sql/nested.sql | 8 ++++---- sql/planstate_projectset_17.sql | 36 +++++++++++++++++++++++++++++++++ sql/planstate_subplans.sql | 2 +- sql/subxact.sql | 2 +- 8 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 sql/planstate_projectset_17.sql diff --git a/Makefile b/Makefile index 3bebb53..9f7d38d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Supported PostgreSQL versions: -PG_VERSIONS = 15 16 +PG_VERSIONS = 15 16 17 # Default version: PG_VERSION ?= $(lastword $(PG_VERSIONS)) @@ -28,13 +28,23 @@ OBJS = \ src/version_compat.o REGRESSCHECKS = setup utility select parameters insert trigger cursor json transaction + ifeq ($(PG_VERSION),15) REGRESSCHECKS += trigger_15 -else +endif + +ifeq ($(shell test $(PG_VERSION) -ge 16; echo $$?),0) REGRESSCHECKS += extended trigger_16 parameters_16 endif + +ifeq ($(shell test $(PG_VERSION) -lt 17; echo $$?),0) +REGRESSCHECKS += planstate_projectset +else +REGRESSCHECKS += planstate_projectset_17 +endif + REGRESSCHECKS += sample planstate planstate_bitmap planstate_hash \ - planstate_projectset planstate_subplans planstate_union \ + planstate_subplans planstate_union \ parallel subxact full_buffer \ guc nested wal cleanup diff --git a/expected/nested.out b/expected/nested.out index f03e131..dcb6be3 100644 --- a/expected/nested.out +++ b/expected/nested.out @@ -130,30 +130,29 @@ SELECT count(*) from pg_tracing_consume_spans where trace_id='000000000000000000 -- Reset tracking setting SET pg_tracing.track TO DEFAULT; -- Create test procedure -CREATE OR REPLACE PROCEDURE sum_one(i int) AS $$ +CREATE OR REPLACE PROCEDURE sum_one() AS $$ DECLARE r int; BEGIN - SELECT (i + i)::int INTO r; + SELECT (10 + 10)::int INTO r; END; $$ LANGUAGE plpgsql; -- Test tracking of procedure with utility tracking enabled SET pg_tracing.track_utility=on; -/*traceparent='00-00000000000000000000000000000054-0000000000000054-01'*/ CALL sum_one(3); +/*traceparent='00-00000000000000000000000000000054-0000000000000054-01'*/ CALL sum_one(); select span_operation, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000054'; - span_operation | lvl ----------------------+----- - CALL sum_one(3); | 1 - ProcessUtility | 2 - SELECT (i + i)::int | 3 - Planner | 4 - Planner | 4 - ExecutorRun | 4 - Result | 5 -(7 rows) + span_operation | lvl +-----------------------+----- + CALL sum_one(); | 1 + ProcessUtility | 2 + SELECT ($1 + $2)::int | 3 + Planner | 4 + ExecutorRun | 4 + Result | 5 +(6 rows) -- Test again with utility tracking disabled SET pg_tracing.track_utility=off; -/*traceparent='00-00000000000000000000000000000055-0000000000000055-01'*/ CALL sum_one(10); +/*traceparent='00-00000000000000000000000000000055-0000000000000055-01'*/ CALL sum_one(); select span_operation, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000055'; span_operation | lvl ----------------+----- diff --git a/expected/planstate_subplans.out b/expected/planstate_subplans.out index b048e26..81e5f6a 100644 --- a/expected/planstate_subplans.out +++ b/expected/planstate_subplans.out @@ -48,7 +48,7 @@ SELECT span_id AS span_c_id, get_epoch(span_start) as span_c_start, get_epoch(span_end) as span_c_end from pg_tracing_peek_spans - where parent_id =:'span_a_id' and span_operation='InitPlan 2 (returns $1)' \gset + where parent_id =:'span_a_id' and span_operation LIKE 'InitPlan 2%' \gset SELECT span_id AS span_d_id, get_epoch(span_start) as span_d_start, get_epoch(span_end) as span_d_end diff --git a/expected/subxact.out b/expected/subxact.out index 517e7c9..3f57b51 100644 --- a/expected/subxact.out +++ b/expected/subxact.out @@ -15,13 +15,12 @@ SELECT 1; COMMIT; -- Check that subxact_count is correctly reported -select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans; +select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans WHERE span_operation NOT LIKE 'SAVEPOINT%'; span_operation | parameters | subxact_count | lvl ------------------------------------------------------------------+-------------+---------------+----- TransactionBlock | | 0 | 1 BEGIN; | | 0 | 2 ProcessUtility | | 0 | 3 - SAVEPOINT s1; | | 0 | 2 ProcessUtility | | 0 | 3 INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3); | {1,2,'aaa'} | 0 | 2 Planner | | 0 | 3 @@ -29,7 +28,6 @@ select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans; Insert on pg_tracing_test | | 1 | 4 ProjectSet | | 1 | 5 Result | | 1 | 6 - SAVEPOINT s2; | | 1 | 2 ProcessUtility | | 1 | 3 INSERT INTO pg_tracing_test VALUES(generate_series($1, $2), $3); | {1,2,'aaa'} | 1 | 2 Planner | | 1 | 3 @@ -37,7 +35,6 @@ select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans; Insert on pg_tracing_test | | 2 | 4 ProjectSet | | 2 | 5 Result | | 2 | 6 - SAVEPOINT s3; | | 2 | 2 ProcessUtility | | 2 | 3 SELECT $1; | {1} | 2 | 2 Planner | | 2 | 3 @@ -46,7 +43,7 @@ select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans; COMMIT; | | 2 | 2 ProcessUtility | | 2 | 3 TransactionCommit | | 2 | 2 -(28 rows) +(25 rows) -- Cleaning CALL clean_spans(); diff --git a/sql/nested.sql b/sql/nested.sql index e70c1d1..cff9130 100644 --- a/sql/nested.sql +++ b/sql/nested.sql @@ -105,21 +105,21 @@ SELECT count(*) from pg_tracing_consume_spans where trace_id='000000000000000000 SET pg_tracing.track TO DEFAULT; -- Create test procedure -CREATE OR REPLACE PROCEDURE sum_one(i int) AS $$ +CREATE OR REPLACE PROCEDURE sum_one() AS $$ DECLARE r int; BEGIN - SELECT (i + i)::int INTO r; + SELECT (10 + 10)::int INTO r; END; $$ LANGUAGE plpgsql; -- Test tracking of procedure with utility tracking enabled SET pg_tracing.track_utility=on; -/*traceparent='00-00000000000000000000000000000054-0000000000000054-01'*/ CALL sum_one(3); +/*traceparent='00-00000000000000000000000000000054-0000000000000054-01'*/ CALL sum_one(); select span_operation, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000054'; -- Test again with utility tracking disabled SET pg_tracing.track_utility=off; -/*traceparent='00-00000000000000000000000000000055-0000000000000055-01'*/ CALL sum_one(10); +/*traceparent='00-00000000000000000000000000000055-0000000000000055-01'*/ CALL sum_one(); select span_operation, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000055'; -- Create immutable function diff --git a/sql/planstate_projectset_17.sql b/sql/planstate_projectset_17.sql new file mode 100644 index 0000000..cba2109 --- /dev/null +++ b/sql/planstate_projectset_17.sql @@ -0,0 +1,36 @@ +/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ select information_schema._pg_expandarray('{0,1,2}'::int[]); +SELECT span_operation, deparse_info, parameters, lvl from peek_ordered_spans where trace_id='00000000000000000000000000000001'; + +-- +---------------------------------------------+ +-- | A: ProjectSet | +-- ++-----------------+--+----------------+------+ +-- | B: Result | | C: TopSpan | +-- +-----------------+ +-+------------+-+ +-- | D: Planner | +-- +------------+ + +SELECT span_id AS span_a_id, + get_epoch(span_start) as span_a_start, + get_epoch(span_end) as span_a_end + from pg_tracing_peek_spans + where trace_id='00000000000000000000000000000001' AND span_operation='ProjectSet' \gset +SELECT span_id AS span_b_id, + get_epoch(span_start) as span_b_start, + get_epoch(span_end) as span_b_end + from pg_tracing_peek_spans + where parent_id =:'span_a_id' and span_operation='Result' \gset +SELECT span_id AS span_c_id, + get_epoch(span_start) as span_c_start, + get_epoch(span_end) as span_c_end + from pg_tracing_peek_spans + where parent_id =:'span_a_id' and span_type='Select query' \gset +SELECT span_id AS span_d_id, + get_epoch(span_start) as span_d_start, + get_epoch(span_end) as span_d_end + from pg_tracing_peek_spans + where parent_id =:'span_c_id' and span_type='Planner' \gset + +SELECT :span_a_end >= :span_c_end as project_set_ends_after_nested_top_span; + +-- Clean created spans +CALL clean_spans(); diff --git a/sql/planstate_subplans.sql b/sql/planstate_subplans.sql index b4813e7..f25bd44 100644 --- a/sql/planstate_subplans.sql +++ b/sql/planstate_subplans.sql @@ -39,7 +39,7 @@ SELECT span_id AS span_c_id, get_epoch(span_start) as span_c_start, get_epoch(span_end) as span_c_end from pg_tracing_peek_spans - where parent_id =:'span_a_id' and span_operation='InitPlan 2 (returns $1)' \gset + where parent_id =:'span_a_id' and span_operation LIKE 'InitPlan 2%' \gset SELECT span_id AS span_d_id, get_epoch(span_start) as span_d_start, get_epoch(span_end) as span_d_end diff --git a/sql/subxact.sql b/sql/subxact.sql index 723faca..bf60cc9 100644 --- a/sql/subxact.sql +++ b/sql/subxact.sql @@ -12,7 +12,7 @@ SELECT 1; COMMIT; -- Check that subxact_count is correctly reported -select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans; +select span_operation, parameters, subxact_count, lvl FROM peek_ordered_spans WHERE span_operation NOT LIKE 'SAVEPOINT%'; -- Cleaning CALL clean_spans();