修复psql 和B模式的delimiter 冲突的问题
This commit is contained in:
@ -93,6 +93,7 @@ typedef enum
|
||||
IDEN_DETERMINISTIC,
|
||||
IDEN_PACKAGE,
|
||||
IDEN_BUTT,
|
||||
IDEN_SELECT
|
||||
}GramIdentify;
|
||||
|
||||
/*
|
||||
@ -2257,6 +2258,8 @@ keywordRead(const char* text)
|
||||
return IDEN_CURSOR;
|
||||
else if (!upperstrcmp(text, "deterministic"))
|
||||
return IDEN_DETERMINISTIC;
|
||||
else if (!upperstrcmp(text, "select"))
|
||||
return IDEN_SELECT;
|
||||
else
|
||||
return IDEN_BUTT;
|
||||
}
|
||||
@ -2273,6 +2276,9 @@ analyze_state(const char* text,PsqlScanStateData* state)
|
||||
/*don't need to read identify*/
|
||||
if (0 == state->count_to_read)
|
||||
return;
|
||||
/*if we set delimiter to other word, don`t let Begin(xp) work*/
|
||||
if (state->is_b_format && strcmp(state->delimiter_name, ";") != 0)
|
||||
return;
|
||||
state->count_to_read--;
|
||||
keyValue = keywordRead(text);
|
||||
|
||||
@ -2337,6 +2343,7 @@ analyze_state(const char* text,PsqlScanStateData* state)
|
||||
}
|
||||
state->gram_state[IDEN_AS] = true;
|
||||
state->gram_state[IDEN_IS] = true;
|
||||
state->gram_state[IDEN_SELECT] = true;
|
||||
state->include_ora_comment = true;
|
||||
state->count_to_read = -1;
|
||||
break;
|
||||
@ -2361,7 +2368,8 @@ analyze_state(const char* text,PsqlScanStateData* state)
|
||||
/* for example:RETURN INTEGER DETERMINISTIC RETURNS NULL ON NULL INPUT */
|
||||
state->gram_state[IDEN_AS] = true;
|
||||
state->gram_state[IDEN_IS] = true;
|
||||
state->count_to_read = 6;
|
||||
/* change into -1 ,to avoid goto Begin(xp) without as or is*/
|
||||
state->count_to_read = -1;
|
||||
break;
|
||||
case IDEN_RETURNS:
|
||||
break;
|
||||
@ -2371,6 +2379,12 @@ analyze_state(const char* text,PsqlScanStateData* state)
|
||||
state->include_ora_comment = true;
|
||||
state->count_to_read = -1;
|
||||
break;
|
||||
case IDEN_SELECT:
|
||||
/*close door of as and is when create procedure select,to ensure not goto Begin(xp)*/
|
||||
state->gram_state[IDEN_AS] = false;
|
||||
state->gram_state[IDEN_IS] = false;
|
||||
state->count_to_read = -1;
|
||||
break;
|
||||
case IDEN_AS:
|
||||
case IDEN_IS:
|
||||
state->count_to_read = 0;
|
||||
|
@ -123,5 +123,73 @@ select 1"sdsd sd"
|
||||
(1 row)
|
||||
|
||||
delimiter ;
|
||||
-- test delimiter use in create procedure situation
|
||||
-- report gram error in server ,not subprogram end error, success in plugin
|
||||
create table test_table (dot_no int);
|
||||
insert into test_table values(1);
|
||||
insert into test_table values(NULL);
|
||||
delimiter //
|
||||
create procedure test91()
|
||||
begin
|
||||
declare rec_curs_value int;
|
||||
declare curs_dot cursor for select dot_no from test_table;
|
||||
open curs_dot;
|
||||
fetch curs_dot into rec_curs_value;
|
||||
while rec_curs_value is not null do
|
||||
fetch curs_dot into rec_curs_value;
|
||||
end while;
|
||||
close curs_dot;
|
||||
end;
|
||||
//
|
||||
ERROR: syntax error at or near "begin"
|
||||
LINE 2: begin
|
||||
^
|
||||
delimiter ;
|
||||
delimiter //
|
||||
create procedure test92()
|
||||
begin
|
||||
declare rec_curs_value int;
|
||||
declare curs_dot cursor for select dot_no from test_table;
|
||||
open curs_dot;
|
||||
fetch curs_dot into rec_curs_value;
|
||||
while rec_curs_value is null do
|
||||
fetch curs_dot into rec_curs_value;
|
||||
end while;
|
||||
close curs_dot;
|
||||
end;
|
||||
//
|
||||
ERROR: syntax error at or near "begin"
|
||||
LINE 2: begin
|
||||
^
|
||||
delimiter ;
|
||||
-- test deterministic error
|
||||
create function fun2(age1 int)return int DETERMINISTIC
|
||||
NOT SHIPPABLE NOT FENCED EXTERNAL SECURITY INVOKER
|
||||
AS
|
||||
declare
|
||||
a1 int;
|
||||
begin
|
||||
return a1;
|
||||
end;
|
||||
/
|
||||
select fun2(1);
|
||||
fun2
|
||||
------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- test create procedure select error
|
||||
create table t1 (a int);
|
||||
insert into t1 values (1),(2);
|
||||
-- server should has gram error,plugin pass
|
||||
create procedure pro_test() select a from t1;
|
||||
ERROR: syntax error at or near "select"
|
||||
LINE 1: create procedure pro_test() select a from t1;
|
||||
^
|
||||
-- server should has gram error, plugin pass;
|
||||
create procedure pro_test2() select a as b from t1;
|
||||
ERROR: syntax error at or near "select"
|
||||
LINE 1: create procedure pro_test2() select a as b from t1;
|
||||
^
|
||||
\c regression
|
||||
drop database my_test;
|
||||
|
@ -58,5 +58,73 @@ delimiter "sdsd sd"
|
||||
select 1"sdsd sd"
|
||||
delimiter ;
|
||||
|
||||
-- test delimiter use in create procedure situation
|
||||
-- report gram error in server ,not subprogram end error, success in plugin
|
||||
create table test_table (dot_no int);
|
||||
insert into test_table values(1);
|
||||
insert into test_table values(NULL);
|
||||
|
||||
delimiter //
|
||||
|
||||
create procedure test91()
|
||||
begin
|
||||
declare rec_curs_value int;
|
||||
declare curs_dot cursor for select dot_no from test_table;
|
||||
open curs_dot;
|
||||
fetch curs_dot into rec_curs_value;
|
||||
while rec_curs_value is not null do
|
||||
fetch curs_dot into rec_curs_value;
|
||||
end while;
|
||||
close curs_dot;
|
||||
end;
|
||||
//
|
||||
delimiter ;
|
||||
|
||||
|
||||
delimiter //
|
||||
|
||||
create procedure test92()
|
||||
begin
|
||||
declare rec_curs_value int;
|
||||
declare curs_dot cursor for select dot_no from test_table;
|
||||
open curs_dot;
|
||||
fetch curs_dot into rec_curs_value;
|
||||
while rec_curs_value is null do
|
||||
fetch curs_dot into rec_curs_value;
|
||||
end while;
|
||||
close curs_dot;
|
||||
end;
|
||||
//
|
||||
|
||||
delimiter ;
|
||||
|
||||
|
||||
-- test deterministic error
|
||||
|
||||
create function fun2(age1 int)return int DETERMINISTIC
|
||||
NOT SHIPPABLE NOT FENCED EXTERNAL SECURITY INVOKER
|
||||
AS
|
||||
declare
|
||||
a1 int;
|
||||
begin
|
||||
return a1;
|
||||
end;
|
||||
/
|
||||
|
||||
select fun2(1);
|
||||
|
||||
-- test create procedure select error
|
||||
create table t1 (a int);
|
||||
|
||||
insert into t1 values (1),(2);
|
||||
|
||||
-- server should has gram error,plugin pass
|
||||
create procedure pro_test() select a from t1;
|
||||
|
||||
-- server should has gram error, plugin pass;
|
||||
create procedure pro_test2() select a as b from t1;
|
||||
|
||||
|
||||
|
||||
\c regression
|
||||
drop database my_test;
|
||||
drop database my_test;
|
||||
|
Reference in New Issue
Block a user