!3725 set return_number to correct number

Merge pull request !3725 from 吴岳川/master
This commit is contained in:
opengauss_bot
2023-07-14 07:37:03 +00:00
committed by Gitee
4 changed files with 41 additions and 3 deletions

View File

@ -4367,7 +4367,6 @@ static int exec_stmt_b_getdiag(PLpgSQL_execstate* estate, PLpgSQL_stmt_getdiag*
StringInfoData buf;
int condCount = 0;
int condition_number = 0;
int currIdx = 0;
int ret = 0;
/*

View File

@ -2982,7 +2982,12 @@ extern bool func_has_refcursor_args(Oid Funcid, FunctionCallInfoData* fcinfo)
} else if (return_refcursor) {
fcinfo->refcursor_data.return_number = out_count;
}
/* func_has_out_param means whether a func with out param and with GUC proc_outparam_override. */
bool func_has_out_param = is_function_with_plpgsql_language_and_outparam((fcinfo->flinfo)->fn_oid);
if (func_has_out_param && (return_refcursor || procStruct->prorettype == REFCURSOROID)) {
fcinfo->refcursor_data.return_number = out_count + 1;
}
ReleaseSysCache(proctup);
return use_cursor;
}

View File

@ -1004,6 +1004,24 @@ end;
/
ERROR: Named argument "b" can not be a const
CONTEXT: compilation of PL/pgSQL function "inline_code_block" near line 4
create table test_table2 (coll int,col2 text);
insert into test_table2 values (1, 'test');
create or replace function test_function2(out rl refcursor, out r2 refcursor)
returns refcursor as
$$
begin
open rl for select coll from test_table2;
open r2 for select col2 from test_table2;
return r2;
end;
$$
LANGUAGE 'plpgsql';
call test_function2('','');
test_function2 | rl | r2
--------------------+--------------------+--------------------
<unnamed portal 2> | <unnamed portal 1> | <unnamed portal 2>
(1 row)
set plsql_compile_check_options='';
drop package body if exists pck1;
drop package body pck1;
@ -1017,7 +1035,7 @@ NOTICE: drop cascades to 2 other objects
--?.*
--?.*
drop schema if exists plpgsql_override_out cascade;
NOTICE: drop cascades to 15 other objects
NOTICE: drop cascades to 17 other objects
DETAIL: drop cascades to function iob_proc(integer,integer)
drop cascades to function bio_proc(integer,integer)
drop cascades to function obi_proc(integer,integer)
@ -1033,3 +1051,5 @@ drop cascades to function plpgsql_override_out.p11()
drop cascades to function p11()
drop cascades to function plpgsql_override_out.p11()
drop cascades to function p11(integer)
drop cascades to table test_table2
drop cascades to function test_function2()

View File

@ -696,6 +696,20 @@ perform pck1.p1(a=>(1,'bb','11'),c=>var1,b=>'aa');--报错
end;
/
create table test_table2 (coll int,col2 text);
insert into test_table2 values (1, 'test');
create or replace function test_function2(out rl refcursor, out r2 refcursor)
returns refcursor as
$$
begin
open rl for select coll from test_table2;
open r2 for select col2 from test_table2;
return r2;
end;
$$
LANGUAGE 'plpgsql';
call test_function2('','');
set plsql_compile_check_options='';
drop package body if exists pck1;
drop package body pck1;