MCPcopy Create free account
hub / github.com/SOCI/soci / load_rowset

Method load_rowset

src/backends/sqlite3/statement.cpp:93–215  ·  view source on GitHub ↗

This is used by bulk operations

Source from the content-addressed store, hash-verified

91
92// This is used by bulk operations
93statement_backend::exec_fetch_result
94sqlite3_statement_backend::load_rowset(int totalRows)
95{
96 statement_backend::exec_fetch_result retVal = ef_success;
97
98 int i = 0;
99 int numCols = 0;
100
101 // just a hack because in some case, describe() is not called, so columns_ is empty
102 if (columns_.empty())
103 {
104 numCols = sqlite3_column_count(stmt_);
105 db_type dbtype;
106 std::string name;
107 for (int c = 1; c <= numCols; ++c)
108 describe_column(c, dbtype, name);
109 }
110 else
111 numCols = isize(columns_);
112
113
114 if (!databaseReady_)
115 {
116 retVal = ef_no_data;
117 }
118 else
119 {
120 // make the vector big enough to hold the data we need
121 dataCache_.resize(totalRows);
122 for (sqlite3_row& row : dataCache_)
123 {
124 row.resize(numCols);
125 }
126
127 for (i = 0; i < totalRows && databaseReady_; ++i)
128 {
129 int const res = sqlite3_step(stmt_);
130
131 if (SQLITE_DONE == res)
132 {
133 databaseReady_ = false;
134 retVal = ef_no_data;
135 break;
136 }
137 else if (SQLITE_ROW == res)
138 {
139 for (int c = 0; c < numCols; ++c)
140 {
141 const sqlite3_column_info &coldef = columns_[c];
142 sqlite3_column &col = dataCache_[i][c];
143
144 if (sqlite3_column_type(stmt_, c) == SQLITE_NULL)
145 {
146 col.isNull_ = true;
147 continue;
148 }
149
150 col.isNull_ = false;

Callers

nothing calls this directly

Calls 3

isizeFunction · 0.85
emptyMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected