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
* eval of argument!
*/
#define RelationIsSecurityView(relation) \
((relation)->rd_options ? \
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options ? \
((ViewOptions *) (relation)->rd_options)->security_barrier : false)
/*
......@@ -361,7 +362,8 @@ typedef struct ViewOptions
* or the cascaded check option. Note multiple eval of argument!
*/
#define RelationHasCheckOption(relation) \
((relation)->rd_options && \
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option != \
VIEW_OPTION_CHECK_OPTION_NOT_SET)
......@@ -371,7 +373,8 @@ typedef struct ViewOptions
* option. Note multiple eval of argument!
*/
#define RelationHasLocalCheckOption(relation) \
((relation)->rd_options && \
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option == \
VIEW_OPTION_CHECK_OPTION_LOCAL)
......@@ -381,7 +384,8 @@ typedef struct ViewOptions
* option. Note multiple eval of argument!
*/
#define RelationHasCascadedCheckOption(relation) \
((relation)->rd_options && \
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \
(relation)->rd_options && \
((ViewOptions *) (relation)->rd_options)->check_option == \
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