pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Nikolay Shaplov <dhyan@nataraj.su>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Nikolay Shaplov <dhyan@nataraj.su>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Dent John <denty@qqdd.eu>
Cc: Iwata, Aya <iwata.aya@jp.fujitsu.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>
Subject: [PATCH] Add some useful asserts into View Options macroses
Date: Sun, 06 Oct 2019 00:23:00 +0300
Message-ID: <3634983.eHpMQ1mJnI@x200m> (raw )
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)
Attachments:
[text/x-patch] some-asserts-for-view-options-macroses_v1.diff (2.0K, ../3634983.eHpMQ1mJnI@x200m/2-some-asserts-for-view-options-macroses_v1.diff)
download | inline diff:
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
[application/pgp-signature] signature.asc (487B, ../3634983.eHpMQ1mJnI@x200m/3-signature.asc)
download
view thread (5+ messages) latest in thread
Message-ID: <3634983.eHpMQ1mJnI@x200m>
Permalink: ../3634983.eHpMQ1mJnI@x200m/
Also on: postgresql.org/message-id/3634983.eHpMQ1mJnI@x200m
copy link · copy postgr.es · copy git am
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: dhyan@nataraj.su, michael@paquier.xyz, tomas.vondra@2ndquadrant.com, pgsql-hackers@lists.postgresql.org, denty@qqdd.eu, iwata.aya@jp.fujitsu.com, alvherre@2ndquadrant.com, 9erthalion6@gmail.com, thomas.munro@gmail.com
Subject: Re: [PATCH] Add some useful asserts into View Options macroses
In-Reply-To: <3634983.eHpMQ1mJnI@x200m>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox