Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3967737

Browse files
committed
Add some assertions to view reloption macros
In these macros, the rd_options pointer is cast to ViewOption *. Addsome assertions that the passed-in relation is actually a view beforedoing that.Author: Nikolay Shaplov <dhyan@nataraj.su>Discussion:https://www.postgresql.org/message-id/flat/3634983.eHpMQ1mJnI@x200m
1 parent604bd36 commit3967737

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

‎src/include/utils/rel.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,19 @@ typedef struct ViewOptions
351351
*Returns whether the relation is security view, or not. Note multiple
352352
*eval of argument!
353353
*/
354-
#defineRelationIsSecurityView(relation)\
355-
((relation)->rd_options ?\
356-
((ViewOptions *) (relation)->rd_options)->security_barrier : false)
354+
#defineRelationIsSecurityView(relation)\
355+
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW),\
356+
(relation)->rd_options ?\
357+
((ViewOptions *) (relation)->rd_options)->security_barrier : false)
357358

358359
/*
359360
* RelationHasCheckOption
360361
*Returns true if the relation is a view defined with either the local
361362
*or the cascaded check option. Note multiple eval of argument!
362363
*/
363364
#defineRelationHasCheckOption(relation)\
364-
((relation)->rd_options &&\
365+
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW),\
366+
(relation)->rd_options &&\
365367
((ViewOptions *) (relation)->rd_options)->check_option !=\
366368
VIEW_OPTION_CHECK_OPTION_NOT_SET)
367369

@@ -371,7 +373,8 @@ typedef struct ViewOptions
371373
*option. Note multiple eval of argument!
372374
*/
373375
#defineRelationHasLocalCheckOption(relation)\
374-
((relation)->rd_options &&\
376+
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW),\
377+
(relation)->rd_options &&\
375378
((ViewOptions *) (relation)->rd_options)->check_option ==\
376379
VIEW_OPTION_CHECK_OPTION_LOCAL)
377380

@@ -381,7 +384,8 @@ typedef struct ViewOptions
381384
*option. Note multiple eval of argument!
382385
*/
383386
#defineRelationHasCascadedCheckOption(relation)\
384-
((relation)->rd_options &&\
387+
(AssertMacro(relation->rd_rel->relkind == RELKIND_VIEW),\
388+
(relation)->rd_options &&\
385389
((ViewOptions *) (relation)->rd_options)->check_option ==\
386390
VIEW_OPTION_CHECK_OPTION_CASCADED)
387391

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp