diff options
| author | Alvaro Herrera | 2014-07-14 21:24:40 +0000 |
|---|---|---|
| committer | Alvaro Herrera | 2014-07-14 21:24:40 +0000 |
| commit | 346d7be184a617ca9f64bdf5c25fd6bcd5231293 (patch) | |
| tree | d9ee36a6ed98803ef671a83caca4243b93268204 /src/backend | |
| parent | 0ffc201a51395ca71fe429ef86c872850a5850ee (diff) | |
Move view reloptions into their own varlena struct
Per discussion after a gripe from me in
http://www.postgresql.org/message-id/20140611194633.GH18688@eldon.alvh.no-ip.org
Jaime Casanova
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/access/common/reloptions.c | 42 | ||||
| -rw-r--r-- | src/backend/commands/tablecmds.c | 9 |
2 files changed, 42 insertions, 9 deletions
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 522b671993e..c7ad6f96f86 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -834,10 +834,12 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, Oid amoptions) { case RELKIND_RELATION: case RELKIND_TOASTVALUE: - case RELKIND_VIEW: case RELKIND_MATVIEW: options = heap_reloptions(classForm->relkind, datum, false); break; + case RELKIND_VIEW: + options = view_reloptions(datum, false); + break; case RELKIND_INDEX: options = index_reloptions(amoptions, datum, false); break; @@ -1200,10 +1202,6 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind) offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, vacuum_scale_factor)}, {"autovacuum_analyze_scale_factor", RELOPT_TYPE_REAL, offsetof(StdRdOptions, autovacuum) +offsetof(AutoVacOpts, analyze_scale_factor)}, - {"security_barrier", RELOPT_TYPE_BOOL, - offsetof(StdRdOptions, security_barrier)}, - {"check_option", RELOPT_TYPE_STRING, - offsetof(StdRdOptions, check_option_offset)}, {"user_catalog_table", RELOPT_TYPE_BOOL, offsetof(StdRdOptions, user_catalog_table)} }; @@ -1225,6 +1223,38 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind) } /* + * Option parser for views + */ +bytea * +view_reloptions(Datum reloptions, bool validate) +{ + relopt_value *options; + ViewOptions *vopts; + int numoptions; + static const relopt_parse_elt tab[] = { + {"security_barrier", RELOPT_TYPE_BOOL, + offsetof(ViewOptions, security_barrier)}, + {"check_option", RELOPT_TYPE_STRING, + offsetof(ViewOptions, check_option_offset)} + }; + + options = parseRelOptions(reloptions, validate, RELOPT_KIND_VIEW, &numoptions); + + /* if none set, we're done */ + if (numoptions == 0) + return NULL; + + vopts = allocateReloptStruct(sizeof(ViewOptions), options, numoptions); + + fillRelOptions((void *) vopts, sizeof(ViewOptions), options, numoptions, + validate, tab, lengthof(tab)); + + pfree(options); + + return (bytea *) vopts; +} + +/* * Parse options for heaps, views and toast tables. */ bytea * @@ -1248,8 +1278,6 @@ heap_reloptions(char relkind, Datum reloptions, bool validate) case RELKIND_RELATION: case RELKIND_MATVIEW: return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP); - case RELKIND_VIEW: - return default_reloptions(reloptions, validate, RELOPT_KIND_VIEW); default: /* other relkinds are not supported */ return NULL; diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 60d387a5e6c..5dc4d18b6a5 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -533,7 +533,10 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId) reloptions = transformRelOptions((Datum) 0, stmt->options, NULL, validnsps, true, false); - (void) heap_reloptions(relkind, reloptions, true); + if (relkind == RELKIND_VIEW) + (void) view_reloptions(reloptions, true); + else + (void) heap_reloptions(relkind, reloptions, true); if (stmt->ofTypename) { @@ -8889,10 +8892,12 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation, { case RELKIND_RELATION: case RELKIND_TOASTVALUE: - case RELKIND_VIEW: case RELKIND_MATVIEW: (void) heap_reloptions(rel->rd_rel->relkind, newOptions, true); break; + case RELKIND_VIEW: + (void) view_reloptions(newOptions, true); + break; case RELKIND_INDEX: (void) index_reloptions(rel->rd_am->amoptions, newOptions, true); break; |
