From ccba122b27a960465257657e9c7741e4f337b0cd Mon Sep 17 00:00:00 2001 From: totaj Date: Mon, 29 Jan 2024 20:58:12 +0800 Subject: [PATCH] Fix ignore in subquery case. --- src/common/backend/parser/analyze.cpp | 1 + src/common/backend/parser/parse_node.cpp | 1 + .../regress/expected/ignore/ignore_invalid_input.out | 10 ++++++++++ src/test/regress/sql/ignore/ignore_invalid_input.sql | 7 ++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/common/backend/parser/analyze.cpp b/src/common/backend/parser/analyze.cpp index 5db36be6b..16390cedb 100644 --- a/src/common/backend/parser/analyze.cpp +++ b/src/common/backend/parser/analyze.cpp @@ -2022,6 +2022,7 @@ static Query* transformInsertStmt(ParseState* pstate, InsertStmt* stmt) sub_pstate->p_resolve_unknowns = false; selectQuery = transformStmt(sub_pstate, stmt->selectStmt); + selectQuery->hasIgnore = stmt->hasIgnore; Assert(selectQuery != NULL); free_parsestate(sub_pstate); diff --git a/src/common/backend/parser/parse_node.cpp b/src/common/backend/parser/parse_node.cpp index 6643328a1..800c77d35 100644 --- a/src/common/backend/parser/parse_node.cpp +++ b/src/common/backend/parser/parse_node.cpp @@ -77,6 +77,7 @@ ParseState* make_parsestate(ParseState* parentParseState) pstate->p_bind_hook_state = parentParseState->p_bind_hook_state; pstate->p_bind_describe_hook = parentParseState->p_bind_describe_hook; pstate->p_describeco_hook_state = parentParseState->p_describeco_hook_state; + pstate->p_has_ignore = parentParseState->p_has_ignore; } return pstate; diff --git a/src/test/regress/expected/ignore/ignore_invalid_input.out b/src/test/regress/expected/ignore/ignore_invalid_input.out index 6b109a35c..40e5495f1 100644 --- a/src/test/regress/expected/ignore/ignore_invalid_input.out +++ b/src/test/regress/expected/ignore/ignore_invalid_input.out @@ -1188,6 +1188,16 @@ select * from varbit; reset sql_ignore_strategy; drop table net, ran, hashvec, varbit; +-- insert + subquery +create table t1(a int); +insert /*+ ignore_error */ into t1 select 'abc'::time; +WARNING: invalid input syntax for type time: "abc" +LINE 1: insert /*+ ignore_error */ into t1 select 'abc'::time; + ^ +CONTEXT: referenced column: time +WARNING: column "a" is of type integer but expression is of type time without time zone. Data truncated automatically. +CONTEXT: referenced column: a +drop table t1; -- restore context reset timezone; show timezone; diff --git a/src/test/regress/sql/ignore/ignore_invalid_input.sql b/src/test/regress/sql/ignore/ignore_invalid_input.sql index de3b27a0b..a1e2b4bd3 100644 --- a/src/test/regress/sql/ignore/ignore_invalid_input.sql +++ b/src/test/regress/sql/ignore/ignore_invalid_input.sql @@ -317,8 +317,13 @@ reset sql_ignore_strategy; drop table net, ran, hashvec, varbit; +-- insert + subquery +create table t1(a int); +insert /*+ ignore_error */ into t1 select 'abc'::time; +drop table t1; + -- restore context reset timezone; show timezone; \c postgres -drop database if exists sql_ignore_invalid_input_test; \ No newline at end of file +drop database if exists sql_ignore_invalid_input_test;