* We've completed processing a tuple group. Decide how many copies (if any) * of its representative row to emit, and store the count into numOutput. * This logic is straight from the SQL92 specification. */
| 147 | * This logic is straight from the SQL92 specification. |
| 148 | */ |
| 149 | static void |
| 150 | set_output_count(SetOpState *setopstate, SetOpStatePerGroup pergroup) |
| 151 | { |
| 152 | SetOp *plannode = (SetOp *) setopstate->ps.plan; |
| 153 | |
| 154 | switch (plannode->cmd) |
| 155 | { |
| 156 | case SETOPCMD_INTERSECT: |
| 157 | if (pergroup->numLeft > 0 && pergroup->numRight > 0) |
| 158 | setopstate->numOutput = 1; |
| 159 | else |
| 160 | setopstate->numOutput = 0; |
| 161 | break; |
| 162 | case SETOPCMD_INTERSECT_ALL: |
| 163 | setopstate->numOutput = |
| 164 | (pergroup->numLeft < pergroup->numRight) ? |
| 165 | pergroup->numLeft : pergroup->numRight; |
| 166 | break; |
| 167 | case SETOPCMD_EXCEPT: |
| 168 | if (pergroup->numLeft > 0 && pergroup->numRight == 0) |
| 169 | setopstate->numOutput = 1; |
| 170 | else |
| 171 | setopstate->numOutput = 0; |
| 172 | break; |
| 173 | case SETOPCMD_EXCEPT_ALL: |
| 174 | setopstate->numOutput = |
| 175 | (pergroup->numLeft < pergroup->numRight) ? |
| 176 | 0 : (pergroup->numLeft - pergroup->numRight); |
| 177 | break; |
| 178 | default: |
| 179 | elog(ERROR, "unrecognized set op: %d", (int) plannode->cmd); |
| 180 | break; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /* ---------------------------------------------------------------- |
no outgoing calls
no test coverage detected