From 000b2237de9e4d36c32a5d76fc00ace6f1205399 Mon Sep 17 00:00:00 2001 From: chenbd Date: Thu, 8 Jun 2023 18:31:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=97=E5=90=8D=E6=95=8F?= =?UTF-8?q?=E6=84=9F=E7=9A=84=E5=87=A0=E4=B8=AA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/dolphin/expected/column_name.out | 62 +++++++++++++++++++- contrib/dolphin/plugin_executor/execQual.cpp | 6 +- contrib/dolphin/sql/column_name.sql | 51 ++++++++++++++++ contrib/dolphin/tablecmds.cpp | 8 +++ 4 files changed, 125 insertions(+), 2 deletions(-) diff --git a/contrib/dolphin/expected/column_name.out b/contrib/dolphin/expected/column_name.out index 6eae0db08..e7e400cb5 100644 --- a/contrib/dolphin/expected/column_name.out +++ b/contrib/dolphin/expected/column_name.out @@ -2155,8 +2155,61 @@ SET check_function_bodies=off; CREATE FUNCTION monot_incr(int) RETURNS bool LANGUAGE sql AS ' select $1 > max(a) from tst_dom_constr; '; CREATE DOMAIN monot_int AS int CHECK (monot_incr(VALUE)); reset check_function_bodies; +--bugfix +drop table if exists t_t1; +NOTICE: table "t_t1" does not exist, skipping +drop table if exists t_t2; +NOTICE: table "t_t2" does not exist, skipping +create table t_t1(passId int); +create table t_t2(passId int); +CREATE OR REPLACE FUNCTION tri_func RETURNS pg_catalog.trigger AS $BODY$ +DECLARE +BEGIN +INSERT INTO t_t2(PAssID) values (new.PaSSID);RETURN NEW; +END; +$BODY$ +LANGUAGE plpgsql VOLATILE; +drop trigger tri1; +ERROR: trigger "tri1" does not exist +create trigger tri1 after insert on t_t1 FOR each row EXECUTE PROCEDURE tri_func(); +insert into t_t1 values(1); +select * from t_t2; + passId +-------- + 1 +(1 row) + +CREATE TABLE interval_normal_exchange (loGdate date not null) +PARTITION BY RANGE (logdate) +INTERVAL ('1 month') +( + PARTITION interval_normal_exchange_p1 VALUES LESS THAN ('2020-03-01'), + PARTITION interval_normal_exchange_p2 VALUES LESS THAN ('2020-04-01'), + PARTITION interval_normal_exchange_p3 VALUES LESS THAN ('2020-05-01') +); +CREATE TABLE interval_exchange_test (logdaTE date not null); +ALTER TABLE interval_normal_exchange EXCHANGE PARTITION (interval_normal_exchange_p1) + WITH TABLE interval_exchange_test; +drop table if exists t2 cascade; +NOTICE: table "t2" does not exist, skipping +drop table if exists t1 cascade; +NOTICE: table "t1" does not exist, skipping +create table t2 (iDdD int); +create table t1 (iddD int); +-- mysql has no create rule grammar not deal yet +CREATE RULE "_RETURN" AS + ON UPDATE TO t1 + DO INSTEAD + UPDATE t2 set iDdd = 7 returning IdDd; +ERROR: column "iddd" of relation "t2" does not exist +LINE 4: UPDATE t2 set iDdd = 7 returning IdDd; + ^ +CREATE RULE "_RETURN" AS + ON UPDATE TO t1 + DO INSTEAD + UPDATE t2 set "iDdD" = 7 returning "iDdD"; drop schema column_name_case_test cascade; -NOTICE: drop cascades to 39 other objects +NOTICE: drop cascades to 46 other objects DETAIL: drop cascades to table a1 drop cascades to table a2 drop cascades to table warehouse_t22 @@ -2196,4 +2249,11 @@ drop cascades to function tfun3() drop cascades to function func8() drop cascades to function monot_incr(integer) drop cascades to type monot_int +drop cascades to table t_t1 +drop cascades to table t_t2 +drop cascades to function tri_func() +drop cascades to table interval_normal_exchange +drop cascades to table interval_exchange_test +drop cascades to table t2 +drop cascades to table t1 reset current_schema; diff --git a/contrib/dolphin/plugin_executor/execQual.cpp b/contrib/dolphin/plugin_executor/execQual.cpp index ce7b0baba..3abb3845e 100644 --- a/contrib/dolphin/plugin_executor/execQual.cpp +++ b/contrib/dolphin/plugin_executor/execQual.cpp @@ -1605,7 +1605,11 @@ Datum GetAttributeByName(HeapTupleHeader tuple, const char* attname, bool* isNul attrno = InvalidAttrNumber; for (i = 0; i < tupDesc->natts; i++) { - if (namestrcmp(&(tupDesc->attrs[i].attname), attname) == 0) { +#ifdef DOLPHIN + if (namestrcasecmp(&(tupDesc->attrs[i].attname), attname) == 0) { +#else + if (namestrcmp(&(tupDesc->attrs[i].attname), attname) == 0) { +#endif attrno = tupDesc->attrs[i].attnum; break; } diff --git a/contrib/dolphin/sql/column_name.sql b/contrib/dolphin/sql/column_name.sql index 62dab945d..050dfc3ef 100644 --- a/contrib/dolphin/sql/column_name.sql +++ b/contrib/dolphin/sql/column_name.sql @@ -1275,5 +1275,56 @@ CREATE FUNCTION monot_incr(int) RETURNS bool LANGUAGE sql AS ' select $1 > max(a CREATE DOMAIN monot_int AS int CHECK (monot_incr(VALUE)); reset check_function_bodies; + +--bugfix + +drop table if exists t_t1; +drop table if exists t_t2; +create table t_t1(passId int); +create table t_t2(passId int); + +CREATE OR REPLACE FUNCTION tri_func RETURNS pg_catalog.trigger AS $BODY$ +DECLARE +BEGIN +INSERT INTO t_t2(PAssID) values (new.PaSSID);RETURN NEW; +END; +$BODY$ +LANGUAGE plpgsql VOLATILE; + +drop trigger tri1; +create trigger tri1 after insert on t_t1 FOR each row EXECUTE PROCEDURE tri_func(); +insert into t_t1 values(1); +select * from t_t2; + +CREATE TABLE interval_normal_exchange (loGdate date not null) +PARTITION BY RANGE (logdate) +INTERVAL ('1 month') +( + PARTITION interval_normal_exchange_p1 VALUES LESS THAN ('2020-03-01'), + PARTITION interval_normal_exchange_p2 VALUES LESS THAN ('2020-04-01'), + PARTITION interval_normal_exchange_p3 VALUES LESS THAN ('2020-05-01') +); + +CREATE TABLE interval_exchange_test (logdaTE date not null); + +ALTER TABLE interval_normal_exchange EXCHANGE PARTITION (interval_normal_exchange_p1) + WITH TABLE interval_exchange_test; + +drop table if exists t2 cascade; +drop table if exists t1 cascade; +create table t2 (iDdD int); +create table t1 (iddD int); + +-- mysql has no create rule grammar not deal yet +CREATE RULE "_RETURN" AS + ON UPDATE TO t1 + DO INSTEAD + UPDATE t2 set iDdd = 7 returning IdDd; + +CREATE RULE "_RETURN" AS + ON UPDATE TO t1 + DO INSTEAD + UPDATE t2 set "iDdD" = 7 returning "iDdD"; + drop schema column_name_case_test cascade; reset current_schema; diff --git a/contrib/dolphin/tablecmds.cpp b/contrib/dolphin/tablecmds.cpp index dbcf2c310..3591d90de 100644 --- a/contrib/dolphin/tablecmds.cpp +++ b/contrib/dolphin/tablecmds.cpp @@ -20460,7 +20460,11 @@ static ObjectAddress ATExecAddOf(Relation rel, const TypeName* ofTypename, LOCKM table_attname = NameStr(table_attr->attname); /* Compare name. */ +#ifdef DOLPHIN + if (strncasecmp(table_attname, type_attname, NAMEDATALEN) != 0) +#else if (strncmp(table_attname, type_attname, NAMEDATALEN) != 0) +#endif ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg("table has column \"%s\" where type requires \"%s\"", table_attname, type_attname))); @@ -26830,7 +26834,11 @@ static void checkColumnForExchange(Relation partTableRel, Relation ordTableRel) } // Check column name +#ifdef DOLPHIN + if (strcasecmp(DatumGetName(ordVals[Anum_pg_attribute_attname - 1])->data, +#else if (strcmp(DatumGetName(ordVals[Anum_pg_attribute_attname - 1])->data, +#endif DatumGetName(partVals[Anum_pg_attribute_attname - 1])->data) != 0) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), -- Gitee