PostgreSQL Source Code: src/backend/executor/nodeTableFuncscan.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
24
35
38
42
43
44
45
46
47
48
49
50
51
52
55{
57
59
60
61
62
63
66
67
68
69
71 true,
72 false,
73 scanslot);
74 return scanslot;
75}
76
77
78
79
80static bool
82{
83
84 return true;
85}
86
87
88
89
90
91
92
93
94
95
98{
100
104}
105
106
107
108
109
112{
116 int i;
117
118
120
121
122
123
126
127
128
129
134
135
136
137
138
139
141
142
143
144
146 tf->coltypes,
147 tf->coltypmods,
148 tf->colcollations);
149
152
153
154
155
158
159
160
161
164
165
168
171 "TableFunc per value context",
173 scanstate->opaque = NULL;
174
175 scanstate->ns_names = tf->ns_names;
176
191
192 scanstate->notnulls = tf->notnulls;
193
194
197
198
199
200
201 for (i = 0; i < tupdesc->natts; i++)
202 {
203 Oid in_funcid;
204
208 }
209
210 return scanstate;
211}
212
213
214
215
216
217
218
219void
221{
222
223
224
228}
229
230
231
232
233
234
235
236void
238{
240
244
245
246
247
248 if (chgparam)
249 {
251 {
254 }
255 }
256
259}
260
261
262
263
264
265
266
267static void
269{
273 bool isnull;
274
276
277
280
281
282
283
284
285
286
287
288
289
291
293 {
296
297
298
299
300
302
303 if (!isnull)
304 {
305
307
308
310
311
313 }
314 }
316 {
317 if (tstate->opaque != NULL)
320 }
322
323
324
325 if (tstate->opaque != NULL)
326 {
328 tstate->opaque = NULL;
329 }
330
333}
334
335
336
337
338
339static void
341{
345 *lc2;
346 bool isnull;
347 int colno;
349 int ordinalitycol =
351
352
353
354
355
357
358
360 {
363 char *ns_uri;
364 char *ns_name;
365
367 if (isnull)
369 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
370 errmsg("namespace URI must not be null")));
372
373
374 ns_name = ns_node ? strVal(ns_node) : NULL;
375
376 routine->SetNamespace(tstate, ns_name, ns_uri);
377 }
378
379
380
381
382
384 {
386 if (isnull)
388 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
389 errmsg("row filter expression must not be null")));
390
392 }
393
394
395
396
397
398
399 colno = 0;
401 foreach(lc1, tstate->colexprs)
402 {
403 char *colfilter;
405
406 if (colno != ordinalitycol)
407 {
409
410 if (colexpr != NULL)
411 {
413 if (isnull)
415 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
416 errmsg("column filter expression must not be null"),
417 errdetail("Filter for column \"%s\" is null.",
418 NameStr(att->attname))));
420 }
421 else
422 colfilter = NameStr(att->attname);
423
425 }
426
427 colno++;
428 }
429}
430
431
432
433
434static void
436{
442 int natts = tupdesc->natts;
444 int ordinalitycol;
445
446 ordinalitycol =
448
449
450
451
452
453
454
456
457
458
459
460 while (routine->FetchRow(tstate))
461 {
463 int colno;
464
466
468
469
470
471
472
473 for (colno = 0; colno < natts; colno++)
474 {
476
477 if (colno == ordinalitycol)
478 {
479
481 nulls[colno] = false;
482 }
483 else
484 {
485 bool isnull;
486
488 colno,
489 att->atttypid,
490 att->atttypmod,
491 &isnull);
492
493
494 if (isnull && cell != NULL)
495 {
497
498 if (coldefexpr != NULL)
500 &isnull);
501 }
502
503
506 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
507 errmsg("null is not allowed in column \"%s\"",
508 NameStr(att->attname))));
509
510 nulls[colno] = isnull;
511 }
512
513
514 if (cell != NULL)
516 }
517
519
521 }
522
524}
bool bms_is_member(int x, const Bitmapset *a)
static Datum values[MAXATTR]
#define TextDatumGetCString(d)
int errdetail(const char *fmt,...)
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)
const TupleTableSlotOps TTSOpsMinimalTuple
void ExecAssignExprContext(EState *estate, PlanState *planstate)
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Assert(PointerIsAligned(start, uint64))
const TableFuncRoutine JsonbTableRoutine
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
void MemoryContextReset(MemoryContext context)
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define CHECK_FOR_INTERRUPTS()
void ExecReScanTableFuncScan(TableFuncScanState *node)
void ExecEndTableFuncScan(TableFuncScanState *node)
static bool TableFuncRecheck(TableFuncScanState *node, TupleTableSlot *slot)
static void tfuncInitialize(TableFuncScanState *tstate, ExprContext *econtext, Datum doc)
TableFuncScanState * ExecInitTableFuncScan(TableFuncScan *node, EState *estate, int eflags)
static void tfuncLoadRows(TableFuncScanState *tstate, ExprContext *econtext)
static void tfuncFetchRows(TableFuncScanState *tstate, ExprContext *econtext)
static TupleTableSlot * ExecTableFuncScan(PlanState *pstate)
static TupleTableSlot * TableFuncNext(TableFuncScanState *node)
#define castNode(_type_, nodeptr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
#define forboth(cell1, list1, cell2, list2)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static Datum Int32GetDatum(int32 X)
MemoryContext ecxt_per_tuple_memory
MemoryContext ecxt_per_query_memory
ExprContext * ps_ExprContext
TupleTableSlot * ps_ResultTupleSlot
ExecProcNodeMtd ExecProcNode
TupleTableSlot * ss_ScanTupleSlot
void(* SetRowFilter)(struct TableFuncScanState *state, const char *path)
bool(* FetchRow)(struct TableFuncScanState *state)
void(* SetNamespace)(struct TableFuncScanState *state, const char *name, const char *uri)
Datum(* GetValue)(struct TableFuncScanState *state, int colnum, Oid typid, int32 typmod, bool *isnull)
void(* InitOpaque)(struct TableFuncScanState *state, int natts)
void(* SetColumnFilter)(struct TableFuncScanState *state, const char *path, int colnum)
void(* SetDocument)(struct TableFuncScanState *state, Datum value)
void(* DestroyOpaque)(struct TableFuncScanState *state)
MemoryContext perTableCxt
Tuplestorestate * tupstore
const struct TableFuncRoutine * routine
TupleDesc tts_tupleDescriptor
TupleDesc BuildDescFromLists(const List *names, const List *types, const List *typmods, const List *collations)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward, bool copy, TupleTableSlot *slot)
void tuplestore_rescan(Tuplestorestate *state)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
void tuplestore_end(Tuplestorestate *state)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
const TableFuncRoutine XmlTableRoutine