OSDN Git Service

Support ON CONFLICT in text plan output
authorKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 26 Aug 2016 04:13:24 +0000 (13:13 +0900)
committerKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 26 Aug 2016 07:09:40 +0000 (16:09 +0900)
ON CONFLICT syntax yields some additional information. This commit
adds support for "Conflict Resolution", "Conflict Arbiter Indexes",
"Tuples Inserted", "Conflicting Tuples". "Conflict Filter" and "Rows
Removed by Conflict Filter" still are not shown in text plans by this
commit.

json2sql.pl
makeplanfile.sql
pgsp_json.c
pgsp_json_int.h
pgsp_json_text.c
pgsp_json_text.h

index c5d99a7..aa5c146 100755 (executable)
@@ -224,6 +224,10 @@ sub setplan0 {
   "Index Cond": "a",
   "TID Cond": "a",
   "Recheck Cond": "a",
+  "Conflict Resolution": "a",
+  "Conflict Arbiter Indexes": "a",
+  "Tuples Inserted": 0,
+  "Conflicting Tuples": 0,
   "Target Tables": "a",
   "Operation": "Insert",
   "Operation": "Delete",
index 4f8cbf8..d40b5a6 100644 (file)
@@ -14,6 +14,9 @@ create index i_tt1 on tt1(a);
 create index i_tt2 on tt2(a);
 create index i_tt3_a on tt3(a);
 create index i_tt3_b on tt3(b);
+create table ct1 (a int unique, b int);
+insert into ct1 values (1,1), (2,2);
+
 create or replace function t_tt1_1() returns trigger as $$
   BEGIN
     NEW.b := -NEW.a;
@@ -166,5 +169,8 @@ explain (analyze on, buffers on, verbose on, format :format)
 \echo ###### Delete on partitioned tables
 explain (analyze on, buffers on, verbose on, format :format)
    DELETE FROM p WHERE a = 100;
+\echo ###### ON CONFLICT
+explain (analyze on, buffers on, verbose on, format :format)
+   INSERT INTO ct1 VALUES (1,1) ON CONFLICT (a) DO UPDATE SET b = EXCLUDED.b + 1;
 
 -- BitmapAnd/Inner/Right/ForegnScan
index 02e5a5d..5a65939 100644 (file)
@@ -135,6 +135,10 @@ word_table propfields[] =
        {P_LossyHeapBlks,       "(" ,"Lossy Heap Blocks",       NULL, false,  NULL,                             SETTER(lossy_heap_blks)},
        {P_RowsJoinFltRemvd,")" ,"Rows Removed by Join Filter", NULL, false,  NULL,             SETTER(joinfilt_removed)},
        {P_TargetTables,    "_" ,"Target Tables",               NULL, false,  NULL,                             NULL},
+       {P_ConfRes,                     "%" ,"Conflict Resolution",     NULL, false,  NULL,                     SETTER(conflict_resolution)},
+       {P_ConfArbitIdx,    "@" ,"Conflict Arbiter Indexes",NULL, false,  NULL,                 SETTER(conflict_arbiter_indexes)},
+       {P_TuplesInserted,  "^" ,"Tuples Inserted",             NULL, false,  NULL,                             SETTER(tuples_inserted)},
+       {P_ConfTuples,          "+" ,"Conflicting Tuples",      NULL, false,  NULL,                             SETTER(conflicting_tuples)},
        {P_Invalid, NULL, NULL, NULL, false, NULL, NULL}
 };
 
index e92024e..93a5a67 100644 (file)
@@ -104,7 +104,11 @@ typedef enum
        P_ExactHeapBlks,
        P_LossyHeapBlks,
        P_RowsJoinFltRemvd,
-       P_TargetTables
+       P_TargetTables,
+       P_ConfRes,
+       P_ConfArbitIdx,
+       P_TuplesInserted,
+       P_ConfTuples
 } pgsp_prop_tags;
 
 typedef struct
index 77a6585..6455955 100644 (file)
@@ -140,6 +140,11 @@ DEFAULT_SETTER(exec_time);
 DEFAULT_SETTER(exact_heap_blks);
 DEFAULT_SETTER(lossy_heap_blks);
 DEFAULT_SETTER(joinfilt_removed);
+DEFAULT_SETTER(conflict_resolution);
+LIST_SETTER(conflict_arbiter_indexes);
+DEFAULT_SETTER(tuples_inserted);
+DEFAULT_SETTER(conflicting_tuples);
+
 
 #define ISZERO(s) (!s || strcmp(s, "0") == 0 || strcmp(s, "0.000") == 0 )
 #define HASSTRING(s) (s && strlen(s) > 0)
@@ -451,6 +456,14 @@ print_current_node(pgspParserContext *ctx)
        }
 
        print_prop_if_exists(s, "Heap Fetches: ", v->heap_fetches, level, exind);
+       print_prop_if_exists(s, "Conflict Resolution: ",
+                                                v->conflict_resolution, level, exind);
+       print_propstr_if_exists(s, "Conflict Arbiter Indexes: ",
+                                                       v->conflict_arbiter_indexes, level, exind);
+       print_prop_if_exists(s, "Tuples Inserted: ",
+                                                v->tuples_inserted, level, exind);
+       print_prop_if_exists(s, "Conflicting Tuples: ",
+                                                v->conflicting_tuples, level, exind);
 
        if (!ISZERO(v->shared_hit_blks) ||
                !ISZERO(v->shared_read_blks) ||
index 202ebdc..8886a13 100644 (file)
@@ -77,6 +77,10 @@ typedef struct
        const char *exact_heap_blks;
        const char *lossy_heap_blks;
        const char *joinfilt_removed;
+       const char *conflict_resolution;
+       StringInfo      conflict_arbiter_indexes;
+       const char *tuples_inserted;
+       const char *conflicting_tuples;
 
        const char *tmp_obj_name;
        const char *tmp_schema_name;
@@ -173,3 +177,7 @@ SETTERDECL(exec_time);
 SETTERDECL(exact_heap_blks);
 SETTERDECL(lossy_heap_blks);
 SETTERDECL(joinfilt_removed);
+SETTERDECL(conflict_resolution);
+SETTERDECL(conflict_arbiter_indexes);
+SETTERDECL(tuples_inserted);
+SETTERDECL(conflicting_tuples);