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/include/access/tablesample.h | |
parent | 11a83bbedd73800db70f6f2af5a8eb10d15d39d7 (diff) | |
download | postgresql-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/include/access/tablesample.h')
-rw-r--r-- | src/include/access/tablesample.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/include/access/tablesample.h b/src/include/access/tablesample.h new file mode 100644 index 00000000000..222fa8d5561 --- /dev/null +++ b/src/include/access/tablesample.h @@ -0,0 +1,60 @@ +/*------------------------------------------------------------------------- + * + * tablesample.h + * Public header file for TABLESAMPLE clause interface + * + * + * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/access/tablesample.h + * + *------------------------------------------------------------------------- + */ +#ifndef TABLESAMPLE_H +#define TABLESAMPLE_H + +#include "access/relscan.h" +#include "executor/executor.h" + +typedef struct TableSampleDesc { + HeapScanDesc heapScan; + TupleDesc tupDesc; /* Mostly useful for tsmexaminetuple */ + + void *tsmdata; /* private method data */ + + /* These point to he function of the TABLESAMPLE Method. */ + FmgrInfo tsminit; + FmgrInfo tsmnextblock; + FmgrInfo tsmnexttuple; + FmgrInfo tsmexaminetuple; + FmgrInfo tsmreset; + FmgrInfo tsmend; +} TableSampleDesc; + + +extern TableSampleDesc *tablesample_init(SampleScanState *scanstate, + TableSampleClause *tablesample); +extern HeapTuple tablesample_getnext(TableSampleDesc *desc); +extern void tablesample_reset(TableSampleDesc *desc); +extern void tablesample_end(TableSampleDesc *desc); +extern HeapTuple tablesample_source_getnext(TableSampleDesc *desc); +extern HeapTuple tablesample_source_gettup(TableSampleDesc *desc, ItemPointer tid, + bool *visible); + +extern Datum tsm_system_init(PG_FUNCTION_ARGS); +extern Datum tsm_system_nextblock(PG_FUNCTION_ARGS); +extern Datum tsm_system_nexttuple(PG_FUNCTION_ARGS); +extern Datum tsm_system_end(PG_FUNCTION_ARGS); +extern Datum tsm_system_reset(PG_FUNCTION_ARGS); +extern Datum tsm_system_cost(PG_FUNCTION_ARGS); + +extern Datum tsm_bernoulli_init(PG_FUNCTION_ARGS); +extern Datum tsm_bernoulli_nextblock(PG_FUNCTION_ARGS); +extern Datum tsm_bernoulli_nexttuple(PG_FUNCTION_ARGS); +extern Datum tsm_bernoulli_end(PG_FUNCTION_ARGS); +extern Datum tsm_bernoulli_reset(PG_FUNCTION_ARGS); +extern Datum tsm_bernoulli_cost(PG_FUNCTION_ARGS); + + +#endif |