OSDN Git Service

Add support for TableSample in text representaion.
authorKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 26 Aug 2016 01:28:40 +0000 (10:28 +0900)
committerKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 26 Aug 2016 07:10:10 +0000 (16:10 +0900)
Text representaion of table sample properties to be shown properly
with this fix.

 Sample Scan  (cost=0.00..2768.00 rows=100000 width=4)
+  Sampling: system ('10'::real) REPEATABLE ('0'::double precision)

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

index 1e54ab2..4c85544 100644 (file)
@@ -178,5 +178,8 @@ explain (analyze on, buffers on, verbose on, format :format)
 \echo ###### GROUPING SETS
 explain (analyze on, buffers on, verbose on, format :format)
    SELECT a, b, max(c) FROM tt1 GROUP BY GROUPING SETS ((a), (b), ());
+\echo ###### Table sample
+explain (analyze on, buffers on, verbose on, format :format)
+   SELECT * FROM tt1 TABLESAMPLE system(1) REPEATABLE (1);
 
 -- BitmapAnd/Inner/Right/ForegnScan
index 0b907de..013f0d3 100644 (file)
@@ -142,6 +142,9 @@ word_table propfields[] =
        {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_SamplingMethod,  ""  ,"Sampling Method" ,    NULL, false,  NULL,                             SETTER(sampling_method)},
+       {P_SamplingParams,  ""  ,"Sampling Parameters" , NULL, false,  NULL,                    SETTER(sampling_params)},
+       {P_RepeatableSeed,  ""  ,"Repeatable Seed" ,    NULL, false,  NULL,                             SETTER(repeatable_seed)},
        {P_Invalid, NULL, NULL, NULL, false, NULL, NULL}
 };
 
index 3d9fdd8..43a2536 100644 (file)
@@ -111,7 +111,10 @@ typedef enum
        P_ConfRes,
        P_ConfArbitIdx,
        P_TuplesInserted,
-       P_ConfTuples
+       P_ConfTuples,
+       P_SamplingMethod,
+       P_SamplingParams,
+       P_RepeatableSeed
 } pgsp_prop_tags;
 
 typedef struct
index 94a8bef..0a80ec5 100644 (file)
@@ -147,7 +147,9 @@ DEFAULT_SETTER(conflict_resolution);
 LIST_SETTER(conflict_arbiter_indexes);
 DEFAULT_SETTER(tuples_inserted);
 DEFAULT_SETTER(conflicting_tuples);
-
+DEFAULT_SETTER(sampling_method);
+LIST_SETTER(sampling_params);
+DEFAULT_SETTER(repeatable_seed);
 
 #define ISZERO(s) (!s || strcmp(s, "0") == 0 || strcmp(s, "0.000") == 0 )
 #define HASSTRING(s) (s && strlen(s) > 0)
@@ -403,8 +405,19 @@ print_current_node(pgspParserContext *ctx)
        print_prop_if_exists(s, "Join Filter: " , v->join_filter, level, exind);
        print_prop_if_exists(s, "Index Cond: " , v->index_cond, level, exind);
        print_prop_if_exists(s, "Recheck Cond: ", v->recheck_cond, level, exind);
-       print_propstr_if_exists(s, "Sort Key: ", v->sort_key, level, exind);
 
+       if (HASSTRING(v->sampling_method))
+       {
+               appendStringInfoString(s, "\n");
+               appendStringInfoSpaces(s, TEXT_INDENT_DETAILS(level, exind));
+               appendStringInfo(s, "Sampling: %s (%s)",
+                                                v->sampling_method,
+                                                v->sampling_params ? v->sampling_params->data : "");
+               if (v->repeatable_seed)
+                       appendStringInfo(s, " REPEATABLE (%s)", v->repeatable_seed);
+       }
+       
+       print_propstr_if_exists(s, "Sort Key: ", v->sort_key, level, exind);
        if (HASSTRING(v->sort_method))
        {
                appendStringInfoString(s, "\n");
index 3e3790a..de2d359 100644 (file)
@@ -89,6 +89,9 @@ typedef struct
        StringInfo      conflict_arbiter_indexes;
        const char *tuples_inserted;
        const char *conflicting_tuples;
+       const char *sampling_method;
+       StringInfo sampling_params;
+       const char *repeatable_seed;
 
        const char *tmp_obj_name;
        const char *tmp_schema_name;
@@ -191,3 +194,6 @@ SETTERDECL(conflict_resolution);
 SETTERDECL(conflict_arbiter_indexes);
 SETTERDECL(tuples_inserted);
 SETTERDECL(conflicting_tuples);
+SETTERDECL(sampling_method);
+SETTERDECL(sampling_params);
+SETTERDECL(repeatable_seed);