#include <cachedresult.h>
Public Types | |
typedef Result::size_type | size_type |
typedef size_type | blocknum |
typedef Result::Tuple | Tuple |
Tuple type. Currently borrowed from Result, but may change in the future. | |
Public Member Functions | |
CachedResult (pqxx::TransactionItf &T, const char Query[], const PGSTD::string &BaseName="query", size_type Granularity=100) | |
const Tuple | operator[] (size_type i) const |
Access a tuple. Invalid index yields undefined behaviour. | |
const Tuple | at (size_type i) const |
Access a tuple. Throws exception if index is out of range. | |
size_type | size () const |
Number of rows in result set. First call may be slow. | |
bool | empty () const |
Is the result set empty, i.e. does it contain no rows? May fetch 1 block. |
The class uses a Cursor internally to fetch results. Data are not fetched row-by-row, but in chunks of configurable size. For internal computational reasons, these chunks (called "blocks" here) must be at least 2 rows large.
CAUTION: PostgreSQL currently doesn't always let you move cursors backwards, which is a feature this class relies upon. As a result, CachedResult will only work on certain types of queries. To make things worse, there is no documentation to define exactly which queries those are. Therefore the only way to use CachedResult at this time is to test carefully. Hopefully this can be fixed in the future.
|
|
|
|
|
Tuple type. Currently borrowed from Result, but may change in the future.
|
|
Perform query and transparently fetch and cache resulting data.
|
|
Access a tuple. Throws exception if index is out of range. If the given index is not the index of an existing row, an out_of_range error will be thrown. Caveat: the Tuple contains a reference to a Result that may be destroyed by any other operation on the CachedResult, even if its constness is preserved. Therefore only use the returned Tuple as a temporary, and do not try to copy-construct it, or keep references or pointers to it.
|
|
Is the result set empty, i.e. does it contain no rows? May fetch 1 block.
|
|
Access a tuple. Invalid index yields undefined behaviour. Caveat: the Tuple contains a reference to a Result that may be destroyed by any other operation on the CachedResult, even if its constness is preserved. Therefore only use the returned Tuple as a temporary, and do not try to copy-construct it, or keep references or pointers to it.
|
|
Number of rows in result set. First call may be slow.
|