aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/nodeFuncs.c
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2015-05-15 14:37:10 -0400
committerSimon Riggs <simon@2ndQuadrant.com>2015-05-15 14:37:10 -0400
commitf6d208d6e51810c73f0e02c477984a6b44627f11 (patch)
tree99d540d0b7bda73ff60479f15444f554403d4679 /src/backend/nodes/nodeFuncs.c
parent11a83bbedd73800db70f6f2af5a8eb10d15d39d7 (diff)
downloadpostgresql-f6d208d6e51810c73f0e02c477984a6b44627f11.tar.gz
postgresql-f6d208d6e51810c73f0e02c477984a6b44627f11.zip
TABLESAMPLE, SQL Standard and extensible
Add a TABLESAMPLE clause to SELECT statements that allows user to specify random BERNOULLI sampling or block level SYSTEM sampling. Implementation allows for extensible sampling functions to be written, using a standard API. Basic version follows SQLStandard exactly. Usable concrete use cases for the sampling API follow in later commits. Petr Jelinek Reviewed by Michael Paquier and Simon Riggs
Diffstat (limited to 'src/backend/nodes/nodeFuncs.c')
-rw-r--r--src/backend/nodes/nodeFuncs.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c
index eac02159236..42d62d32d93 100644
--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -2058,6 +2058,14 @@ range_table_walker(List *rtable,
switch (rte->rtekind)
{
case RTE_RELATION:
+ if (rte->tablesample)
+ {
+ if (walker(rte->tablesample->args, context))
+ return true;
+ if (walker(rte->tablesample->repeatable, context))
+ return true;
+ }
+ break;
case RTE_CTE:
/* nothing to do */
break;
@@ -2813,6 +2821,14 @@ range_table_mutator(List *rtable,
switch (rte->rtekind)
{
case RTE_RELATION:
+ if (rte->tablesample)
+ {
+ MUTATE(rte->tablesample->args, rte->tablesample->args,
+ List *);
+ MUTATE(rte->tablesample->repeatable,
+ rte->tablesample->repeatable, Node *);
+ }
+ break;
case RTE_CTE:
/* we don't bother to copy eref, aliases, etc; OK? */
break;
@@ -3309,6 +3325,18 @@ raw_expression_tree_walker(Node *node,
break;
case T_CommonTableExpr:
return walker(((CommonTableExpr *) node)->ctequery, context);
+ case T_RangeTableSample:
+ {
+ RangeTableSample *rts = (RangeTableSample *) node;
+
+ if (walker(rts->relation, context))
+ return true;
+ if (walker(rts->repeatable, context))
+ return true;
+ if (walker(rts->args, context))
+ return true;
+ }
+ break;
default:
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(node));