Skip to content

Commit 3d88742

Browse files
committed
Fix crash when using CALL on an aggregate
Author: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> Reported-by: Rushabh Lathia <rushabh.lathia@gmail.com>
1 parent 8e211f5 commit 3d88742

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/backend/parser/parse_func.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,15 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
336336
Form_pg_aggregate classForm;
337337
int catDirectArgs;
338338

339+
if (proc_call)
340+
ereport(ERROR,
341+
(errcode(ERRCODE_UNDEFINED_FUNCTION),
342+
errmsg("%s is not a procedure",
343+
func_signature_string(funcname, nargs,
344+
argnames,
345+
actual_arg_types)),
346+
parser_errposition(pstate, location)));
347+
339348
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcid));
340349
if (!HeapTupleIsValid(tup)) /* should not happen */
341350
elog(ERROR, "cache lookup failed for aggregate %u", funcid);

src/test/regress/expected/create_procedure.out

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ SELECT 5;
4141
$$;
4242
CALL ptest2();
4343
-- various error cases
44+
CALL version(); -- error: not a procedure
45+
ERROR: version() is not a procedure
46+
LINE 1: CALL version();
47+
^
48+
HINT: To call a function, use SELECT.
49+
CALL sum(1); -- error: not a procedure
50+
ERROR: sum(integer) is not a procedure
51+
LINE 1: CALL sum(1);
52+
^
4453
CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
4554
ERROR: invalid attribute in procedure definition
4655
LINE 1: CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT I...

src/test/regress/sql/create_procedure.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ CALL ptest2();
3030

3131
-- various error cases
3232

33+
CALL version(); -- error: not a procedure
34+
CALL sum(1); -- error: not a procedure
35+
3336
CREATE PROCEDURE ptestx() LANGUAGE SQL WINDOW AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
3437
CREATE PROCEDURE ptestx() LANGUAGE SQL STRICT AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;
3538
CREATE PROCEDURE ptestx(OUT a int) LANGUAGE SQL AS $$ INSERT INTO cp_test VALUES (1, 'a') $$;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy