This thread is a follow up to the thread https://www.postgresql.org/message-id/2620882.s52SJui4ql@x200m where I've been trying to remove StdRdOptions structure and replace it with unique structure for each relation kind.
I've decided to split that patch into smaller parts. This part adds some asserts to ViewOptions macroses. Since an option pointer there is converted into (ViewOptions *) it would be really good to make sure that this macros is called in proper context, and we do the convertation properly. At least when running tests with asserts turned on. -- Software Developer: https://www.upwork.com/freelancers/~014a87e140ff02c0da Body-oriented Therapist: https://vk.com/nataraj_rebalancing (Russian)
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index a5cf804..b24fb1d 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,9 +362,10 @@ typedef struct ViewOptions * or the cascaded check option. Note multiple eval of argument! */ #define RelationHasCheckOption(relation) \ + (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \ ((relation)->rd_options && \ ((ViewOptions *) (relation)->rd_options)->check_option != \ - VIEW_OPTION_CHECK_OPTION_NOT_SET) + VIEW_OPTION_CHECK_OPTION_NOT_SET)) /* * RelationHasLocalCheckOption @@ -371,9 +373,10 @@ typedef struct ViewOptions * option. Note multiple eval of argument! */ #define RelationHasLocalCheckOption(relation) \ + (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \ ((relation)->rd_options && \ ((ViewOptions *) (relation)->rd_options)->check_option == \ - VIEW_OPTION_CHECK_OPTION_LOCAL) + VIEW_OPTION_CHECK_OPTION_LOCAL)) /* * RelationHasCascadedCheckOption @@ -381,9 +384,10 @@ typedef struct ViewOptions * option. Note multiple eval of argument! */ #define RelationHasCascadedCheckOption(relation) \ + (AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW), \ ((relation)->rd_options && \ ((ViewOptions *) (relation)->rd_options)->check_option == \ - VIEW_OPTION_CHECK_OPTION_CASCADED) + VIEW_OPTION_CHECK_OPTION_CASCADED)) /* * RelationIsValid
signature.asc
Description: This is a digitally signed message part.