* ExecSetOp for non-hashed case */
| 224 | * ExecSetOp for non-hashed case |
| 225 | */ |
| 226 | static TupleTableSlot * |
| 227 | setop_retrieve_direct(SetOpState *setopstate) |
| 228 | { |
| 229 | PlanState *outerPlan; |
| 230 | SetOpStatePerGroup pergroup; |
| 231 | TupleTableSlot *outerslot; |
| 232 | TupleTableSlot *resultTupleSlot; |
| 233 | ExprContext *econtext = setopstate->ps.ps_ExprContext; |
| 234 | |
| 235 | /* |
| 236 | * get state info from node |
| 237 | */ |
| 238 | outerPlan = outerPlanState(setopstate); |
| 239 | pergroup = (SetOpStatePerGroup) setopstate->pergroup; |
| 240 | resultTupleSlot = setopstate->ps.ps_ResultTupleSlot; |
| 241 | |
| 242 | /* |
| 243 | * We loop retrieving groups until we find one we should return |
| 244 | */ |
| 245 | while (!setopstate->setop_done) |
| 246 | { |
| 247 | /* |
| 248 | * If we don't already have the first tuple of the new group, fetch it |
| 249 | * from the outer plan. |
| 250 | */ |
| 251 | if (setopstate->grp_firstTuple == NULL) |
| 252 | { |
| 253 | outerslot = ExecProcNode(outerPlan); |
| 254 | if (!TupIsNull(outerslot)) |
| 255 | { |
| 256 | /* Make a copy of the first input tuple */ |
| 257 | setopstate->grp_firstTuple = ExecCopySlotHeapTuple(outerslot); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | /* outer plan produced no tuples at all */ |
| 262 | setopstate->setop_done = true; |
| 263 | return NULL; |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | /* |
| 268 | * Store the copied first input tuple in the tuple table slot reserved |
| 269 | * for it. The tuple will be deleted when it is cleared from the |
| 270 | * slot. |
| 271 | */ |
| 272 | ExecStoreHeapTuple(setopstate->grp_firstTuple, |
| 273 | resultTupleSlot, |
| 274 | true); |
| 275 | setopstate->grp_firstTuple = NULL; /* don't keep two pointers */ |
| 276 | |
| 277 | /* Initialize working state for a new input tuple group */ |
| 278 | initialize_counts(pergroup); |
| 279 | |
| 280 | /* Count the first input tuple */ |
| 281 | advance_counts(pergroup, |
| 282 | fetch_tuple_flag(setopstate, resultTupleSlot)); |
| 283 |
no test coverage detected