MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestCursorSimpleQuery

Function TestCursorSimpleQuery

tests/integration/cursor_test.go:191–213  ·  view source on GitHub ↗

TestCursorSimpleQuery exercises the simple-query-protocol cursor path against Duckgres.

(t *testing.T)

Source from the content-addressed store, hash-verified

189// TestCursorSimpleQuery exercises the simple-query-protocol cursor path
190// against Duckgres.
191func 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

Callers

nothing calls this directly

Calls 10

cursorLifecycleFlowFunction · 0.85
cursorMoveFlowFunction · 0.85
cursorBackwardFlowFunction · 0.85
cursorMissingFlowFunction · 0.85
beginCursorTxFunction · 0.85
mustExecTxFunction · 0.85
assertCursorRowsFunction · 0.85
fetchCursorRowsFunction · 0.85
cursorUsersFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected