issue:解决存储过程创建时row type错误使用时不报错的问题

This commit is contained in:
Julong-Li
2023-09-04 14:30:07 +08:00
committed by li-julong9909
parent 0fa6e3d817
commit 810f96544d
5 changed files with 110 additions and 3 deletions

View File

@ -11282,6 +11282,14 @@ read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row, bool *strict, int firstto
errmsg("record or row variable cannot be part of multiple-item INTO list"),
parser_errposition(yylloc)));
}
if (tok == '.') {
const char* message = "Improper use of '.*'. The '.*' operator cannot be used with a row type variable.";
InsertErrorMessage(message, plpgsql_yylloc);
ereport(errstate,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("Improper use of '.*'. The '.*' operator cannot be used with a row type variable."),
parser_errposition(yylloc)));
}
if (tok == T_DATUM || tok == T_VARRAY_VAR
|| tok == T_TABLE_VAR || tok == T_PACKAGE_VARIABLE) {
const char* message = "syntax error, expected \",\"";

View File

@ -0,0 +1,61 @@
create table type_test(a int, b char(10));
create table test_row_type(a int, b char(10));
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* , x2.a into rec, a from test_row_type();
end;
/
ERROR: record or row variable cannot be part of multiple-item INTO list
LINE 5: select x.* , x2.a into rec, a from test_row_type();
^
QUERY: declare
rec type_test%rowtype;
a int;
begin
select x.* , x2.a into rec, a from test_row_type();
end
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* , x2.a into rec.*, a from test_row_type();
end;
/
ERROR: Improper use of '.*'. The '.*' operator cannot be used with a row type variable.
LINE 5: select x.* , x2.a into rec.*, a from test_row_type();
^
QUERY: declare
rec type_test%rowtype;
a int;
begin
select x.* , x2.a into rec.*, a from test_row_type();
end
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* into rec.* from test_row_type();
end;
/
ERROR: Improper use of '.*'. The '.*' operator cannot be used with a row type variable.
LINE 5: select x.* into rec.* from test_row_type();
^
QUERY: declare
rec type_test%rowtype;
a int;
begin
select x.* into rec.* from test_row_type();
end
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* into rec from test_row_type();
end;
/

View File

@ -32,7 +32,7 @@ test: replace_func_with_two_args trunc_func_for_date nlssort_pinyin updatable_vi
# test multiple statistics
test: functional_dependency
test: pg_proc_test
test: pg_proc_test test_row_type_in_proc
# test fdw
# NOTICE: In the "fdw_prepare", we copy the fdw test to be used from contrib into regress sql set.
@ -1099,4 +1099,4 @@ test: enable_expr_fusion_flatten
# test for on update timestamp and generated column
test: on_update_session1 on_update_session2
test: ts_gb18030_utf8
test: ts_gb18030_utf8

View File

@ -29,7 +29,7 @@ test: replace_func_with_two_args trunc_func_for_date nlssort_pinyin updatable_vi
# test multiple statistics
test: functional_dependency
test: pg_proc_test
test: pg_proc_test test_row_type_in_proc
# test fdw
# NOTICE: In the "fdw_prepare", we copy the fdw test to be used from contrib into regress sql set.

View File

@ -0,0 +1,38 @@
create table type_test(a int, b char(10));
create table test_row_type(a int, b char(10));
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* , x2.a into rec, a from test_row_type();
end;
/
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* , x2.a into rec.*, a from test_row_type();
end;
/
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* into rec.* from test_row_type();
end;
/
create or replace procedure test_row_type_in_pro()
as declare
rec type_test%rowtype;
a int;
begin
select x.* into rec from test_row_type();
end;
/