set 类型支持copy为空

This commit is contained in:
suncan
2023-10-24 15:19:58 +08:00
parent 24957d758b
commit eef22014b3
3 changed files with 13 additions and 1 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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;