!5761 修复copy使用参数when_expr空语句后core问题

Merge pull request !5761 from zhubin79/copy_whenexpr
This commit is contained in:
opengauss_bot
2024-07-17 02:09:46 +00:00
committed by Gitee
3 changed files with 15 additions and 0 deletions

View File

@ -6165,6 +6165,9 @@ copy_generic_opt_list:
copy_generic_opt_elem:
ColLabel copy_generic_opt_arg
{
/* Character "when_expr" may be injected as "COPY ... WHEN ... "*/
if (pg_strcasecmp($1, "when_expr") == 0)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("option \"%s\" not recognized", $1)));
$$ = makeDefElem($1, $2);
}
;

View File

@ -60,6 +60,13 @@ ERROR: syntax error at or near "("
LINE 1: copy (select * from test1) (t,id) to stdout;
^
--
-- Test when_expr
--
copy (select * from test1) to stdout with (when_expr); -- error
ERROR: option "when_expr" not recognized
copy (select * from test1) to stdout with (when_expr''); -- error
ERROR: option "when_expr" not recognized
--
-- Test JOIN
--
copy (select * from test1 join test2 using (id) order by 1) to stdout;

View File

@ -47,6 +47,11 @@ copy (select * from test1) from stdin;
--
copy (select * from test1) (t,id) to stdout;
--
-- Test when_expr
--
copy (select * from test1) to stdout with (when_expr); -- error
copy (select * from test1) to stdout with (when_expr''); -- error
--
-- Test JOIN
--
copy (select * from test1 join test2 using (id) order by 1) to stdout;