!2821 修复:存储过程selet into 变量报错
Merge pull request !2821 from chenbd/fix_delim_bug
This commit is contained in:
@ -92,8 +92,8 @@ typedef enum
|
||||
IDEN_SCROLL,
|
||||
IDEN_DETERMINISTIC,
|
||||
IDEN_PACKAGE,
|
||||
IDEN_BUTT,
|
||||
IDEN_SELECT
|
||||
IDEN_SELECT,
|
||||
IDEN_BUTT
|
||||
}GramIdentify;
|
||||
|
||||
/*
|
||||
@ -2277,7 +2277,7 @@ analyze_state(const char* text,PsqlScanStateData* state)
|
||||
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)
|
||||
if (state->is_b_format && state->delimiter_name && strcmp(state->delimiter_name, ";") != 0)
|
||||
return;
|
||||
state->count_to_read--;
|
||||
keyValue = keywordRead(text);
|
||||
@ -2343,7 +2343,9 @@ 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;
|
||||
if (state->is_b_format) {
|
||||
state->gram_state[IDEN_SELECT] = true;
|
||||
}
|
||||
state->include_ora_comment = true;
|
||||
state->count_to_read = -1;
|
||||
break;
|
||||
|
1
src/test/regress/data/f_pro_exp_001_1.data
Normal file
1
src/test/regress/data/f_pro_exp_001_1.data
Normal file
@ -0,0 +1 @@
|
||||
1,2,3,4,5,'2020-01-01 12:13:14',1.23,nothing
|
130
src/test/regress/input/mysql_delimiter_fix.source
Normal file
130
src/test/regress/input/mysql_delimiter_fix.source
Normal file
@ -0,0 +1,130 @@
|
||||
--delimiter bug
|
||||
create database delim_fix dbcompatibility 'B';
|
||||
\c delim_fix
|
||||
create or replace procedure pro_exp_001_1 as
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
;
|
||||
end;
|
||||
/
|
||||
|
||||
create table pro_exp_001_1(a int);
|
||||
create or replace procedure pro_exp_001_2 as
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
copy f_pro_exp_001_1 from '@abs_srcdir@/data/f_pro_exp_001_1.data' delimiter ',';
|
||||
perform count(*) from f_pro_exp_001_1;
|
||||
begin
|
||||
drop table if exists pro_exp_001_1;
|
||||
create table pro_exp_001_1(h_c_id int NOT NULL,
|
||||
h_c_d_id int NOT NULL,
|
||||
h_c_w_id int NOT NULL,
|
||||
h_d_id int NOT NULL,
|
||||
h_w_id int NOT NULL,
|
||||
h_date timestamp NOT NULL,
|
||||
h_amount numeric(6,2) NOT NULL,
|
||||
h_data varchar(24) NOT NULL)
|
||||
;
|
||||
for i in 1..10 loop
|
||||
insert into pro_exp_001_1 select * from f_pro_exp_001_1 where h_c_id > 2800;
|
||||
end loop;
|
||||
end;
|
||||
drop table if exists fto_pro_exp_001_1;
|
||||
create table fto_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
insert into fto_pro_exp_001_1 select * from pro_exp_001_1;
|
||||
delete from pro_exp_001_1;
|
||||
exception
|
||||
when OTHERS then
|
||||
raise 'Error Occurs.';
|
||||
end;
|
||||
/
|
||||
|
||||
call pro_exp_001_2();
|
||||
select * from f_pro_exp_001_1 where h_c_id = 1;
|
||||
|
||||
create database db_delimiter_a dbcompatibility 'A';
|
||||
\c db_delimiter_a;
|
||||
create table pro_exp_001_1(a int);
|
||||
create or replace procedure pro_exp_001_1 as
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
copy f_pro_exp_001_1 from '@abs_srcdir@/data/f_pro_exp_001_1.data' delimiter ',';
|
||||
perform count(*) from f_pro_exp_001_1;
|
||||
begin
|
||||
drop table if exists pro_exp_001_1;
|
||||
create table pro_exp_001_1(h_c_id int NOT NULL,
|
||||
h_c_d_id int NOT NULL,
|
||||
h_c_w_id int NOT NULL,
|
||||
h_d_id int NOT NULL,
|
||||
h_w_id int NOT NULL,
|
||||
h_date timestamp NOT NULL,
|
||||
h_amount numeric(6,2) NOT NULL,
|
||||
h_data varchar(24) NOT NULL)
|
||||
;
|
||||
for i in 1..10 loop
|
||||
insert into pro_exp_001_1 select * from f_pro_exp_001_1 where h_c_id > 2800;
|
||||
end loop;
|
||||
end;
|
||||
drop table if exists fto_pro_exp_001_1;
|
||||
create table fto_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
insert into fto_pro_exp_001_1 select * from pro_exp_001_1;
|
||||
delete from pro_exp_001_1;
|
||||
exception
|
||||
when OTHERS then
|
||||
raise 'Error Occurs.';
|
||||
end;
|
||||
/
|
||||
|
||||
call pro_exp_001_1();
|
||||
select * from f_pro_exp_001_1 where h_c_id = 1;
|
||||
|
||||
\c regression
|
||||
drop database delim_fix;
|
||||
drop database db_delimiter_a;
|
176
src/test/regress/output/mysql_delimiter_fix.source
Normal file
176
src/test/regress/output/mysql_delimiter_fix.source
Normal file
@ -0,0 +1,176 @@
|
||||
--delimiter bug
|
||||
create database delim_fix dbcompatibility 'B';
|
||||
\c delim_fix
|
||||
create or replace procedure pro_exp_001_1 as
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
;
|
||||
end;
|
||||
/
|
||||
ERROR: syntax error at or near ";"
|
||||
LINE 15: ;
|
||||
^
|
||||
QUERY:
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
;
|
||||
end
|
||||
create table pro_exp_001_1(a int);
|
||||
create or replace procedure pro_exp_001_2 as
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
copy f_pro_exp_001_1 from '@abs_srcdir@/data/f_pro_exp_001_1.data' delimiter ',';
|
||||
perform count(*) from f_pro_exp_001_1;
|
||||
begin
|
||||
drop table if exists pro_exp_001_1;
|
||||
create table pro_exp_001_1(h_c_id int NOT NULL,
|
||||
h_c_d_id int NOT NULL,
|
||||
h_c_w_id int NOT NULL,
|
||||
h_d_id int NOT NULL,
|
||||
h_w_id int NOT NULL,
|
||||
h_date timestamp NOT NULL,
|
||||
h_amount numeric(6,2) NOT NULL,
|
||||
h_data varchar(24) NOT NULL)
|
||||
;
|
||||
for i in 1..10 loop
|
||||
insert into pro_exp_001_1 select * from f_pro_exp_001_1 where h_c_id > 2800;
|
||||
end loop;
|
||||
end;
|
||||
drop table if exists fto_pro_exp_001_1;
|
||||
create table fto_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
insert into fto_pro_exp_001_1 select * from pro_exp_001_1;
|
||||
delete from pro_exp_001_1;
|
||||
exception
|
||||
when OTHERS then
|
||||
raise 'Error Occurs.';
|
||||
end;
|
||||
/
|
||||
call pro_exp_001_2();
|
||||
NOTICE: table "f_pro_exp_001_1" does not exist, skipping
|
||||
CONTEXT: SQL statement "drop table if exists f_pro_exp_001_1"
|
||||
PL/pgSQL function pro_exp_001_2() line 6 at SQL statement
|
||||
NOTICE: table "fto_pro_exp_001_1" does not exist, skipping
|
||||
CONTEXT: SQL statement "drop table if exists fto_pro_exp_001_1"
|
||||
PL/pgSQL function pro_exp_001_2() line 32 at SQL statement
|
||||
pro_exp_001_2
|
||||
---------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select * from f_pro_exp_001_1 where h_c_id = 1;
|
||||
h_c_id | h_c_d_id | h_c_w_id | h_d_id | h_w_id | h_date | h_amount | h_data
|
||||
--------+----------+----------+--------+--------+--------------------------+----------+---------
|
||||
1 | 2 | 3 | 4 | 5 | Wed Jan 01 12:13:14 2020 | 1.23 | nothing
|
||||
(1 row)
|
||||
|
||||
create database db_delimiter_a dbcompatibility 'A';
|
||||
\c db_delimiter_a;
|
||||
create table pro_exp_001_1(a int);
|
||||
create or replace procedure pro_exp_001_1 as
|
||||
declare
|
||||
count_num int;
|
||||
f_count_num int;
|
||||
begin
|
||||
drop table if exists f_pro_exp_001_1;
|
||||
create table f_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
copy f_pro_exp_001_1 from '@abs_srcdir@/data/f_pro_exp_001_1.data' delimiter ',';
|
||||
perform count(*) from f_pro_exp_001_1;
|
||||
begin
|
||||
drop table if exists pro_exp_001_1;
|
||||
create table pro_exp_001_1(h_c_id int NOT NULL,
|
||||
h_c_d_id int NOT NULL,
|
||||
h_c_w_id int NOT NULL,
|
||||
h_d_id int NOT NULL,
|
||||
h_w_id int NOT NULL,
|
||||
h_date timestamp NOT NULL,
|
||||
h_amount numeric(6,2) NOT NULL,
|
||||
h_data varchar(24) NOT NULL)
|
||||
;
|
||||
for i in 1..10 loop
|
||||
insert into pro_exp_001_1 select * from f_pro_exp_001_1 where h_c_id > 2800;
|
||||
end loop;
|
||||
end;
|
||||
drop table if exists fto_pro_exp_001_1;
|
||||
create table fto_pro_exp_001_1 (h_c_id int,
|
||||
h_c_d_id int,
|
||||
h_c_w_id int,
|
||||
h_d_id int,
|
||||
h_w_id int,
|
||||
h_date timestamp,
|
||||
h_amount numeric(6,2),
|
||||
h_data varchar(24));
|
||||
insert into fto_pro_exp_001_1 select * from pro_exp_001_1;
|
||||
delete from pro_exp_001_1;
|
||||
exception
|
||||
when OTHERS then
|
||||
raise 'Error Occurs.';
|
||||
end;
|
||||
/
|
||||
call pro_exp_001_1();
|
||||
NOTICE: table "f_pro_exp_001_1" does not exist, skipping
|
||||
CONTEXT: SQL statement "drop table if exists f_pro_exp_001_1"
|
||||
PL/pgSQL function pro_exp_001_1() line 6 at SQL statement
|
||||
NOTICE: table "fto_pro_exp_001_1" does not exist, skipping
|
||||
CONTEXT: SQL statement "drop table if exists fto_pro_exp_001_1"
|
||||
PL/pgSQL function pro_exp_001_1() line 32 at SQL statement
|
||||
pro_exp_001_1
|
||||
---------------
|
||||
|
||||
(1 row)
|
||||
|
||||
select * from f_pro_exp_001_1 where h_c_id = 1;
|
||||
h_c_id | h_c_d_id | h_c_w_id | h_d_id | h_w_id | h_date | h_amount | h_data
|
||||
--------+----------+----------+--------+--------+--------------------------+----------+---------
|
||||
1 | 2 | 3 | 4 | 5 | Wed Jan 01 12:13:14 2020 | 1.23 | nothing
|
||||
(1 row)
|
||||
|
||||
\c regression
|
||||
drop database delim_fix;
|
||||
drop database db_delimiter_a;
|
@ -995,7 +995,7 @@ test: fdw_audit
|
||||
test: gs_global_config_audit
|
||||
test: detail declare_multiple_variable
|
||||
test: gs_dump_encrypt substr
|
||||
test: composite_datum_record mysql_function b_comments mysql_syntax mysql_delimiter
|
||||
test: composite_datum_record mysql_function b_comments mysql_syntax mysql_delimiter mysql_delimiter_fix
|
||||
|
||||
test: join_test_alias alter_ctable_compress
|
||||
test: ignore/ignore_type_transform ignore/ignore_not_null_constraints ignore/ignore_unique_constraints ignore/ignore_no_matched_partition ignore/ignore_invalid_input
|
||||
|
Reference in New Issue
Block a user