Cursor
depot/lib/cursor.march Server-side cursor support for streaming large result sets.
PostgreSQL cursors allow fetching rows in batches, avoiding loading millions of rows into memory. Cursors MUST be used within a transaction.
IMPORTANT: declare_sql uses compile_inline (literal values embedded in SQL) because PostgreSQL DECLARE ... CURSOR FOR does not support $N parameters in this form.
SECURITY: Only use cursor queries with values you control. Do NOT pass arbitrary user input as filter values. Although string literals are single-quote-escaped, the inline path does not use $N bind parameters, so it offers weaker protection than compile_parameterized. Prefer building queries with parameterized execution (simple_query + compiled params) for any data that originates from user input.
Usage: match simple_query(conn, "BEGIN") do | Ok(_) -> let name = "my_cursor" match simple_query(conn, declare_sql(name, q)) do | Ok(_) -> fetch_loop(conn, name, 500) | Err(e) -> ... end | Err(e) -> ... end