!4201 修复prepare自定义变量时的core问题
Merge pull request !4201 from pengjiong/fix_col
This commit is contained in:
@ -5166,10 +5166,16 @@ List* QueryRewritePrepareStmt(Query* parsetree)
|
||||
(errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE),
|
||||
errmsg("userdefined variable in prepare statement must be text type.")));
|
||||
}
|
||||
if (value->constvalue == (Datum)0) {
|
||||
ereport(ERROR, (errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE), errmsg("Query was empty")));
|
||||
}
|
||||
|
||||
sqlstr = TextDatumGetCString(value->constvalue);
|
||||
|
||||
raw_parsetree_list = pg_parse_query(sqlstr);
|
||||
if (raw_parsetree_list == NIL) {
|
||||
ereport(ERROR, (errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE), errmsg("Query was empty")));
|
||||
}
|
||||
|
||||
if (raw_parsetree_list->length != 1) {
|
||||
ereport(ERROR,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
-- B db compatibility case
|
||||
drop database if exists B_db;
|
||||
NOTICE: database "B_db" does not exist, skipping
|
||||
NOTICE: database "b_db" does not exist, skipping
|
||||
create database B_db dbcompatibility 'B';
|
||||
--------------------concat--------------------
|
||||
-- concat case in A db compatibility
|
||||
@ -634,7 +634,7 @@ select timestampdiff(second, '2018-01-01', now());
|
||||
(1 row)
|
||||
|
||||
select timestampdiff(microsecond, '2018-01-01', now());
|
||||
timestamp_diff
|
||||
--?.*
|
||||
--?.*
|
||||
--?.*
|
||||
(1 row)
|
||||
@ -797,6 +797,12 @@ select @v1, @1a_b.2$3, @a_b.2$3, @_ab.2$3, @.ab_2$3, @$ab.2_3;
|
||||
drop table if exists test1;
|
||||
NOTICE: table "test1" does not exist, skipping
|
||||
create table test1 (f1 int,f2 int,f3 text);
|
||||
-- prepare with empty var or not exist var
|
||||
set @v_empty := '';
|
||||
prepare stmt_empty as @v_empty;
|
||||
ERROR: Query was empty
|
||||
prepare stmt_empty as @does_not_exist;
|
||||
ERROR: Query was empty
|
||||
-- insertStmt
|
||||
set @v2 := 'insert into test1 values(1, 2, 123)';
|
||||
prepare stmt2 as @v2;
|
||||
|
||||
@ -1032,7 +1032,7 @@ test: fdw_audit
|
||||
test: gs_global_config_audit
|
||||
test: detail declare_multiple_variable
|
||||
# mysql_function_prepare must precede mysql_function/mysql_function_2, and mysql_function_clearup must follow mysql_function/mysql_function_2
|
||||
test: gs_dump_encrypt substr mysql_function_prepare
|
||||
test: gs_dump_encrypt substr mysql_function_prepare mysql_compatibility
|
||||
test: composite_datum_record mysql_function mysql_function_2 b_comments mysql_syntax mysql_condition mysql_delimiter mysql_delimiter_fix mysql_indexhint mysql_trigger mysql_signal mysql_resignal
|
||||
|
||||
test: join_test_alias alter_ctable_compress
|
||||
|
||||
@ -119,7 +119,7 @@ test: fdw_audit
|
||||
test: gs_global_config_audit
|
||||
test: detail declare_multiple_variable
|
||||
# mysql_function_prepare must precede mysql_function/mysql_function_2, and mysql_function_clearup must follow mysql_function/mysql_function_2
|
||||
test: gs_dump_encrypt substr mysql_function_prepare
|
||||
test: gs_dump_encrypt substr mysql_function_prepare mysql_compatibility
|
||||
test: composite_datum_record mysql_function mysql_function_2 b_comments mysql_syntax mysql_condition mysql_delimiter mysql_delimiter_fix mysql_indexhint mysql_trigger
|
||||
|
||||
test: join_test_alias alter_ctable_compress
|
||||
|
||||
@ -216,6 +216,12 @@ select @v1, @1a_b.2$3, @a_b.2$3, @_ab.2$3, @.ab_2$3, @$ab.2_3;
|
||||
|
||||
drop table if exists test1;
|
||||
create table test1 (f1 int,f2 int,f3 text);
|
||||
|
||||
-- prepare with empty var or not exist var
|
||||
set @v_empty := '';
|
||||
prepare stmt_empty as @v_empty;
|
||||
prepare stmt_empty as @does_not_exist;
|
||||
|
||||
-- insertStmt
|
||||
set @v2 := 'insert into test1 values(1, 2, 123)';
|
||||
prepare stmt2 as @v2;
|
||||
|
||||
Reference in New Issue
Block a user