mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Add prokind column, replacing proisagg and proiswindow
The new column distinguishes normal functions, procedures, aggregates, and window functions. This replaces the existing columns proisagg and proiswindow, and replaces the convention that procedures are indicated by prorettype == 0. Also change prorettype to be VOIDOID for procedures. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Michael Paquier <michael@paquier.xyz>
This commit is contained in:
@ -2481,12 +2481,12 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
|
||||
proc = (Form_pg_proc) GETSTRUCT(proctup);
|
||||
name = NameStr(proc->proname);
|
||||
|
||||
if (proc->proisagg)
|
||||
if (proc->prokind == PROKIND_AGGREGATE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is an aggregate function", name)));
|
||||
|
||||
isfunction = (proc->prorettype != InvalidOid);
|
||||
isfunction = (proc->prokind != PROKIND_PROCEDURE);
|
||||
|
||||
/*
|
||||
* We always qualify the function name, to ensure the right function gets
|
||||
@ -2513,7 +2513,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
|
||||
/* Emit some miscellaneous options on one line */
|
||||
oldlen = buf.len;
|
||||
|
||||
if (proc->proiswindow)
|
||||
if (proc->prokind == PROKIND_WINDOW)
|
||||
appendStringInfoString(&buf, " WINDOW");
|
||||
switch (proc->provolatile)
|
||||
{
|
||||
@ -2717,7 +2717,7 @@ pg_get_function_result(PG_FUNCTION_ARGS)
|
||||
if (!HeapTupleIsValid(proctup))
|
||||
PG_RETURN_NULL();
|
||||
|
||||
if (((Form_pg_proc) GETSTRUCT(proctup))->prorettype == InvalidOid)
|
||||
if (((Form_pg_proc) GETSTRUCT(proctup))->prokind == PROKIND_PROCEDURE)
|
||||
{
|
||||
ReleaseSysCache(proctup);
|
||||
PG_RETURN_NULL();
|
||||
@ -2817,7 +2817,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup,
|
||||
}
|
||||
|
||||
/* Check for special treatment of ordered-set aggregates */
|
||||
if (proc->proisagg)
|
||||
if (proc->prokind == PROKIND_AGGREGATE)
|
||||
{
|
||||
HeapTuple aggtup;
|
||||
Form_pg_aggregate agg;
|
||||
|
Reference in New Issue
Block a user