Cursor with SQL positioning semantics. More...
#include <cursor.hxx>
Public Types | |
enum | accesspolicy { forward_only, random_access } |
Cursor access-pattern policy. More... | |
typedef result::difference_type | difference_type |
enum | ownershippolicy { owned, loose } |
Cursor destruction policy. More... | |
typedef result::size_type | size_type |
enum | updatepolicy { read_only, update } |
Cursor update policy. More... | |
Public Member Functions | |
sql_cursor (transaction_base &t, const PGSTD::string &query, const PGSTD::string &cname, cursor_base::accesspolicy ap, cursor_base::updatepolicy up, cursor_base::ownershippolicy op, bool hold) | |
sql_cursor (transaction_base &t, const PGSTD::string &cname, cursor_base::ownershippolicy op) | |
~sql_cursor () throw () | |
void | close () throw () |
const result & | empty_result () const throw () |
Return zero-row result for this cursor. More... | |
difference_type | endpos () const throw () |
End position, or -1 for unknown. More... | |
result | fetch (difference_type rows, difference_type &displacement) |
result | fetch (difference_type rows) |
difference_type | move (difference_type rows, difference_type &displacement) |
difference_type | move (difference_type rows) |
const PGSTD::string & | name () const throw () |
Name of underlying SQL cursor. More... | |
difference_type | pos () const throw () |
Current position, or -1 for unknown. More... | |
Static Public Member Functions | |
Special movement distances | |
static difference_type | all () throw () |
Special value: read until end. More... | |
static difference_type | next () throw () |
Special value: read one row only. More... | |
static difference_type | prior () throw () |
Special value: read backwards, one row only. More... | |
static difference_type | backward_all () throw () |
Special value: read backwards from current position back to origin. More... | |
Protected Attributes | |
const PGSTD::string | m_name |
Private Member Functions | |
difference_type | adjust (difference_type hoped, difference_type actual) |
void | init_empty_result (transaction_base &) |
Initialize cached empty result. Call only at beginning or end! More... | |
Static Private Member Functions | |
static PGSTD::string | stridestring (difference_type) |
Private Attributes | |
bool | m_adopted |
Is this cursor adopted (as opposed to created by this cursor object)? More... | |
int | m_at_end |
At starting position (-1), somewhere in the middle (0), or past end (1) More... | |
result | m_cached_current_row |
result | m_empty_result |
Zero-row result from this cursor (or plain empty one if cursor is adopted) More... | |
difference_type | m_endpos |
End position, or -1 for unknown. More... | |
connection_base & | m_home |
Connection this cursor lives in. More... | |
cursor_base::ownershippolicy | m_ownership |
Will this cursor object destroy its SQL cursor when it dies? More... | |
difference_type | m_pos |
Position, or -1 for unknown. More... | |
Cursor with SQL positioning semantics.
Thin wrapper around an SQL cursor, with SQL's ideas of positioning.
SQL cursors have pre-increment/pre-decrement semantics, with on either end of the result set a special position that does not repesent a row. This class models SQL cursors for the purpose of implementing more C++-like semantics on top.
Positions of actual rows are numbered starting at 1. Position 0 exists but does not refer to a row. There is a similar non-row position at the end of the result set.
Don't use this at home. You deserve better. Use the stateles_cursor instead.
|
inherited |
|
inherited |
|
inherited |
|
inherited |
Cursor destruction policy.
The normal thing to do is to make a cursor object the owner of the SQL cursor it represents. There may be cases, however, where a cursor needs to persist beyond the end of the current transaction (and thus also beyond the lifetime of the cursor object that created it!), where it can be "adopted" into a new cursor object. See the basic_cursor documentation for an explanation of cursor adoption.
If a cursor is created with "loose" ownership policy, the object representing the underlying SQL cursor will not take the latter with it when its own lifetime ends, nor will its originating transaction.
Enumerator | |
---|---|
owned |
Destroy SQL cursor when cursor object is closed at end of transaction. |
loose |
Leave SQL cursor in existence after close of object and transaction. |
|
inherited |
pqxx::internal::sql_cursor::sql_cursor | ( | transaction_base & | t, |
const PGSTD::string & | query, | ||
const PGSTD::string & | cname, | ||
cursor_base::accesspolicy | ap, | ||
cursor_base::updatepolicy | up, | ||
cursor_base::ownershippolicy | op, | ||
bool | hold | ||
) |
pqxx::internal::sql_cursor::sql_cursor | ( | transaction_base & | t, |
const PGSTD::string & | cname, | ||
cursor_base::ownershippolicy | op | ||
) |
|
inline |
|
private |
|
inlinestaticinherited |
Special value: read until end.
|
inlinestaticinherited |
Special value: read backwards from current position back to origin.
Referenced by pqxx::stateless_cursor< up, op >::stateless_cursor().
void pqxx::internal::sql_cursor::close | ( | ) | throw () |
|
inline |
Return zero-row result for this cursor.
|
inline |
End position, or -1 for unknown.
Returns the final position, just after the last row in the result set. The starting position, just before the first row, counts as position zero.
End position is unknown until it is encountered during use.
result pqxx::internal::sql_cursor::fetch | ( | difference_type | rows, |
difference_type & | displacement | ||
) |
|
inline |
|
private |
Initialize cached empty result. Call only at beginning or end!
difference_type pqxx::internal::sql_cursor::move | ( | difference_type | rows, |
difference_type & | displacement | ||
) |
|
inline |
|
inlineinherited |
Name of underlying SQL cursor.
|
inlinestaticinherited |
Special value: read one row only.
|
inline |
Current position, or -1 for unknown.
The starting position, just before the first row, counts as position zero.
Position may be unknown if (and only if) this cursor was adopted, and has never hit its starting position (position zero).
|
inlinestaticinherited |
Special value: read backwards, one row only.
|
staticprivate |
|
private |
Is this cursor adopted (as opposed to created by this cursor object)?
|
private |
At starting position (-1), somewhere in the middle (0), or past end (1)
|
private |
|
private |
Zero-row result from this cursor (or plain empty one if cursor is adopted)
|
private |
End position, or -1 for unknown.
|
private |
Connection this cursor lives in.
|
protectedinherited |
|
private |
Will this cursor object destroy its SQL cursor when it dies?
|
private |
Position, or -1 for unknown.