From eef22014b3f9765a8b07ae4b5642e59b27cc21f6 Mon Sep 17 00:00:00 2001 From: suncan <1006949218@qq.com> Date: Tue, 24 Oct 2023 15:19:58 +0800 Subject: [PATCH] =?UTF-8?q?set=20=E7=B1=BB=E5=9E=8B=E6=94=AF=E6=8C=81copy?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/optimizer/commands/copy.cpp | 3 +++ src/test/regress/expected/hw_datatype_set.out | 5 ++++- src/test/regress/sql/hw_datatype_set.sql | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/gausskernel/optimizer/commands/copy.cpp b/src/gausskernel/optimizer/commands/copy.cpp index 4dac63f51..b44cdc180 100644 --- a/src/gausskernel/optimizer/commands/copy.cpp +++ b/src/gausskernel/optimizer/commands/copy.cpp @@ -5663,6 +5663,9 @@ static int CopyFromCompressAndInsertBatch(PageCompress* pcState, EState* estate, // bool IsTypeAcceptEmptyStr(Oid typeOid) { + if (type_is_set(typeOid)) { + return true; + } switch (typeOid) { case VARCHAROID: case NVARCHAR2OID: diff --git a/src/test/regress/expected/hw_datatype_set.out b/src/test/regress/expected/hw_datatype_set.out index e0c60328d..7e407f05b 100644 --- a/src/test/regress/expected/hw_datatype_set.out +++ b/src/test/regress/expected/hw_datatype_set.out @@ -4125,6 +4125,7 @@ ERROR: invalid input value for set t1_c1_set: '' LINE 1: insert into t1 values ('a,,b'); ^ CONTEXT: referenced column: c1 +COPY t1(c1) FROM stdin WITH NULL 'NULL' CSV QUOTE '"' DELIMITER ',' ESCAPE '"'; -- 2. define set type include '' drop table if exists t2; create table t2 (c1 set('a', '', 'b') default ''); @@ -4140,14 +4141,16 @@ select c1, c1+0 from t2; insert into t2 values ('a,,b'); -- expect 2, not 0 insert into t2 values (',a,b'); -- expect 2, not 0 +COPY t2(c1) FROM stdin WITH NULL 'NULL' CSV QUOTE '"' DELIMITER ',' ESCAPE '"'; select c1, c1+0 from t2 order by 2; c1 | ?column? ------+---------- | 0 | 0 + | 0 a,,b | 7 a,,b | 7 -(4 rows) +(5 rows) drop table t1; drop table t2; diff --git a/src/test/regress/sql/hw_datatype_set.sql b/src/test/regress/sql/hw_datatype_set.sql index fc71a6e24..fd4bebb5e 100644 --- a/src/test/regress/sql/hw_datatype_set.sql +++ b/src/test/regress/sql/hw_datatype_set.sql @@ -722,6 +722,9 @@ insert into t1 values (''); insert into t1 values (default); select c1, c1+0 from t1; -- expect value 0 insert into t1 values ('a,,b'); -- expect error +COPY t1(c1) FROM stdin WITH NULL 'NULL' CSV QUOTE '"' DELIMITER ',' ESCAPE '"'; +"" +\. -- 2. define set type include '' drop table if exists t2; @@ -731,6 +734,9 @@ insert into t2 values (default); select c1, c1+0 from t2; insert into t2 values ('a,,b'); -- expect 2, not 0 insert into t2 values (',a,b'); -- expect 2, not 0 +COPY t2(c1) FROM stdin WITH NULL 'NULL' CSV QUOTE '"' DELIMITER ',' ESCAPE '"'; +"" +\. select c1, c1+0 from t2 order by 2; drop table t1; drop table t2;