TestCursorSimpleQuery exercises the simple-query-protocol cursor path against Duckgres.
(t *testing.T)
| 189 | // TestCursorSimpleQuery exercises the simple-query-protocol cursor path |
| 190 | // against Duckgres. |
| 191 | func TestCursorSimpleQuery(t *testing.T) { |
| 192 | db := testHarness.DuckgresDB |
| 193 | |
| 194 | t.Run("lifecycle_fetch_close", func(t *testing.T) { cursorLifecycleFlow(t, db) }) |
| 195 | t.Run("move_advances_position", func(t *testing.T) { cursorMoveFlow(t, db) }) |
| 196 | t.Run("backward_fetch_rejected", func(t *testing.T) { cursorBackwardFlow(t, db) }) |
| 197 | t.Run("missing_cursor_errors", func(t *testing.T) { cursorMissingFlow(t, db) }) |
| 198 | |
| 199 | t.Run("redeclare_replaces_cursor", func(t *testing.T) { |
| 200 | tx := beginCursorTx(t, db) |
| 201 | |
| 202 | mustExecTx(t, tx, "DECLARE cur_redeclare CURSOR FOR SELECT id, name FROM users ORDER BY id") |
| 203 | assertCursorRows(t, "FETCH 2", fetchCursorRows(t, tx, "FETCH 2 FROM cur_redeclare"), cursorUsers(1, 2)) |
| 204 | |
| 205 | // Re-DECLARE with the same name replaces the cursor: the next FETCH |
| 206 | // reads the new query from the start. Deliberate divergence: real |
| 207 | // PostgreSQL raises 42P03 duplicate_cursor here. |
| 208 | mustExecTx(t, tx, "DECLARE cur_redeclare CURSOR FOR SELECT id, name FROM users WHERE id >= 9 ORDER BY id") |
| 209 | assertCursorRows(t, "FETCH ALL after re-DECLARE", fetchCursorRows(t, tx, "FETCH ALL FROM cur_redeclare"), cursorUsers(9, 10)) |
| 210 | |
| 211 | mustExecTx(t, tx, "CLOSE cur_redeclare") |
| 212 | }) |
| 213 | } |
| 214 | |
| 215 | // TestCursorPostgresParity runs the shared cursor flows against the |
| 216 | // comparison PostgreSQL 16 instance, keeping the expectations in the flows |
nothing calls this directly
no test coverage detected