PostgreSQL Source Code: src/backend/executor/nodeFunctionscan.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
30
31
32
33
34
36{
44
46
47
48
49
50
51
52
53
54
55
56
57
60{
64 bool alldone;
66 int funcno;
67 int att;
68
69
70
71
75
77 {
78
79
80
81
82
83
85
86
87
88
89
90
91 if (tstore == NULL)
92 {
99
100
101
102
103
104
106 }
107
108
109
110
113 false,
114 scanslot);
115 return scanslot;
116 }
117
118
119
120
121
122
123
127 else
129
130
131
132
133
134
135
136
138 att = 0;
139 alldone = true;
140 for (funcno = 0; funcno < node->nfuncs; funcno++)
141 {
143 int i;
144
145
146
147
148
149
150 if (fs->tstore == NULL)
151 {
158
159
160
161
162
163
165 }
166
167
168
169
170
171
172
173
176 else
179 false,
181
183 {
184
185
186
187
188
189
190
193
194
195
196
198 {
201 att++;
202 }
203 }
204 else
205 {
206
207
208
210
212 {
215 att++;
216 }
217
218
219
220
221
222 alldone = false;
223 }
224 }
225
226
227
228
230 {
233 }
234
235
236
237
238
239 if (!alldone)
241
242 return scanslot;
243}
244
245
246
247
248static bool
250{
251
252 return true;
253}
254
255
256
257
258
259
260
261
262
263
266{
268
272}
273
274
275
276
277
280{
284 int i,
285 natts;
287
288
290
291
292
293
296
297
298
299
304 scanstate->eflags = eflags;
305
306
307
308
310
311 scanstate->nfuncs = nfuncs;
313 scanstate->simple = true;
314 else
315 scanstate->simple = false;
316
317
318
319
320
321
322
323
324
325
326
328
329
330
331
332
333
335
337
338 natts = 0;
339 i = 0;
341 {
344 int colcount = rtfunc->funccolcount;
347
352
353
354
355
356
357
360
361
362
363
364
365
366
367
368
369
370
371
372
373 if (rtfunc->funccolnames != NIL)
374 {
376 rtfunc->funccoltypes,
377 rtfunc->funccoltypmods,
378 rtfunc->funccolcollations);
379
380
381
382
383
384
386 }
387 else
388 {
390 Oid funcrettype;
391
393 &funcrettype,
394 &tupdesc);
395
398 {
399
401
403 }
405 {
406
410 NULL,
411 funcrettype,
412 -1,
413 0);
417 }
418 else
419 {
420
421 elog(ERROR, "function in FROM has unsupported return type");
422 }
423 }
424
427
428
429
430
431
432
433 if (!scanstate->simple)
434 {
437 }
438 else
440
441 natts += colcount;
442 i++;
443 }
444
445
446
447
448
449
450
451
452 if (scanstate->simple)
453 {
455 scan_tupdesc->tdtypeid = RECORDOID;
457 }
458 else
459 {
461
463 natts++;
464
466
467 for (i = 0; i < nfuncs; i++)
468 {
471 int j;
472
473 for (j = 1; j <= colcount; j++)
475 }
476
477
479 {
481 ++attno,
482 NULL,
483 INT8OID,
484 -1,
485 0);
486 }
487
488 Assert(attno == natts);
489 }
490
491
492
493
496
497
498
499
502
503
504
505
508
509
510
511
512
513
514
515
517 "Table function arguments",
519
520 return scanstate;
521}
522
523
524
525
526
527
528
529void
531{
532 int i;
533
534
535
536
537 for (i = 0; i < node->nfuncs; i++)
538 {
540
541 if (fs->tstore != NULL)
542 {
545 }
546 }
547}
548
549
550
551
552
553
554
555void
557{
559 int i;
561
564 for (i = 0; i < node->nfuncs; i++)
565 {
567
570 }
571
573
574
575
576
577
578
579
580
581
582 if (chgparam)
583 {
585
586 i = 0;
588 {
590
591 if (bms_overlap(chgparam, rtfunc->funcparams))
592 {
594 {
597 }
599 }
600 i++;
601 }
602 }
603
604
606
607
608 for (i = 0; i < node->nfuncs; i++)
609 {
612 }
613}
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
ExprState * ExecInitQual(List *qual, PlanState *parent)
Tuplestorestate * ExecMakeTableFunctionResult(SetExprState *setexpr, ExprContext *econtext, MemoryContext argContext, TupleDesc expectedDesc, bool randomAccess)
SetExprState * ExecInitTableFunctionResult(Expr *expr, ExprContext *econtext, PlanState *parent)
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
void ExecAssignScanProjectionInfo(ScanState *node)
void ExecScanReScan(ScanState *node)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTypeTL(PlanState *planstate)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps TTSOpsMinimalTuple
void ExecAssignExprContext(EState *estate, PlanState *planstate)
#define EXEC_FLAG_BACKWARD
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
TypeFuncClass get_expr_result_type(Node *expr, Oid *resultTypeId, TupleDesc *resultTupleDesc)
@ TYPEFUNC_COMPOSITE_DOMAIN
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
MemoryContext CurrentMemoryContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
Oid exprCollation(const Node *expr)
static TupleTableSlot * ExecFunctionScan(PlanState *pstate)
FunctionScanState * ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags)
static TupleTableSlot * FunctionNext(FunctionScanState *node)
struct FunctionScanPerFuncState FunctionScanPerFuncState
void ExecReScanFunctionScan(FunctionScanState *node)
void ExecEndFunctionScan(FunctionScanState *node)
static bool FunctionRecheck(FunctionScanState *node, TupleTableSlot *slot)
#define castNode(_type_, nodeptr)
static int list_length(const List *l)
#define Int64GetDatumFast(X)
#define ScanDirectionIsForward(direction)
ScanDirection es_direction
TupleTableSlot * func_slot
struct FunctionScanPerFuncState * funcstates
ExprContext * ps_ExprContext
TupleTableSlot * ps_ResultTupleSlot
ExecProcNodeMtd ExecProcNode
TupleTableSlot * ss_ScanTupleSlot
TupleDesc CreateTemplateTupleDesc(int natts)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
TupleDesc BuildDescFromLists(const List *names, const List *types, const List *typmods, const List *collations)
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
void TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno, TupleDesc src, AttrNumber srcAttno)
bool tuplestore_gettupleslot(Tuplestorestate *state, bool forward, bool copy, TupleTableSlot *slot)
void tuplestore_rescan(Tuplestorestate *state)
void tuplestore_end(Tuplestorestate *state)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static void slot_getallattrs(TupleTableSlot *slot)