Use macro NUM_MERGE_MATCH_KINDS instead of '3' in MERGE code.
authorDean Rasheed <[email protected]>
Fri, 19 Apr 2024 08:40:20 +0000 (09:40 +0100)
committerDean Rasheed <[email protected]>
Fri, 19 Apr 2024 08:40:20 +0000 (09:40 +0100)
Code quality improvement for 0294df2f1f84.

Aleksander Alekseev, reviewed by Richard Guo.

Discussion: https://postgr.es/m/CAJ7c6TMsiaV5urU_Pq6zJ2tXPDwk69-NKVh4AMN5XrRiM7N%2BGA%40mail.gmail.com

src/backend/optimizer/prep/prepjointree.c
src/backend/parser/parse_merge.c
src/include/nodes/execnodes.h
src/include/nodes/primnodes.h

index fb768ad52c2a1c44bc83c950720c7457056c3f59..41da670f1506ecee67c1f80c6b1f9bba0bce195f 100644 (file)
@@ -153,7 +153,7 @@ transform_MERGE_to_join(Query *parse)
 {
    RangeTblEntry *joinrte;
    JoinExpr   *joinexpr;
-   bool        have_action[3];
+   bool        have_action[NUM_MERGE_MATCH_KINDS];
    JoinType    jointype;
    int         joinrti;
    List       *vars;
index bce11d59561debf5fa4c990d8c8e91a92275c0ca..87df79027d7fb3169d66f9f5966646342ddaa8d9 100644 (file)
@@ -109,7 +109,7 @@ transformMergeStmt(ParseState *pstate, MergeStmt *stmt)
    Query      *qry = makeNode(Query);
    ListCell   *l;
    AclMode     targetPerms = ACL_NO_RIGHTS;
-   bool        is_terminal[3];
+   bool        is_terminal[NUM_MERGE_MATCH_KINDS];
    Index       sourceRTI;
    List       *mergeActionList;
    ParseNamespaceItem *nsitem;
index fa2f70b7a4894104ba5ec7dfccf207a43147bc93..c1a65bad2a988363f7110712e7b52da94d26a2fc 100644 (file)
@@ -545,7 +545,7 @@ typedef struct ResultRelInfo
    OnConflictSetState *ri_onConflict;
 
    /* for MERGE, lists of MergeActionState (one per MergeMatchKind) */
-   List       *ri_MergeActions[3];
+   List       *ri_MergeActions[NUM_MERGE_MATCH_KINDS];
 
    /* for MERGE, expr state for checking the join condition */
    ExprState  *ri_MergeJoinCondition;
index 719c4b7b6156c2010f380f8a92b2237a92f2a735..247cecb4b4574244362c94d7da9400ac9ab935d5 100644 (file)
@@ -1970,6 +1970,8 @@ typedef enum MergeMatchKind
    MERGE_WHEN_NOT_MATCHED_BY_TARGET
 } MergeMatchKind;
 
+#define NUM_MERGE_MATCH_KINDS (MERGE_WHEN_NOT_MATCHED_BY_TARGET + 1)
+
 typedef struct MergeAction
 {
    NodeTag     type;