Skip to content

Commit 2e068db

Browse files
committed
Use macro NUM_MERGE_MATCH_KINDS instead of '3' in MERGE code.
Code quality improvement for 0294df2. Aleksander Alekseev, reviewed by Richard Guo. Discussion: https://postgr.es/m/CAJ7c6TMsiaV5urU_Pq6zJ2tXPDwk69-NKVh4AMN5XrRiM7N%2BGA%40mail.gmail.com
1 parent f6e8451 commit 2e068db

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

src/backend/optimizer/prep/prepjointree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ transform_MERGE_to_join(Query *parse)
153153
{
154154
RangeTblEntry *joinrte;
155155
JoinExpr *joinexpr;
156-
bool have_action[3];
156+
bool have_action[NUM_MERGE_MATCH_KINDS];
157157
JoinType jointype;
158158
int joinrti;
159159
List *vars;

src/backend/parser/parse_merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
109109
Query *qry = makeNode(Query);
110110
ListCell *l;
111111
AclMode targetPerms = ACL_NO_RIGHTS;
112-
bool is_terminal[3];
112+
bool is_terminal[NUM_MERGE_MATCH_KINDS];
113113
Index sourceRTI;
114114
List *mergeActionList;
115115
ParseNamespaceItem *nsitem;

src/include/nodes/execnodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ typedef struct ResultRelInfo
545545
OnConflictSetState *ri_onConflict;
546546

547547
/* for MERGE, lists of MergeActionState (one per MergeMatchKind) */
548-
List *ri_MergeActions[3];
548+
List *ri_MergeActions[NUM_MERGE_MATCH_KINDS];
549549

550550
/* for MERGE, expr state for checking the join condition */
551551
ExprState *ri_MergeJoinCondition;

src/include/nodes/primnodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,8 @@ typedef enum MergeMatchKind
19701970
MERGE_WHEN_NOT_MATCHED_BY_TARGET
19711971
} MergeMatchKind;
19721972

1973+
#define NUM_MERGE_MATCH_KINDS (MERGE_WHEN_NOT_MATCHED_BY_TARGET + 1)
1974+
19731975
typedef struct MergeAction
19741976
{
19751977
NodeTag type;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy