lintel 0.2.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
lintel::db::Cursor Class Reference

#include <Cursor.h>

Classes

class  Iterator
 

Public Member Functions

 Cursor ()=default
 
Cursor & setFetchSize (std::size_t rows)
 
Cursor & setCursorName (const std::string &name)
 
Cursor & setNoScroll (bool enable)
 
std::vector< db::Arguments > fetchNext (std::size_t maxRows)
 
Iterator begin ()
 
Iterator end ()
 

Friends

class Statement
 

Detailed Description

Forward-only cursor over a query result.

Two modes controlled by fetchSize:

The cursor is single-pass: iterate it once with begin()/end(), or consume it with fetchNext(). The underlying Connection must outlive the cursor.

Configuration (setFetchSize / setCursorName / setNoScroll) must be called before the first call to begin() or fetchNext().

Constructor & Destructor Documentation

◆ Cursor()

lintel::db::Cursor::Cursor ( )
default

Default constructor, creates an exhausted cursor.

Member Function Documentation

◆ begin()

Iterator lintel::db::Cursor::begin ( )

Starts the stream and returns an iterator to the first row.

◆ end()

Iterator lintel::db::Cursor::end ( )
Returns
iterator marking the end of the stream

◆ fetchNext()

std::vector< db::Arguments > lintel::db::Cursor::fetchNext ( std::size_t  maxRows)

Fetches up to maxRows further rows from the stream.

Parameters
maxRowsmaximum number of rows to fetch (must be > 0)
Returns
the fetched rows; fewer rows than requested means the result set is exhausted

◆ setCursorName()

Cursor & lintel::db::Cursor::setCursorName ( const std::string &  name)

Sets the server-side cursor name. If empty (default), a unique name is auto-generated. Must be called before begin() or fetchNext().

◆ setFetchSize()

Cursor & lintel::db::Cursor::setFetchSize ( std::size_t  rows)

Sets the number of rows fetched per backend round-trip. 0 = client-side streaming (PQsetSingleRowMode on PG, no DECLARE CURSOR) >0 = server-side cursor (DECLARE/FETCH/CLOSE on PG, prefetch buffer on SQLite) Default: 100 (server-side). Must be called before begin() or fetchNext().

◆ setNoScroll()

Cursor & lintel::db::Cursor::setNoScroll ( bool  enable)

Sets the NO SCROLL flag on the server-side cursor. Default: true (NO SCROLL). Must be called before begin() or fetchNext().

Friends And Related Symbol Documentation

◆ Statement


The documentation for this class was generated from the following file: