Add necessary machinery to support for TABLESAMPLE clause
authorPavan Deolasee <[email protected]>
Wed, 1 Jul 2015 09:33:45 +0000 (15:03 +0530)
committerPavan Deolasee <[email protected]>
Wed, 1 Jul 2015 09:33:45 +0000 (15:03 +0530)
The required infrastructure to distribute SampleScan to the remote node was
missing. Also, necessary _read function was missing to convert a string
representation of SampleScan node to its binary equivalent. This patch adds all
of that

src/backend/nodes/readfuncs.c
src/backend/optimizer/util/pathnode.c

index 3d8b831472ad4d4e85f44cc17959513a2c724d53..fae88fe1092f002f8ba279603e0338563bb2b624 100644 (file)
@@ -2426,6 +2426,16 @@ _readSeqScan(void)
        READ_DONE();
 }
 
+/*
+ * _readSampleScan
+ */
+static SampleScan *
+_readSampleScan(void)
+{
+       READ_SCAN_FIELDS(SampleScan);
+
+       READ_DONE();
+}
 
 /*
  * _readIndexScan
@@ -3645,6 +3655,8 @@ parseNodeString(void)
                return_value = _readScan();
        else if (MATCH("SEQSCAN", 7))
                return_value = _readSeqScan();
+       else if (MATCH("SAMPLESCAN", 10))
+               return_value = _readSampleScan();
        else if (MATCH("INDEXSCAN", 9))
                return_value = _readIndexScan();
        else if (MATCH("INDEXONLYSCAN", 13))
index fd223d8b9ce507d76dd18d54a7e5d5d22592ea47..b393b5021a911f34cc5365c3cf2530a7ec90b643 100644 (file)
@@ -1681,6 +1681,19 @@ create_samplescan_path(PlannerInfo *root, RelOptInfo *rel, Relids required_outer
                                                                                                         required_outer);
        pathnode->pathkeys = NIL;       /* samplescan has unordered result */
 
+#ifdef XCP
+       set_scanpath_distribution(root, rel, pathnode);
+       if (rel->baserestrictinfo)
+       {
+               ListCell *lc;
+               foreach (lc, rel->baserestrictinfo)
+               {
+                       RestrictInfo *ri = (RestrictInfo *) lfirst(lc);
+                       restrict_distribution(root, ri, pathnode);
+               }
+       }
+#endif
+
        cost_samplescan(pathnode, root, rel);
 
        return pathnode;