PostgreSQL Source Code: src/backend/executor/nodeSamplescan.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
23#include "utils/fmgrprotos.h"
25
29
30
31
32
33
34
35
36
37
38
39
40
43{
44
45
46
49
50
51
52
54}
55
56
57
58
59static bool
61{
62
63
64
65
66 return true;
67}
68
69
70
71
72
73
74
75
76
77
80{
82
86}
87
88
89
90
91
94{
98
101
102
103
104
109
110
111
112
113
114
116
117
118
119
123 eflags);
124
125
127
128
132
133
134
135
138
139
140
141
144
148
149
150
151
152
155
156
157
158
162
165
166
167 scanstate->begun = false;
168
169 return scanstate;
170}
171
172
173
174
175
176
177
178void
180{
181
182
183
186
187
188
189
192}
193
194
195
196
197
198
199
200
201void
203{
204
205 node->begun = false;
206 node->done = false;
209
211}
212
213
214
215
216
217static void
219{
224 bool isnull;
226 bool allow_sync;
227 int i;
229
232
233 i = 0;
234 foreach(arg, scanstate->args)
235 {
237
239 econtext,
240 &isnull);
241 if (isnull)
243 (errcode(ERRCODE_INVALID_TABLESAMPLE_ARGUMENT),
244 errmsg("TABLESAMPLE parameter cannot be null")));
245 i++;
246 }
247
249 {
251 econtext,
252 &isnull);
253 if (isnull)
255 (errcode(ERRCODE_INVALID_TABLESAMPLE_REPEAT),
256 errmsg("TABLESAMPLE REPEATABLE parameter cannot be null")));
257
258
259
260
261
262
263
264
265
266
267
268
269
271 }
272 else
273 {
274
275 seed = scanstate->seed;
276 }
277
278
281
282
284 params,
286 seed);
287
288
290
291
293 {
297 0, NULL,
299 allow_sync,
301 }
302 else
303 {
306 allow_sync,
308 }
309
311
312
313 scanstate->begun = true;
314}
315
316
317
318
321{
324
326
327 if (scanstate->done)
328 return NULL;
329
330 for (;;)
331 {
333 {
335 {
337 scanstate->done = true;
338
339
340 return NULL;
341 }
342
344 }
345
347 {
348
349
350
351
353 continue;
354 }
355
356
357 break;
358 }
359
361
362 return slot;
363}
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
ExprState * ExecInitQual(List *qual, PlanState *parent)
List * ExecInitExprList(List *nodes, PlanState *parent)
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
void ExecAssignScanProjectionInfo(ScanState *node)
void ExecScanReScan(ScanState *node)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTypeTL(PlanState *planstate)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
#define DirectFunctionCall1(func, arg1)
Assert(PointerIsAligned(start, uint64))
Datum hashfloat8(PG_FUNCTION_ARGS)
void pfree(void *pointer)
static void tablesample_init(SampleScanState *scanstate)
SampleScanState * ExecInitSampleScan(SampleScan *node, EState *estate, int eflags)
void ExecReScanSampleScan(SampleScanState *node)
void ExecEndSampleScan(SampleScanState *node)
static TupleTableSlot * ExecSampleScan(PlanState *pstate)
static TupleTableSlot * SampleNext(SampleScanState *node)
static bool SampleRecheck(SampleScanState *node, TupleTableSlot *slot)
static TupleTableSlot * tablesample_getnext(SampleScanState *scanstate)
#define castNode(_type_, nodeptr)
static int list_length(const List *l)
uint32 pg_prng_uint32(pg_prng_state *state)
pg_prng_state pg_global_prng_state
static uint32 DatumGetUInt32(Datum X)
#define RelationGetDescr(relation)
ExprContext * ps_ExprContext
ExecProcNodeMtd ExecProcNode
struct TsmRoutine * tsmroutine
struct TableSampleClause * tablesample
Relation ss_currentRelation
TupleTableSlot * ss_ScanTupleSlot
struct TableScanDescData * ss_currentScanDesc
EndSampleScan_function EndSampleScan
BeginSampleScan_function BeginSampleScan
NextSampleBlock_function NextSampleBlock
InitSampleScan_function InitSampleScan
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
static void table_endscan(TableScanDesc scan)
static TableScanDesc table_beginscan_sampling(Relation rel, Snapshot snapshot, int nkeys, struct ScanKeyData *key, bool allow_strat, bool allow_sync, bool allow_pagemode)
static void table_rescan_set_params(TableScanDesc scan, struct ScanKeyData *key, bool allow_strat, bool allow_sync, bool allow_pagemode)
static bool table_scan_sample_next_block(TableScanDesc scan, struct SampleScanState *scanstate)
static bool table_scan_sample_next_tuple(TableScanDesc scan, struct SampleScanState *scanstate, TupleTableSlot *slot)
TsmRoutine * GetTsmRoutine(Oid tsmhandler)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)