mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Fix crash when using CALL on an aggregate
Author: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> Reported-by: Rushabh Lathia <rushabh.lathia@gmail.com>
This commit is contained in:
parent
8e211f5391
commit
3d8874224f
@ -336,6 +336,15 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
|||||||
Form_pg_aggregate classForm;
|
Form_pg_aggregate classForm;
|
||||||
int catDirectArgs;
|
int catDirectArgs;
|
||||||
|
|
||||||
|
if (proc_call)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||||
|
errmsg("%s is not a procedure",
|
||||||
|
func_signature_string(funcname, nargs,
|
||||||
|
argnames,
|
||||||
|
actual_arg_types)),
|
||||||
|
parser_errposition(pstate, location)));
|
||||||
|
|
||||||
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid));
|
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid));
|
||||||
if (!HeapTupleIsValid(tup)) /* should not happen */
|
if (!HeapTupleIsValid(tup)) /* should not happen */
|
||||||
elog(ERROR, "cache lookup failed for aggregate %u", funcid);
|
elog(ERROR, "cache lookup failed for aggregate %u", funcid);
|
||||||
|
@ -41,6 +41,15 @@ SELECT 5;
|
|||||||
$$;
|
$$;
|
||||||
CALL ptest2();
|
CALL ptest2();
|
||||||
-- various error cases
|
-- various error cases
|
||||||
|
CALL version(); -- error: not a procedure
|
||||||
|
ERROR: version() is not a procedure
|
||||||
|
LINE 1: CALL version();
|
||||||
|
^
|
||||||
|
HINT: To call a function, use SELECT.
|
||||||
|
CALL sum(1); -- error: not a procedure
|
||||||
|
ERROR: sum(integer) is not a procedure
|
||||||
|
LINE 1: CALL sum(1);
|
||||||
|
^
|
||||||
CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
||||||
ERROR: invalid attribute in procedure definition
|
ERROR: invalid attribute in procedure definition
|
||||||
LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT I...
|
LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT I...
|
||||||
|
@ -30,6 +30,9 @@ CALL ptest2();
|
|||||||
|
|
||||||
-- various error cases
|
-- various error cases
|
||||||
|
|
||||||
|
CALL version(); -- error: not a procedure
|
||||||
|
CALL sum(1); -- error: not a procedure
|
||||||
|
|
||||||
CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
||||||
CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
||||||
CREATE PROCEDURE ptestx(OUT a int) LANGUAGE SQL AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
CREATE PROCEDURE ptestx(OUT a int) LANGUAGE SQL AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user