aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-12-01 21:05:14 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-12-01 21:05:14 +0000
commit8e3a87fbd4d5552599888b087e23a28df0bb6be5 (patch)
treee99856f0fdd38b253a25f9cb0334ad23e576baf5 /src/backend/utils
parent02f8c9a38297459c2664044ea6d98d91678a4d79 (diff)
downloadpostgresql-8e3a87fbd4d5552599888b087e23a28df0bb6be5.tar.gz
postgresql-8e3a87fbd4d5552599888b087e23a28df0bb6be5.zip
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.
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/cache/lsyscache.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index cd7dc8d549f..ec0c45ea78a 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -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.
@@ -416,6 +416,22 @@ op_hashjoinable(Oid opno, Oid ltype, Oid rtype)
}
/*
+ * 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
*
* Get the provolatile flag for the operator's underlying function.
@@ -607,6 +623,27 @@ get_func_retset(Oid funcid)
}
/*
+ * 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.
*/