diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2019-11-01 13:16:21 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2019-11-01 13:25:38 +0100 |
commit | 396773762425126a85243fc85a267d401496beb8 (patch) | |
tree | d2b46ab1bfbf9fe201409fe95b96d4f7b7dc1116 | |
parent | 604bd3671121b51f977de146ed95484c2297fb3e (diff) | |
download | postgresql-396773762425126a85243fc85a267d401496beb8.tar.gz postgresql-396773762425126a85243fc85a267d401496beb8.zip |
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
-rw-r--r-- | src/include/utils/rel.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index a5cf804f9fc..8b8b237f0d8 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -351,9 +351,10 @@ typedef struct ViewOptions * Returns whether the relation is security view, or not. Note multiple * eval of argument! */ -#define RelationIsSecurityView(relation) \ - ((relation)->rd_options ? \ - ((ViewOptions *) (relation)->rd_options)->security_barrier : false) +#define RelationIsSecurityView(relation) \ + (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \ + (relation)->rd_options ? \ + ((ViewOptions *) (relation)->rd_options)->security_barrier : false) /* * RelationHasCheckOption @@ -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) |