diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2015-05-15 14:37:10 -0400 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2015-05-15 14:37:10 -0400 |
commit | f6d208d6e51810c73f0e02c477984a6b44627f11 (patch) | |
tree | 99d540d0b7bda73ff60479f15444f554403d4679 /src/backend/optimizer/plan/planner.c | |
parent | 11a83bbedd73800db70f6f2af5a8eb10d15d39d7 (diff) | |
download | postgresql-f6d208d6e51810c73f0e02c477984a6b44627f11.tar.gz |
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/optimizer/plan/planner.c')
-rw-r--r-- | src/backend/optimizer/plan/planner.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 8de57c8e6b..9ba10516bb 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -60,6 +60,7 @@ planner_hook_type planner_hook = NULL; #define EXPRKIND_LIMIT 6 #define EXPRKIND_APPINFO 7 #define EXPRKIND_PHV 8 +#define EXPRKIND_TABLESAMPLE 9 /* Passthrough data for standard_qp_callback */ typedef struct @@ -486,7 +487,19 @@ subquery_planner(PlannerGlobal *glob, Query *parse, RangeTblEntry *rte = (RangeTblEntry *) lfirst(l); int kind; - if (rte->rtekind == RTE_SUBQUERY) + if (rte->rtekind == RTE_RELATION) + { + if (rte->tablesample) + { + rte->tablesample->args = (List *) + preprocess_expression(root, (Node *) rte->tablesample->args, + EXPRKIND_TABLESAMPLE); + rte->tablesample->repeatable = (Node *) + preprocess_expression(root, rte->tablesample->repeatable, + EXPRKIND_TABLESAMPLE); + } + } + else if (rte->rtekind == RTE_SUBQUERY) { /* * We don't want to do all preprocessing yet on the subquery's |