From 8d111d967c0eda892bf391111511f20b2c0d8646 Mon Sep 17 00:00:00 2001 From: wangfeihuo Date: Fri, 28 Mar 2025 18:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B4=A8=E9=87=8F=E5=8A=A0=E5=9B=BA?= =?UTF-8?q?=E3=80=91=E4=B8=8A=E4=BC=A0=E9=83=A8=E5=88=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/dolphin/expected/test_dcl_func.out | 401 +++++++++++++++++++++ contrib/dolphin/parallel_schedule_dolphinB | 2 +- contrib/dolphin/sql/test_dcl_func.sql | 224 ++++++++++++ 3 files changed, 626 insertions(+), 1 deletion(-) create mode 100644 contrib/dolphin/expected/test_dcl_func.out create mode 100644 contrib/dolphin/sql/test_dcl_func.sql diff --git a/contrib/dolphin/expected/test_dcl_func.out b/contrib/dolphin/expected/test_dcl_func.out new file mode 100644 index 000000000..3ff2ed270 --- /dev/null +++ b/contrib/dolphin/expected/test_dcl_func.out @@ -0,0 +1,401 @@ +create schema test_dcl_func; +set current_schema to 'test_dcl_func'; +create table table1(a int); +insert into table1 values (1),(2); +-- save point and roll back +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint2; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint2; +ERROR: no such savepoint +end; +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +end; +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint3; +ERROR: no such savepoint +ROLLBACK TO SAVEPOINT my_savepoint3; +ERROR: no such savepoint +end; +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK work to savepoint my_savepoint; +ROLLBACK to my_savepoint; +ROLLBACK work to my_savepoint; +end; +create or replace procedure test_cursor_0 +as + a int; + cursor c1 is SELECT * from table1; +begin + INSERT INTO table1 VALUES (3),(4); + SAVEPOINT my_savepoint; + INSERT INTO table1 VALUES (3),(4); + SAVEPOINT my_savepoint; + ROLLBACK TO SAVEPOINT my_savepoint; + ROLLBACK TO SAVEPOINT my_savepoint; + ROLLBACK work to savepoint my_savepoint; + ROLLBACK to my_savepoint; + ROLLBACK work to my_savepoint; +end; +/ +ERROR: syntax error at or near "work" +LINE 10: ROLLBACK work to savepoint my_savepoint; + ^ +QUERY: DECLARE a int; + cursor c1 is SELECT * from table1; +begin + INSERT INTO table1 VALUES (3),(4); + SAVEPOINT my_savepoint; + INSERT INTO table1 VALUES (3),(4); + SAVEPOINT my_savepoint; + ROLLBACK TO SAVEPOINT my_savepoint; + ROLLBACK TO SAVEPOINT my_savepoint; + ROLLBACK work to savepoint my_savepoint; + ROLLBACK to my_savepoint; + ROLLBACK work to my_savepoint; +end +--- close cursor +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +CLOSE cursor1; +CLOSE cursor1; +ERROR: cursor "cursor1" does not exist +end; +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +commit; +CLOSE cursor1; +ERROR: cursor "cursor1" does not exist +end; +WARNING: there is no transaction in progress +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +CLOSE cursor1; +FETCH FORWARD 2 FROM cursor1; +ERROR: cursor "cursor1" does not exist +end; +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +CLOSE ALL; +FETCH FORWARD 2 FROM cursor1; +ERROR: cursor "cursor1" does not exist +end; +create or replace procedure test_cursor_1 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close c1; + fetch c1 into a; +end; +/ +call test_cursor_1(); +ERROR: cursor "" does not exist in FETCH statement. +CONTEXT: PL/pgSQL function test_cursor_1() line 6 at FETCH +create or replace procedure test_cursor_2 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close c1; + open c1; + fetch c1 into a; + close c1; + open c1; + close c1; +end; +/ +call test_cursor_2(); + test_cursor_2 +--------------- + +(1 row) + +create or replace procedure test_cursor_3 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close c1; + close c1; + open c1; + fetch c1 into a; +end; +/ +call test_cursor_3(); +ERROR: cursor "" does not exist in CLOSE statement. +CONTEXT: PL/pgSQL function test_cursor_3() line 6 at CLOSE +create or replace procedure test_cursor_4 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close all; + close c1; + open c1; + fetch c1 into a; +end; +/ +ERROR: syntax error at or near "all" +LINE 5: close all; + ^ +QUERY: DECLARE a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close all; + close c1; + open c1; + fetch c1 into a; +end +call test_cursor_4(); +ERROR: function "test_cursor_4" doesn't exist +-- desc +create table test1(id int, id1 int, id2 int, not_id int); +insert into test1 values (1, 2, 3); +create view v1 as select * from test1; +create MATERIALIZED view mv1 as select * from test1; +create index idx1 on test1(id); +desc test1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | MUL | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +desc test1 'id%'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 'id%'; + ^ +desc test1 'id'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 'id'; + ^ +desc test1 '.%'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 '.%'; + ^ +desc test1 '*%'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 '*%'; + ^ +desc test1 '..%'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 '..%'; + ^ +desc test1 '***%'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 '***%'; + ^ +desc test2; +ERROR: Table 'test_dcl_func.test2' doesn't exist. +desc 'tes%' '.*%'; +ERROR: syntax error at or near "'tes%'" +LINE 1: desc 'tes%' '.*%'; + ^ +desc test1 'id1,id2'; +ERROR: syntax error at or near "test1" +LINE 1: desc test1 'id1,id2'; + ^ +desc v1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +desc v1 'id%'; +ERROR: syntax error at or near "v1" +LINE 1: desc v1 'id%'; + ^ +desc mv1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +desc mv1 'id%'; +ERROR: syntax error at or near "mv1" +LINE 1: desc mv1 'id%'; + ^ +describe test1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | MUL | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +describe test1 'id%'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 'id%'; + ^ +describe test1 'id'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 'id'; + ^ +describe test1 '.%'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 '.%'; + ^ +describe test1 '*%'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 '*%'; + ^ +describe test1 '..%'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 '..%'; + ^ +describe test1 '***%'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 '***%'; + ^ +describe test2; +ERROR: Table 'test_dcl_func.test2' doesn't exist. +describe 'tes%' '.*%'; +ERROR: syntax error at or near "'tes%'" +LINE 1: describe 'tes%' '.*%'; + ^ +describe test1 'id1,id2'; +ERROR: syntax error at or near "test1" +LINE 1: describe test1 'id1,id2'; + ^ +describe v1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +describe v1 'id%'; +ERROR: syntax error at or near "v1" +LINE 1: describe v1 'id%'; + ^ +describe mv1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +describe mv1 'id%'; +ERROR: syntax error at or near "mv1" +LINE 1: describe mv1 'id%'; + ^ +EXPLAIN test1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | MUL | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +EXPLAIN test1 'id%'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 'id%'; + ^ +EXPLAIN test1 'id'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 'id'; + ^ +EXPLAIN test1 '.%'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 '.%'; + ^ +EXPLAIN test1 '*%'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 '*%'; + ^ +EXPLAIN test1 '..%'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 '..%'; + ^ +EXPLAIN test1 '***%'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 '***%'; + ^ +EXPLAIN test2; +ERROR: Table 'test_dcl_func.test2' doesn't exist. +EXPLAIN 'tes%' '.*%'; +ERROR: syntax error at or near "'tes%'" +LINE 1: EXPLAIN 'tes%' '.*%'; + ^ +EXPLAIN test1 'id1,id2'; +ERROR: syntax error at or near "test1" +LINE 1: EXPLAIN test1 'id1,id2'; + ^ +EXPLAIN v1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +EXPLAIN v1 'id%'; +ERROR: syntax error at or near "v1" +LINE 1: EXPLAIN v1 'id%'; + ^ +EXPLAIN mv1; + Field | Type | Null | Key | Default | Extra +--------+---------+------+-----+---------+------- + id | integer | YES | | NULL | + id1 | integer | YES | | NULL | + id2 | integer | YES | | NULL | + not_id | integer | YES | | NULL | +(4 rows) + +EXPLAIN mv1 'id%'; +ERROR: syntax error at or near "mv1" +LINE 1: EXPLAIN mv1 'id%'; + ^ +drop view v1; +drop MATERIALIZED view mv1; +drop table test1; +drop table table1; +drop procedure test_cursor_0; +ERROR: function test_cursor_0 does not exist +drop procedure test_cursor_1; +drop procedure test_cursor_2; +drop procedure test_cursor_3; +drop procedure test_cursor_4; +ERROR: function test_cursor_4 does not exist +drop schema test_dcl_func cascade; +reset current_schema; diff --git a/contrib/dolphin/parallel_schedule_dolphinB b/contrib/dolphin/parallel_schedule_dolphinB index e7d23d66a..67a81636b 100644 --- a/contrib/dolphin/parallel_schedule_dolphinB +++ b/contrib/dolphin/parallel_schedule_dolphinB @@ -1,7 +1,7 @@ # show storage engines # enable_mot_server must be before at test_show_storage_engines_1 and test_show_storage_engines_2 test: enable_mot_server -test: m_testcase_fix test_dml_func +test: m_testcase_fix test_dml_func test_dcl_func test: test_show_storage_engines_1 test: disable_ustore_incremental_checkpoint test: test_show_storage_engines_2 show_create show_create_database diff --git a/contrib/dolphin/sql/test_dcl_func.sql b/contrib/dolphin/sql/test_dcl_func.sql new file mode 100644 index 000000000..5750d1dda --- /dev/null +++ b/contrib/dolphin/sql/test_dcl_func.sql @@ -0,0 +1,224 @@ +create schema test_dcl_func; +set current_schema to 'test_dcl_func'; + +create table table1(a int); +insert into table1 values (1),(2); + + +-- save point and roll back +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint2; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint2; +end; + + +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +end; + + +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint3; +ROLLBACK TO SAVEPOINT my_savepoint3; +end; + + +START TRANSACTION; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +INSERT INTO table1 VALUES (3),(4); +SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK TO SAVEPOINT my_savepoint; +ROLLBACK work to savepoint my_savepoint; +ROLLBACK to my_savepoint; +ROLLBACK work to my_savepoint; +end; + + +create or replace procedure test_cursor_0 +as + a int; + cursor c1 is SELECT * from table1; +begin + INSERT INTO table1 VALUES (3),(4); + SAVEPOINT my_savepoint; + INSERT INTO table1 VALUES (3),(4); + SAVEPOINT my_savepoint; + ROLLBACK TO SAVEPOINT my_savepoint; + ROLLBACK TO SAVEPOINT my_savepoint; + ROLLBACK work to savepoint my_savepoint; + ROLLBACK to my_savepoint; + ROLLBACK work to my_savepoint; +end; +/ + +--- close cursor +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +CLOSE cursor1; +CLOSE cursor1; +end; + +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +commit; +CLOSE cursor1; +end; + + +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +CLOSE cursor1; +FETCH FORWARD 2 FROM cursor1; +end; + + +START TRANSACTION; +CURSOR cursor1 FOR SELECT * from table1; +CLOSE ALL; +FETCH FORWARD 2 FROM cursor1; +end; + + +create or replace procedure test_cursor_1 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close c1; + fetch c1 into a; +end; +/ +call test_cursor_1(); + + +create or replace procedure test_cursor_2 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close c1; + open c1; + fetch c1 into a; + close c1; + open c1; + close c1; +end; +/ +call test_cursor_2(); + + +create or replace procedure test_cursor_3 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close c1; + close c1; + open c1; + fetch c1 into a; +end; +/ +call test_cursor_3(); + + +create or replace procedure test_cursor_4 +as + a int; + cursor c1 is SELECT * from table1; +begin + OPEN c1; + close all; + close c1; + open c1; + fetch c1 into a; +end; +/ +call test_cursor_4(); + + +-- desc +create table test1(id int, id1 int, id2 int, not_id int); +insert into test1 values (1, 2, 3); + +create view v1 as select * from test1; +create MATERIALIZED view mv1 as select * from test1; +create index idx1 on test1(id); + + +desc test1; +desc test1 'id%'; +desc test1 'id'; +desc test1 '.%'; +desc test1 '*%'; +desc test1 '..%'; +desc test1 '***%'; +desc test2; +desc 'tes%' '.*%'; +desc test1 'id1,id2'; +desc v1; +desc v1 'id%'; +desc mv1; +desc mv1 'id%'; + + +describe test1; +describe test1 'id%'; +describe test1 'id'; +describe test1 '.%'; +describe test1 '*%'; +describe test1 '..%'; +describe test1 '***%'; +describe test2; +describe 'tes%' '.*%'; +describe test1 'id1,id2'; +describe v1; +describe v1 'id%'; +describe mv1; +describe mv1 'id%'; + +EXPLAIN test1; +EXPLAIN test1 'id%'; +EXPLAIN test1 'id'; +EXPLAIN test1 '.%'; +EXPLAIN test1 '*%'; +EXPLAIN test1 '..%'; +EXPLAIN test1 '***%'; +EXPLAIN test2; +EXPLAIN 'tes%' '.*%'; +EXPLAIN test1 'id1,id2'; +EXPLAIN v1; +EXPLAIN v1 'id%'; +EXPLAIN mv1; +EXPLAIN mv1 'id%'; + + +drop view v1; +drop MATERIALIZED view mv1; +drop table test1; +drop table table1; +drop procedure test_cursor_0; +drop procedure test_cursor_1; +drop procedure test_cursor_2; +drop procedure test_cursor_3; +drop procedure test_cursor_4; + +drop schema test_dcl_func cascade; +reset current_schema; -- Gitee