TestQuerySourceMixedBatchSetThenShow is the regression for the e2e bug: a single simple query batching `SET duckgres.query_source='endpoints'; SHOW duckgres.query_source` must run BOTH statements in order — the SET (session-side) then the SHOW returning the just-set value. Previously the whole-batch
(t *testing.T)
| 129 | ctx: context.Background(), |
| 130 | cancel: func() {}, |
| 131 | txStatus: txStatusIdle, |
| 132 | executor: exec, |
| 133 | } |
| 134 | return c, &out |
| 135 | } |
| 136 | |
| 137 | // selectOneExecutor answers any QueryContext with a single-row RowSet, so a |
| 138 | // SELECT in a batch alongside the query_source GUC actually executes. |
| 139 | type selectOneExecutor struct { |
| 140 | noopProfiling |
| 141 | queryCalls int |
| 142 | } |
| 143 | |
| 144 | func (e *selectOneExecutor) QueryContext(context.Context, string, ...any) (RowSet, error) { |
| 145 | e.queryCalls++ |
| 146 | return &staticCountRowSet{count: 1}, nil |
| 147 | } |
| 148 | func (e *selectOneExecutor) ExecContext(context.Context, string, ...any) (ExecResult, error) { |
| 149 | return &fakeExecResult{}, nil |
| 150 | } |
| 151 | func (e *selectOneExecutor) Query(string, ...any) (RowSet, error) { |
| 152 | return nil, errors.New("not implemented") |
| 153 | } |
| 154 | func (e *selectOneExecutor) Exec(string, ...any) (ExecResult, error) { |
| 155 | return nil, errors.New("not implemented") |
| 156 | } |
| 157 | func (e *selectOneExecutor) ConnContext(context.Context) (RawConn, error) { |
| 158 | return nil, errors.New("not implemented") |
| 159 | } |
| 160 | func (e *selectOneExecutor) PingContext(context.Context) error { return nil } |
| 161 | func (e *selectOneExecutor) Close() error { return nil } |
| 162 | |
| 163 | // TestQuerySourceMixedBatchSetThenShow is the regression for the e2e bug: a |
| 164 | // single simple query batching `SET duckgres.query_source='endpoints'; SHOW |
| 165 | // duckgres.query_source` must run BOTH statements in order — the SET |
| 166 | // (session-side) then the SHOW returning the just-set value. Previously the |
| 167 | // whole-batch transpile surfaced QuerySourceSet on the first statement and |
| 168 | // returned early, swallowing the trailing SHOW so it never emitted `endpoints`. |
| 169 | func TestQuerySourceMixedBatchSetThenShow(t *testing.T) { |
| 170 | c, out := newBufferedConn(&selectOneExecutor{}) |
| 171 | |
| 172 | if err := c.handleQuery([]byte("SET duckgres.query_source = 'endpoints'; SHOW duckgres.query_source\x00")); err != nil { |
| 173 | t.Fatalf("handleQuery: %v", err) |
| 174 | } |
| 175 | |
| 176 | msgs := parseWireMsgs(t, out.Bytes()) |
| 177 | |
| 178 | // Expect: CommandComplete(SET), RowDescription, DataRow(endpoints), |
| 179 | // CommandComplete(SHOW), ReadyForQuery — in that order. |
| 180 | var sawSetComplete, sawShowRow, sawShowComplete bool |
nothing calls this directly
no test coverage detected