---------------------------------------------------------------- * ExecInitFunctionScan * ---------------------------------------------------------------- */
| 358 | * ---------------------------------------------------------------- |
| 359 | */ |
| 360 | FunctionScanState * |
| 361 | ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags) |
| 362 | { |
| 363 | FunctionScanState *scanstate; |
| 364 | int nfuncs = list_length(node->functions); |
| 365 | TupleDesc scan_tupdesc; |
| 366 | int i, |
| 367 | natts; |
| 368 | ListCell *lc; |
| 369 | |
| 370 | /* check for unsupported flags */ |
| 371 | Assert(!(eflags & EXEC_FLAG_MARK)); |
| 372 | |
| 373 | /* |
| 374 | * FunctionScan should not have any children. |
| 375 | */ |
| 376 | Assert(outerPlan(node) == NULL); |
| 377 | Assert(innerPlan(node) == NULL); |
| 378 | |
| 379 | /* |
| 380 | * create new ScanState for node |
| 381 | */ |
| 382 | scanstate = makeNode(FunctionScanState); |
| 383 | scanstate->ss.ps.plan = (Plan *) node; |
| 384 | scanstate->ss.ps.state = estate; |
| 385 | scanstate->ss.ps.ExecProcNode = ExecFunctionScan; |
| 386 | scanstate->eflags = eflags; |
| 387 | scanstate->resultInTupleStore = node->resultInTupleStore; |
| 388 | scanstate->initplanId = node->initplanId; |
| 389 | scanstate->ts_state = NULL; |
| 390 | |
| 391 | /* |
| 392 | * are we adding an ordinality column? |
| 393 | */ |
| 394 | scanstate->ordinality = node->funcordinality; |
| 395 | |
| 396 | scanstate->nfuncs = nfuncs; |
| 397 | if (nfuncs == 1 && !node->funcordinality) |
| 398 | scanstate->simple = true; |
| 399 | else |
| 400 | scanstate->simple = false; |
| 401 | |
| 402 | /* |
| 403 | * Ordinal 0 represents the "before the first row" position. |
| 404 | * |
| 405 | * We need to track ordinal position even when not adding an ordinality |
| 406 | * column to the result, in order to handle backwards scanning properly |
| 407 | * with multiple functions with different result sizes. (We can't position |
| 408 | * any individual function's tuplestore any more than 1 place beyond its |
| 409 | * end, so when scanning backwards, we need to know when to start |
| 410 | * including the function in the scan again.) |
| 411 | */ |
| 412 | scanstate->ordinal = 0; |
| 413 | |
| 414 | /* |
| 415 | * Miscellaneous initialization |
| 416 | * |
| 417 | * create expression context for node |
no test coverage detected