Commit d36f7efb authored by Andres Freund's avatar Andres Freund

Add minimal regression test for blessed record type transfer.

Test that blessed records can be transferred through a TupleQueue and
correctly decoded by another backend.  While touching the file, make
sure that force_parallel_mode settings only cover relevant tests.

Author: Thomas Munro, editorialized by Andres Freund
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/20170823054644.efuzftxjpfi6wwqs%40alap3.anarazel.de
parent d7694fc1
...@@ -326,7 +326,8 @@ select string4 from tenk1 order by string4 limit 5; ...@@ -326,7 +326,8 @@ select string4 from tenk1 order by string4 limit 5;
reset max_parallel_workers; reset max_parallel_workers;
reset enable_hashagg; reset enable_hashagg;
set force_parallel_mode=1; SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
explain (costs off) explain (costs off)
select stringu1::int2 from tenk1 where unique1 = 1; select stringu1::int2 from tenk1 where unique1 = 1;
QUERY PLAN QUERY PLAN
...@@ -338,7 +339,38 @@ explain (costs off) ...@@ -338,7 +339,38 @@ explain (costs off)
Index Cond: (unique1 = 1) Index Cond: (unique1 = 1)
(5 rows) (5 rows)
ROLLBACK TO SAVEPOINT settings;
-- exercise record typmod remapping between backends
CREATE OR REPLACE FUNCTION make_record(n int)
RETURNS RECORD LANGUAGE plpgsql PARALLEL SAFE AS
$$
BEGIN
RETURN CASE n
WHEN 1 THEN ROW(1)
WHEN 2 THEN ROW(1, 2)
WHEN 3 THEN ROW(1, 2, 3)
WHEN 4 THEN ROW(1, 2, 3, 4)
ELSE ROW(1, 2, 3, 4, 5)
END;
END;
$$;
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
SELECT make_record(x) FROM (SELECT generate_series(1, 5) x) ss ORDER BY x;
make_record
-------------
(1)
(1,2)
(1,2,3)
(1,2,3,4)
(1,2,3,4,5)
(5 rows)
ROLLBACK TO SAVEPOINT settings;
DROP function make_record(n int);
-- to increase the parallel query test coverage -- to increase the parallel query test coverage
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1; EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1;
QUERY PLAN QUERY PLAN
------------------------------------------------------------- -------------------------------------------------------------
...@@ -348,8 +380,12 @@ EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1; ...@@ -348,8 +380,12 @@ EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1;
-> Parallel Seq Scan on tenk1 (actual rows=2000 loops=5) -> Parallel Seq Scan on tenk1 (actual rows=2000 loops=5)
(4 rows) (4 rows)
ROLLBACK TO SAVEPOINT settings;
-- provoke error in worker -- provoke error in worker
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
select stringu1::int2 from tenk1 where unique1 = 1; select stringu1::int2 from tenk1 where unique1 = 1;
ERROR: invalid input syntax for integer: "BAAAAA" ERROR: invalid input syntax for integer: "BAAAAA"
CONTEXT: parallel worker CONTEXT: parallel worker
ROLLBACK TO SAVEPOINT settings;
rollback; rollback;
...@@ -126,15 +126,42 @@ select string4 from tenk1 order by string4 limit 5; ...@@ -126,15 +126,42 @@ select string4 from tenk1 order by string4 limit 5;
reset max_parallel_workers; reset max_parallel_workers;
reset enable_hashagg; reset enable_hashagg;
set force_parallel_mode=1; SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
explain (costs off) explain (costs off)
select stringu1::int2 from tenk1 where unique1 = 1; select stringu1::int2 from tenk1 where unique1 = 1;
ROLLBACK TO SAVEPOINT settings;
-- exercise record typmod remapping between backends
CREATE OR REPLACE FUNCTION make_record(n int)
RETURNS RECORD LANGUAGE plpgsql PARALLEL SAFE AS
$$
BEGIN
RETURN CASE n
WHEN 1 THEN ROW(1)
WHEN 2 THEN ROW(1, 2)
WHEN 3 THEN ROW(1, 2, 3)
WHEN 4 THEN ROW(1, 2, 3, 4)
ELSE ROW(1, 2, 3, 4, 5)
END;
END;
$$;
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
SELECT make_record(x) FROM (SELECT generate_series(1, 5) x) ss ORDER BY x;
ROLLBACK TO SAVEPOINT settings;
DROP function make_record(n int);
-- to increase the parallel query test coverage -- to increase the parallel query test coverage
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1; EXPLAIN (analyze, timing off, summary off, costs off) SELECT * FROM tenk1;
ROLLBACK TO SAVEPOINT settings;
-- provoke error in worker -- provoke error in worker
SAVEPOINT settings;
SET LOCAL force_parallel_mode = 1;
select stringu1::int2 from tenk1 where unique1 = 1; select stringu1::int2 from tenk1 where unique1 = 1;
ROLLBACK TO SAVEPOINT settings;
rollback; rollback;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment