aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/lsyscache.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2010-04-23 22:23:39 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2010-04-23 22:23:39 +0000
commit473af3973710b9e2f4e945d8290adae8de9696cc (patch)
tree90fcd98789af3364f33256cfaef2fa9bb7581644 /src/backend/utils/cache/lsyscache.c
parent491d1ea5b3605809ec1103e939b3324acc9a2516 (diff)
downloadpostgresql-473af3973710b9e2f4e945d8290adae8de9696cc.tar.gz
postgresql-473af3973710b9e2f4e945d8290adae8de9696cc.zip
Add missing optimizer hooks for function cost and number of rows.
Closely follow design of other optimizer hooks: if hook exists retrieve value from plugin; if still not set then get from cache.
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r--src/backend/utils/cache/lsyscache.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 63dde8f9cb9..891abf422bc 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
- * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.168 2010/02/26 02:01:11 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.169 2010/04/23 22:23:39 sriggs Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -38,6 +38,9 @@
/* Hook for plugins to get control in get_attavgwidth() */
get_attavgwidth_hook_type get_attavgwidth_hook = NULL;
+/* Hook for plugins to get control in get_func_cost and get_func_rows */
+get_func_cost_hook_type get_func_cost_hook = NULL;
+get_func_rows_hook_type get_func_rows_hook = NULL;
/* ---------- AMOP CACHES ---------- */
@@ -1409,6 +1412,12 @@ get_func_cost(Oid funcid)
HeapTuple tp;
float4 result;
+ if (get_func_cost_hook)
+ {
+ result = (*get_func_cost_hook) (funcid);
+ if (result > (float4) 0)
+ return result;
+ }
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
@@ -1428,6 +1437,12 @@ get_func_rows(Oid funcid)
HeapTuple tp;
float4 result;
+ if (get_func_rows_hook)
+ {
+ result = (*get_func_rows_hook) (funcid);
+ if (result > (float4) 0)
+ return result;
+ }
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);