exit handler sqlexception场景的core问题
This commit is contained in:
@ -3350,7 +3350,8 @@ static int expand_stmts(PLpgSQL_execstate* estate, List* stmts, bool& exception_
|
||||
|
||||
while(stmtid < num_stmts && !early_exit) {
|
||||
if (exception_flag) {
|
||||
rc = PLPGSQL_RC_EXIT;
|
||||
if (rc == -1)
|
||||
rc = PLPGSQL_RC_EXIT;
|
||||
break;
|
||||
}
|
||||
PLpgSQL_stmt* stmt = (PLpgSQL_stmt*)list_nth(stmts, stmtid);
|
||||
@ -3491,8 +3492,6 @@ static int expand_stmt_block(PLpgSQL_execstate* estate, PLpgSQL_stmt_block* stmt
|
||||
{
|
||||
int rc = -1;
|
||||
if (stmt->exceptions != NULL) {
|
||||
stmt->exceptions->exc_list = list_concat(stmt->exceptions->exc_list,
|
||||
((PLpgSQL_stmt_block*)lfirst(block_ptr_stack->head))->exceptions->exc_list);
|
||||
lcons(stmt,block_ptr_stack);
|
||||
}
|
||||
|
||||
|
@ -1693,6 +1693,55 @@ select @p1,@p2,@p3,@p4;
|
||||
| | |
|
||||
(1 row)
|
||||
|
||||
-- core
|
||||
drop table if exists t1;
|
||||
NOTICE: table "t1" does not exist, skipping
|
||||
create table t3 (w char unique, x char);
|
||||
NOTICE: CREATE TABLE / UNIQUE will create implicit index "t3_w_key" for table "t3"
|
||||
insert into t3 values ('a', 'b');
|
||||
create or replace procedure bug6900_9074(a int)
|
||||
AS
|
||||
begin
|
||||
declare exit handler for sqlstate '23000'
|
||||
begin
|
||||
RAISE NOTICE 'SQLSTATE = %, SQLCODE = %, SQLERRM = %', SQLSTATE, SQLCODE, SQLERRM;
|
||||
end;
|
||||
begin
|
||||
declare exit handler for sqlexception
|
||||
begin
|
||||
RAISE NOTICE 'SQLSTATE = %, SQLCODE = %, SQLERRM = %', SQLSTATE, SQLCODE, SQLERRM;
|
||||
end;
|
||||
|
||||
if a = 1 then
|
||||
insert into t3 values ('a', 'b');
|
||||
elseif a = 2 then
|
||||
insert into t3 values ('c', 'd');
|
||||
else
|
||||
insert into t3 values ('x', 'y', 'z');
|
||||
end if;
|
||||
end;
|
||||
drop table t1;
|
||||
end;
|
||||
/
|
||||
call bug6900_9074(0);
|
||||
NOTICE: SQLSTATE = 42601, SQLCODE = 16801924, SQLERRM = INSERT has more expressions than target columns
|
||||
bug6900_9074
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
call bug6900_9074(1);
|
||||
NOTICE: SQLSTATE = 23505, SQLCODE = 83906754, SQLERRM = duplicate key value violates unique constraint "t3_w_key"
|
||||
bug6900_9074
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
call bug6900_9074(2);
|
||||
ERROR: table "t1" does not exist
|
||||
CONTEXT: SQL statement "drop table t1"
|
||||
PL/pgSQL function bug6900_9074(integer) line 20 at SQL statement
|
||||
drop procedure bug6900_9074;
|
||||
\c regression
|
||||
-- test access to exception data
|
||||
create function zero_divide() returns int as $$
|
||||
|
@ -1107,6 +1107,40 @@ call p_resig1();
|
||||
get diagnostics condition 1 @p1 = CLASS_ORIGIN,@p2 = SUBCLASS_ORIGIN,@p3 = MESSAGE_TEXT,@p4 = MYSQL_ERRNO,@p5 = CONSTRAINT_CATALOG,@p6 = CONSTRAINT_SCHEMA,
|
||||
@p7 = CONSTRAINT_NAME,@p8 = CATALOG_NAME,@p9 = SCHEMA_NAME,@p10 = TABLE_NAME,@p11 = COLUMN_NAME,@p12 = CURSOR_NAME;
|
||||
select @p1,@p2,@p3,@p4;
|
||||
|
||||
-- core
|
||||
drop table if exists t1;
|
||||
create table t3 (w char unique, x char);
|
||||
insert into t3 values ('a', 'b');
|
||||
|
||||
create or replace procedure bug6900_9074(a int)
|
||||
AS
|
||||
begin
|
||||
declare exit handler for sqlstate '23000'
|
||||
begin
|
||||
RAISE NOTICE 'SQLSTATE = %, SQLCODE = %, SQLERRM = %', SQLSTATE, SQLCODE, SQLERRM;
|
||||
end;
|
||||
begin
|
||||
declare exit handler for sqlexception
|
||||
begin
|
||||
RAISE NOTICE 'SQLSTATE = %, SQLCODE = %, SQLERRM = %', SQLSTATE, SQLCODE, SQLERRM;
|
||||
end;
|
||||
|
||||
if a = 1 then
|
||||
insert into t3 values ('a', 'b');
|
||||
elseif a = 2 then
|
||||
insert into t3 values ('c', 'd');
|
||||
else
|
||||
insert into t3 values ('x', 'y', 'z');
|
||||
end if;
|
||||
end;
|
||||
drop table t1;
|
||||
end;
|
||||
/
|
||||
call bug6900_9074(0);
|
||||
call bug6900_9074(1);
|
||||
call bug6900_9074(2);
|
||||
drop procedure bug6900_9074;
|
||||
\c regression
|
||||
-- test access to exception data
|
||||
create function zero_divide() returns int as $$
|
||||
|
Reference in New Issue
Block a user