Skip to content

Commit

Permalink
Add PG17 to test matrix and make tests compatible with PG17
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Aug 30, 2024
1 parent ddc7d2f commit 6029134
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 29 deletions.
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Supported PostgreSQL versions:
PG_VERSIONS = 15 16
PG_VERSIONS = 15 16 17

# Default version:
PG_VERSION ?= $(lastword $(PG_VERSIONS))
Expand Down Expand Up @@ -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

Expand Down
27 changes: 13 additions & 14 deletions expected/nested.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------+-----
Expand Down
2 changes: 1 addition & 1 deletion expected/planstate_subplans.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions expected/subxact.out
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,26 @@ 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
ExecutorRun | | 0 | 3
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
ExecutorRun | | 1 | 3
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
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions sql/nested.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions sql/planstate_projectset_17.sql
Original file line number Diff line number Diff line change
@@ -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();
2 changes: 1 addition & 1 deletion sql/planstate_subplans.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sql/subxact.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 6029134

Please sign in to comment.