!5883 【测试类型:SQL功能】【支持用ROWTYPE给游标赋值】创建使用游标rowtype的触发器函数,挂库
Merge pull request !5883 from 雷紫薇/bug133809
This commit is contained in:
@ -3892,15 +3892,15 @@ PLpgSQL_variable* plpgsql_build_variable(const char* refname, int lineno, PLpgSQ
|
||||
}
|
||||
|
||||
rec->tupdesc = getCursorTupleDesc(rec->expr, false, false);
|
||||
|
||||
nulls = (bool *)palloc(rec->tupdesc->natts * sizeof(bool));
|
||||
rc = memset_s(nulls, rec->tupdesc->natts * sizeof(bool), true, rec->tupdesc->natts * sizeof(bool));
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
rec->tup = (HeapTuple)tableam_tops_form_tuple(rec->tupdesc, NULL, nulls);
|
||||
rec->freetupdesc = (rec->tupdesc != NULL) ? true : false;
|
||||
rec->freetup = (rec->tup != NULL) ? true : false;
|
||||
pfree_ext(nulls);
|
||||
if (rec->tupdesc) {
|
||||
nulls = (bool*)palloc(rec->tupdesc->natts * sizeof(bool));
|
||||
rc = memset_s(nulls, rec->tupdesc->natts * sizeof(bool), true, rec->tupdesc->natts * sizeof(bool));
|
||||
securec_check(rc, "\0", "\0");
|
||||
rec->tup = (HeapTuple)tableam_tops_form_tuple(rec->tupdesc, NULL, nulls);
|
||||
rec->freetupdesc = (rec->tupdesc != NULL) ? true : false;
|
||||
rec->freetup = (rec->tup != NULL) ? true : false;
|
||||
pfree_ext(nulls);
|
||||
}
|
||||
|
||||
if (target_cxt) {
|
||||
temp = MemoryContextSwitchTo(temp);
|
||||
|
||||
@ -1203,6 +1203,11 @@ static void exec_cursor_rowtype_init(PLpgSQL_execstate *estate, PLpgSQL_datum *d
|
||||
|
||||
rec->expr->func = func;
|
||||
new_tupdesc = get_cursor_tupledesc_exec(rec->expr, false, false);
|
||||
if (new_tupdesc == NULL) {
|
||||
temp = MemoryContextSwitchTo(temp);
|
||||
return;
|
||||
}
|
||||
|
||||
new_natts = new_tupdesc->natts;
|
||||
|
||||
newnulls = (bool *)palloc(new_natts * sizeof(bool));
|
||||
|
||||
@ -1264,6 +1264,24 @@ INFO: after loop: (,)
|
||||
|
||||
drop package pck_for;
|
||||
NOTICE: drop cascades to function plpgsql_cursor_rowtype.p1()
|
||||
create table t_Compare_Case0013(id int,first_name varchar(100), last_name varchar(100));
|
||||
create table t_CurRowtype_PLObject_Case0013(first_name varchar(100), last_name varchar(100));
|
||||
insert into t_CurRowtype_PLObject_Case0013 values('Jason','Statham');
|
||||
create or replace function f_CurRowtype_PLObject_Case0013() returns trigger as
|
||||
$$
|
||||
declare
|
||||
cursor cur_1 is select * from t_CurRowtype_PLObject_Case0013;
|
||||
source cur_1%rowtype;
|
||||
begin
|
||||
source.first_name:=new.first_name;
|
||||
source.last_name:=new.last_name;
|
||||
insert into t_Compare_Case0013 values (source.first_name,source.last_name);
|
||||
return new;
|
||||
end
|
||||
$$ language plpgsql;
|
||||
drop function f_CurRowtype_PLObject_Case0013;
|
||||
drop table t_CurRowtype_PLObject_Case0013;
|
||||
drop table t_Compare_Case0013;
|
||||
set behavior_compat_options='';
|
||||
set plsql_compile_check_options='for_loop';
|
||||
-- (b) definde as scarlar
|
||||
|
||||
@ -977,6 +977,27 @@ end pck_for;
|
||||
call pck_for.p1();
|
||||
drop package pck_for;
|
||||
|
||||
create table t_Compare_Case0013(id int,first_name varchar(100), last_name varchar(100));
|
||||
create table t_CurRowtype_PLObject_Case0013(first_name varchar(100), last_name varchar(100));
|
||||
insert into t_CurRowtype_PLObject_Case0013 values('Jason','Statham');
|
||||
|
||||
create or replace function f_CurRowtype_PLObject_Case0013() returns trigger as
|
||||
$$
|
||||
declare
|
||||
cursor cur_1 is select * from t_CurRowtype_PLObject_Case0013;
|
||||
source cur_1%rowtype;
|
||||
begin
|
||||
source.first_name:=new.first_name;
|
||||
source.last_name:=new.last_name;
|
||||
insert into t_Compare_Case0013 values (source.first_name,source.last_name);
|
||||
return new;
|
||||
end
|
||||
$$ language plpgsql;
|
||||
|
||||
drop function f_CurRowtype_PLObject_Case0013;
|
||||
drop table t_CurRowtype_PLObject_Case0013;
|
||||
drop table t_Compare_Case0013;
|
||||
|
||||
set behavior_compat_options='';
|
||||
set plsql_compile_check_options='for_loop';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user