Skip to content

Commit

Permalink
Add pg18 version in makefile with additional extended protocol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bonnefoa committed Sep 2, 2024
1 parent 06f0e39 commit 65637b6
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Supported PostgreSQL versions:
PG_VERSIONS = 15 16 17
PG_VERSIONS = 15 16 17 18

# Default version:
PG_VERSION ?= $(lastword $(PG_VERSIONS))
Expand Down Expand Up @@ -43,6 +43,11 @@ else
REGRESSCHECKS += planstate_projectset_17
endif

# PG 18 contains additional psql metacommand to test extended protocol
ifeq ($(shell test $(PG_VERSION) -ge 18; echo $$?),0)
REGRESSCHECKS += psql_extended
endif

REGRESSCHECKS += sample planstate planstate_bitmap planstate_hash \
planstate_subplans planstate_union \
parallel subxact full_buffer \
Expand Down
112 changes: 112 additions & 0 deletions expected/psql_extended.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
-- Simple query with extended protocol
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ SELECT $1, $2 \parse stmt1
\bind_named stmt1 1 2 \g
?column? | ?column?
----------+----------
1 | 2
(1 row)

SELECT trace_id, span_type, span_operation, parameters, lvl FROM peek_ordered_spans;
trace_id | span_type | span_operation | parameters | lvl
----------------------------------+--------------+----------------+------------+-----
00000000000000000000000000000001 | Select query | SELECT $1, $2 | | 1
00000000000000000000000000000001 | Select query | SELECT $1, $2 | {1,2} | 1
00000000000000000000000000000001 | Planner | Planner | | 2
00000000000000000000000000000001 | ExecutorRun | ExecutorRun | | 2
00000000000000000000000000000001 | Result | Result | | 3
(5 rows)

BEGIN;
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000001-01'*/ select $1 \parse ''
\bind_named '' 1 \g
?column?
----------
1
(1 row)

/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000001-01'*/ select $1, $2 \parse ''
\bind_named '' 1 2 \g
?column? | ?column?
----------+----------
1 | 2
(1 row)

/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000004-0000000000000001-01'*/ select $1, $2, $3 \parse ''
\bind_named '' 1 2 3 \g
?column? | ?column? | ?column?
----------+----------+----------
1 | 2 | 3
(1 row)

COMMIT;
SELECT trace_id, span_type, span_operation, parameters, lvl FROM peek_ordered_spans;
trace_id | span_type | span_operation | parameters | lvl
----------------------------------+------------------+-------------------+------------+-----
00000000000000000000000000000001 | Select query | SELECT $1, $2 | | 1
00000000000000000000000000000001 | Select query | SELECT $1, $2 | {1,2} | 1
00000000000000000000000000000001 | Planner | Planner | | 2
00000000000000000000000000000001 | ExecutorRun | ExecutorRun | | 2
00000000000000000000000000000001 | Result | Result | | 3
00000000000000000000000000000002 | TransactionBlock | TransactionBlock | | 1
00000000000000000000000000000002 | Select query | select $1 | {1} | 2
00000000000000000000000000000002 | Planner | Planner | | 3
00000000000000000000000000000002 | ExecutorRun | ExecutorRun | | 3
00000000000000000000000000000002 | Result | Result | | 4
00000000000000000000000000000003 | Select query | SELECT $1, $2 | {1,2} | 2
00000000000000000000000000000003 | Planner | Planner | | 3
00000000000000000000000000000003 | ExecutorRun | ExecutorRun | | 3
00000000000000000000000000000003 | Result | Result | | 4
00000000000000000000000000000004 | Select query | select $1, $2, $3 | {1,2,3} | 2
00000000000000000000000000000004 | Planner | Planner | | 3
00000000000000000000000000000004 | ExecutorRun | ExecutorRun | | 3
00000000000000000000000000000004 | Result | Result | | 4
(18 rows)

/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000005-0000000000000001-01'*/ BEGIN;
select $1 \parse ''
\bind_named '' 1 \g
?column?
----------
1
(1 row)

select $1, $2 \parse ''
\bind_named '' 1 2 \g
?column? | ?column?
----------+----------
1 | 2
(1 row)

select $1, $2, $3 \parse ''
\bind_named '' 1 2 3 \g
?column? | ?column? | ?column?
----------+----------+----------
1 | 2 | 3
(1 row)

COMMIT;
SELECT span_type, span_operation, parameters, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000005';
span_type | span_operation | parameters | lvl
------------------+-------------------+------------+-----
TransactionBlock | TransactionBlock | | 1
Utility query | BEGIN; | | 2
ProcessUtility | ProcessUtility | | 3
Select query | select $1 | {1} | 2
Planner | Planner | | 3
ExecutorRun | ExecutorRun | | 3
Result | Result | | 4
Select query | SELECT $1, $2 | {1,2} | 2
Planner | Planner | | 3
ExecutorRun | ExecutorRun | | 3
Result | Result | | 4
Select query | select $1, $2, $3 | {1,2,3} | 2
Planner | Planner | | 3
ExecutorRun | ExecutorRun | | 3
Result | Result | | 4
Utility query | COMMIT; | | 2
ProcessUtility | ProcessUtility | | 3
(17 rows)

-- Cleanup
CALL clean_spans();
CALL reset_settings();
31 changes: 31 additions & 0 deletions sql/psql_extended.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- Simple query with extended protocol
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000001-0000000000000001-01'*/ SELECT $1, $2 \parse stmt1
\bind_named stmt1 1 2 \g

SELECT trace_id, span_type, span_operation, parameters, lvl FROM peek_ordered_spans;

BEGIN;
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000002-0000000000000001-01'*/ select $1 \parse ''
\bind_named '' 1 \g
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000003-0000000000000001-01'*/ select $1, $2 \parse ''
\bind_named '' 1 2 \g
/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000004-0000000000000001-01'*/ select $1, $2, $3 \parse ''
\bind_named '' 1 2 3 \g
COMMIT;

SELECT trace_id, span_type, span_operation, parameters, lvl FROM peek_ordered_spans;

/*dddbs='postgres.db',traceparent='00-00000000000000000000000000000005-0000000000000001-01'*/ BEGIN;
select $1 \parse ''
\bind_named '' 1 \g
select $1, $2 \parse ''
\bind_named '' 1 2 \g
select $1, $2, $3 \parse ''
\bind_named '' 1 2 3 \g
COMMIT;

SELECT span_type, span_operation, parameters, lvl FROM peek_ordered_spans where trace_id='00000000000000000000000000000005';

-- Cleanup
CALL clean_spans();
CALL reset_settings();

0 comments on commit 65637b6

Please sign in to comment.