* Helper function to push a tuple to the reorder queue. */
| 459 | * Helper function to push a tuple to the reorder queue. |
| 460 | */ |
| 461 | static void |
| 462 | reorderqueue_push(IndexScanState *node, TupleTableSlot *slot, |
| 463 | Datum *orderbyvals, bool *orderbynulls) |
| 464 | { |
| 465 | IndexScanDesc scandesc = node->iss_ScanDesc; |
| 466 | EState *estate = node->ss.ps.state; |
| 467 | MemoryContext oldContext = MemoryContextSwitchTo(estate->es_query_cxt); |
| 468 | ReorderTuple *rt; |
| 469 | int i; |
| 470 | |
| 471 | rt = (ReorderTuple *) palloc(sizeof(ReorderTuple)); |
| 472 | rt->htup = ExecCopySlotHeapTuple(slot); |
| 473 | rt->orderbyvals = |
| 474 | (Datum *) palloc(sizeof(Datum) * scandesc->numberOfOrderBys); |
| 475 | rt->orderbynulls = |
| 476 | (bool *) palloc(sizeof(bool) * scandesc->numberOfOrderBys); |
| 477 | for (i = 0; i < node->iss_NumOrderByKeys; i++) |
| 478 | { |
| 479 | if (!orderbynulls[i]) |
| 480 | rt->orderbyvals[i] = datumCopy(orderbyvals[i], |
| 481 | node->iss_OrderByTypByVals[i], |
| 482 | node->iss_OrderByTypLens[i]); |
| 483 | else |
| 484 | rt->orderbyvals[i] = (Datum) 0; |
| 485 | rt->orderbynulls[i] = orderbynulls[i]; |
| 486 | } |
| 487 | pairingheap_add(node->iss_ReorderQueue, &rt->ph_node); |
| 488 | |
| 489 | MemoryContextSwitchTo(oldContext); |
| 490 | } |
| 491 | |
| 492 | /* |
| 493 | * Helper function to pop the next tuple from the reorder queue. |
no test coverage detected