Commit 39677376 authored by Peter Eisentraut's avatar Peter Eisentraut

Add some assertions to view reloption macros

In these macros, the rd_options pointer is cast to ViewOption *.  Add
some assertions that the passed-in relation is actually a view before
doing that.

Author: Nikolay Shaplov <dhyan@nataraj.su>
Discussion: https://www.postgresql.org/message-id/flat/3634983.eHpMQ1mJnI@x200m
parent 604bd367
...@@ -352,7 +352,8 @@ typedef struct ViewOptions ...@@ -352,7 +352,8 @@ typedef struct ViewOptions
* eval of argument! * eval of argument!
*/ */
#define RelationIsSecurityView(relation) \ #define RelationIsSecurityView(relation) \
((relation)->rd_options ? \ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options ? \
((ViewOptions *) (relation)->rd_options)->security_barrier : false) ((ViewOptions *) (relation)->rd_options)->security_barrier : false)
/* /*
...@@ -361,7 +362,8 @@ typedef struct ViewOptions ...@@ -361,7 +362,8 @@ typedef struct ViewOptions
* or the cascaded check option. Note multiple eval of argument! * or the cascaded check option. Note multiple eval of argument!
*/ */
#define RelationHasCheckOption(relation) \ #define RelationHasCheckOption(relation) \
((relation)->rd_options && \ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option != \ ((ViewOptions *) (relation)->rd_options)->check_option != \
VIEW_OPTION_CHECK_OPTION_NOT_SET) VIEW_OPTION_CHECK_OPTION_NOT_SET)
...@@ -371,7 +373,8 @@ typedef struct ViewOptions ...@@ -371,7 +373,8 @@ typedef struct ViewOptions
* option. Note multiple eval of argument! * option. Note multiple eval of argument!
*/ */
#define RelationHasLocalCheckOption(relation) \ #define RelationHasLocalCheckOption(relation) \
((relation)->rd_options && \ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option == \ ((ViewOptions *) (relation)->rd_options)->check_option == \
VIEW_OPTION_CHECK_OPTION_LOCAL) VIEW_OPTION_CHECK_OPTION_LOCAL)
...@@ -381,7 +384,8 @@ typedef struct ViewOptions ...@@ -381,7 +384,8 @@ typedef struct ViewOptions
* option. Note multiple eval of argument! * option. Note multiple eval of argument!
*/ */
#define RelationHasCascadedCheckOption(relation) \ #define RelationHasCascadedCheckOption(relation) \
((relation)->rd_options && \ (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option == \ ((ViewOptions *) (relation)->rd_options)->check_option == \
VIEW_OPTION_CHECK_OPTION_CASCADED) VIEW_OPTION_CHECK_OPTION_CASCADED)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment