* ExecSetOp for hashed case: phase 2, retrieving groups from hash table */
| 422 | * ExecSetOp for hashed case: phase 2, retrieving groups from hash table |
| 423 | */ |
| 424 | static TupleTableSlot * |
| 425 | setop_retrieve_hash_table(SetOpState *setopstate) |
| 426 | { |
| 427 | TupleHashEntryData *entry; |
| 428 | TupleTableSlot *resultTupleSlot; |
| 429 | |
| 430 | /* |
| 431 | * get state info from node |
| 432 | */ |
| 433 | resultTupleSlot = setopstate->ps.ps_ResultTupleSlot; |
| 434 | |
| 435 | /* |
| 436 | * We loop retrieving groups until we find one we should return |
| 437 | */ |
| 438 | while (!setopstate->setop_done) |
| 439 | { |
| 440 | CHECK_FOR_INTERRUPTS(); |
| 441 | |
| 442 | /* |
| 443 | * Find the next entry in the hash table |
| 444 | */ |
| 445 | entry = ScanTupleHashTable(setopstate->hashtable, &setopstate->hashiter); |
| 446 | if (entry == NULL) |
| 447 | { |
| 448 | /* No more entries in hashtable, so done */ |
| 449 | setopstate->setop_done = true; |
| 450 | return NULL; |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * See if we should emit any copies of this tuple, and if so return |
| 455 | * the first copy. |
| 456 | */ |
| 457 | set_output_count(setopstate, (SetOpStatePerGroup) entry->additional); |
| 458 | |
| 459 | if (setopstate->numOutput > 0) |
| 460 | { |
| 461 | setopstate->numOutput--; |
| 462 | return ExecStoreMinimalTuple(entry->firstTuple, |
| 463 | resultTupleSlot, |
| 464 | false); |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | /* No more groups */ |
| 469 | ExecClearTuple(resultTupleSlot); |
| 470 | return NULL; |
| 471 | } |
| 472 | |
| 473 | /* ---------------------------------------------------------------- |
| 474 | * ExecInitSetOp |
no test coverage detected