libpqxx
The C++ client library for PostgreSQL
Loading...
Searching...
No Matches
sql_cursor.hxx
Go to the documentation of this file.
1
11#ifndef PQXX_H_SQL_CURSOR
12#define PQXX_H_SQL_CURSOR
13
14namespace pqxx::internal
15{
17
31class PQXX_LIBEXPORT sql_cursor : public cursor_base
32{
33public:
35 transaction_base &t, std::string_view query, std::string_view cname,
36 cursor_base::access_policy ap, cursor_base::update_policy up,
37 cursor_base::ownership_policy op, bool hold);
38
40 transaction_base &t, std::string_view cname,
41 cursor_base::ownership_policy op);
42
43 ~sql_cursor() noexcept { close(); }
44
45 result fetch(difference_type rows, difference_type &displacement);
46 result fetch(difference_type rows)
47 {
48 difference_type d = 0;
49 return fetch(rows, d);
50 }
51 difference_type move(difference_type rows, difference_type &displacement);
52 difference_type move(difference_type rows)
53 {
54 difference_type d = 0;
55 return move(rows, d);
56 }
57
59
65 difference_type pos() const noexcept { return m_pos; }
66
68
74 difference_type endpos() const noexcept { return m_endpos; }
75
77 result const &empty_result() const noexcept { return m_empty_result; }
78
79 void close() noexcept;
80
81private:
82 difference_type adjust(difference_type hoped, difference_type actual);
83 static std::string stridestring(difference_type);
85 void init_empty_result(transaction_base &);
86
88 connection &m_home;
89
92 result m_empty_result;
93
94 result m_cached_current_row;
95
97 cursor_base::ownership_policy m_ownership;
98
100 int m_at_end;
101
103 difference_type m_pos;
104
106 difference_type m_endpos = -1;
107};
108
109
112 sql_cursor &, result::difference_type size,
113 result::difference_type begin_pos, result::difference_type end_pos);
114} // namespace pqxx::internal
115#endif
Cursor with SQL positioning semantics.
Definition sql_cursor.hxx:32
sql_cursor(transaction_base &t, std::string_view query, std::string_view cname, cursor_base::access_policy ap, cursor_base::update_policy up, cursor_base::ownership_policy op, bool hold)
Definition sql_cursor.cxx:93
difference_type move(difference_type rows)
Definition sql_cursor.hxx:52
difference_type endpos() const noexcept
End position, or -1 for unknown.
Definition sql_cursor.hxx:74
~sql_cursor() noexcept
Definition sql_cursor.hxx:43
result fetch(difference_type rows)
Definition sql_cursor.hxx:46
difference_type move(difference_type rows, difference_type &displacement)
Definition sql_cursor.cxx:236
result const & empty_result() const noexcept
Return zero-row result for this cursor.
Definition sql_cursor.hxx:77
result fetch(difference_type rows, difference_type &displacement)
Definition sql_cursor.cxx:220
difference_type pos() const noexcept
Current position, or -1 for unknown.
Definition sql_cursor.hxx:65
void close() noexcept
Definition sql_cursor.cxx:139
Result set containing data returned by a query or command.
Definition result.hxx:93
#define PQXX_LIBEXPORT
Definition header-pre.hxx:157
Internal items for libpqxx' own use. Do not use these yourself.
Definition encodings.cxx:33
PQXX_LIBEXPORT result_size_type obtain_stateless_cursor_size(sql_cursor &)
Definition cursor.cxx:34
PQXX_LIBEXPORT result stateless_cursor_retrieve(sql_cursor &, result::difference_type size, result::difference_type begin_pos, result::difference_type end_pos)
Definition cursor.cxx:42
int result_size_type
Number of rows in a result set.
Definition types.hxx:28