From 0d2f74b220990d14cc47cd2435c07663b9064696 Mon Sep 17 00:00:00 2001 From: laishenghao Date: Tue, 19 Sep 2023 18:18:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3load=20data=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/dolphin/data/load-ignore.txt | 1 + contrib/dolphin/input/load.source | 8 +++++++ contrib/dolphin/output/load.source | 24 +++++++++++++++++++ .../plugin_optimizer/commands/copy.cpp | 4 ++++ 4 files changed, 37 insertions(+) create mode 100644 contrib/dolphin/data/load-ignore.txt diff --git a/contrib/dolphin/data/load-ignore.txt b/contrib/dolphin/data/load-ignore.txt new file mode 100644 index 000000000..4f30778b5 --- /dev/null +++ b/contrib/dolphin/data/load-ignore.txt @@ -0,0 +1 @@ +(11, ,'男','test')(12, , ,'test')(13, , ,'test')(14,12,'man','test')(15,12, ,'test')(16,\N,\N,'test') \ No newline at end of file diff --git a/contrib/dolphin/input/load.source b/contrib/dolphin/input/load.source index 66d3d8434..89873153d 100644 --- a/contrib/dolphin/input/load.source +++ b/contrib/dolphin/input/load.source @@ -37,6 +37,14 @@ insert into t_space_float values(5, ' 1.5 ', ' 2.6 ', ' 3.9 ', ' 4.9 '); - insert into t_space_float values(5, ' 1.5. ', ' 2.6 ', ' 3.9 ', ' 4.9 '); -- should error select * from t_space_float order by n; +-- test ignore +create table t_load_ignore(c_01 int primary key,c_02 int default 18,c_03 char(5) default '女',c_04 varchar(15)); +load data infile '@abs_builddir@/data/load-ignore.txt' ignore + into table t_load_ignore character set 'utf8' + fields terminated by ',' enclosed by '"' + lines starting by '(' terminated by ')'; +select * from t_load_ignore order by c_01; + create table t1(a int, b int); load data infile '@abs_builddir@/data/load1.csv' into table t1; select * from t1; diff --git a/contrib/dolphin/output/load.source b/contrib/dolphin/output/load.source index 3cd302ac6..3dcb1139b 100644 --- a/contrib/dolphin/output/load.source +++ b/contrib/dolphin/output/load.source @@ -68,6 +68,30 @@ select * from t_space_float order by n; 5 | 2 | 3 | 4 | 5 (5 rows) +-- test ignore +create table t_load_ignore(c_01 int primary key,c_02 int default 18,c_03 char(5) default '女',c_04 varchar(15)); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_load_ignore_pkey" for table "t_load_ignore" +load data infile '@abs_builddir@/data/load-ignore.txt' ignore + into table t_load_ignore character set 'utf8' + fields terminated by ',' enclosed by '"' + lines starting by '(' terminated by ')'; +WARNING: invalid input syntax for integer: " " +CONTEXT: COPY t_load_ignore, line 1, column c_02: " " +WARNING: invalid input syntax for integer: " " +CONTEXT: COPY t_load_ignore, line 2, column c_02: " " +WARNING: invalid input syntax for integer: " " +CONTEXT: COPY t_load_ignore, line 3, column c_02: " " +select * from t_load_ignore order by c_01; + c_01 | c_02 | c_03 | c_04 +------+------+-------+-------- + 11 | 0 | '男' | 'test' + 12 | 0 | | 'test' + 13 | 0 | | 'test' + 14 | 12 | 'man' | 'test' + 15 | 12 | | 'test' + 16 | | | 'test' +(6 rows) + create table t1(a int, b int); load data infile '@abs_builddir@/data/load1.csv' into table t1; select * from t1; diff --git a/contrib/dolphin/plugin_optimizer/commands/copy.cpp b/contrib/dolphin/plugin_optimizer/commands/copy.cpp index b405070ef..b4dfd0317 100644 --- a/contrib/dolphin/plugin_optimizer/commands/copy.cpp +++ b/contrib/dolphin/plugin_optimizer/commands/copy.cpp @@ -6420,6 +6420,10 @@ Datum InputFunctionCallForBulkload(CopyState cstate, FmgrInfo* flinfo, char* str if (str == NULL && flinfo->fn_strict) return (Datum)0; /* just return null result */ +#ifdef DOLPHIN + fcinfo.can_ignore = cstate->is_ignore; +#endif + SPI_STACK_LOG("push cond", NULL, NULL); pushed = SPI_push_conditional(); -- Gitee