!6029 修复创建带嵌套tableof入参的包函数coredump的问题
Merge pull request !6029 from chenxiaobin/fixPkg
This commit is contained in:
@ -683,6 +683,7 @@ void delete_package(PLpgSQL_package* pkg)
|
||||
/* free package memory,*/
|
||||
plpgsql_pkg_HashTableDelete(pkg);
|
||||
plpgsql_free_package_memory(pkg);
|
||||
pfree_ext(pkg);
|
||||
}
|
||||
|
||||
static void plpgsql_pkg_append_dlcell(plpgsql_pkg_HashEnt* entity)
|
||||
@ -703,7 +704,6 @@ static void plpgsql_pkg_append_dlcell(plpgsql_pkg_HashEnt* entity)
|
||||
/* delete from the hash and delete the function's compile */
|
||||
CheckCurrCompileDependOnPackage(pkg->pkg_oid);
|
||||
delete_package(pkg);
|
||||
pfree_ext(pkg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -825,7 +825,8 @@ static PLpgSQL_package* do_pkg_compile(Oid pkgOid, HeapTuple pkg_tup, PLpgSQL_pa
|
||||
PLpgSQL_compile_context* curr_compile = createCompileContext(context_name);
|
||||
SPI_NESTCOMPILE_LOG(curr_compile->compile_cxt);
|
||||
bool pkg_is_null = false;
|
||||
if (pkg == NULL) {
|
||||
/* pkg_cxt is null, means that delete_package has been done, and pkg has been freed. */
|
||||
if (pkg == NULL || pkg->pkg_cxt == NULL) {
|
||||
pkg = (PLpgSQL_package*)MemoryContextAllocZero(
|
||||
SESS_GET_MEM_CXT_GROUP(MEMORY_CONTEXT_OPTIMIZER), sizeof(PLpgSQL_package));
|
||||
pkg->pkg_cxt = curr_compile->compile_cxt;
|
||||
@ -1330,6 +1331,10 @@ Oid findPackageParameter(const char* objname)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PLPGSQL_NSTYPE_TABLE:
|
||||
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("nested-table type is not supported for parameter yet")));
|
||||
break;
|
||||
default:
|
||||
toid = InvalidOid;
|
||||
}
|
||||
|
||||
@ -86,5 +86,67 @@ NOTICE: ID: 1, NAME: RECORD
|
||||
|
||||
(1 row)
|
||||
|
||||
set behavior_compat_options='plpgsql_dependency';
|
||||
create or replace package pac_PLArray_Case0021 is
|
||||
type typ_PLArray_1 is table of varchar(100);
|
||||
type typ_PLArray_2 is table of typ_PLArray_1;
|
||||
nstarr typ_PLArray_2;
|
||||
|
||||
procedure p_PLArray_1;
|
||||
procedure p_PLArray_2(var typ_PLArray_2);
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
WARNING: Type typ_plarray_2 does not exist.
|
||||
ERROR: nested-table type is not supported for parameter yet
|
||||
create or replace package body pac_PLArray_Case0021 is
|
||||
procedure p_PLArray_1() is
|
||||
begin
|
||||
nstarr(2)(1):='第二行第一列';
|
||||
perform p_PLArray_2(nstarr);
|
||||
end;
|
||||
|
||||
procedure p_PLArray_2(var typ_PLArray_2) is
|
||||
begin
|
||||
insert into t_PLArray_case0021(col) values(var(2)(1));
|
||||
end;
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
ERROR: package spec not found
|
||||
create or replace package pac_PLArray_Case0021 is
|
||||
procedure p_PLArray_1;
|
||||
procedure p_PLArray_2(var typ_PLArray_3);
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
WARNING: Type typ_plarray_3 does not exist.
|
||||
WARNING: The header information of function p_plarray_2 is not defined.
|
||||
CONTEXT: compilation of PL/pgSQL package near line 1
|
||||
WARNING: Package created with compilation erors.
|
||||
create or replace package body pac_PLArray_Case0021 is
|
||||
procedure p_PLArray_1() is
|
||||
begin
|
||||
nstarr(2)(1):='第二行第一列';
|
||||
perform p_PLArray_2(nstarr);
|
||||
end;
|
||||
|
||||
procedure p_PLArray_2(var typ_PLArray_3) is
|
||||
begin
|
||||
insert into t_PLArray_case0021(col) values(var(2)(1));
|
||||
end;
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
WARNING: Type typ_plarray_3 does not exist.
|
||||
WARNING: The header information of function p_plarray_2 is not defined.
|
||||
CONTEXT: compilation of PL/pgSQL package near line 1
|
||||
WARNING: function "nstarr" doesn't exist
|
||||
DETAIL: N/A
|
||||
CONTEXT: compilation of PL/pgSQL package near line 1
|
||||
WARNING: syntax error at or near "(" when compile function p_plarray_2(undefined)
|
||||
DETAIL: N/A
|
||||
CONTEXT: compilation of PL/pgSQL package near line 1
|
||||
WARNING: Package Body created with compilation erors.
|
||||
drop package pac_PLArray_Case0021;
|
||||
NOTICE: drop cascades to 2 other objects
|
||||
DETAIL: drop cascades to function plpgsql_nested_array_and_record.p_plarray_1()
|
||||
drop cascades to function plpgsql_nested_array_and_record.p_plarray_2(undefined)
|
||||
DROP SCHEMA plpgsql_nested_array_and_record CASCADE;
|
||||
NOTICE: drop cascades to function test_nested()
|
||||
|
||||
@ -60,4 +60,52 @@ END;
|
||||
/
|
||||
CALL test_nested();
|
||||
|
||||
set behavior_compat_options='plpgsql_dependency';
|
||||
|
||||
create or replace package pac_PLArray_Case0021 is
|
||||
type typ_PLArray_1 is table of varchar(100);
|
||||
type typ_PLArray_2 is table of typ_PLArray_1;
|
||||
nstarr typ_PLArray_2;
|
||||
|
||||
procedure p_PLArray_1;
|
||||
procedure p_PLArray_2(var typ_PLArray_2);
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
|
||||
create or replace package body pac_PLArray_Case0021 is
|
||||
procedure p_PLArray_1() is
|
||||
begin
|
||||
nstarr(2)(1):='第二行第一列';
|
||||
perform p_PLArray_2(nstarr);
|
||||
end;
|
||||
|
||||
procedure p_PLArray_2(var typ_PLArray_2) is
|
||||
begin
|
||||
insert into t_PLArray_case0021(col) values(var(2)(1));
|
||||
end;
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
|
||||
create or replace package pac_PLArray_Case0021 is
|
||||
procedure p_PLArray_1;
|
||||
procedure p_PLArray_2(var typ_PLArray_3);
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
|
||||
create or replace package body pac_PLArray_Case0021 is
|
||||
procedure p_PLArray_1() is
|
||||
begin
|
||||
nstarr(2)(1):='第二行第一列';
|
||||
perform p_PLArray_2(nstarr);
|
||||
end;
|
||||
|
||||
procedure p_PLArray_2(var typ_PLArray_3) is
|
||||
begin
|
||||
insert into t_PLArray_case0021(col) values(var(2)(1));
|
||||
end;
|
||||
end pac_PLArray_Case0021;
|
||||
/
|
||||
|
||||
drop package pac_PLArray_Case0021;
|
||||
|
||||
DROP SCHEMA plpgsql_nested_array_and_record CASCADE;
|
||||
|
||||
Reference in New Issue
Block a user