* Get the next tuple from anytable * * will alloc memory in caller's memory context. * caller need to release the memory using pfree() */
| 497 | * caller need to release the memory using pfree() |
| 498 | */ |
| 499 | HeapTuple |
| 500 | AnyTable_GetNextTuple(AnyTable t) |
| 501 | { |
| 502 | MemoryContext oldcontext; |
| 503 | TupleTableSlot *slot; |
| 504 | |
| 505 | if (t == NULL) |
| 506 | { |
| 507 | ereport(ERROR, |
| 508 | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 509 | errmsg("invalid null value for anytable type"))); |
| 510 | } |
| 511 | |
| 512 | /* Fetch the next tuple into the tuple slot */ |
| 513 | oldcontext = MemoryContextSwitchTo(t->econtext->ecxt_per_query_memory); |
| 514 | t->econtext->ecxt_outertuple = ExecProcNode(t->subplan); |
| 515 | MemoryContextSwitchTo(oldcontext); |
| 516 | if (TupIsNull(t->econtext->ecxt_outertuple)) |
| 517 | { |
| 518 | return (HeapTuple) NULL; |
| 519 | } |
| 520 | |
| 521 | /* ---------------------------------------- |
| 522 | * 1) Fetch the tuple from the tuple slot |
| 523 | * 2) apply resjunk filtering |
| 524 | * 3) copy result into a HeapTuple |
| 525 | * ---------------------------------------- |
| 526 | */ |
| 527 | |
| 528 | slot = ExecFilterJunk(t->junkfilter, t->econtext->ecxt_outertuple); |
| 529 | return ExecCopySlotHeapTuple(slot); |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | * tf_set_userdata_internal |