mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
WITH CHECK OPTION support for auto-updatable VIEWs
For simple views which are automatically updatable, this patch allows the user to specify what level of checking should be done on records being inserted or updated. For 'LOCAL CHECK', new tuples are validated against the conditionals of the view they are being inserted into, while for 'CASCADED CHECK' the new tuples are validated against the conditionals for all views involved (from the top down). This option is part of the SQL specification. Dean Rasheed, reviewed by Pavel Stehule
This commit is contained in:
@@ -208,6 +208,7 @@ typedef struct StdRdOptions
|
||||
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 */
|
||||
} StdRdOptions;
|
||||
|
||||
#define HEAP_MIN_FILLFACTOR 10
|
||||
@@ -243,6 +244,39 @@ typedef struct StdRdOptions
|
||||
((relation)->rd_options ? \
|
||||
((StdRdOptions *) (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.
|
||||
*/
|
||||
#define RelationHasCheckOption(relation) \
|
||||
((relation)->rd_options && \
|
||||
((StdRdOptions *) (relation)->rd_options)->check_option_offset != 0)
|
||||
|
||||
/*
|
||||
* RelationHasLocalCheckOption
|
||||
* Returns true if the relation is a view defined with the local check
|
||||
* option.
|
||||
*/
|
||||
#define RelationHasLocalCheckOption(relation) \
|
||||
((relation)->rd_options && \
|
||||
((StdRdOptions *) (relation)->rd_options)->check_option_offset != 0 ? \
|
||||
strcmp((char *) (relation)->rd_options + \
|
||||
((StdRdOptions *) (relation)->rd_options)->check_option_offset, \
|
||||
"local") == 0 : false)
|
||||
|
||||
/*
|
||||
* RelationHasCascadedCheckOption
|
||||
* Returns true if the relation is a view defined with the cascaded check
|
||||
* option.
|
||||
*/
|
||||
#define RelationHasCascadedCheckOption(relation) \
|
||||
((relation)->rd_options && \
|
||||
((StdRdOptions *) (relation)->rd_options)->check_option_offset != 0 ? \
|
||||
strcmp((char *) (relation)->rd_options + \
|
||||
((StdRdOptions *) (relation)->rd_options)->check_option_offset, \
|
||||
"cascaded") == 0 : false)
|
||||
|
||||
/*
|
||||
* RelationIsValid
|
||||
* True iff relation descriptor is valid.
|
||||
|
||||
Reference in New Issue
Block a user