8000 Add some assertions to view reloption macros · postgres/postgres@3967737 · GitHub
[go: up one dir, main page]

Skip to content
{"payload":{"commit":{"oid":"396773762425126a85243fc85a267d401496beb8","url":"/postgres/postgres/commit/396773762425126a85243fc85a267d401496beb8","authoredDate":"2019-11-01T13:16:21.000+01:00","committedDate":"2019-11-01T13:25:38.000+01:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eAdd some assertions to view reloption macros\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"In these macros, the rd_options pointer is cast to ViewOption *. Add\nsome assertions that the passed-in relation is actually a view before\ndoing that.\n\nAuthor: Nikolay Shaplov \u0026lt;dhyan@nataraj.su\u0026gt;\nDiscussion: \u003ca href=\"https://www.postgresql.org/message-id/flat/3634983.eHpMQ1mJnI@x200m\" rel=\"nofollow\"\u003ehttps://www.postgresql.org/message-id/flat/3634983.eHpMQ1mJnI@x200m\u003c/a\u003e","authors":[{"login":"petere","displayName":"Peter Eisentraut","avatarUrl":"https://avatars.githubusercontent.com/u/105543?v=4","path":"/petere","isGitHub":false}],"committerAttribution":false,"committer":{"login":"petere","displayName":"Peter Eisentraut","avatarUrl":"https://avatars.githubusercontent.com/u/105543?v=4","path":"/petere","isGitHub":false},"parents":["604bd3671121b51f977de146ed95484c2297fb3e"],"globalRelayId":"MDY6Q29tbWl0OTI3NDQyOjM5Njc3Mzc2MjQyNTEyNmE4NTI0M2ZjODVhMjY3ZDQwMTQ5NmJlYjg=","sha1":"604bd3671121b51f977de146ed95484c2297fb3e","sha2":"396773762425126a85243fc85a267d401496beb8"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":350,"text":"@@ -351,17 +351,19 @@ typedef struct ViewOptions","html":"@@ -351,17 +351,19 @@ typedef struct ViewOptions","displayNoNewLineWarning":false,"position":0,"left":350,"right":350},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":351,"text":" *\t\tReturns whether the relation is security view, or not. Note multiple","html":" \u003cspan class=pl-c\u003e *\t\tReturns whether the relation is security view, or not. Note multiple\u003c/span\u003e","displayNoNewLineWarning":false,"position":1,"left":351,"right":351},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":352,"text":" *\t\teval of argument!","html":" \u003cspan class=pl-c\u003e *\t\teval of argument!\u003c/span\u003e","displayNoNewLineWarning":false,"position":2,"left":352,"right":352},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":353,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":3,"left":353,"right":353},{"stylingDirective":null,"type":"DELETION","blobLineNumber":354,"text":"-#define RelationIsSecurityView(relation)\t\\","html":"-\u003cspan class=pl-k\u003e#define\u003c/span\u003e \u003cspan class=pl-en\u003eRelationIsSecurityView\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e)\t\\","displayNoNewLineWarning":false,"position":4,"left":354,"right":353},{"stylingDirective":null,"type":"DELETION","blobLineNumber":355,"text":"-\t((relation)-\u003erd_options ?\t\t\t\t\\","html":"-\t((relation)-\u0026gt;rd_options ?\t\t\t\t\\","displayNoNewLineWarning":false,"position":5,"left":355,"right":353},{"stylingDirective":null,"type":"DELETION","blobLineNumber":356,"text":"-\t ((ViewOptions *) (relation)-\u003erd_options)-\u003esecurity_barrier : false)","html":"-\t ((ViewOptions *) (relation)-\u0026gt;rd_options)-\u0026gt;security_barrier : false)","displayNoNewLineWarning":false,"position":6,"left":356,"right":353},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":354,"text":"+#define RelationIsSecurityView(relation)\t\t\t\t\t\t\t\t\t\\","html":"+\u003cspan class=pl-k\u003e#define\u003c/span\u003e \u003cspan class=pl-en\u003eRelationIsSecurityView\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e)\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":7,"left":356,"right":354},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":355,"text":"+\t(AssertMacro(relation-\u003erd_rel-\u003erelkind == RELKIND_VIEW),\t\t\t\t\\","html":"+\t(AssertMacro(relation-\u0026gt;rd_rel-\u0026gt;relkind == RELKIND_VIEW),\t\t\t\t\\","displayNoNewLineWarning":false,"position":8,"left":356,"right":355},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":356,"text":"+\t (relation)-\u003erd_options ?\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"+\t (relation)-\u0026gt;rd_options ?\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":9,"left":356,"right":356},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":357,"text":"+\t ((ViewOptions *) (relation)-\u003erd_options)-\u003esecurity_barrier : false)","html":"+\t ((ViewOptions *) (relation)-\u0026gt;rd_options)-\u0026gt;security_barrier : false)","displayNoNewLineWarning":false,"position":10,"left":356,"right":357},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":358,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":11,"left":357,"right":358},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":359,"text":" /*","html":" \u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":12,"left":358,"right":359},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":360,"text":" * RelationHasCheckOption","html":" \u003cspan class=pl-c\u003e * RelationHasCheckOption\u003c/span\u003e","displayNoNewLineWarning":false,"position":13,"left":359,"right":360},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":361,"text":" *\t\tReturns true if the relation is a view defined with either the local","html":" \u003cspan class=pl-c\u003e *\t\tReturns true if the relation is a view defined with either the local\u003c/span\u003e","displayNoNewLineWarning":false,"position":14,"left":360,"right":361},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":362,"text":" *\t\tor the cascaded check option. Note multiple eval of argument!","html":" \u003cspan class=pl-c\u003e *\t\tor the cascaded check option. Note multiple eval of argument!\u003c/span\u003e","displayNoNewLineWarning":false,"position":15,"left":361,"right":362},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":363,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":16,"left":362,"right":363},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":364,"text":" #define RelationHasCheckOption(relation)\t\t\t\t\t\t\t\t\t\\","html":" \u003cspan class=pl-k\u003e#define\u003c/span\u003e \u003cspan class=pl-en\u003eRelationHasCheckOption\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e)\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":17,"left":363,"right":364},{"stylingDirective":null,"type":"DELETION","blobLineNumber":364,"text":"-\t((relation)-\u003erd_options \u0026\u0026\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"-\t((relation)-\u0026gt;rd_options \u0026amp;\u0026amp;\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":18,"left":364,"right":364},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":365,"text":"+\t(AssertMacro(relation-\u003erd_rel-\u003erelkind == RELKIND_VIEW),\t\t\t\t\\","html":"+\t(AssertMacro(relation-\u0026gt;rd_rel-\u0026gt;relkind == RELKIND_VIEW),\t\t\t\t\\","displayNoNewLineWarning":false,"position":19,"left":364,"right":365},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":366,"text":"+\t (relation)-\u003erd_options \u0026\u0026\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"+\t (relation)-\u0026gt;rd_options \u0026amp;\u0026amp;\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":20,"left":364,"right":366},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":367,"text":" \t ((ViewOptions *) (relation)-\u003erd_options)-\u003echeck_option !=\t\t\t\t\\","html":" \t ((ViewOptions *) (relation)-\u0026gt;rd_options)-\u0026gt;check_option !=\t\t\t\t\\","displayNoNewLineWarning":false,"position":21,"left":365,"right":367},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":368,"text":" \t VIEW_OPTION_CHECK_OPTION_NOT_SET)","html":" \t VIEW_OPTION_CHECK_OPTION_NOT_SET)","displayNoNewLineWarning":false,"position":22,"left":366,"right":368},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":369,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":23,"left":367,"right":369},{"stylingDirective":null,"type":"HUNK","blobLineNumber":372,"text":"@@ -371,7 +373,8 @@ typedef struct ViewOptions","html":"@@ -371,7 +373,8 @@ typedef struct ViewOptions","displayNoNewLineWarning":false,"position":24,"left":370,"right":372},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":373,"text":" *\t\toption. Note multiple eval of argument!","html":" \u003cspan class=pl-c\u003e *\t\toption. Note multiple eval of argument!\u003c/span\u003e","displayNoNewLineWarning":false,"position":25,"left":371,"right":373},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":374,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":26,"left":372,"right":374},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":375,"text":" #define RelationHasLocalCheckOption(relation)\t\t\t\t\t\t\t\t\\","html":" \u003cspan class=pl-k\u003e#define\u003c/span\u003e \u003cspan class=pl-en\u003eRelationHasLocalCheckOption\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e)\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":27,"left":373,"right":375},{"stylingDirective":null,"type":"DELETION","blobLineNumber":374,"text":"-\t((relation)-\u003erd_options \u0026\u0026\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"-\t((relation)-\u0026gt;rd_options \u0026amp;\u0026amp;\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":28,"left":374,"right":375},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":376,"text":"+\t(AssertMacro(relation-\u003erd_rel-\u003erelkind == RELKIND_VIEW),\t\t\t\t\\","html":"+\t(AssertMacro(relation-\u0026gt;rd_rel-\u0026gt;relkind == RELKIND_VIEW),\t\t\t\t\\","displayNoNewLineWarning":false,"position":29,"left":374,"right":376},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":377,"text":"+\t (relation)-\u003erd_options \u0026\u0026\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"+\t (relation)-\u0026gt;rd_options \u0026amp;\u0026amp;\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":30,"left":374,"right":377},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":378,"text":" \t ((ViewOptions *) (relation)-\u003erd_options)-\u003echeck_option ==\t\t\t\t\\","html":" \t ((ViewOptions *) (relation)-\u0026gt;rd_options)-\u0026gt;check_option ==\t\t\t\t\\","displayNoNewLineWarning":false,"position":31,"left":375,"right":378},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":379,"text":" \t VIEW_OPTION_CHECK_OPTION_LOCAL)","html":" \t VIEW_OPTION_CHECK_OPTION_LOCAL)","displayNoNewLineWarning":false,"position":32,"left":376,"right":379},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":380,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":33,"left":377,"right":380},{"stylingDirective":null,"type":"HUNK","blobLineNumber":383,"text":"@@ -381,7 +384,8 @@ typedef struct ViewOptions","html":"@@ -381,7 +384,8 @@ typedef struct ViewOptions","displayNoNewLineWarning":false,"position":34,"left":380,"right":383},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":384,"text":" *\t\toption. Note multiple eval of argument!","html":" \u003cspan class=pl-c\u003e *\t\toption. Note multiple eval of argument!\u003c/span\u003e","displayNoNewLineWarning":false,"position":35,"left":381,"right":384},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":385,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":36,"left":382,"right":385},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":386,"text":" #define RelationHasCascadedCheckOption(relation)\t\t\t\t\t\t\t\\","html":" \u003cspan class=pl-k\u003e#define\u003c/span\u003e \u003cspan class=pl-en\u003eRelationHasCascadedCheckOption\u003c/span\u003e(\u003cspan class=pl-s1\u003erelation\u003c/span\u003e)\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":37,"left":383,"right":386},{"stylingDirective":null,"type":"DELETION","blobLineNumber":384,"text":"-\t((relation)-\u003erd_options \u0026\u0026\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"-\t((relation)-\u0026gt;rd_options \u0026amp;\u0026amp;\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":38,"left":384,"right":386},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":387,"text":"+\t(AssertMacro(relation-\u003erd_rel-\u003erelkind == RELKIND_VIEW),\t\t\t\t\\","html":"+\t(AssertMacro(relation-\u0026gt;rd_rel-\u0026gt;relkind == RELKIND_VIEW),\t\t\t\t\\","displayNoNewLineWarning":false,"position":39,"left":384,"right":387},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":388,"text":"+\t (relation)-\u003erd_options \u0026\u0026\t\t\t\t\t\t\t\t\t\t\t\t\\","html":"+\t (relation)-\u0026gt;rd_options \u0026amp;\u0026amp;\t\t\t\t\t\t\t\t\t\t\t\t\\","displayNoNewLineWarning":false,"position":40,"left":384,"right":388},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":389,"text":" \t ((ViewOptions *) (relation)-\u003erd_options)-\u003echeck_option ==\t\t\t\t\\","html":" \t ((ViewOptions *) (relation)-\u0026gt;rd_options)-\u0026gt;check_option ==\t\t\t\t\\","displayNoNewLineWarning":false,"position":41,"left":385,"right":389},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":390,"text":" \t VIEW_OPTION_CHECK_OPTION_CASCADED)","html":" \t VIEW_OPTION_CHECK_OPTION_CASCADED)","displayNoNewLineWarning":false,"position":42,"left":386,"right":390},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":391,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":43,"left":387,"right":391}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":616,"linesChanged":16,"newTreeEntry":{"lineCount":616,"path":"src/include/utils/rel.h","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/include/utils/rel.h","mode":100644},"linesAdded":10,"linesDeleted":6,"path":"src/include/utils/rel.h","pathDigest":"4f8f083d4a9e7e2a8dcdabc9cfd9426652b647f85e310aba2b876d6753755e10","status":"MODIFIED","truncatedReason":null,"oldOid":"604bd3671121b51f977de146ed95484c2297fb3e","newOid":"396773762425126a85243fc85a267d401496beb8","copilotChatReference":null,"deletedSha":"604bd3671121b51f977de146ed95484c2297fb3e","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/396773762425126a85243fc85a267d401496beb8","fileTreeExpanded":true,"headerInfo":{"additions":10,"deletions":6,"filesChanged":1,"filesChangedString":"1"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":1,"truncated":false,"byteCount":1829,"lineShownCount":44},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"SsqbqxE59eGOtk9w2HZBNmLDt2GyrSqOYV-uag7WQkMPXEKcSmZHQ7y2RQ0au8VNCsVsn-Ms--XoLWuHSt5UBw"},"/users/diffview?diff=unified":{"post":"p3WQNQ8S0W66LH3b27v-7V9MiqLqRz-FBjTb4EYPkx_i40kCVE1jzIgsd6YZdnqWN0pRXLvG7u6PRh4NAgeFWw"},"/notifications/thread":{"post":"FIxks-UL-cMDzCgcbt_zz_diHU6RdFPI4GBZzUKQfeNRCG45nP2Lfl0XTdTNe-PYgFtuyq3kPaF_hkhqgU7y1Q"}}},"title":"Add some assertions to view reloption macros · postgres/postgres@3967737","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

Commit 3967737

Browse files
committed
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
1 parent 604bd36 commit 3967737

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-
#define RelationIsSecurityView(relation) \
355-
((relation)->rd_options ? \
356-
((ViewOptions *) (relation)->rd_options)->security_barrier : false)
354+
#define RelationIsSecurityView(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
#define RelationHasCheckOption(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
#define RelationHasLocalCheckOption(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
#define RelationHasCascadedCheckOption(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)
0