提交 583c4be1 编写于 作者: H Heikki Linnakangas 提交者: Jimmy Yih

Move transient_types tests to installcheck-good suite.

These are straightforward "run SQL, check expected output" style tests,
and only take a few seconds to run. Let's get them into the normal
regression suite.
上级 0a084e0e
create schema transient_types;
set search_path='transient_types';
-- prepare a distributed table
create table t as select i as id from generate_series(1,8) i;
-- test row
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
row | row | row
-----+-------+---------------
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
(8 rows)
-- test function
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
select row(id, 1), foo(id) from t;
row | foo
-------+-------
(1,1) | (1,1)
(2,1) | (2,2)
(3,1) | (3,3)
(4,1) | (4,4)
(5,1) | (5,5)
(6,1) | (6,6)
(7,1) | (7,7)
(8,1) | (8,8)
(8 rows)
-- cleanup
drop table t;
drop function foo(int);
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- create type
drop type if exists myudt;
create type myudt as (i int, c char);
-- test row
select row((1,'a')::myudt), row((2,'b')::myudt, 2) from t;
row | row
-----------+-------------
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
(8 rows)
-- test function
create or replace function foo(in int, out int, out myudt) as
$$
select $1, ($1, 't')::myudt;
$$ language sql;
select row(id, 1), foo(id) from t;
row | foo
-------+-------------
(1,1) | (1,"(1,t)")
(2,1) | (2,"(2,t)")
(3,1) | (3,"(3,t)")
(4,1) | (4,"(4,t)")
(5,1) | (5,"(5,t)")
(6,1) | (6,"(6,t)")
(7,1) | (7,"(7,t)")
(8,1) | (8,"(8,t)")
(8 rows)
--cleanup
drop function foo(int);
drop type myudt;
drop table t;
-- Test when old QE got released, all types will be dispatched to new QE.
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- set QE release timeout 10ms
set gp_vmem_idle_resource_timeout=10;
-- query 1
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
row | row | row
-----+-------+---------------
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
(8 rows)
-- sleep 1000ms
select pg_sleep(1);
pg_sleep
----------
(1 row)
-- query 2
select row(1, 2, 3, 4, 5, 6), row(), row(1, 2, 3, 4, 5), row(1, 2), row(1, 2, 3, 4), row(1, 'a', 'abc', 1.5) from t;
row | row | row | row | row | row
---------------+-----+-------------+-------+-----------+---------------
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(8 rows)
-- start_ignore
-- end_ignore
-- Utility statement won't need to dispatch transient types. So QE may have transient type which is not mapped to QD.
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- 2 types on QD, but not on QE.
select row(1, row(1,2), 3), row(1, 2, 3, 4);
row | row
---------------+-----------
(1,"(1,2)",3) | (1,2,3,4)
(1 row)
-- 1 another type on both QD and QE, but not mapped since it's not dispatched.
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
-- dispatch 3 types to QE.
select foo(id) from t;
foo
-------
(1,1)
(2,2)
(3,3)
(4,4)
(5,5)
(6,6)
(7,7)
(8,8)
(8 rows)
--cleanup
drop function foo(int);
drop table t;
-- prepare a distributed table
drop table if exists t;
psql:/path/sql_file:1: NOTICE: table "t" does not exist, skipping
DROP TABLE
create table t as select i as id from generate_series(1,8) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 8
-- commit
begin;
BEGIN
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
row | row | row
-----+-------+---------------
......@@ -25,10 +174,8 @@ select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
(8 rows)
commit;
COMMIT
-- abort
begin;
BEGIN
select row(), row(1, row(1, 2)), row(1, 2, 3) from t;
row | row | row
-----+-------------+---------
......@@ -43,10 +190,8 @@ select row(), row(1, row(1, 2)), row(1, 2, 3) from t;
(8 rows)
abort;
ROLLBACK
-- subtrans
begin;
BEGIN
select row(1, 2) from t;
row
-------
......@@ -61,7 +206,6 @@ select row(1, 2) from t;
(8 rows)
savepoint s1;
SAVEPOINT
select row(1, 2, 3, 'a'), row(1, 2), row(1, 2, 3);
row | row | row
-----------+-------+---------
......@@ -82,9 +226,7 @@ select row(1, 'b', 3, 'a'), row(1, 2, 3, 4, 5, 6), row(1, 2, 3, 4) from t;
(8 rows)
rollback to savepoint s1;
ROLLBACK
savepoint s2;
SAVEPOINT
select row(), row(1), row(1, 'a'), row(1, 2, 3);
row | row | row | row
-----+-----+-------+---------
......@@ -92,7 +234,6 @@ select row(), row(1), row(1, 'a'), row(1, 2, 3);
(1 row)
rollback to savepoint s2;
ROLLBACK
select row(), row(1), row('a', 'b'), row(1, 2, 3, 4) from t;
row | row | row | row
-----+-----+-------+-----------
......@@ -107,7 +248,53 @@ select row(), row(1), row('a', 'b'), row(1, 2, 3, 4) from t;
(8 rows)
commit;
COMMIT
-- cleanup
drop table t;
DROP TABLE
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,100000) i;
-- cursor
begin;
declare foo cursor for select row(id, 1),id from t order by id;
savepoint x;
fetch from foo;
row | id
-------+----
(1,1) | 1
(1 row)
rollback to x;
fetch ABSOLUTE 100000 from foo;
row | id
------------+--------
(100000,1) | 100000
(1 row)
abort;
truncate table t;
select row(id, 1) from t;
row
-----
(0 rows)
-- cleanup
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
create or replace function foo() returns void as $$
begin
EXECUTE 'SELECT row(id, 2) from t';
RETURN;
end
$$ language 'plpgsql';
select foo();
foo
-----
(1 row)
-- cleanup
drop function foo();
drop table t;
drop schema transient_types;
......@@ -18,7 +18,7 @@
ignore: leastsquares
test: opr_sanity_gp decode_expr bitmapscan bitmapscan_ao case_gp limit_gp notin percentile naivebayes join_gp union_gp gpcopy gp_create_table
test: filter gpctas gpdist matrix toast sublink table_functions olap_setup complex opclass_ddl bitmap_index information_schema
test: indexjoin as_alias regex_gp gpparams with_clause
test: indexjoin as_alias regex_gp gpparams with_clause transient_types
test: dispatch
......
create schema transient_types;
set search_path='transient_types';
-- prepare a distributed table
create table t as select i as id from generate_series(1,8) i;
-- test row
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
-- test function
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
select row(id, 1), foo(id) from t;
-- cleanup
drop table t;
drop function foo(int);
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- create type
drop type if exists myudt;
create type myudt as (i int, c char);
-- test row
select row((1,'a')::myudt), row((2,'b')::myudt, 2) from t;
-- test function
create or replace function foo(in int, out int, out myudt) as
$$
select $1, ($1, 't')::myudt;
$$ language sql;
select row(id, 1), foo(id) from t;
--cleanup
drop function foo(int);
drop type myudt;
drop table t;
-- Test when old QE got released, all types will be dispatched to new QE.
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- set QE release timeout 10ms
set gp_vmem_idle_resource_timeout=10;
-- query 1
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
-- sleep 1000ms
select pg_sleep(1);
-- query 2
select row(1, 2, 3, 4, 5, 6), row(), row(1, 2, 3, 4, 5), row(1, 2), row(1, 2, 3, 4), row(1, 'a', 'abc', 1.5) from t;
-- Utility statement won't need to dispatch transient types. So QE may have transient type which is not mapped to QD.
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- 2 types on QD, but not on QE.
select row(1, row(1,2), 3), row(1, 2, 3, 4);
-- 1 another type on both QD and QE, but not mapped since it's not dispatched.
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
-- dispatch 3 types to QE.
select foo(id) from t;
--cleanup
drop function foo(int);
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- commit
begin;
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
commit;
-- abort
begin;
select row(), row(1, row(1, 2)), row(1, 2, 3) from t;
abort;
-- subtrans
begin;
select row(1, 2) from t;
savepoint s1;
select row(1, 2, 3, 'a'), row(1, 2), row(1, 2, 3);
select row(1, 'b', 3, 'a'), row(1, 2, 3, 4, 5, 6), row(1, 2, 3, 4) from t;
rollback to savepoint s1;
savepoint s2;
select row(), row(1), row(1, 'a'), row(1, 2, 3);
rollback to savepoint s2;
select row(), row(1), row('a', 'b'), row(1, 2, 3, 4) from t;
commit;
-- cleanup
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,100000) i;
-- cursor
begin;
declare foo cursor for select row(id, 1),id from t order by id;
savepoint x;
fetch from foo;
rollback to x;
fetch ABSOLUTE 100000 from foo;
abort;
truncate table t;
select row(id, 1) from t;
-- cleanup
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
create or replace function foo() returns void as $$
begin
EXECUTE 'SELECT row(id, 2) from t';
RETURN;
end
$$ language 'plpgsql';
select foo();
-- cleanup
drop function foo();
drop table t;
drop schema transient_types;
-- start_ignore
-- end_ignore
-- prepare a distributed table
drop table if exists t;
psql:/path/sql_file:1: NOTICE: table "t" does not exist, skipping
DROP TABLE
create table t as select i as id from generate_series(1,8) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 8
-- test row
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
row | row | row
-----+-------+---------------
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
(8 rows)
-- test function
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
CREATE FUNCTION
select row(id, 1), foo(id) from t;
row | foo
-------+-------
(1,1) | (1,1)
(2,1) | (2,2)
(3,1) | (3,3)
(4,1) | (4,4)
(5,1) | (5,5)
(6,1) | (6,6)
(7,1) | (7,7)
(8,1) | (8,8)
(8 rows)
-- cleanup
drop table t;
DROP TABLE
drop function foo(int);
DROP FUNCTION
-- start_ignore
-- end_ignore
-- prepare a distributed table
drop table if exists t;
psql:/path/sql_file:1: NOTICE: table "t" does not exist, skipping
DROP TABLE
create table t as select i as id from generate_series(1,8) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 8
-- create type
drop type if exists myudt;
psql:/path/sql_file:1: NOTICE: type "myudt" does not exist, skipping
DROP TYPE
create type myudt as (i int, c char);
CREATE TYPE
-- test row
select row((1,'a')::myudt), row((2,'b')::myudt, 2) from t;
row | row
-----------+-------------
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
("(1,a)") | ("(2,b)",2)
(8 rows)
-- test function
create or replace function foo(in int, out int, out myudt) as
$$
select $1, ($1, 't')::myudt;
$$ language sql;
CREATE FUNCTION
select row(id, 1), foo(id) from t;
row | foo
-------+-------------
(1,1) | (1,"(1,t)")
(2,1) | (2,"(2,t)")
(3,1) | (3,"(3,t)")
(4,1) | (4,"(4,t)")
(5,1) | (5,"(5,t)")
(6,1) | (6,"(6,t)")
(7,1) | (7,"(7,t)")
(8,1) | (8,"(8,t)")
(8 rows)
--cleanup
drop function foo(int);
DROP FUNCTION
drop type myudt;
DROP TYPE
drop table t;
DROP TABLE
-- start_ignore
-- end_ignore
-- Test when old QE got released, all types will be dispatched to new QE.
-- prepare a distributed table
drop table if exists t;
psql:/path/sql_file:1: NOTICE: table "t" does not exist, skipping
DROP TABLE
create table t as select i as id from generate_series(1,8) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 8
-- set QE release timeout 10ms
set gp_vmem_idle_resource_timeout=10;
SET
-- query 1
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
row | row | row
-----+-------+---------------
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
() | (1,2) | (1,a,abc,1.5)
(8 rows)
-- sleep 1000ms
select pg_sleep(1);
pg_sleep
----------
(1 row)
-- query 2
select row(1, 2, 3, 4, 5, 6), row(), row(1, 2, 3, 4, 5), row(1, 2), row(1, 2, 3, 4), row(1, 'a', 'abc', 1.5) from t;
row | row | row | row | row | row
---------------+-----+-------------+-------+-----------+---------------
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(1,2,3,4,5,6) | () | (1,2,3,4,5) | (1,2) | (1,2,3,4) | (1,a,abc,1.5)
(8 rows)
-- start_ignore
-- end_ignore
-- Utility statement won't need to dispatch transient types. So QE may have transient type which is not mapped to QD.
-- prepare a distributed table
drop table if exists t;
DROP TABLE
create table t as select i as id from generate_series(1,8) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 8
-- 2 types on QD, but not on QE.
select row(1, row(1,2), 3), row(1, 2, 3, 4);
row | row
---------------+-----------
(1,"(1,2)",3) | (1,2,3,4)
(1 row)
-- 1 another type on both QD and QE, but not mapped since it's not dispatched.
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
CREATE FUNCTION
-- dispatch 3 types to QE.
select foo(id) from t;
foo
-------
(1,1)
(2,2)
(3,3)
(4,4)
(5,5)
(6,6)
(7,7)
(8,8)
(8 rows)
--cleanup
drop function foo(int);
DROP FUNCTION
drop table t;
DROP TABLE
-- start_ignore
-- end_ignore
-- prepare a distributed table
drop table if exists t;
psql:/path/sql_file:1: NOTICE: table "t" does not exist, skipping
DROP TABLE
create table t as select i as id from generate_series(1,100000) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 100000
-- cursor
begin;
BEGIN
declare foo cursor for select row(id, 1),id from t order by id;
DECLARE CURSOR
savepoint x;
SAVEPOINT
fetch from foo;
row | id
-------+----
(1,1) | 1
(1 row)
rollback to x;
ROLLBACK
fetch ABSOLUTE 100000 from foo;
row | id
------------+--------
(100000,1) | 100000
(1 row)
abort;
ROLLBACK
truncate table t;
TRUNCATE TABLE
select row(id, 1) from t;
row
-----
(0 rows)
-- cleanup
drop table t;
DROP TABLE
-- start_ignore
-- end_ignore
-- prepare a distributed table
drop table if exists t;
psql:/path/sql_file:1: NOTICE: table "t" does not exist, skipping
DROP TABLE
create table t as select i as id from generate_series(1,8) i;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 8
create or replace function foo() returns void as $$
begin
EXECUTE 'SELECT row(id, 2) from t';
RETURN;
end
$$ language 'plpgsql';
CREATE FUNCTION
select foo();
foo
-----
(1 row)
-- cleanup
drop function foo();
DROP FUNCTION
drop table t;
DROP TABLE
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- test row
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
-- test function
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
select row(id, 1), foo(id) from t;
-- cleanup
drop table t;
drop function foo(int);
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- create type
drop type if exists myudt;
create type myudt as (i int, c char);
-- test row
select row((1,'a')::myudt), row((2,'b')::myudt, 2) from t;
-- test function
create or replace function foo(in int, out int, out myudt) as
$$
select $1, ($1, 't')::myudt;
$$ language sql;
select row(id, 1), foo(id) from t;
--cleanup
drop function foo(int);
drop type myudt;
drop table t;
-- Test when old QE got released, all types will be dispatched to new QE.
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- set QE release timeout 10ms
set gp_vmem_idle_resource_timeout=10;
-- query 1
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
-- sleep 1000ms
select pg_sleep(1);
-- query 2
select row(1, 2, 3, 4, 5, 6), row(), row(1, 2, 3, 4, 5), row(1, 2), row(1, 2, 3, 4), row(1, 'a', 'abc', 1.5) from t;
-- Utility statement won't need to dispatch transient types. So QE may have transient type which is not mapped to QD.
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- 2 types on QD, but not on QE.
select row(1, row(1,2), 3), row(1, 2, 3, 4);
-- 1 another type on both QD and QE, but not mapped since it's not dispatched.
create or replace function foo(in int, out int, out int) as
$$
select $1, $1;
$$ language sql;
-- dispatch 3 types to QE.
select foo(id) from t;
--cleanup
drop function foo(int);
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
-- commit
begin;
select row(), row(1, 2), row(1, 'a', 'abc', 1.5) from t;
commit;
-- abort
begin;
select row(), row(1, row(1, 2)), row(1, 2, 3) from t;
abort;
-- subtrans
begin;
select row(1, 2) from t;
savepoint s1;
select row(1, 2, 3, 'a'), row(1, 2), row(1, 2, 3);
select row(1, 'b', 3, 'a'), row(1, 2, 3, 4, 5, 6), row(1, 2, 3, 4) from t;
rollback to savepoint s1;
savepoint s2;
select row(), row(1), row(1, 'a'), row(1, 2, 3);
rollback to savepoint s2;
select row(), row(1), row('a', 'b'), row(1, 2, 3, 4) from t;
commit;
-- cleanup
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,100000) i;
-- cursor
begin;
declare foo cursor for select row(id, 1),id from t order by id;
savepoint x;
fetch from foo;
rollback to x;
fetch ABSOLUTE 100000 from foo;
abort;
truncate table t;
select row(id, 1) from t;
-- cleanup
drop table t;
-- prepare a distributed table
drop table if exists t;
create table t as select i as id from generate_series(1,8) i;
create or replace function foo() returns void as $$
begin
EXECUTE 'SELECT row(id, 2) from t';
RETURN;
end
$$ language 'plpgsql';
select foo();
-- cleanup
drop function foo();
drop table t;
"""
Copyright (C) 2004-2015 Pivotal Software, Inc. All rights reserved.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from mpp.models import SQLTestCase
class TransientTypesTestCase(SQLTestCase):
"""
@db_name transienttypes
@product_version gpdb: [4.3.6.0-9.9.99.99]
@tags list_mgmt_expand
"""
sql_dir = 'sql/'
ans_dir = 'expected/'
out_dir = 'output/'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册