Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iGrWG-000410-1P for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Oct 2019 21:23:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iGrWD-0004f5-RU for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Oct 2019 21:23:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iGrWD-0004ek-FM for pgsql-hackers@lists.postgresql.org; Sat, 05 Oct 2019 21:23:13 +0000 Received: from ssl.nataraj.su ([195.54.209.170]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iGrW6-0001mx-3D for pgsql-hackers@lists.postgresql.org; Sat, 05 Oct 2019 21:23:12 +0000 Received: from x200m.localnet (unknown [91.203.188.92]) by ssl.nataraj.su (Postfix) with ESMTPSA id 48A3A26C8BB7; Sun, 6 Oct 2019 00:23:04 +0300 (MSK) From: Nikolay Shaplov To: Michael Paquier Cc: Tomas Vondra , Nikolay Shaplov , PostgreSQL Hackers , Dent John , "Iwata, Aya" , Alvaro Herrera , Dmitry Dolgov <9erthalion6@gmail.com>, Thomas Munro Subject: [PATCH] Add some useful asserts into View Options macroses Date: Sun, 06 Oct 2019 00:23:00 +0300 Message-ID: <3634983.eHpMQ1mJnI@x200m> User-Agent: KMail/5.2.3 (Linux/4.9.0-8-amd64; KDE/5.28.0; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1787117.km8xlbCmCQ"; micalg="pgp-sha256"; protocol="application/pgp-signature" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --nextPart1787117.km8xlbCmCQ Content-Type: multipart/mixed; boundary="nextPart3274661.7R8MTXBARm" Content-Transfer-Encoding: 7Bit This is a multi-part message in MIME format. --nextPart3274661.7R8MTXBARm Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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) --nextPart3274661.7R8MTXBARm Content-Disposition: attachment; filename="some-asserts-for-view-options-macroses_v1.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="some-asserts-for-view-options-macroses_v1.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 --nextPart3274661.7R8MTXBARm-- --nextPart1787117.km8xlbCmCQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEJQDMAFm5foZxo7fMpzXcejAr4fgFAl2ZCbQACgkQpzXcejAr 4fhWxwf+KT+OTO4XgLaZ6DcukC/32xUE9o/qu6GlWAa4P2GCk0x1wg5pHSRjgArN 9hHCSP2Dr98oK3hwbu89cvJwVVBfow6rf4Lccf1n/klw5/m7o96xqQnpcs92yUn0 y1GmxuTXjIYmGcWPjGJ6w/4JpcJKDbo7y4Ge/v3Hwngg2I1A0aUPq9/VNNnFCFhI FNGlug6q1T/lGc0T80KjuCIyHo1JZNTsxGYV3QOfYBF8HuYRwVGgxRcMI/86cMRO PwALjrJS7gq9X4n3CASbA1IExr3JdHbgP4Dpa2uPgw+jRc6lZ+U9YdNia3RHP/NH 9CAJNjzHFs+K7wEoaG4SvV5eKdDBMg== =ATEV -----END PGP SIGNATURE----- --nextPart1787117.km8xlbCmCQ--