* ExecHashTableExplainInit * Called after ExecHashTableCreate to set up EXPLAIN ANALYZE reporting. */
| 2545 | * Called after ExecHashTableCreate to set up EXPLAIN ANALYZE reporting. |
| 2546 | */ |
| 2547 | void |
| 2548 | ExecHashTableExplainInit(HashState *hashState, HashJoinState *hjstate, |
| 2549 | HashJoinTable hashtable) |
| 2550 | { |
| 2551 | MemoryContext oldcxt; |
| 2552 | int nbatch = Max(hashtable->nbatch, 1); |
| 2553 | |
| 2554 | /* Switch to a memory context that survives until ExecutorEnd. */ |
| 2555 | oldcxt = MemoryContextSwitchTo(hjstate->js.ps.state->es_query_cxt); |
| 2556 | |
| 2557 | /* Request a callback at end of query. */ |
| 2558 | hjstate->js.ps.cdbexplainfun = ExecHashTableExplainEnd; |
| 2559 | |
| 2560 | /* Create workarea and attach it to the HashJoinTable. */ |
| 2561 | hashtable->stats = (HashJoinTableStats *)palloc0(sizeof(*hashtable->stats)); |
| 2562 | hashtable->stats->endedbatch = -1; |
| 2563 | |
| 2564 | /* Create per-batch statistics array. */ |
| 2565 | hashtable->stats->batchstats = |
| 2566 | (HashJoinBatchStats *)palloc0(nbatch * sizeof(hashtable->stats->batchstats[0])); |
| 2567 | hashtable->stats->nbatchstats = nbatch; |
| 2568 | |
| 2569 | /* Restore caller's memory context. */ |
| 2570 | MemoryContextSwitchTo(oldcxt); |
| 2571 | } /* ExecHashTableExplainInit */ |
| 2572 | |
| 2573 | |
| 2574 | /* |
no test coverage detected