| 49 | } |
| 50 | |
| 51 | Status CardinalityCheckNode::Open(RuntimeState* state) { |
| 52 | SCOPED_TIMER(runtime_profile_->total_time_counter()); |
| 53 | ScopedOpenEventAdder ea(this); |
| 54 | RETURN_IF_ERROR(ExecNode::Open(state)); |
| 55 | RETURN_IF_ERROR(child(0)->Open(state)); |
| 56 | row_batch_.reset(new RowBatch(row_desc(), 1, mem_tracker())); |
| 57 | |
| 58 | // Read rows from the child, raise error if there are more rows than one |
| 59 | RowBatch child_batch(child(0)->row_desc(), state->batch_size(), mem_tracker()); |
| 60 | bool child_eos = false; |
| 61 | int rows_collected = 0; |
| 62 | do { |
| 63 | RETURN_IF_CANCELLED(state); |
| 64 | RETURN_IF_ERROR(QueryMaintenance(state)); |
| 65 | RETURN_IF_ERROR(child(0)->GetNext(state, &child_batch, &child_eos)); |
| 66 | |
| 67 | rows_collected += child_batch.num_rows(); |
| 68 | if (rows_collected > 1) { |
| 69 | return Status(Substitute("Subquery must not return more than one row: $0", |
| 70 | display_statement_)); |
| 71 | } |
| 72 | if (child_batch.num_rows() != 0) child_batch.DeepCopyTo(row_batch_.get()); |
| 73 | child_batch.Reset(); |
| 74 | } while (!child_eos); |
| 75 | |
| 76 | DCHECK(rows_collected == 0 || rows_collected == 1); |
| 77 | |
| 78 | // If we are inside a subplan we can expect a call to Open()/GetNext() |
| 79 | // on the child again. |
| 80 | if (!IsInSubplan()) child(0)->Close(state); |
| 81 | return Status::OK(); |
| 82 | } |
| 83 | |
| 84 | Status CardinalityCheckNode::GetNext( |
| 85 | RuntimeState* state, RowBatch* output_row_batch, bool* eos) { |
nothing calls this directly
no test coverage detected