cursorMissingFlow covers FETCH/CLOSE on a cursor that was never declared. Each statement gets its own transaction because the error aborts the transaction on real PostgreSQL.
(t *testing.T, db *sql.DB)
| 167 | // Each statement gets its own transaction because the error aborts the |
| 168 | // transaction on real PostgreSQL. |
| 169 | func cursorMissingFlow(t *testing.T, db *sql.DB) { |
| 170 | tx := beginCursorTx(t, db) |
| 171 | rows, err := tx.Query("FETCH 1 FROM cur_never_declared") |
| 172 | if err == nil { |
| 173 | _ = rows.Close() |
| 174 | t.Fatal("FETCH from undeclared cursor succeeded, want error") |
| 175 | } |
| 176 | if !strings.Contains(err.Error(), `cursor "cur_never_declared" does not exist`) { |
| 177 | t.Errorf("FETCH from undeclared cursor: error = %q", err) |
| 178 | } |
| 179 | _ = tx.Rollback() |
| 180 | |
| 181 | tx2 := beginCursorTx(t, db) |
| 182 | if _, err := tx2.Exec("CLOSE cur_never_declared"); err == nil { |
| 183 | t.Fatal("CLOSE of undeclared cursor succeeded, want error") |
| 184 | } else if !strings.Contains(err.Error(), `cursor "cur_never_declared" does not exist`) { |
| 185 | t.Errorf("CLOSE of undeclared cursor: error = %q", err) |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | // TestCursorSimpleQuery exercises the simple-query-protocol cursor path |
| 190 | // against Duckgres. |