---------------------------------------------------------------- * ExecInitSort * * Creates the run-time state information for the sort node * produced by the planner and initializes its outer subtree. * ---------------------------------------------------------------- */
| 202 | * ---------------------------------------------------------------- |
| 203 | */ |
| 204 | SortState * |
| 205 | ExecInitSort(Sort *node, EState *estate, int eflags) |
| 206 | { |
| 207 | SortState *sortstate; |
| 208 | |
| 209 | SO1_printf("ExecInitSort: %s\n", |
| 210 | "initializing sort node"); |
| 211 | |
| 212 | /* |
| 213 | * GPDB |
| 214 | */ |
| 215 | #ifdef FAULT_INJECTOR |
| 216 | if (SIMPLE_FAULT_INJECTOR("rg_qmem_qd_qe") == FaultInjectorTypeSkip) |
| 217 | { |
| 218 | elog(NOTICE, "op_mem=%d", (int) (((Plan *) node)->operatorMemKB)); |
| 219 | } |
| 220 | #endif |
| 221 | |
| 222 | /* |
| 223 | * create state structure |
| 224 | */ |
| 225 | sortstate = makeNode(SortState); |
| 226 | sortstate->ss.ps.plan = (Plan *) node; |
| 227 | sortstate->ss.ps.state = estate; |
| 228 | sortstate->ss.ps.ExecProcNode = ExecSort; |
| 229 | |
| 230 | /* |
| 231 | * We must have random access to the sort output to do backward scan or |
| 232 | * mark/restore. We also prefer to materialize the sort output if we |
| 233 | * might be called on to rewind and replay it many times. |
| 234 | */ |
| 235 | sortstate->randomAccess = (eflags & (EXEC_FLAG_REWIND | |
| 236 | EXEC_FLAG_BACKWARD | |
| 237 | EXEC_FLAG_MARK)) != 0; |
| 238 | |
| 239 | sortstate->bounded = false; |
| 240 | sortstate->sort_Done = false; |
| 241 | sortstate->tuplesortstate = NULL; |
| 242 | |
| 243 | /* CDB */ |
| 244 | |
| 245 | /* BUT: |
| 246 | * The LIMIT optimizations requires exprcontext in which to |
| 247 | * evaluate the limit/offset parameters. |
| 248 | */ |
| 249 | ExecAssignExprContext(estate, &sortstate->ss.ps); |
| 250 | |
| 251 | /* |
| 252 | * Miscellaneous initialization |
| 253 | * |
| 254 | * Sort nodes don't initialize their ExprContexts because they never call |
| 255 | * ExecQual or ExecProject. |
| 256 | */ |
| 257 | |
| 258 | /* |
| 259 | * CDB: Offer extra info for EXPLAIN ANALYZE. |
| 260 | */ |
| 261 | if (estate->es_instrument && (estate->es_instrument & INSTRUMENT_CDB)) |
no test coverage detected