From e9e8a07381f07ba9fa1657a520f56331b7cc9a1c Mon Sep 17 00:00:00 2001 From: lukeman Date: Thu, 24 Apr 2025 21:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86issue=EF=BC=9Anotnull?= =?UTF-8?q?=E4=B8=94=E6=97=A0default=E5=80=BC=E7=9A=84date=E5=88=97?= =?UTF-8?q?=E6=8F=92=E5=85=A5null=EF=BC=8C=E7=BB=93=E6=9E=9C=E4=B8=8EMySQL?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/dolphin/expected/empty_value_list.out | 4 +- .../dolphin/expected/empty_value_lists.out | 8 +- .../ignore_not_null_constraints.out | 32 +- contrib/dolphin/expected/union.out | 380 +++++++++--------- .../include/plugin_parser/parse_expr.h | 4 +- .../dolphin/output/dump_dumpall_test.source | 8 +- contrib/dolphin/plugin_parser/analyze.cpp | 11 + contrib/dolphin/plugin_postgres.cpp | 7 +- .../ignore_not_null_constraints.sql | 12 + 9 files changed, 259 insertions(+), 207 deletions(-) diff --git a/contrib/dolphin/expected/empty_value_list.out b/contrib/dolphin/expected/empty_value_list.out index 0f9a94630..a22a631b6 100644 --- a/contrib/dolphin/expected/empty_value_list.out +++ b/contrib/dolphin/expected/empty_value_list.out @@ -385,7 +385,7 @@ insert into test31 values(); select *from test31; num ------------ - 1970-01-01 + 0000-00-00 (1 row) insert into test32 values(); @@ -484,7 +484,7 @@ insert into m2 values(); select * from m2; a | b | c | d ------------+---+---------------------+--------------------- - 1970-01-01 | | 2020-01-01 00:00:00 | 2020-01-01 00:00:00 + 0000-00-00 | | 2020-01-01 00:00:00 | 2020-01-01 00:00:00 (1 row) insert into m3 values(); diff --git a/contrib/dolphin/expected/empty_value_lists.out b/contrib/dolphin/expected/empty_value_lists.out index 1054ada99..7354c27f6 100644 --- a/contrib/dolphin/expected/empty_value_lists.out +++ b/contrib/dolphin/expected/empty_value_lists.out @@ -415,8 +415,8 @@ insert into test31 values(),(); select *from test31; num ------------ - 1970-01-01 - 1970-01-01 + 0000-00-00 + 0000-00-00 (2 rows) insert into test32 values(),(); @@ -528,8 +528,8 @@ insert into m2 values(),(); select * from m2; a | b | c | d ------------+---+---------------------+--------------------- - 1970-01-01 | | 2020-01-01 00:00:00 | 2020-01-01 00:00:00 - 1970-01-01 | | 2020-01-01 00:00:00 | 2020-01-01 00:00:00 + 0000-00-00 | | 2020-01-01 00:00:00 | 2020-01-01 00:00:00 + 0000-00-00 | | 2020-01-01 00:00:00 | 2020-01-01 00:00:00 (2 rows) insert into m3 values(),(); diff --git a/contrib/dolphin/expected/keyword_ignore_test/ignore_not_null_constraints.out b/contrib/dolphin/expected/keyword_ignore_test/ignore_not_null_constraints.out index eed240ddf..dbe74b6e7 100644 --- a/contrib/dolphin/expected/keyword_ignore_test/ignore_not_null_constraints.out +++ b/contrib/dolphin/expected/keyword_ignore_test/ignore_not_null_constraints.out @@ -398,23 +398,26 @@ create table t_date(c date not null); insert ignore into t_date values (null); WARNING: null value in column "c" violates not-null constraint DETAIL: Failing row contains (null). +WARNING: date/time field value out of range: "0000-00-00" select * from t_date; c ------------ - 1970-01-01 + 0000-00-00 (1 row) insert into t_date values('1991-01-01 08:00:00'); update ignore t_date set c = null; WARNING: null value in column "c" violates not-null constraint DETAIL: Failing row contains (null). +WARNING: date/time field value out of range: "0000-00-00" WARNING: null value in column "c" violates not-null constraint DETAIL: Failing row contains (null). +WARNING: date/time field value out of range: "0000-00-00" select * from t_date; c ------------ - 1970-01-01 - 1970-01-01 + 0000-00-00 + 0000-00-00 (2 rows) -- uuid @@ -1635,6 +1638,29 @@ delete from ignore_t1 where id = 0; update /*+ ignore_error */ ignore_t1 set id = NULL where id = 1; WARNING: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null). +-- test for issue #IC205M +drop table if exists tb3; +NOTICE: table "tb3" does not exist, skipping +create table tb3(id int not null,col1 date not null); +set dolphin.sql_mode=''; +set sql_ignore_strategy = 'overwrite_null'; +insert into tb3 values(5,null),(6,null); +WARNING: null value in column "col1" violates not-null constraint +DETAIL: Failing row contains (5, null). +WARNING: null value in column "col1" violates not-null constraint +DETAIL: Failing row contains (6, null). +insert into tb3 values(7,default); +select * from tb3; + id | col1 +----+------------ + 5 | 0000-00-00 + 6 | 0000-00-00 + 7 | 0000-00-00 +(3 rows) + +drop table tb3; +reset dolphin.sql_mode; +reset sql_ignore_strategy; -- restore context drop schema sql_ignore_not_null_test cascade; NOTICE: drop cascades to 34 other objects diff --git a/contrib/dolphin/expected/union.out b/contrib/dolphin/expected/union.out index 52a0cf1e5..dcdfc7fe2 100644 --- a/contrib/dolphin/expected/union.out +++ b/contrib/dolphin/expected/union.out @@ -395,8 +395,8 @@ select * from test1 union select * from test30; select * from test1 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test1 union select * from test32; @@ -1005,8 +1005,8 @@ select * from test2 union select * from test30; select * from test2 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test2 union select * from test32; @@ -1615,8 +1615,8 @@ select * from test3 union select * from test30; select * from test3 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test3 union select * from test32; @@ -2225,8 +2225,8 @@ select * from test4 union select * from test30; select * from test4 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test4 union select * from test32; @@ -2835,8 +2835,8 @@ select * from test5 union select * from test30; select * from test5 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test5 union select * from test32; @@ -3458,8 +3458,8 @@ select * from test6 union select * from test30; select * from test6 union select * from test31; num ------------ - 1970-01-01 \x + 0000-00-00 (2 rows) select * from test6 union select * from test32; @@ -4086,8 +4086,8 @@ select * from test7 union select * from test30; select * from test7 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test7 union select * from test32; @@ -4709,8 +4709,8 @@ select * from test8 union select * from test30; select * from test8 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test8 union select * from test32; @@ -5333,8 +5333,8 @@ select * from test9 union select * from test30; select * from test9 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test9 union select * from test32; @@ -5948,8 +5948,8 @@ select * from test10 union select * from test30; select * from test10 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test10 union select * from test32; @@ -6571,8 +6571,8 @@ select * from test11 union select * from test30; select * from test11 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test11 union select * from test32; @@ -7194,8 +7194,8 @@ select * from test12 union select * from test30; select * from test12 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test12 union select * from test32; @@ -7817,8 +7817,8 @@ select * from test13 union select * from test30; select * from test13 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test13 union select * from test32; @@ -8441,8 +8441,8 @@ select * from test14 union select * from test30; select * from test14 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test14 union select * from test32; @@ -9057,8 +9057,8 @@ select * from test15 union select * from test30; select * from test15 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test15 union select * from test32; @@ -9680,8 +9680,8 @@ select * from test16 union select * from test30; select * from test16 union select * from test31; num ------------ - 1970-01-01 (0,0) + 0000-00-00 (2 rows) select * from test16 union select * from test32; @@ -10316,8 +10316,8 @@ select * from test17 union select * from test30; select * from test17 union select * from test31; num --------------- - 1970-01-01 [(0,0),(0,0)] + 0000-00-00 (2 rows) select * from test17 union select * from test32; @@ -10951,8 +10951,8 @@ select * from test18 union select * from test30; select * from test18 union select * from test31; num ------------ - 1970-01-01 ((0,0)) + 0000-00-00 (2 rows) select * from test18 union select * from test32; @@ -11588,7 +11588,7 @@ select * from test19 union select * from test31; num ------------- (0,0),(0,0) - 1970-01-01 + 0000-00-00 (2 rows) select * from test19 union select * from test32; @@ -12222,8 +12222,8 @@ select * from test20 union select * from test30; select * from test20 union select * from test31; num ------------ - 1970-01-01 ((0,0)) + 0000-00-00 (2 rows) select * from test20 union select * from test32; @@ -12858,8 +12858,8 @@ select * from test21 union select * from test30; select * from test21 union select * from test31; num ------------------ - 1970-01-01 0000000000000000 + 0000-00-00 (2 rows) select * from test21 union select * from test32; @@ -13492,8 +13492,8 @@ select * from test22 union select * from test30; select * from test22 union select * from test31; num --------------------- - 1970-01-01 1970-01-01 08:00:00 + 0000-00-00 (2 rows) select * from test22 union select * from test32; @@ -14126,7 +14126,7 @@ select * from test23 union select * from test31; num ------------------------ 1970-01-01 08:00:00+08 - 1970-01-01 + 0000-00-00 (2 rows) select * from test23 union select * from test32; @@ -14759,8 +14759,8 @@ select * from test24 union select * from test30; select * from test24 union select * from test31; num ------------ - 1970-01-01 @ 0 + 0000-00-00 (2 rows) select * from test24 union select * from test32; @@ -15394,8 +15394,8 @@ select * from test25 union select * from test30; select * from test25 union select * from test31; num ----------------------------------------------------- - 1970-01-01 ["1970-01-01 00:00:00+08" "1970-01-01 00:00:00+08"] + 0000-00-00 (2 rows) select * from test25 union select * from test32; @@ -16031,7 +16031,7 @@ select * from test26 union select * from test31; num ------------ <(0,0),0> - 1970-01-01 + 0000-00-00 (2 rows) select * from test26 union select * from test32; @@ -16667,7 +16667,7 @@ select * from test27 union select * from test31; num ------------ $0.00 - 1970-01-01 + 0000-00-00 (2 rows) select * from test27 union select * from test32; @@ -17294,8 +17294,8 @@ select * from test28 union select * from test30; select * from test28 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test28 union select * from test32; @@ -17917,8 +17917,8 @@ select * from test29 union select * from test30; select * from test29 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test29 union select * from test32; @@ -18540,8 +18540,8 @@ select * from test30 union select * from test30; select * from test30 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test30 union select * from test32; @@ -18962,636 +18962,637 @@ select * from test30 union select * from test91; select * from test31 union select * from test1; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test2; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test3; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test4; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test5; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test6; num ------------ - 1970-01-01 \x + 0000-00-00 (2 rows) select * from test31 union select * from test7; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test8; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test9; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test10; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test11; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test12; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test13; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test14; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test15; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test16; num ------------ - 1970-01-01 (0,0) + 0000-00-00 (2 rows) select * from test31 union select * from test17; num --------------- - 1970-01-01 [(0,0),(0,0)] + 0000-00-00 (2 rows) select * from test31 union select * from test18; num ------------ - 1970-01-01 ((0,0)) + 0000-00-00 (2 rows) select * from test31 union select * from test19; num ------------- (0,0),(0,0) - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test20; num ------------ - 1970-01-01 ((0,0)) + 0000-00-00 (2 rows) select * from test31 union select * from test21; num ------------------ - 1970-01-01 0000000000000000 + 0000-00-00 (2 rows) select * from test31 union select * from test22; num --------------------- - 1970-01-01 1970-01-01 08:00:00 + 0000-00-00 (2 rows) select * from test31 union select * from test23; num ------------------------ 1970-01-01 08:00:00+08 - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test24; num ------------ - 1970-01-01 @ 0 + 0000-00-00 (2 rows) select * from test31 union select * from test25; num ----------------------------------------------------- - 1970-01-01 ["1970-01-01 00:00:00+08" "1970-01-01 00:00:00+08"] + 0000-00-00 (2 rows) select * from test31 union select * from test26; num ------------ <(0,0),0> - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test27; num ------------ $0.00 - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test28; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test29; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test30; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (1 row) select * from test31 union select * from test32; num ------------ - 1970-01-01 00:00:00 + 0000-00-00 (2 rows) select * from test31 union select * from test33; - num ------------------------- + num +--------------------------------- 1970-01-01 08:00:00+08 - 1970-01-01 00:00:00+08 + 4714-12-31 00:00:00+08:05:43 BC (2 rows) select * from test31 union select * from test34; - num ------------------------- + num +--------------------------------- 1970-01-01 08:00:00+08 - 1970-01-01 00:00:00+08 + 4714-12-31 00:00:00+08:05:43 BC (2 rows) select * from test31 union select * from test35; num ------------ - 1970-01-01 @ 0 + 0000-00-00 (2 rows) select * from test31 union select * from test36; num ------------- - 1970-01-01 00:00:00+08 + 0000-00-00 (2 rows) select * from test31 union select * from test37; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test38; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test39; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test40; num -------------------------------------- - 1970-01-01 00000000-0000-0000-0000-000000000000 + 0000-00-00 (2 rows) select * from test31 union select * from test41; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test42; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test43; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test44; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test45; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test46; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test47; num --------------------- 1970-01-01 00:00:00 -(1 row) + 0000-00-00 00:00:00 +(2 rows) select * from test31 union select * from test48; num ------------ - 1970-01-01 a + 0000-00-00 (2 rows) select * from test31 union select * from test49; num ------------ - 1970-01-01 a + 0000-00-00 (2 rows) select * from test31 union select * from test50; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test51; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test31 union select * from test52; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test53; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test54; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test55; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test56; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test57; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test58; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test59; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test60; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test61; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test62; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test63; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test64; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test65; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test66; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test67; num --------------- - 1970-01-01 magnetic disk + 0000-00-00 (2 rows) select * from test31 union select * from test68; num ------------------ - 1970-01-01 0000000000000000 + 0000-00-00 (2 rows) select * from test31 union select * from test69; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test70; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test71; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test72; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test73; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test74; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test75; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test31 union select * from test76; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test77; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test31 union select * from test78; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test31 union select * from test79; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test31 union select * from test80; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test81; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test82; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test83; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test31 union select * from test84; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test31 union select * from test85; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test86; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test87; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test88; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test89; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test90; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test31 union select * from test91; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test32 union select * from test1; @@ -19807,8 +19808,8 @@ select * from test32 union select * from test30; select * from test32 union select * from test31; num ------------ - 1970-01-01 00:00:00 + 0000-00-00 (2 rows) select * from test32 union select * from test32; @@ -20438,10 +20439,10 @@ select * from test33 union select * from test30; (2 rows) select * from test33 union select * from test31; - num ------------------------- + num +--------------------------------- 1970-01-01 08:00:00+08 - 1970-01-01 00:00:00+08 + 4714-12-31 00:00:00+08:05:43 BC (2 rows) select * from test33 union select * from test32; @@ -21071,10 +21072,10 @@ select * from test34 union select * from test30; (2 rows) select * from test34 union select * from test31; - num ------------------------- + num +--------------------------------- 1970-01-01 08:00:00+08 - 1970-01-01 00:00:00+08 + 4714-12-31 00:00:00+08:05:43 BC (2 rows) select * from test34 union select * from test32; @@ -21707,8 +21708,8 @@ select * from test35 union select * from test30; select * from test35 union select * from test31; num ------------ - 1970-01-01 @ 0 + 0000-00-00 (2 rows) select * from test35 union select * from test32; @@ -22343,8 +22344,8 @@ select * from test36 union select * from test30; select * from test36 union select * from test31; num ------------- - 1970-01-01 00:00:00+08 + 0000-00-00 (2 rows) select * from test36 union select * from test32; @@ -22969,8 +22970,8 @@ select * from test37 union select * from test30; select * from test37 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test37 union select * from test32; @@ -23592,8 +23593,8 @@ select * from test38 union select * from test30; select * from test38 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test38 union select * from test32; @@ -24216,8 +24217,8 @@ select * from test39 union select * from test30; select * from test39 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test39 union select * from test32; @@ -24840,8 +24841,8 @@ select * from test40 union select * from test30; select * from test40 union select * from test31; num -------------------------------------- - 1970-01-01 00000000-0000-0000-0000-000000000000 + 0000-00-00 (2 rows) select * from test40 union select * from test32; @@ -25468,8 +25469,8 @@ select * from test41 union select * from test30; select * from test41 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test41 union select * from test32; @@ -26084,8 +26085,8 @@ select * from test42 union select * from test30; select * from test42 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test42 union select * from test32; @@ -26700,8 +26701,8 @@ select * from test43 union select * from test30; select * from test43 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test43 union select * from test32; @@ -27316,8 +27317,8 @@ select * from test44 union select * from test30; select * from test44 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test44 union select * from test32; @@ -27932,8 +27933,8 @@ select * from test45 union select * from test30; select * from test45 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test45 union select * from test32; @@ -28548,8 +28549,8 @@ select * from test46 union select * from test30; select * from test46 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test46 union select * from test32; @@ -29173,7 +29174,8 @@ select * from test47 union select * from test31; num --------------------- 1970-01-01 00:00:00 -(1 row) + 0000-00-00 00:00:00 +(2 rows) select * from test47 union select * from test32; num @@ -29807,8 +29809,8 @@ select * from test48 union select * from test30; select * from test48 union select * from test31; num ------------ - 1970-01-01 a + 0000-00-00 (2 rows) select * from test48 union select * from test32; @@ -30442,8 +30444,8 @@ select * from test49 union select * from test30; select * from test49 union select * from test31; num ------------ - 1970-01-01 a + 0000-00-00 (2 rows) select * from test49 union select * from test32; @@ -31078,7 +31080,7 @@ select * from test50 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test50 union select * from test32; @@ -31685,8 +31687,8 @@ select * from test51 union select * from test30; select * from test51 union select * from test31; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test51 union select * from test32; @@ -32307,8 +32309,8 @@ select * from test52 union select * from test30; select * from test52 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test52 union select * from test32; @@ -32926,7 +32928,7 @@ select * from test53 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test53 union select * from test32; @@ -33529,8 +33531,8 @@ select * from test54 union select * from test30; select * from test54 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test54 union select * from test32; @@ -34145,8 +34147,8 @@ select * from test55 union select * from test30; select * from test55 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test55 union select * from test32; @@ -34761,8 +34763,8 @@ select * from test56 union select * from test30; select * from test56 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test56 union select * from test32; @@ -35376,8 +35378,8 @@ select * from test57 union select * from test30; select * from test57 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test57 union select * from test32; @@ -36009,7 +36011,7 @@ select * from test58 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test58 union select * from test32; @@ -36621,7 +36623,7 @@ select * from test59 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test59 union select * from test32; @@ -37233,7 +37235,7 @@ select * from test60 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test60 union select * from test32; @@ -37845,7 +37847,7 @@ select * from test61 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test61 union select * from test32; @@ -38457,7 +38459,7 @@ select * from test62 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test62 union select * from test32; @@ -39069,7 +39071,7 @@ select * from test63 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test63 union select * from test32; @@ -39681,7 +39683,7 @@ select * from test64 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test64 union select * from test32; @@ -40293,7 +40295,7 @@ select * from test65 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test65 union select * from test32; @@ -40905,7 +40907,7 @@ select * from test66 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test66 union select * from test32; @@ -41516,8 +41518,8 @@ select * from test67 union select * from test30; select * from test67 union select * from test31; num --------------- - 1970-01-01 magnetic disk + 0000-00-00 (2 rows) select * from test67 union select * from test32; @@ -42151,8 +42153,8 @@ select * from test68 union select * from test30; select * from test68 union select * from test31; num ------------------ - 1970-01-01 0000000000000000 + 0000-00-00 (2 rows) select * from test68 union select * from test32; @@ -42788,7 +42790,7 @@ select * from test69 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test69 union select * from test32; @@ -43400,7 +43402,7 @@ select * from test70 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test70 union select * from test32; @@ -44012,7 +44014,7 @@ select * from test71 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test71 union select * from test32; @@ -44624,7 +44626,7 @@ select * from test72 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test72 union select * from test32; @@ -45236,7 +45238,7 @@ select * from test73 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test73 union select * from test32; @@ -45838,8 +45840,8 @@ select * from test74 union select * from test30; select * from test74 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test74 union select * from test32; @@ -46466,8 +46468,8 @@ select * from test75 union select * from test30; select * from test75 union select * from test31; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test75 union select * from test32; @@ -47088,8 +47090,8 @@ select * from test76 union select * from test30; select * from test76 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test76 union select * from test32; @@ -47704,8 +47706,8 @@ select * from test77 union select * from test30; select * from test77 union select * from test31; num ------------ - 1970-01-01 0 + 0000-00-00 (2 rows) select * from test77 union select * from test32; @@ -48324,8 +48326,8 @@ select * from test78 union select * from test30; select * from test78 union select * from test31; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test78 union select * from test32; @@ -48950,8 +48952,8 @@ select * from test79 union select * from test30; select * from test79 union select * from test31; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test79 union select * from test32; @@ -49571,8 +49573,8 @@ select * from test80 union select * from test30; select * from test80 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test80 union select * from test32; @@ -50204,7 +50206,7 @@ select * from test81 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test81 union select * from test32; @@ -50816,7 +50818,7 @@ select * from test82 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test82 union select * from test32; @@ -51423,8 +51425,8 @@ select * from test83 union select * from test30; select * from test83 union select * from test31; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test83 union select * from test32; @@ -52049,8 +52051,8 @@ select * from test84 union select * from test30; select * from test84 union select * from test31; num ------------ - 1970-01-01 - + 0000-00-00 (2 rows) select * from test84 union select * from test32; @@ -52680,7 +52682,7 @@ select * from test85 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test85 union select * from test32; @@ -53292,7 +53294,7 @@ select * from test86 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test86 union select * from test32; @@ -53904,7 +53906,7 @@ select * from test87 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test87 union select * from test32; @@ -54516,7 +54518,7 @@ select * from test88 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test88 union select * from test32; @@ -55128,7 +55130,7 @@ select * from test89 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test89 union select * from test32; @@ -55740,7 +55742,7 @@ select * from test90 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test90 union select * from test32; @@ -56352,7 +56354,7 @@ select * from test91 union select * from test31; num ------------ - 1970-01-01 + 0000-00-00 (2 rows) select * from test91 union select * from test32; diff --git a/contrib/dolphin/include/plugin_parser/parse_expr.h b/contrib/dolphin/include/plugin_parser/parse_expr.h index 77adb5314..a4ba34caa 100644 --- a/contrib/dolphin/include/plugin_parser/parse_expr.h +++ b/contrib/dolphin/include/plugin_parser/parse_expr.h @@ -43,8 +43,8 @@ extern void AddStartWithTargetRelInfo(ParseState* pstate, Node* relNode, extern void AdaptSWSelectStmt(ParseState *pstate, SelectStmt *stmt); extern bool IsQuerySWCBRewrite(Query *query); extern bool IsSWCBRewriteRTE(RangeTblEntry *rte); -extern Datum GetTypeZeroValue(Form_pg_attribute att_tup); -typedef Datum (*getTypeZeroValueFunc)(Form_pg_attribute att_tup); +extern Datum GetTypeZeroValue(Form_pg_attribute att_tup, bool can_ignore = false); +typedef Datum (*getTypeZeroValueFunc)(Form_pg_attribute att_tup, bool can_ignore); extern PlannedStmt* getCursorStreamFromFuncArg(Node* node, CursorExpression** ce = NULL); #endif /* PARSE_EXPR_H */ diff --git a/contrib/dolphin/output/dump_dumpall_test.source b/contrib/dolphin/output/dump_dumpall_test.source index 01b043f24..36fd759b2 100644 --- a/contrib/dolphin/output/dump_dumpall_test.source +++ b/contrib/dolphin/output/dump_dumpall_test.source @@ -735,7 +735,7 @@ select * from test_insert_value; select * from test_insert_empty_value_with_not_null; c1 | c2 ----+------------ - 0 | 1970-01-01 + 0 | 0000-00-00 (1 row) select * from test_insert_empty_value_with_unique; @@ -1250,7 +1250,7 @@ select * from test_insert_value; select * from test_insert_empty_value_with_not_null; c1 | c2 ----+------------ - 0 | 1970-01-01 + 0 | 0000-00-00 (1 row) select * from test_insert_empty_value_with_unique; @@ -1766,7 +1766,7 @@ select * from test_insert_value; select * from test_insert_empty_value_with_not_null; c1 | c2 ----+------------ - 0 | 1970-01-01 + 0 | 0000-00-00 (1 row) select * from test_insert_empty_value_with_unique; @@ -2280,7 +2280,7 @@ select * from test_insert_value; select * from test_insert_empty_value_with_not_null; c1 | c2 ----+------------ - 0 | 1970-01-01 + 0 | 0000-00-00 (1 row) select * from test_insert_empty_value_with_unique; diff --git a/contrib/dolphin/plugin_parser/analyze.cpp b/contrib/dolphin/plugin_parser/analyze.cpp index 3a1f4471c..3a422dd7a 100644 --- a/contrib/dolphin/plugin_parser/analyze.cpp +++ b/contrib/dolphin/plugin_parser/analyze.cpp @@ -2542,6 +2542,17 @@ static Node* makeTimetypeConst(Oid targetType, int32 targetTypmod, Oid targetCol targetByval); break; } + case DATEOID: { + new_expr = (Node*)makeConst(targetType, + targetTypmod, + targetCollation, + targetLen, + (Datum)DirectFunctionCall3( + date_in, CStringGetDatum("0000-00-00"), ObjectIdGetDatum(0), Int32GetDatum(-1)), + false, + targetByval); + break; + } default: { new_expr = (Node*)makeConst(targetType, targetTypmod, diff --git a/contrib/dolphin/plugin_postgres.cpp b/contrib/dolphin/plugin_postgres.cpp index 790993515..4d413f229 100644 --- a/contrib/dolphin/plugin_postgres.cpp +++ b/contrib/dolphin/plugin_postgres.cpp @@ -229,7 +229,7 @@ extern "C" DLL_PUBLIC Datum dolphin_types(); extern "C" Datum dolphin_binaryin(PG_FUNCTION_ARGS); static void InitDolphinTypeId(BSqlPluginContext* cxt); static void InitDolphinOperator(BSqlPluginContext* cxt); -static Datum DolphinGetTypeZeroValue(Form_pg_attribute att_tup); +static Datum DolphinGetTypeZeroValue(Form_pg_attribute att_tup, bool can_ignore = false); static bool ReplaceNullOrNot(); static bool NoAutoValueOnZero(); static bool NullsMinimalPolicy(); @@ -1677,7 +1677,7 @@ static void InitDolphinOperator(BSqlPluginContext* cxt) } /* copy from openGauss-server's execUtils.cpp GetTypeZeroValue */ -static Datum DolphinGetTypeZeroValue(Form_pg_attribute att_tup) +static Datum DolphinGetTypeZeroValue(Form_pg_attribute att_tup, bool can_ignore) { Datum result; switch (att_tup->atttypid) { @@ -1711,7 +1711,8 @@ static Datum DolphinGetTypeZeroValue(Form_pg_attribute att_tup) break; } case DATEOID: { - result = timestamp2date(SetEpochTimestamp()); + result = (Datum)DirectFunctionCall3Coll(date_in, InvalidOid, CStringGetDatum("0000-00-00"), + ObjectIdGetDatum(0), Int32GetDatum(-1), can_ignore); break; } case UUIDOID: { diff --git a/contrib/dolphin/sql/keyword_ignore_test/ignore_not_null_constraints.sql b/contrib/dolphin/sql/keyword_ignore_test/ignore_not_null_constraints.sql index 8354f23ee..c16bd5ac6 100644 --- a/contrib/dolphin/sql/keyword_ignore_test/ignore_not_null_constraints.sql +++ b/contrib/dolphin/sql/keyword_ignore_test/ignore_not_null_constraints.sql @@ -615,6 +615,18 @@ insert /*+ ignore_error */ into ignore_t1 values (2) ON DUPLICATE KEY UPDATE id delete from ignore_t1 where id = 0; update /*+ ignore_error */ ignore_t1 set id = NULL where id = 1; +-- test for issue #IC205M +drop table if exists tb3; +create table tb3(id int not null,col1 date not null); +set dolphin.sql_mode=''; +set sql_ignore_strategy = 'overwrite_null'; +insert into tb3 values(5,null),(6,null); +insert into tb3 values(7,default); +select * from tb3; +drop table tb3; +reset dolphin.sql_mode; +reset sql_ignore_strategy; + -- restore context drop schema sql_ignore_not_null_test cascade; reset current_schema; \ No newline at end of file -- Gitee