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/include | |
| 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/include')
| -rw-r--r-- | src/include/access/reloptions.h | 1 | ||||
| -rw-r--r-- | src/include/utils/rel.h | 52 |
2 files changed, 33 insertions, 20 deletions
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h index 81ff3286cf2..c22644841f9 100644 --- a/src/include/access/reloptions.h +++ b/src/include/access/reloptions.h @@ -268,6 +268,7 @@ extern void fillRelOptions(void *rdopts, Size basesize, extern bytea *default_reloptions(Datum reloptions, bool validate, relopt_kind kind); extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate); +extern bytea *view_reloptions(Datum reloptions, bool validate); extern bytea *index_reloptions(RegProcedure amoptions, Datum reloptions, bool validate); extern bytea *attribute_reloptions(Datum reloptions, bool validate); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index af4f53f1121..37b6cbbb4d0 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -216,8 +216,6 @@ typedef struct StdRdOptions int32 vl_len_; /* varlena header (do not touch directly!) */ int fillfactor; /* page fill factor in percent (0..100) */ AutoVacOpts autovacuum; /* autovacuum-related options */ - bool security_barrier; /* for views */ - int check_option_offset; /* for views */ bool user_catalog_table; /* use as an additional catalog * relation */ } StdRdOptions; @@ -248,54 +246,68 @@ typedef struct StdRdOptions (BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100) /* + * RelationIsUsedAsCatalogTable + * Returns whether the relation should be treated as a catalog table + * from the pov of logical decoding. Note multiple eval or argument! + */ +#define RelationIsUsedAsCatalogTable(relation) \ + ((relation)->rd_options ? \ + ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false) + + +/* + * ViewOptions + * Contents of rd_options for views + */ +typedef struct ViewOptions +{ + int32 vl_len_; /* varlena header (do not touch directly!) */ + bool security_barrier; + int check_option_offset; +} ViewOptions; + +/* * RelationIsSecurityView - * Returns whether the relation is security view, or not + * Returns whether the relation is security view, or not. Note multiple + * eval of argument! */ #define RelationIsSecurityView(relation) \ ((relation)->rd_options ? \ - ((StdRdOptions *) (relation)->rd_options)->security_barrier : false) + ((ViewOptions *) (relation)->rd_options)->security_barrier : false) /* * RelationHasCheckOption * Returns true if the relation is a view defined with either the local - * or the cascaded check option. + * or the cascaded check option. Note multiple eval of argument! */ #define RelationHasCheckOption(relation) \ ((relation)->rd_options && \ - ((StdRdOptions *) (relation)->rd_options)->check_option_offset != 0) + ((ViewOptions *) (relation)->rd_options)->check_option_offset != 0) /* * RelationHasLocalCheckOption * Returns true if the relation is a view defined with the local check - * option. + * option. Note multiple eval of argument! */ #define RelationHasLocalCheckOption(relation) \ ((relation)->rd_options && \ - ((StdRdOptions *) (relation)->rd_options)->check_option_offset != 0 ? \ + ((ViewOptions *) (relation)->rd_options)->check_option_offset != 0 ? \ strcmp((char *) (relation)->rd_options + \ - ((StdRdOptions *) (relation)->rd_options)->check_option_offset, \ + ((ViewOptions *) (relation)->rd_options)->check_option_offset, \ "local") == 0 : false) /* * RelationHasCascadedCheckOption * Returns true if the relation is a view defined with the cascaded check - * option. + * option. Note multiple eval of argument! */ #define RelationHasCascadedCheckOption(relation) \ ((relation)->rd_options && \ - ((StdRdOptions *) (relation)->rd_options)->check_option_offset != 0 ? \ + ((ViewOptions *) (relation)->rd_options)->check_option_offset != 0 ? \ strcmp((char *) (relation)->rd_options + \ - ((StdRdOptions *) (relation)->rd_options)->check_option_offset, \ + ((ViewOptions *) (relation)->rd_options)->check_option_offset, \ "cascaded") == 0 : false) -/* - * RelationIsUsedAsCatalogTable - * Returns whether the relation should be treated as a catalog table - * from the pov of logical decoding. - */ -#define RelationIsUsedAsCatalogTable(relation) \ - ((relation)->rd_options ? \ - ((StdRdOptions *) (relation)->rd_options)->user_catalog_table : false) /* * RelationIsValid |
