Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+1-1
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

+1-1
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

+1-1
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

+2
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)