diff options
Diffstat (limited to 'src/backend/access/common/reloptions.c')
-rw-r--r-- | src/backend/access/common/reloptions.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 28eacb4e478..65328a9f288 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.31 2010/01/05 21:53:58 rhaas Exp $ + * $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.32 2010/01/22 16:40:18 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,7 @@ #include "commands/tablespace.h" #include "nodes/makefuncs.h" #include "utils/array.h" +#include "utils/attoptcache.h" #include "utils/builtins.h" #include "utils/guc.h" #include "utils/memutils.h" @@ -196,6 +197,22 @@ static relopt_real realRelOpts[] = }, -1, 0.0, DBL_MAX }, + { + { + "n_distinct", + "Sets the planner's estimate of the number of distinct values appearing in a column (excluding child relations).", + RELOPT_KIND_ATTRIBUTE + }, + 0, -1.0, DBL_MAX + }, + { + { + "n_distinct_inherited", + "Sets the planner's estimate of the number of distinct values appearing in a column (including child relations).", + RELOPT_KIND_ATTRIBUTE + }, + 0, -1.0, DBL_MAX + }, /* list terminator */ {{NULL}} }; @@ -1187,6 +1204,37 @@ index_reloptions(RegProcedure amoptions, Datum reloptions, bool validate) } /* + * Option parser for attribute reloptions + */ +bytea * +attribute_reloptions(Datum reloptions, bool validate) +{ + relopt_value *options; + AttributeOpts *aopts; + int numoptions; + static const relopt_parse_elt tab[] = { + {"n_distinct", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct)}, + {"n_distinct_inherited", RELOPT_TYPE_REAL, offsetof(AttributeOpts, n_distinct_inherited)} + }; + + options = parseRelOptions(reloptions, validate, RELOPT_KIND_ATTRIBUTE, + &numoptions); + + /* if none set, we're done */ + if (numoptions == 0) + return NULL; + + aopts = allocateReloptStruct(sizeof(AttributeOpts), options, numoptions); + + fillRelOptions((void *) aopts, sizeof(AttributeOpts), options, numoptions, + validate, tab, lengthof(tab)); + + pfree(options); + + return (bytea *) aopts; +} + +/* * Option parser for tablespace reloptions */ bytea * |