!2940 修复explain后导致匿名块无法调用存储过程的bug
Merge pull request !2940 from Cross-罗/explain_bugfix
This commit is contained in:
@ -67,8 +67,14 @@ static DestReceiver donothingDR = {donothingReceive, donothingStartup, donothing
|
||||
|
||||
static DestReceiver debugtupDR = {debugtup, debugStartup, donothingCleanup, donothingCleanup, DestDebug};
|
||||
|
||||
static DestReceiver spi_printtupDR = {spi_printtup, spi_dest_startup, donothingCleanup, donothingCleanup, DestSPI};
|
||||
|
||||
void InitSpiPrinttupDR(DestReceiver* dr)
|
||||
{
|
||||
dr->receiveSlot = spi_printtup;
|
||||
dr->rStartup = spi_dest_startup;
|
||||
dr->rShutdown = donothingCleanup;
|
||||
dr->rDestroy = donothingCleanup;
|
||||
dr->mydest = DestSPI;
|
||||
}
|
||||
/* Globally available receiver for DestNone */
|
||||
DestReceiver* None_Receiver = &donothingDR;
|
||||
|
||||
@ -118,7 +124,8 @@ DestReceiver* CreateDestReceiver(CommandDest dest)
|
||||
return &debugtupDR;
|
||||
|
||||
case DestSPI:
|
||||
return &spi_printtupDR;
|
||||
u_sess->utils_cxt.spi_printtupDR->mydest = DestSPI;
|
||||
return u_sess->utils_cxt.spi_printtupDR;
|
||||
|
||||
case DestSPITupleAnalyze:
|
||||
return createAnalyzeSPIDestReceiver(dest);
|
||||
|
||||
@ -463,6 +463,9 @@ static void knl_u_utils_init(knl_u_utils_context* utils_cxt)
|
||||
utils_cxt->enable_memory_context_control = false;
|
||||
utils_cxt->sql_ignore_strategy_val = 0;
|
||||
(void)syscalllockInit(&utils_cxt->deleMemContextMutex);
|
||||
|
||||
utils_cxt->spi_printtupDR = (DestReceiver*)palloc0(sizeof(DestReceiver));
|
||||
InitSpiPrinttupDR(utils_cxt->spi_printtupDR);
|
||||
}
|
||||
|
||||
static void knl_u_security_init(knl_u_security_context* sec_cxt) {
|
||||
|
||||
@ -67,6 +67,7 @@
|
||||
#include "utils/memgroup.h"
|
||||
#include "storage/lock/lock.h"
|
||||
#include "utils/elog.h"
|
||||
#include "tcop/dest.h"
|
||||
|
||||
typedef void (*pg_on_exit_callback)(int code, Datum arg);
|
||||
|
||||
@ -665,6 +666,7 @@ typedef struct knl_u_utils_context {
|
||||
unsigned int sql_ignore_strategy_val;
|
||||
|
||||
HTAB* set_user_params_htab;
|
||||
DestReceiver* spi_printtupDR;
|
||||
} knl_u_utils_context;
|
||||
|
||||
typedef struct knl_u_security_context {
|
||||
|
||||
@ -169,5 +169,7 @@ extern void NullCommand(CommandDest dest);
|
||||
extern void ReadyForQuery(CommandDest dest);
|
||||
extern void ReadyForQuery_noblock(CommandDest dest, int timeout);
|
||||
|
||||
extern void InitSpiPrinttupDR(DestReceiver* dr);
|
||||
|
||||
#endif /* !FRONTEND_PARSER */
|
||||
#endif /* DEST_H */
|
||||
|
||||
56
src/test/regress/expected/plan_table_for_anonymous_block.out
Normal file
56
src/test/regress/expected/plan_table_for_anonymous_block.out
Normal file
@ -0,0 +1,56 @@
|
||||
drop table if exists t_s_condition_0011_1 cascade;
|
||||
NOTICE: table "t_s_condition_0011_1" does not exist, skipping
|
||||
drop table if exists t_s_condition_0011_2;
|
||||
NOTICE: table "t_s_condition_0011_2" does not exist, skipping
|
||||
create table t_s_condition_0011_2(id int) with (storage_type=ustore);
|
||||
insert into t_s_condition_0011_2 values(1);
|
||||
create table t_s_condition_0011_1(staff_id int not null, highest_degree char(8), graduate_school varchar(64), graduate_date smalldatetime, t_education_note varchar(70)) with (storage_type=ustore);
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(10,'博士','西安电子科技大学','2017-07-06 12:00:00','211');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(11,'博士','西北农林科技大学','2017-07-06 12:00:00','211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(12,'硕士','西北工业大学','2017-07-06 12:00:00','211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(15,'学士','西安建筑科技大学','2017-07-06 12:00:00','非211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(18,'硕士','西安理工大学','2017-07-06 12:00:00','非211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(20,'学士','北京师范大学','2017-07-06 12:00:00','211和985');
|
||||
create or replace function f_s_condition_0011(a int) return int
|
||||
as
|
||||
c int;
|
||||
d int;
|
||||
begin
|
||||
c := a;
|
||||
select id into d from t_s_condition_0011_2 where rownum = c;
|
||||
return d;
|
||||
end ;
|
||||
/
|
||||
drop procedure if exists p_s_condition_0011_1;
|
||||
NOTICE: function p_s_condition_0011_1() does not exist, skipping
|
||||
create or replace procedure p_s_condition_0011_1
|
||||
as
|
||||
begin
|
||||
explain plan for select * from (select highest_degree,graduate_date from t_s_condition_0011_2 right join t_s_condition_0011_1 on staff_id = id where f_s_condition_0011(1) = 1) where graduate_date < to_date('2018-06-28 13:14:15', 'yyyy-mm-dd hh24:mi:ss:ff') order by highest_degree asc;
|
||||
explain plan for select * from (select highest_degree,graduate_date from t_s_condition_0011_2 right join t_s_condition_0011_1 on staff_id = id where f_s_condition_0011(1) = 1) where graduate_date < to_date('2018-06-28 13:14:15', 'yyyy-mm-dd hh24:mi:ss:ff') order by highest_degree desc;
|
||||
end;
|
||||
/
|
||||
select p_s_condition_0011_1();
|
||||
p_s_condition_0011_1
|
||||
----------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
create or replace procedure t_ustore_Proc_temp_table_0008(v_name varchar2) as
|
||||
v_num int;
|
||||
begin
|
||||
execute immediate 'drop table if exists t_ustore_Proc_temp_table_'||v_name;
|
||||
execute immediate 'create local temporary table t_ustore_Proc_temp_table_'||v_name||'(id int,name varchar2(200)) with (storage_type=ustore)';
|
||||
end;
|
||||
/
|
||||
declare
|
||||
v_name varchar2:= '0008';
|
||||
begin
|
||||
t_ustore_Proc_temp_table_0008(v_name);
|
||||
end;
|
||||
/
|
||||
NOTICE: table "t_ustore_proc_temp_table_0008" does not exist, skipping
|
||||
CONTEXT: SQL statement "drop table if exists t_ustore_Proc_temp_table_0008"
|
||||
PL/pgSQL function t_ustore_proc_temp_table_0008(character varying) line 4 at EXECUTE statement
|
||||
SQL statement "CALL t_ustore_proc_temp_table_0008(v_name)"
|
||||
PL/pgSQL function inline_code_block line 4 at PERFORM
|
||||
@ -276,7 +276,7 @@ test: single_node_produce_commit_rollback
|
||||
test: single_node_function_commit_rollback
|
||||
|
||||
test: instr_unique_sql
|
||||
test: auto_explain
|
||||
test: auto_explain plan_table_for_anonymous_block
|
||||
test: shutdown
|
||||
|
||||
# List/Hash table exchange
|
||||
@ -1049,4 +1049,3 @@ test: show_warnings
|
||||
test: partition_expr_key
|
||||
test: alter_foreign_schema
|
||||
|
||||
|
||||
|
||||
48
src/test/regress/sql/plan_table_for_anonymous_block.sql
Normal file
48
src/test/regress/sql/plan_table_for_anonymous_block.sql
Normal file
@ -0,0 +1,48 @@
|
||||
drop table if exists t_s_condition_0011_1 cascade;
|
||||
drop table if exists t_s_condition_0011_2;
|
||||
create table t_s_condition_0011_2(id int) with (storage_type=ustore);
|
||||
insert into t_s_condition_0011_2 values(1);
|
||||
|
||||
create table t_s_condition_0011_1(staff_id int not null, highest_degree char(8), graduate_school varchar(64), graduate_date smalldatetime, t_education_note varchar(70)) with (storage_type=ustore);
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(10,'博士','西安电子科技大学','2017-07-06 12:00:00','211');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(11,'博士','西北农林科技大学','2017-07-06 12:00:00','211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(12,'硕士','西北工业大学','2017-07-06 12:00:00','211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(15,'学士','西安建筑科技大学','2017-07-06 12:00:00','非211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(18,'硕士','西安理工大学','2017-07-06 12:00:00','非211和985');
|
||||
insert into t_s_condition_0011_1(staff_id,highest_degree,graduate_school,graduate_date,t_education_note) values(20,'学士','北京师范大学','2017-07-06 12:00:00','211和985');
|
||||
|
||||
create or replace function f_s_condition_0011(a int) return int
|
||||
as
|
||||
c int;
|
||||
d int;
|
||||
begin
|
||||
c := a;
|
||||
select id into d from t_s_condition_0011_2 where rownum = c;
|
||||
return d;
|
||||
end ;
|
||||
/
|
||||
|
||||
drop procedure if exists p_s_condition_0011_1;
|
||||
create or replace procedure p_s_condition_0011_1
|
||||
as
|
||||
begin
|
||||
explain plan for select * from (select highest_degree,graduate_date from t_s_condition_0011_2 right join t_s_condition_0011_1 on staff_id = id where f_s_condition_0011(1) = 1) where graduate_date < to_date('2018-06-28 13:14:15', 'yyyy-mm-dd hh24:mi:ss:ff') order by highest_degree asc;
|
||||
explain plan for select * from (select highest_degree,graduate_date from t_s_condition_0011_2 right join t_s_condition_0011_1 on staff_id = id where f_s_condition_0011(1) = 1) where graduate_date < to_date('2018-06-28 13:14:15', 'yyyy-mm-dd hh24:mi:ss:ff') order by highest_degree desc;
|
||||
end;
|
||||
/
|
||||
select p_s_condition_0011_1();
|
||||
|
||||
create or replace procedure t_ustore_Proc_temp_table_0008(v_name varchar2) as
|
||||
v_num int;
|
||||
begin
|
||||
execute immediate 'drop table if exists t_ustore_Proc_temp_table_'||v_name;
|
||||
execute immediate 'create local temporary table t_ustore_Proc_temp_table_'||v_name||'(id int,name varchar2(200)) with (storage_type=ustore)';
|
||||
end;
|
||||
/
|
||||
|
||||
declare
|
||||
v_name varchar2:= '0008';
|
||||
begin
|
||||
t_ustore_Proc_temp_table_0008(v_name);
|
||||
end;
|
||||
/
|
||||
Reference in New Issue
Block a user