修复INOUT不能设置默认值的bug

This commit is contained in:
luozihao
2023-01-13 15:33:48 +08:00
parent fc359a7d90
commit e130660c6a
3 changed files with 12 additions and 2 deletions

View File

@ -449,12 +449,12 @@ static void examine_parameter_list(List* parameters, Oid languageOid, const char
if (fp->defexpr) {
#ifndef ENABLE_MULTIPLE_NODES
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT
&& (fp->mode == FUNC_PARAM_OUT || fp->mode == FUNC_PARAM_INOUT)) {
&& fp->mode == FUNC_PARAM_OUT && enable_out_param_override()) {
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("The out/inout Parameter can't have default value.")));
}
#endif
#endif
Node* def = NULL;
if (!isinput)

View File

@ -1608,6 +1608,11 @@ referenced column: fun_test_2
(1 row)
CREATE FUNCTION w_testfun3 (c_int INOUT int DEFAULT 1) RETURNS int AS $$
BEGIN
RETURN (c_int);
END;
$$ LANGUAGE plpgsql;
DROP FUNCTION func_increment_sql_1;
DROP FUNCTION func_increment_sql_2;
DROP FUNCTION fun_test_1;

View File

@ -924,6 +924,11 @@ end;
$$language plpgsql;
select fun_test_2(1);
CREATE FUNCTION w_testfun3 (c_int INOUT int DEFAULT 1) RETURNS int AS $$
BEGIN
RETURN (c_int);
END;
$$ LANGUAGE plpgsql;
DROP FUNCTION func_increment_sql_1;
DROP FUNCTION func_increment_sql_2;
DROP FUNCTION fun_test_1;