mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Teach planner to expand sufficiently simple SQL-language functions
('SELECT expression') inline, like macros, during the constant-folding phase of planning. The actual expansion is not difficult, but checking that we're not changing the semantics of the call turns out to be more subtle than one might think; in particular must pay attention to permissions issues, strictness, and volatility.
This commit is contained in:
39
src/backend/utils/cache/lsyscache.c
vendored
39
src/backend/utils/cache/lsyscache.c
vendored
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.86 2002/11/25 21:29:42 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.87 2002/12/01 21:05:14 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Eventually, the index information should go through here, too.
|
||||
@ -415,6 +415,22 @@ op_hashjoinable(Oid opno, Oid ltype, Oid rtype)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* op_strict
|
||||
*
|
||||
* Get the proisstrict flag for the operator's underlying function.
|
||||
*/
|
||||
bool
|
||||
op_strict(Oid opno)
|
||||
{
|
||||
RegProcedure funcid = get_opcode(opno);
|
||||
|
||||
if (funcid == (RegProcedure) InvalidOid)
|
||||
elog(ERROR, "Operator OID %u does not exist", opno);
|
||||
|
||||
return func_strict((Oid) funcid);
|
||||
}
|
||||
|
||||
/*
|
||||
* op_volatile
|
||||
*
|
||||
@ -606,6 +622,27 @@ get_func_retset(Oid funcid)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* func_strict
|
||||
* Given procedure id, return the function's proisstrict flag.
|
||||
*/
|
||||
bool
|
||||
func_strict(Oid funcid)
|
||||
{
|
||||
HeapTuple tp;
|
||||
bool result;
|
||||
|
||||
tp = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "Function OID %u does not exist", funcid);
|
||||
|
||||
result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
|
||||
ReleaseSysCache(tp);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* func_volatile
|
||||
* Given procedure id, return the function's provolatile flag.
|
||||
|
Reference in New Issue
Block a user