aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-01-22 01:35:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-01-22 01:35:23 +0000
commit5a7471c307533a1b56260b3b074dfdd20e1be5ae (patch)
tree6a3cff705e779eefac734882a66aee1631224394 /src/backend/parser
parenta85e9c61e579b15d0635e04870cf1cb069fdf9ee (diff)
downloadpostgresql-5a7471c307533a1b56260b3b074dfdd20e1be5ae.tar.gz
postgresql-5a7471c307533a1b56260b3b074dfdd20e1be5ae.zip
Add COST and ROWS options to CREATE/ALTER FUNCTION, plus underlying pg_proc
columns procost and prorows, to allow simple user adjustment of the estimated cost of a function call, as well as control of the estimated number of rows returned by a set-returning function. We might eventually wish to extend this to allow function-specific estimation routines, but there seems to be consensus that we should try a simple constant estimate first. In particular this provides a relatively simple way to control the order in which different WHERE clauses are applied in a plan node, which is a Good Thing in view of the fact that the recent EquivalenceClass planner rewrite made that much less predictable than before.
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/gram.y13
-rw-r--r--src/backend/parser/keywords.c3
2 files changed, 13 insertions, 3 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index db66a69b3ff..cf32e912539 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.574 2007/01/14 13:11:53 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.575 2007/01/22 01:35:21 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -370,7 +370,7 @@ static Node *makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args)
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
COMMITTED CONCURRENTLY CONNECTION CONSTRAINT CONSTRAINTS
- CONTENT_P CONVERSION_P CONVERT COPY CREATE CREATEDB
+ CONTENT_P CONVERSION_P CONVERT COPY COST CREATE CREATEDB
CREATEROLE CREATEUSER CROSS CSV CURRENT_DATE CURRENT_ROLE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
@@ -3958,6 +3958,14 @@ common_func_opt_item:
{
$$ = makeDefElem("security", (Node *)makeInteger(FALSE));
}
+ | COST NumericOnly
+ {
+ $$ = makeDefElem("cost", (Node *)$2);
+ }
+ | ROWS NumericOnly
+ {
+ $$ = makeDefElem("rows", (Node *)$2);
+ }
;
createfunc_opt_item:
@@ -8564,6 +8572,7 @@ unreserved_keyword:
| CONTENT_P
| CONVERSION_P
| COPY
+ | COST
| CREATEDB
| CREATEROLE
| CREATEUSER
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index e1592736f0d..5e858d10b0a 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.181 2007/01/09 02:14:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.182 2007/01/22 01:35:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -93,6 +93,7 @@ static const ScanKeyword ScanKeywords[] = {
{"conversion", CONVERSION_P},
{"convert", CONVERT},
{"copy", COPY},
+ {"cost", COST},
{"create", CREATE},
{"createdb", CREATEDB},
{"createrole", CREATEROLE},