diff --git a/src/common/backend/utils/adt/date.cpp b/src/common/backend/utils/adt/date.cpp index 207e607f1..243075e45 100644 --- a/src/common/backend/utils/adt/date.cpp +++ b/src/common/backend/utils/adt/date.cpp @@ -203,7 +203,7 @@ Datum date_in(PG_FUNCTION_ARGS) } /* - * the following logic is unified for date parsing.` + * the following logic is unified for date parsing. */ if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday)) ereport(ERROR, (errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE), errmsg("date out of range: \"%s\"", str))); @@ -1105,7 +1105,7 @@ Datum time_in(PG_FUNCTION_ARGS) int nf; int dterr; char workbuf[MAXDATELEN + 1]; - char* field[MAXDATEFIELDS]; + char* field[MAXDATEFIELDS] = {0}; int dtype; int ftype[MAXDATEFIELDS]; char* time_fmt = NULL; @@ -1135,6 +1135,9 @@ Datum time_in(PG_FUNCTION_ARGS) * then we will return 00:00:xx if the first 1 or 2 character is lower than 60, otherwise return 00:00:00 */ char* field_str = field[0]; + if (field_str == NULL) { + PG_RETURN_TIMEADT(0); + } if (*field_str == '+') { field_str++; } @@ -1870,7 +1873,7 @@ Datum timetz_in(PG_FUNCTION_ARGS) int nf; int dterr; char workbuf[MAXDATELEN + 1]; - char* field[MAXDATEFIELDS]; + char* field[MAXDATEFIELDS] = {0}; int dtype; int ftype[MAXDATEFIELDS]; @@ -1884,13 +1887,17 @@ Datum timetz_in(PG_FUNCTION_ARGS) * then we will return 00:00:xx if the first 1 or 2 character is lower than 60, otherwise return 00:00:00 */ char* field_str = field[0]; - if (*field_str == '+') { - field_str++; + if (field_str == NULL) { + tm->tm_sec = 0; + } else { + if (*field_str == '+') { + field_str++; + } + int trunc_val = getStartingDigits(field_str); + tm->tm_sec = (trunc_val < 0 || trunc_val >= 60) ? 0 : trunc_val; } tm->tm_hour = 0; tm->tm_min = 0; - int trunc_val = getStartingDigits(field_str); - tm->tm_sec = (trunc_val < 0 || trunc_val >= 60) ? 0 : trunc_val; fsec = 0; } diff --git a/src/common/backend/utils/adt/float.cpp b/src/common/backend/utils/adt/float.cpp index f76a2c971..563b9de90 100644 --- a/src/common/backend/utils/adt/float.cpp +++ b/src/common/backend/utils/adt/float.cpp @@ -257,10 +257,17 @@ Datum float4in(PG_FUNCTION_ARGS) * Check for an empty-string input to begin with, to avoid the vagaries of * strtod() on different platforms. */ - if (*num == '\0') + if (*num == '\0') { + if (fcinfo->can_ignore) { + ereport(WARNING, + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("invalid input syntax for type real: \"%s\". truncated automatically", orig_num))); + PG_RETURN_FLOAT4(0); + } ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type real: \"%s\"", orig_num))); + } /* skip leading whitespace */ while (*num != '\0' && isspace((unsigned char)*num)) @@ -493,10 +500,17 @@ Datum float8in(PG_FUNCTION_ARGS) * Check for an empty-string input to begin with, to avoid the vagaries of * strtod() on different platforms. */ - if (*num == '\0') + if (*num == '\0') { + if (fcinfo->can_ignore) { + ereport(WARNING, + (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), + errmsg("invalid input syntax for type double precision: \"%s\". truncated automatically", orig_num))); + PG_RETURN_FLOAT8(0); + } ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type double precision: \"%s\"", orig_num))); + } /* skip leading whitespace */ while (*num != '\0' && isspace((unsigned char)*num)) diff --git a/src/common/backend/utils/adt/json.cpp b/src/common/backend/utils/adt/json.cpp index b6fc8ce1b..ba3e0a283 100644 --- a/src/common/backend/utils/adt/json.cpp +++ b/src/common/backend/utils/adt/json.cpp @@ -162,6 +162,7 @@ Datum json_in(PG_FUNCTION_ARGS) /* validate it */ lex = makeJsonLexContext(result, false); + MemoryContext oldcxt = CurrentMemoryContext; PG_TRY(); { pg_parse_json(lex, &nullSemAction); @@ -169,9 +170,13 @@ Datum json_in(PG_FUNCTION_ARGS) PG_CATCH(); { if (fcinfo->can_ignore) { + (void)MemoryContextSwitchTo(oldcxt); + ErrorData *edata = CopyErrorData(); ereport(WARNING, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type json"))); + FlushErrorState(); + FreeErrorData(edata); PG_RETURN_DATUM((Datum)DirectFunctionCall1(json_in, CStringGetDatum("null"))); } else { PG_RE_THROW(); diff --git a/src/common/backend/utils/adt/jsonb.cpp b/src/common/backend/utils/adt/jsonb.cpp index 12d021ccf..b4e0d239c 100644 --- a/src/common/backend/utils/adt/jsonb.cpp +++ b/src/common/backend/utils/adt/jsonb.cpp @@ -45,6 +45,7 @@ Datum jsonb_in(PG_FUNCTION_ARGS) json = json == NULL ? pstrdup("") : json; Datum result; + MemoryContext oldcxt = CurrentMemoryContext; PG_TRY(); { result = jsonb_from_cstring(json, strlen(json)); @@ -52,9 +53,13 @@ Datum jsonb_in(PG_FUNCTION_ARGS) PG_CATCH(); { if (fcinfo->can_ignore) { + (void)MemoryContextSwitchTo(oldcxt); + ErrorData *edata = CopyErrorData(); ereport(WARNING, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), errmsg("invalid input syntax for type json"))); + FlushErrorState(); + FreeErrorData(edata); PG_RETURN_DATUM((Datum)DirectFunctionCall1(jsonb_in, CStringGetDatum("null"))); } else { PG_RE_THROW(); diff --git a/src/test/regress/expected/ignore/ignore_invalid_input.out b/src/test/regress/expected/ignore/ignore_invalid_input.out index 80807ccf4..4ea21ea05 100644 --- a/src/test/regress/expected/ignore/ignore_invalid_input.out +++ b/src/test/regress/expected/ignore/ignore_invalid_input.out @@ -17,6 +17,7 @@ LINE 1: insert /*+ ignore_error */ into t_tinyint values('-12555a34'... CONTEXT: referenced column: c insert /*+ ignore_error */ into t_tinyint values('aaa123a34'); insert /*+ ignore_error */ into t_tinyint values('abcde'); +insert /*+ ignore_error */ into t_tinyint values(''); select * from t_tinyint; c ----- @@ -25,7 +26,8 @@ select * from t_tinyint; 0 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_tinyint set c = '12a34'; -- type: smallint @@ -43,6 +45,7 @@ LINE 1: ...nsert /*+ ignore_error */ into t_smallint values ('-12333333... CONTEXT: referenced column: c insert /*+ ignore_error */ into t_smallint values ('aaa1234a5'); insert /*+ ignore_error */ into t_smallint values ('abcde'); +insert /*+ ignore_error */ into t_smallint values (''); select * from t_smallint; c -------- @@ -51,7 +54,8 @@ select * from t_smallint; -32768 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_smallint set c = '12a34'; -- type: int4 @@ -69,6 +73,7 @@ LINE 1: insert /*+ ignore_error */ into t_int values ('-123333333333... CONTEXT: referenced column: c insert /*+ ignore_error */ into t_int values ('aaa123a45'); insert /*+ ignore_error */ into t_int values ('abcde'); +insert /*+ ignore_error */ into t_int values (''); select * from t_int; c ------------- @@ -77,7 +82,8 @@ select * from t_int; -2147483648 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_int set c = '12a34'; -- type: bigint @@ -95,6 +101,7 @@ LINE 1: insert /*+ ignore_error */ into t_bigint values ('-123333333... CONTEXT: referenced column: c insert /*+ ignore_error */ into t_bigint values ('aaa123a45'); insert /*+ ignore_error */ into t_bigint values ('abcde'); +insert /*+ ignore_error */ into t_bigint values (''); select * from t_bigint; c ---------------------- @@ -103,7 +110,8 @@ select * from t_bigint; -9223372036854775808 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_bigint set c = '12a34'; -- type: float4 @@ -133,6 +141,11 @@ WARNING: invalid input syntax for type real: "abcde". truncated automatically LINE 1: insert /*+ ignore_error */ into t_float4 values ('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_float4 values (''); +WARNING: invalid input syntax for type real: "". truncated automatically +LINE 1: insert /*+ ignore_error */ into t_float4 values (''); + ^ +CONTEXT: referenced column: c select * from t_float4; c -------------- @@ -141,7 +154,8 @@ select * from t_float4; -3.40282e+38 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_float4 set c = '12a34'; WARNING: invalid input syntax for type real: "12a34". truncated automatically @@ -183,6 +197,11 @@ WARNING: invalid input syntax for type double precision: "abcde". truncated aut LINE 1: insert /*+ ignore_error */ into t_float8 values ('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_float8 values (''); +WARNING: invalid input syntax for type double precision: "". truncated automatically +LINE 1: insert /*+ ignore_error */ into t_float8 values (''); + ^ +CONTEXT: referenced column: c select * from t_float8; c ----------------------- @@ -191,7 +210,8 @@ select * from t_float8; 2.2250738585072e-308 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_float8 set c = '12a34'; WARNING: invalid input syntax for type double precision: "12a34". truncated automatically @@ -217,6 +237,7 @@ LINE 1: insert /*+ ignore_error */ into t_numeric values ('-33333189... CONTEXT: referenced column: c insert /*+ ignore_error */ into t_numeric values ('aaa123.12a45'); insert /*+ ignore_error */ into t_numeric values ('abcde'); +insert /*+ ignore_error */ into t_numeric values (''); select * from t_numeric; c ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -225,7 +246,8 @@ select * from t_numeric; -333331892038097432987589432759843769348605436304758493758943758943758943759843756983760945860948605948765487689547893475893475918920380974329875894327598437693486054363047584937589437589437589437598437569837609458609486059487654876895478934758934759627346378267863475863875648365843734895749837589437589473988.18920380974329875894327598437693486054363047584937589437589437589437598437569837609458609486059487654876895478934758934759189203809743298758943275984376934860543630475849375894375894375894375984375698376094586094860594876548768954789347589347593874894375984 0 0 -(5 rows) + 0 +(6 rows) update /*+ ignore_error */ t_numeric set c = '12a34'; WARNING: invalid input syntax for type numeric: "12a34" @@ -259,6 +281,11 @@ WARNING: invalid input syntax for type date: "abcde" LINE 1: insert /*+ ignore_error */ into t_date values('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_date values(''); +WARNING: invalid input syntax for type date: "" +LINE 1: insert /*+ ignore_error */ into t_date values(''); + ^ +CONTEXT: referenced column: c select * from t_date; c ------------ @@ -267,7 +294,8 @@ select * from t_date; 01-01-1970 01-01-1970 01-01-1970 -(5 rows) + 01-01-1970 +(6 rows) update /*+ ignore_error */ t_date set c = '12a34'; WARNING: invalid input syntax for type date: "12a34" @@ -301,6 +329,11 @@ WARNING: invalid input syntax for type time: "abcde" LINE 1: insert /*+ ignore_error */ into t_time values('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_time values(''); +WARNING: invalid input syntax for type time: "" +LINE 1: insert /*+ ignore_error */ into t_time values(''); + ^ +CONTEXT: referenced column: c select * from t_time; c ---------- @@ -309,7 +342,8 @@ select * from t_time; 00:00:12 00:00:00 00:00:00 -(5 rows) + 00:00:00 +(6 rows) update /*+ ignore_error */ t_time set c = '12a34'; WARNING: invalid input syntax for type time: "12a34" @@ -333,13 +367,19 @@ WARNING: invalid input syntax for type timestamp: "aaaaaa12a34" LINE 1: ...sert /*+ ignore_error */ into t_timestamp values('aaaaaa12a... ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_timestamp values(''); +WARNING: invalid input syntax for type timestamp: "" +LINE 1: insert /*+ ignore_error */ into t_timestamp values(''); + ^ +CONTEXT: referenced column: c select * from t_timestamp; c --------------------------------- --?.* --?.* --?.* -(3 rows) +--?.* +(4 rows) update /*+ ignore_error */ t_timestamp set c = '12a34'; WARNING: invalid input syntax for type timestamp: "12a34" @@ -363,13 +403,19 @@ WARNING: invalid input syntax for type timestamp with time zone: "aaaaaa12a34" LINE 1: ...rt /*+ ignore_error */ into t_timestamptz values('aaaaaa12a... ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_timestamptz values(''); +WARNING: invalid input syntax for type timestamp with time zone: "" +LINE 1: insert /*+ ignore_error */ into t_timestamptz values(''); + ^ +CONTEXT: referenced column: c select * from t_timestamptz; c ------------------------------------- --?.* --?.* --?.* -(3 rows) +--?.* +(4 rows) update /*+ ignore_error */ t_timestamptz set c = '12a34'; WARNING: invalid input syntax for type timestamp with time zone: "12a34" @@ -403,6 +449,11 @@ WARNING: invalid input syntax for type time with time zone: "abcde" LINE 1: insert /*+ ignore_error */ into t_timetz values('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_timetz values(''); +WARNING: invalid input syntax for type time with time zone: "" +LINE 1: insert /*+ ignore_error */ into t_timetz values(''); + ^ +CONTEXT: referenced column: c select * from t_timetz; c ------------- @@ -411,7 +462,8 @@ select * from t_timetz; 00:00:12+00 00:00:00+00 00:00:00+00 -(5 rows) + 00:00:00+00 +(6 rows) update /*+ ignore_error */ t_timetz set c = '12a34'; WARNING: invalid input syntax for type time with time zone: "12a34" @@ -445,6 +497,11 @@ WARNING: invalid input syntax for type interval: "abcde" LINE 1: insert /*+ ignore_error */ into t_interval values('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_interval values(''); +WARNING: invalid input syntax for type interval: "" +LINE 1: insert /*+ ignore_error */ into t_interval values(''); + ^ +CONTEXT: referenced column: c select * from t_interval; c ----- @@ -453,7 +510,8 @@ select * from t_interval; @ 0 @ 0 @ 0 -(5 rows) + @ 0 +(6 rows) update /*+ ignore_error */ t_interval set c = '12a34'; WARNING: invalid input syntax for type interval: "12a34" @@ -487,6 +545,11 @@ WARNING: invalid input syntax for type tinterval: "abcde" LINE 1: insert /*+ ignore_error */ into t_tinterval values('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_tinterval values(''); +WARNING: invalid input syntax for type tinterval: "" +LINE 1: insert /*+ ignore_error */ into t_tinterval values(''); + ^ +CONTEXT: referenced column: c select * from t_tinterval; c ----------------------------------------------------------------- @@ -495,7 +558,8 @@ select * from t_tinterval; ["Thu Jan 01 08:00:00 1970 CST" "Thu Jan 01 08:00:00 1970 CST"] ["Thu Jan 01 08:00:00 1970 CST" "Thu Jan 01 08:00:00 1970 CST"] ["Thu Jan 01 08:00:00 1970 CST" "Thu Jan 01 08:00:00 1970 CST"] -(5 rows) + ["Thu Jan 01 08:00:00 1970 CST" "Thu Jan 01 08:00:00 1970 CST"] +(6 rows) update /*+ ignore_error */ t_tinterval set c = '12a34'; WARNING: invalid input syntax for type tinterval: "12a34" @@ -529,6 +593,11 @@ WARNING: invalid input syntax for type smalldatetime: "abcde" LINE 1: ...rt /*+ ignore_error */ into t_smalldatetime values('abcde'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_smalldatetime values(''); +WARNING: invalid input syntax for type smalldatetime: "" +LINE 1: insert /*+ ignore_error */ into t_smalldatetime values(''); + ^ +CONTEXT: referenced column: c select * from t_smalldatetime; c -------------------------- @@ -537,7 +606,8 @@ select * from t_smalldatetime; Thu Jan 01 00:00:00 1970 Thu Jan 01 00:00:00 1970 Thu Jan 01 00:00:00 1970 -(5 rows) + Thu Jan 01 00:00:00 1970 +(6 rows) update /*+ ignore_error */ t_smalldatetime set c = '12a34'; WARNING: invalid input syntax for type smalldatetime: "12a34" @@ -551,6 +621,11 @@ WARNING: invalid input syntax for uuid: "12a34" LINE 1: insert /*+ ignore_error */ into t_uuid values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_uuid values(''); +WARNING: invalid input syntax for uuid: "" +LINE 1: insert /*+ ignore_error */ into t_uuid values(''); + ^ +CONTEXT: referenced column: c update /*+ ignore_error */ t_uuid set c = '12a34'; WARNING: invalid input syntax for uuid: "12a34" LINE 1: update /*+ ignore_error */ t_uuid set c = '12a34'; @@ -560,7 +635,8 @@ select * from t_uuid; c -------------------------------------- 00000000-0000-0000-0000-000000000000 -(1 row) + 00000000-0000-0000-0000-000000000000 +(2 rows) -- type: point create table t_point(c point); @@ -569,11 +645,17 @@ WARNING: invalid input syntax for type point: "12a34" LINE 1: insert /*+ ignore_error */ into t_point values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_point values(''); +WARNING: invalid input syntax for type point: "" +LINE 1: insert /*+ ignore_error */ into t_point values(''); + ^ +CONTEXT: referenced column: c select * from t_point; c ------- (0,0) -(1 row) + (0,0) +(2 rows) update /*+ ignore_error */ t_point set c = '12a34'; WARNING: invalid input syntax for type point: "12a34" @@ -584,7 +666,8 @@ select * from t_point; c ------- (0,0) -(1 row) + (0,0) +(2 rows) -- type: path create table t_path(c path); @@ -593,11 +676,17 @@ WARNING: invalid input syntax for type path: "12a34" LINE 1: insert /*+ ignore_error */ into t_path values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_path values(''); +WARNING: invalid input syntax for type path: "" +LINE 1: insert /*+ ignore_error */ into t_path values(''); + ^ +CONTEXT: referenced column: c select * from t_path; c --------- ((0,0)) -(1 row) + ((0,0)) +(2 rows) update /*+ ignore_error */ t_path set c = '12a34'; WARNING: invalid input syntax for type path: "12a34" @@ -608,7 +697,8 @@ select * from t_path; c --------- ((0,0)) -(1 row) + ((0,0)) +(2 rows) -- type: polygon create table t_polygon(c polygon); @@ -617,11 +707,17 @@ WARNING: invalid input syntax for type polygon: "12a34" LINE 1: insert /*+ ignore_error */ into t_polygon values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_polygon values(''); +WARNING: invalid input syntax for type polygon: "" +LINE 1: insert /*+ ignore_error */ into t_polygon values(''); + ^ +CONTEXT: referenced column: c select * from t_polygon; c --------- ((0,0)) -(1 row) + ((0,0)) +(2 rows) update /*+ ignore_error */ t_polygon set c = '12a34'; WARNING: invalid input syntax for type polygon: "12a34" @@ -632,7 +728,8 @@ select * from t_polygon; c --------- ((0,0)) -(1 row) + ((0,0)) +(2 rows) -- type: circle create table t_circle(c circle); @@ -641,11 +738,17 @@ WARNING: invalid input syntax for type circle: "12a34" LINE 1: insert /*+ ignore_error */ into t_circle values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_circle values(''); +WARNING: invalid input syntax for type circle: "" +LINE 1: insert /*+ ignore_error */ into t_circle values(''); + ^ +CONTEXT: referenced column: c select * from t_circle; c ----------- <(0,0),0> -(1 row) + <(0,0),0> +(2 rows) update /*+ ignore_error */ t_circle set c = '12a34'; WARNING: invalid input syntax for type circle: "12a34" @@ -656,7 +759,8 @@ select * from t_circle; c ----------- <(0,0),0> -(1 row) + <(0,0),0> +(2 rows) -- type: lseg create table t_lseg(c lseg); @@ -665,11 +769,17 @@ WARNING: invalid input syntax for type lseg: "12a34" LINE 1: insert /*+ ignore_error */ into t_lseg values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_lseg values(''); +WARNING: invalid input syntax for type lseg: "" +LINE 1: insert /*+ ignore_error */ into t_lseg values(''); + ^ +CONTEXT: referenced column: c select * from t_lseg; c --------------- [(0,0),(0,0)] -(1 row) + [(0,0),(0,0)] +(2 rows) update /*+ ignore_error */ t_lseg set c = '12a34'; WARNING: invalid input syntax for type lseg: "12a34" @@ -680,7 +790,8 @@ select * from t_lseg; c --------------- [(0,0),(0,0)] -(1 row) + [(0,0),(0,0)] +(2 rows) -- type: box create table t_box(c box); @@ -689,11 +800,17 @@ WARNING: invalid input syntax for type box: "12a34" LINE 1: insert /*+ ignore_error */ into t_box values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_box values(''); +WARNING: invalid input syntax for type box: "" +LINE 1: insert /*+ ignore_error */ into t_box values(''); + ^ +CONTEXT: referenced column: c select * from t_box; c ------------- (0,0),(0,0) -(1 row) + (0,0),(0,0) +(2 rows) update /*+ ignore_error */ t_box set c = '12a34'; WARNING: invalid input syntax for type box: "12a34" @@ -704,7 +821,8 @@ select * from t_box; c ------------- (0,0),(0,0) -(1 row) + (0,0),(0,0) +(2 rows) -- type: json create table t_json(c json); @@ -713,11 +831,47 @@ WARNING: invalid input syntax for type json LINE 1: insert /*+ ignore_error */ into t_json values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_json values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_json values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_json values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_json values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_json values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_json values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_json values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_json values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_json values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_json values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_json values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_json values(''); + ^ +CONTEXT: referenced column: c select * from t_json; c ------ null -(1 row) + null + null + null + null + null + null +(7 rows) update /*+ ignore_error */ t_json set c = '12a34'; WARNING: invalid input syntax for type json @@ -728,7 +882,13 @@ select * from t_json; c ------ null -(1 row) + null + null + null + null + null + null +(7 rows) -- type: jsonb create table t_jsonb(c jsonb); @@ -737,11 +897,47 @@ WARNING: invalid input syntax for type json LINE 1: insert /*+ ignore_error */ into t_jsonb values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_jsonb values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_jsonb values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_jsonb values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_jsonb values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_jsonb values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_jsonb values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_jsonb values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_jsonb values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_jsonb values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_jsonb values(''); + ^ +CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_jsonb values(''); +WARNING: invalid input syntax for type json +LINE 1: insert /*+ ignore_error */ into t_jsonb values(''); + ^ +CONTEXT: referenced column: c select * from t_jsonb; c ------ null -(1 row) + null + null + null + null + null + null +(7 rows) update /*+ ignore_error */ t_jsonb set c = '12a34'; WARNING: invalid input syntax for type json @@ -752,7 +948,13 @@ select * from t_jsonb; c ------ null -(1 row) + null + null + null + null + null + null +(7 rows) -- type: bit create table t_bit(c bit); @@ -761,11 +963,13 @@ WARNING: "2" is not a valid binary digit LINE 1: insert /*+ ignore_error */ into t_bit values('12a34'); ^ CONTEXT: referenced column: c +insert /*+ ignore_error */ into t_bit values(''); select * from t_bit; c --- 0 -(1 row) + 0 +(2 rows) update /*+ ignore_error */ t_bit set c = '12a34'; WARNING: "2" is not a valid binary digit @@ -776,7 +980,8 @@ select * from t_bit; c --- 0 -(1 row) + 0 +(2 rows) -- restore context reset timezone; diff --git a/src/test/regress/sql/ignore/ignore_invalid_input.sql b/src/test/regress/sql/ignore/ignore_invalid_input.sql index 4abfa7660..814b0eb03 100644 --- a/src/test/regress/sql/ignore/ignore_invalid_input.sql +++ b/src/test/regress/sql/ignore/ignore_invalid_input.sql @@ -10,6 +10,7 @@ insert /*+ ignore_error */ into t_tinyint values('12555a34'); insert /*+ ignore_error */ into t_tinyint values('-12555a34'); insert /*+ ignore_error */ into t_tinyint values('aaa123a34'); insert /*+ ignore_error */ into t_tinyint values('abcde'); +insert /*+ ignore_error */ into t_tinyint values(''); select * from t_tinyint; update /*+ ignore_error */ t_tinyint set c = '12a34'; @@ -20,6 +21,7 @@ insert /*+ ignore_error */ into t_smallint values ('123333333333333a34'); insert /*+ ignore_error */ into t_smallint values ('-123333333333333a34'); insert /*+ ignore_error */ into t_smallint values ('aaa1234a5'); insert /*+ ignore_error */ into t_smallint values ('abcde'); +insert /*+ ignore_error */ into t_smallint values (''); select * from t_smallint; update /*+ ignore_error */ t_smallint set c = '12a34'; @@ -30,6 +32,7 @@ insert /*+ ignore_error */ into t_int values ('123333333333333333333333333a34'); insert /*+ ignore_error */ into t_int values ('-123333333333333333333333333a34'); insert /*+ ignore_error */ into t_int values ('aaa123a45'); insert /*+ ignore_error */ into t_int values ('abcde'); +insert /*+ ignore_error */ into t_int values (''); select * from t_int; update /*+ ignore_error */ t_int set c = '12a34'; @@ -40,6 +43,7 @@ insert /*+ ignore_error */ into t_bigint values ('123333333333333333333333333333 insert /*+ ignore_error */ into t_bigint values ('-123333333333333333333333333333333333333333333333333333333333333333333333333333333333333a34'); insert /*+ ignore_error */ into t_bigint values ('aaa123a45'); insert /*+ ignore_error */ into t_bigint values ('abcde'); +insert /*+ ignore_error */ into t_bigint values (''); select * from t_bigint; update /*+ ignore_error */ t_bigint set c = '12a34'; @@ -50,6 +54,7 @@ insert /*+ ignore_error */ into t_float4 values ('123333333333333333333333333333 insert /*+ ignore_error */ into t_float4 values ('-123333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333.123a34'); insert /*+ ignore_error */ into t_float4 values ('aaa123.12a45'); insert /*+ ignore_error */ into t_float4 values ('abcde'); +insert /*+ ignore_error */ into t_float4 values (''); select * from t_float4; update /*+ ignore_error */ t_float4 set c = '12a34'; @@ -60,6 +65,7 @@ insert /*+ ignore_error */ into t_float8 values ('333333333189203809743298758943 insert /*+ ignore_error */ into t_float8 values ('-3333333331892038097432987589432759843769348605436304758493758943758943758943759843756983760945860948605948765487689547893475893475918920380974329875894327598437693486054363047584937589437589437589437598437569837609458609486059487654876895478934758934759627346378267863475863875648365843734895749837589437589473988.18920380974329875894327598437693486054363047584937589437589437589437598437569837609458609486059487654876895478934758934759189203809743298758943275984376934860543630475849375894375894375894375984375698376094586094860594876548768954789347589347593874894375984aaa34'); insert /*+ ignore_error */ into t_float8 values ('aaa123.12a45'); insert /*+ ignore_error */ into t_float8 values ('abcde'); +insert /*+ ignore_error */ into t_float8 values (''); select * from t_float8; update /*+ ignore_error */ t_float8 set c = '12a34'; @@ -70,6 +76,7 @@ insert /*+ ignore_error */ into t_numeric values ('33333189203809743298758943275 insert /*+ ignore_error */ into t_numeric values ('-333331892038097432987589432759843769348605436304758493758943758943758943759843756983760945860948605948765487689547893475893475918920380974329875894327598437693486054363047584937589437589437589437598437569837609458609486059487654876895478934758934759627346378267863475863875648365843734895749837589437589473988.18920380974329875894327598437693486054363047584937589437589437589437598437569837609458609486059487654876895478934758934759189203809743298758943275984376934860543630475849375894375894375894375984375698376094586094860594876548768954789347589347593874894375984aaa34'); insert /*+ ignore_error */ into t_numeric values ('aaa123.12a45'); insert /*+ ignore_error */ into t_numeric values ('abcde'); +insert /*+ ignore_error */ into t_numeric values (''); select * from t_numeric; update /*+ ignore_error */ t_numeric set c = '12a34'; @@ -80,6 +87,7 @@ insert /*+ ignore_error */ into t_date values('123a34'); insert /*+ ignore_error */ into t_date values('12aaaaaaa34'); insert /*+ ignore_error */ into t_date values('aaaaaaa12aaaaaaa34'); insert /*+ ignore_error */ into t_date values('abcde'); +insert /*+ ignore_error */ into t_date values(''); select * from t_date; update /*+ ignore_error */ t_date set c = '12a34'; @@ -90,6 +98,7 @@ insert /*+ ignore_error */ into t_time values('123a34'); insert /*+ ignore_error */ into t_time values('12aaaaaaa34'); insert /*+ ignore_error */ into t_time values('aaaaaaa12aaaaaaa34'); insert /*+ ignore_error */ into t_time values('abcde'); +insert /*+ ignore_error */ into t_time values(''); select * from t_time; update /*+ ignore_error */ t_time set c = '12a34'; @@ -98,6 +107,7 @@ create table t_timestamp(c timestamp); insert /*+ ignore_error */ into t_timestamp values('12a34'); insert /*+ ignore_error */ into t_timestamp values('abcde'); insert /*+ ignore_error */ into t_timestamp values('aaaaaa12a34'); +insert /*+ ignore_error */ into t_timestamp values(''); select * from t_timestamp; update /*+ ignore_error */ t_timestamp set c = '12a34'; @@ -106,6 +116,7 @@ create table t_timestamptz(c timestamptz); insert /*+ ignore_error */ into t_timestamptz values('12a34'); insert /*+ ignore_error */ into t_timestamptz values('abcde'); insert /*+ ignore_error */ into t_timestamptz values('aaaaaa12a34'); +insert /*+ ignore_error */ into t_timestamptz values(''); select * from t_timestamptz; update /*+ ignore_error */ t_timestamptz set c = '12a34'; @@ -116,6 +127,7 @@ insert /*+ ignore_error */ into t_timetz values('123a34'); insert /*+ ignore_error */ into t_timetz values('12aaaaaaa34'); insert /*+ ignore_error */ into t_timetz values('aaaaaaa12aaaaaaa34'); insert /*+ ignore_error */ into t_timetz values('abcde'); +insert /*+ ignore_error */ into t_timetz values(''); select * from t_timetz; update /*+ ignore_error */ t_timetz set c = '12a34'; @@ -126,6 +138,7 @@ insert /*+ ignore_error */ into t_interval values('123a34'); insert /*+ ignore_error */ into t_interval values('12aaaaaaa34'); insert /*+ ignore_error */ into t_interval values('aaaaaaa12aaaaaaa34'); insert /*+ ignore_error */ into t_interval values('abcde'); +insert /*+ ignore_error */ into t_interval values(''); select * from t_interval; update /*+ ignore_error */ t_interval set c = '12a34'; @@ -136,6 +149,7 @@ insert /*+ ignore_error */ into t_tinterval values('123a34'); insert /*+ ignore_error */ into t_tinterval values('12aaaaaaa34'); insert /*+ ignore_error */ into t_tinterval values('aaaaaaa12aaaaaaa34'); insert /*+ ignore_error */ into t_tinterval values('abcde'); +insert /*+ ignore_error */ into t_tinterval values(''); select * from t_tinterval; update /*+ ignore_error */ t_tinterval set c = '12a34'; @@ -146,18 +160,21 @@ insert /*+ ignore_error */ into t_smalldatetime values('123a34'); insert /*+ ignore_error */ into t_smalldatetime values('12aaaaaaa34'); insert /*+ ignore_error */ into t_smalldatetime values('aaaaaaa12aaaaaaa34'); insert /*+ ignore_error */ into t_smalldatetime values('abcde'); +insert /*+ ignore_error */ into t_smalldatetime values(''); select * from t_smalldatetime; update /*+ ignore_error */ t_smalldatetime set c = '12a34'; -- type: uuid create table t_uuid(c uuid); insert /*+ ignore_error */ into t_uuid values('12a34'); +insert /*+ ignore_error */ into t_uuid values(''); update /*+ ignore_error */ t_uuid set c = '12a34'; select * from t_uuid; -- type: point create table t_point(c point); insert /*+ ignore_error */ into t_point values('12a34'); +insert /*+ ignore_error */ into t_point values(''); select * from t_point; update /*+ ignore_error */ t_point set c = '12a34'; select * from t_point; @@ -165,6 +182,7 @@ select * from t_point; -- type: path create table t_path(c path); insert /*+ ignore_error */ into t_path values('12a34'); +insert /*+ ignore_error */ into t_path values(''); select * from t_path; update /*+ ignore_error */ t_path set c = '12a34'; select * from t_path; @@ -172,6 +190,7 @@ select * from t_path; -- type: polygon create table t_polygon(c polygon); insert /*+ ignore_error */ into t_polygon values('12a34'); +insert /*+ ignore_error */ into t_polygon values(''); select * from t_polygon; update /*+ ignore_error */ t_polygon set c = '12a34'; select * from t_polygon; @@ -179,6 +198,7 @@ select * from t_polygon; -- type: circle create table t_circle(c circle); insert /*+ ignore_error */ into t_circle values('12a34'); +insert /*+ ignore_error */ into t_circle values(''); select * from t_circle; update /*+ ignore_error */ t_circle set c = '12a34'; select * from t_circle; @@ -186,6 +206,7 @@ select * from t_circle; -- type: lseg create table t_lseg(c lseg); insert /*+ ignore_error */ into t_lseg values('12a34'); +insert /*+ ignore_error */ into t_lseg values(''); select * from t_lseg; update /*+ ignore_error */ t_lseg set c = '12a34'; select * from t_lseg; @@ -193,6 +214,7 @@ select * from t_lseg; -- type: box create table t_box(c box); insert /*+ ignore_error */ into t_box values('12a34'); +insert /*+ ignore_error */ into t_box values(''); select * from t_box; update /*+ ignore_error */ t_box set c = '12a34'; select * from t_box; @@ -200,6 +222,12 @@ select * from t_box; -- type: json create table t_json(c json); insert /*+ ignore_error */ into t_json values('12a34'); +insert /*+ ignore_error */ into t_json values(''); +insert /*+ ignore_error */ into t_json values(''); +insert /*+ ignore_error */ into t_json values(''); +insert /*+ ignore_error */ into t_json values(''); +insert /*+ ignore_error */ into t_json values(''); +insert /*+ ignore_error */ into t_json values(''); select * from t_json; update /*+ ignore_error */ t_json set c = '12a34'; select * from t_json; @@ -207,6 +235,12 @@ select * from t_json; -- type: jsonb create table t_jsonb(c jsonb); insert /*+ ignore_error */ into t_jsonb values('12a34'); +insert /*+ ignore_error */ into t_jsonb values(''); +insert /*+ ignore_error */ into t_jsonb values(''); +insert /*+ ignore_error */ into t_jsonb values(''); +insert /*+ ignore_error */ into t_jsonb values(''); +insert /*+ ignore_error */ into t_jsonb values(''); +insert /*+ ignore_error */ into t_jsonb values(''); select * from t_jsonb; update /*+ ignore_error */ t_jsonb set c = '12a34'; select * from t_jsonb; @@ -214,6 +248,7 @@ select * from t_jsonb; -- type: bit create table t_bit(c bit); insert /*+ ignore_error */ into t_bit values('12a34'); +insert /*+ ignore_error */ into t_bit values(''); select * from t_bit; update /*+ ignore_error */ t_bit set c = '12a34'; select * from t_bit;