dodo  0.0.1
A C++ library to create containerized Linux services
sqlite.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the dodo library (https://github.com/jmspit/dodo).
3  * Copyright (c) 2019 Jan-Marten Spit.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, version 3.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /**
19  * @file
20  * SQLite3 wrapper c++ header file.
21  */
22 
24 #include <common/exception.hpp>
25 #include <common/util.hpp>
26 #include <map>
27 #include <sstream>
28 #include <iostream>
29 #include <assert.h>
30 #include <errno.h>
31 #include <math.h>
32 #include <string.h>
33 
34 namespace dodo::persist {
35 
36  namespace sqlite {
37 
38  /**
39  * Power function extension for SQLite
40  * @param context SQLite context.
41  * @param argc The number of arguments to this function.
42  * @param argv The arguments to this funcxtion.
43  */
44  static void sqlite_ext_pow(sqlite3_context *context, int argc, sqlite3_value **argv) {
45  assert( argc==2 );
46  if( sqlite3_value_type(argv[0]) == SQLITE_NULL || sqlite3_value_type(argv[1]) == SQLITE_NULL ) {
47  sqlite3_result_null(context);
48  } else {
49  errno = 0;
50  double r1 = sqlite3_value_double(argv[0]);
51  double r2 = sqlite3_value_double(argv[1]);
52  double val = pow(r1,r2);
53  if (errno == 0) {
54  sqlite3_result_double( context, val );
55  } else {
56  sqlite3_result_error( context, strerror(errno), errno );
57  }
58  }
59  }
60 
61  /**
62  * Base 2 logarithm extension for SQLite
63  * @param context SQLite context.
64  * @param argc The number of arguments to this function.
65  * @param argv The arguments to this funcxtion.
66  */
67  static void sqlite_ext_log2(sqlite3_context *context, int argc, sqlite3_value **argv) {
68  assert( argc==1 );
69  if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){
70  sqlite3_result_null(context);
71  } else {
72  errno = 0;
73  double r1 = sqlite3_value_double(argv[0]);
74  double val = log2(r1);
75  if (errno == 0) {
76  sqlite3_result_double(context, val);
77  } else {
78  sqlite3_result_error(context, strerror(errno), errno);
79  }
80  }
81  }
82 
83  /**
84  * Ceiling function extension for SQLite
85  * @param context SQLite context.
86  * @param argc The number of arguments to this function.
87  * @param argv The arguments to this funcxtion.
88  */
89  static void sqlite_ext_ceil(sqlite3_context *context, int argc, sqlite3_value **argv) {
90  assert( argc==1 );
91 
92  if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){
93  sqlite3_result_null(context);
94  } else {
95  errno = 0;
96  double r1 = sqlite3_value_double(argv[0]);
97  double val = ceil(r1);
98  if (errno == 0) {
99  sqlite3_result_double(context, val);
100  } else {
101  sqlite3_result_error(context, strerror(errno), errno);
102  }
103  }
104  }
105 
106  /**
107  * Floor function extension for SQLite
108  * @param context SQLite context.
109  * @param argc The number of arguments to this function.
110  * @param argv The arguments to this funcxtion.
111  */
112  static void sqlite_ext_floor(sqlite3_context *context, int argc, sqlite3_value **argv) {
113  assert( argc==1 );
114 
115  if( sqlite3_value_type(argv[0]) == SQLITE_NULL ){
116  sqlite3_result_null(context);
117  } else {
118  double r1 = 0.0;
119  double val;
120  r1 = sqlite3_value_double(argv[0]);
121  errno = 0;
122  val = floor(r1);
123  if (errno == 0) {
124  sqlite3_result_double(context, val);
125  } else {
126  sqlite3_result_error(context, strerror(errno), errno);
127  }
128  }
129  }
130 
131  Database::Database( const std::string &filename, WaitHandler handler ) {
132  database_ = NULL;
133  int r = sqlite3_open_v2( filename.c_str(), &database_, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NOMUTEX, nullptr );
134  if ( r != SQLITE_OK ) {
135  throw_Exception( sqlite3_errmsg( database_ ) );
136  }
137  int eTextRep = SQLITE_UTF8;
138  #if SQLITE_VERSION_NUMBER > 3008003
139  eTextRep |= SQLITE_DETERMINISTIC;
140  #endif
141  r = sqlite3_create_function_v2( database_,
142  "power",
143  2,
144  eTextRep,
145  NULL,
147  NULL,
148  NULL,
149  NULL );
150  if ( r != SQLITE_OK ) {
151  throw_Exception( sqlite3_errmsg( database_ ) );
152  }
153  r = sqlite3_create_function_v2( database_,
154  "ceil",
155  1,
156  eTextRep,
157  NULL,
159  NULL,
160  NULL,
161  NULL );
162  if ( r != SQLITE_OK ) {
163  throw_Exception( sqlite3_errmsg( database_ ) );
164  }
165  r = sqlite3_create_function_v2( database_,
166  "floor",
167  1,
168  eTextRep,
169  NULL,
171  NULL,
172  NULL,
173  NULL );
174  if ( r != SQLITE_OK ) {
175  throw_Exception( sqlite3_errmsg( database_ ) );
176  }
177  r = sqlite3_create_function_v2( database_,
178  "log2",
179  1,
180  eTextRep,
181  NULL,
183  NULL,
184  NULL,
185  NULL );
186  if ( r != SQLITE_OK ) {
187  throw_Exception( sqlite3_errmsg( database_ ) );
188  }
189 
190 
191  if ( handler ) sqlite3_busy_handler( database_, handler, database_ );
192  }
193 
195  int r = sqlite3_close_v2( database_ );
196  if ( r != SQLITE_OK ) std::cout << "sqlite3_close returns " << r << std::endl;
197  }
198 
200  int succes = 0;
201  int r = sqlite3_db_config( database_, SQLITE_DBCONFIG_ENABLE_FKEY, 1, &succes );
202  if ( r != SQLITE_OK ) {
203  throw_Exception( sqlite3_errmsg( database_ ) );
204  }
205  }
206 
208  int succes = 0;
209  int r = sqlite3_db_config( database_, SQLITE_DBCONFIG_ENABLE_FKEY, 0, &succes );
210  if ( r != SQLITE_OK ) {
211  throw_Exception( sqlite3_errmsg( database_ ) );
212  }
213  }
214 
216  int succes = 0;
217  int r = sqlite3_db_config( database_, SQLITE_DBCONFIG_ENABLE_TRIGGER, 1, &succes );
218  if ( r != SQLITE_OK ) {
219  throw_Exception( sqlite3_errmsg( database_ ) );
220  }
221  }
222 
224  std::stringstream ss;
225  ss << "BEGIN";
226  DDL ddl( *this );
227  ddl.prepare( ss.str() );
228  ddl.execute();
229  }
230 
232  std::stringstream ss;
233  ss << "BEGIN IMMEDIATE";
234  DDL ddl( *this );
235  ddl.prepare( ss.str() );
236  ddl.execute();
237  }
238 
240  std::stringstream ss;
241  ss << "BEGIN EXCLUSIVE";
242  DDL ddl( *this );
243  ddl.prepare( ss.str() );
244  ddl.execute();
245  }
246 
248  std::stringstream ss;
249  ss << "COMMIT";
250  DDL ddl( *this );
251  ddl.prepare( ss.str() );
252  ddl.execute();
253  }
254 
256  std::stringstream ss;
257  ss << "ROLLBACK";
258  DDL ddl( *this );
259  ddl.prepare( ss.str() );
260  ddl.execute();
261  }
262 
263  void Database::createSavepoint( const std::string &sp ) {
264  std::stringstream ss;
265  ss << "SAVEPOINT " << sp;
266  DDL ddl( *this );
267  ddl.prepare( ss.str() );
268  ddl.execute();
269  }
270 
271  void Database::releaseSavepoint( const std::string &sp ) {
272  std::stringstream ss;
273  ss << "RELEASE " << sp;
274  DDL ddl( *this );
275  ddl.prepare( ss.str() );
276  ddl.execute();
277  }
278 
279  void Database::rollback( const std::string &sp ) {
280  std::stringstream ss;
281  ss << "ROLLBACK TO SAVEPOINT " << sp;
282  DDL ddl( *this );
283  ddl.prepare( ss.str() );
284  ddl.execute();
285  }
286 
287  int64_t Database::lastInsertRowid() const {
288  int64_t r = sqlite3_last_insert_rowid( database_ );
289  if ( !r ) {
290  throw_Exception( "lastInsertRowid failed" );
291  }
292  return r;
293  }
294 
296  int nLog = 0;
297  int nCkpt = 0;
298  int r = sqlite3_wal_checkpoint_v2( database_, NULL, SQLITE_CHECKPOINT_FULL, &nLog, &nCkpt );
299  if ( r != SQLITE_OK ) {
300  throw_Exception( sqlite3_errmsg( database_ ) );
301  }
302  }
303 
305  int nLog = 0;
306  int nCkpt = 0;
307  int r = sqlite3_wal_checkpoint_v2( database_, NULL, SQLITE_CHECKPOINT_PASSIVE, &nLog, &nCkpt );
308  if ( r != SQLITE_OK ) {
309  throw_Exception( sqlite3_errmsg( database_ ) );
310  }
311  }
312 
314  int nLog = 0;
315  int nCkpt = 0;
316  #if SQLITE_VERSION_NUMBER > 30080303
317  int r = sqlite3_wal_checkpoint_v2( database_, NULL, SQLITE_CHECKPOINT_TRUNCATE, &nLog, &nCkpt );
318  #else
319  int r = sqlite3_wal_checkpoint_v2( database_, NULL, SQLITE_CHECKPOINT_RESTART, &nLog, &nCkpt );
320  #endif
321  if ( r != SQLITE_OK ) {
322  throw_Exception( sqlite3_errmsg( database_ ) );
323  }
324  }
325 
326  void Database::setUserVersion( int version ) {
327  std::stringstream ss;
328  ss << "PRAGMA user_version=" << version;
329  DDL ddl( *this );
330  ddl.prepare( ss.str() );
331  ddl.execute();
332  }
333 
335  int r = 0;
336  sqlite::Query query( *this );
337  query.prepare( "PRAGMA user_version" );
338  if ( query.step() ) {
339  r = query.getInt( 0 );
340  } else throw_Exception( sqlite3_errmsg( database_ ) );
341  return r;
342  }
343 
345  sqlite3_db_release_memory(database_);
346  }
347 
349  database_ = db.getDB();
350  stmt_ = 0;
351  }
352 
354  if ( stmt_ ) close();
355  }
356 
357  void Statement::prepare( const std::string &sql ) {
358  const char *err = 0;
359  if ( stmt_ ) close();
360  int r = sqlite3_prepare_v2( database_, sql.c_str(), -1, &stmt_, &err );
361  if ( r != SQLITE_OK ) {
362  std::stringstream ss;
363  ss << sqlite3_errmsg( database_ ) << " at '" << err << "' sql='" << sql << "'";
364  throw_Exception( ss.str() );
365  }
366  }
367 
368  void Statement::reset( bool clear ) {
369  if ( clear ) {
370  auto r = sqlite3_clear_bindings( stmt_ );
371  if ( r != SQLITE_OK ) {
372  throw_Exception( sqlite3_errmsg( database_ ) );
373  }
374  }
375  auto r = sqlite3_reset( stmt_ );
376  if ( r != SQLITE_OK ) {
377  throw_Exception( sqlite3_errmsg( database_ ) );
378  }
379  }
380 
382  int r = sqlite3_finalize( stmt_ );
383  stmt_ = 0;
384  if ( r != SQLITE_OK ) {
385  throw_Exception( sqlite3_errmsg( database_ ) );
386  }
387  }
388 
389  void DDL::execute() {
390  int r = sqlite3_step( stmt_ );
391  if ( r != SQLITE_DONE ) {
392  throw_Exception( sqlite3_errmsg( database_ ) );
393  }
394  }
395 
397  return sqlite3_step( stmt_ );
398  }
399 
400  DML::DML( const Database& db ) : Statement( db ) {
401  }
402 
403  int DML::execute() {
404  int r = sqlite3_step( stmt_ );
405  if ( r != SQLITE_DONE ) {
406  throw_Exception( sqlite3_errmsg( database_ ) );
407  }
408  return sqlite3_changes( database_ );
409  }
410 
411  void DML::bind( int position, double value ) {
412  int r = sqlite3_bind_double( stmt_, position, value );
413  if ( r != SQLITE_OK ) {
414  throw_Exception( sqlite3_errmsg( database_ ) );
415  }
416  }
417 
418  void DML::bind( int position, int value ) {
419  int r = sqlite3_bind_int( stmt_, position, value );
420  if ( r != SQLITE_OK ) {
421  throw_Exception( sqlite3_errmsg( database_ ) );
422  }
423  }
424 
425  void DML::bind( int position, int64_t value ) {
426  int r = sqlite3_bind_int64( stmt_, position, value );
427  if ( r != SQLITE_OK ) {
428  throw_Exception( sqlite3_errmsg( database_ ) );
429  }
430  }
431 
432  void DML::bind( int position, const std::string &value ) {
433  int r = sqlite3_bind_text( stmt_, position, value.c_str(), static_cast<int>(value.length()), SQLITE_TRANSIENT );
434  if ( r != SQLITE_OK ) {
435  throw_Exception( sqlite3_errmsg( database_ ) );
436  }
437  }
438 
439  void DML::bind( int position, const common::Bytes &value ) {
440  int r = sqlite3_bind_blob64( stmt_, position, value.getArray(), value.getSize(), SQLITE_TRANSIENT );
441  if ( r != SQLITE_OK ) {
442  throw_Exception( sqlite3_errmsg( database_ ) );
443  }
444  }
445 
446  void DML::bind( const std::string &name, double value ) {
447  auto rc = sqlite3_bind_parameter_index( stmt_, name.c_str() );
448  if ( !rc ) throw_Exception( "parameter " << name << " not found i ");
449  else bind( rc, value );
450  }
451 
452  void DML::bind( const std::string &name, int value ) {
453  auto rc = sqlite3_bind_parameter_index( stmt_, name.c_str() );
454  if ( !rc ) throw_Exception( "parameter " << name << " not found i ");
455  else bind( rc, value );
456  }
457 
458  void DML::bind( const std::string &name, int64_t value ) {
459  auto rc = sqlite3_bind_parameter_index( stmt_, name.c_str() );
460  if ( !rc ) throw_Exception( "parameter " << name << " not found i ");
461  else bind( rc, value );
462  }
463 
464  void DML::bind( const std::string &name, const std::string &value ) {
465  auto rc = sqlite3_bind_parameter_index( stmt_, name.c_str() );
466  if ( !rc ) throw_Exception( "parameter " << name << " not found i ");
467  else bind( rc, value );
468  }
469 
470  void DML::bind( const std::string &name, const common::Bytes &value ) {
471  auto rc = sqlite3_bind_parameter_index( stmt_, name.c_str() );
472  if ( !rc ) throw_Exception( "parameter " << name << " not found i ");
473  else bind( rc, value );
474  }
475 
476  bool Query::step() {
477  int r = sqlite3_step( stmt_ );
478  if ( r != SQLITE_DONE && r != SQLITE_ROW ) {
479  throw_Exception( sqlite3_errmsg( database_ ) );
480  }
481  return r == SQLITE_ROW;
482  }
483 
484  bool Query::isNull( int col ) const {
485  return sqlite3_column_type( stmt_, col ) == SQLITE_NULL;
486  }
487 
489  return static_cast<DataType>( sqlite3_column_type( stmt_, col ) );
490  }
491 
492  int Query::getInt( int col ) const {
493  return sqlite3_column_int( stmt_, col );
494  }
495 
496  int64_t Query::getInt64( int col ) const {
497  return sqlite3_column_int64( stmt_, col );
498  }
499 
500  double Query::getDouble( int col ) const {
501  return sqlite3_column_double( stmt_, col );
502  }
503 
504  std::string Query::getText( int col ) const {
505  const char* c = (const char*)sqlite3_column_text( stmt_, col );
506  if ( c ) return c; else return "";
507  }
508 
509  void Query::getBytes( int col, common::Bytes &bytes ) const {
510  const common::Octet* tmp_data = static_cast<const common::Octet*>( sqlite3_column_blob( stmt_, col ) );
511  int size = sqlite3_column_bytes( stmt_, col );
512  bytes.free();
513  bytes.append( tmp_data, size );
514  }
515 
516  int Query::getColumnCount() const {
517  return sqlite3_column_count( stmt_ );
518  }
519 
520  }; // namespace persist
521 
522 }; // namespace leanux
dodo::persist::sqlite::Statement::~Statement
virtual ~Statement()
Destructor.
Definition: sqlite.cpp:353
dodo::persist::sqlite::sqlite_ext_floor
static void sqlite_ext_floor(sqlite3_context *context, int argc, sqlite3_value **argv)
Floor function extension for SQLite.
Definition: sqlite.cpp:112
dodo::persist::sqlite::sqlite_ext_log2
static void sqlite_ext_log2(sqlite3_context *context, int argc, sqlite3_value **argv)
Base 2 logarithm extension for SQLite.
Definition: sqlite.cpp:67
dodo::persist::sqlite::Database::rollback
void rollback()
Rollback a transaction.
Definition: sqlite.cpp:255
dodo::common::Bytes::getArray
Octet * getArray() const
Return the array.
Definition: bytes.hpp:186
dodo::persist::sqlite::Database::checkPointTruncate
void checkPointTruncate()
Issue a (WAL) truncate checpoint.
Definition: sqlite.cpp:313
dodo::persist::sqlite::Database::lastInsertRowid
int64_t lastInsertRowid() const
Get the rowid of the last inserted row.
Definition: sqlite.cpp:287
dodo::common::Bytes::free
void free()
Free and clear data.
Definition: bytes.cpp:56
dodo::persist::sqlite::Database::enableTriggers
void enableTriggers()
Enable triggers.
Definition: sqlite.cpp:215
sqlite.hpp
dodo::persist::sqlite::Statement
Generic SQL Statement.
Definition: sqlite.hpp:210
dodo::persist::sqlite::Database::commit
void commit()
Commit a transaction.
Definition: sqlite.cpp:247
dodo::persist::sqlite::Query
Queries can take bind values and return select lists.
Definition: sqlite.hpp:387
dodo::common::Bytes
An array of Octets with size elements.
Definition: bytes.hpp:44
dodo::persist::sqlite::Database::~Database
~Database()
Destructor.
Definition: sqlite.cpp:194
dodo::persist::sqlite::Query::getText
std::string getText(int col) const
Get string value from select list.
Definition: sqlite.cpp:504
dodo::persist::sqlite::Database::enableForeignKeys
void enableForeignKeys()
Enable foreign key constraints.
Definition: sqlite.cpp:199
dodo::common::Bytes::append
void append(const Bytes &src)
Append another Bytes.
Definition: bytes.cpp:65
dodo::persist::sqlite::WaitHandler
int(* WaitHandler)(void *, int)
Prototype for wait/busy handlers.
Definition: sqlite.hpp:43
dodo::persist::sqlite::Database::disableForeignKeys
void disableForeignKeys()
Disable foreign key constraints.
Definition: sqlite.cpp:207
dodo::persist::sqlite::Database::releaseMemory
void releaseMemory()
Have SQLite attempt to release a much memory as possible.
Definition: sqlite.cpp:344
dodo::persist::sqlite::Query::getColumnCount
int getColumnCount() const
get the number of columns in the query result set.
Definition: sqlite.cpp:516
dodo::persist::sqlite::Query::DataType
DataType
The data type of a select-list value.
Definition: sqlite.hpp:393
dodo::persist::sqlite::Query::step
bool step()
Step the result list, end of list returns false.
Definition: sqlite.cpp:476
dodo::persist::sqlite::Database::beginExclusiveTransaction
void beginExclusiveTransaction()
Begin an exclusive transaction.
Definition: sqlite.cpp:239
dodo::persist::sqlite::Statement::database_
sqlite3 * database_
database handle on which the stmt_ is created.
Definition: sqlite.hpp:253
dodo::persist::sqlite::Query::getDataType
DataType getDataType(int col) const
Get the dataype of a select list column.
Definition: sqlite.cpp:488
dodo::persist::sqlite::DDL::execute_r
int execute_r()
execute and return result code.
Definition: sqlite.cpp:396
dodo::persist::sqlite::Query::isNull
bool isNull(int col) const
Test if the result is NULL.
Definition: sqlite.cpp:484
dodo::persist::sqlite::Database::checkPointPassive
void checkPointPassive()
Issue a passive checpoint.
Definition: sqlite.cpp:304
dodo::persist::sqlite::Database::getDB
sqlite3 * getDB() const
Return database handle.
Definition: sqlite.hpp:128
dodo::persist::sqlite::Database::beginTransaction
void beginTransaction()
Begin a transaction.
Definition: sqlite.cpp:223
dodo::persist::sqlite::Statement::close
void close()
A statement handle can be explicitly closed without deleting the Statement object itself.
Definition: sqlite.cpp:381
throw_Exception
#define throw_Exception(what)
Throws an Exception, passes FILE and LINE to constructor.
Definition: exception.hpp:174
dodo::persist::sqlite::Database::setUserVersion
void setUserVersion(int version)
set the user_version pragma
Definition: sqlite.cpp:326
dodo::persist
Persistent storage structures.
Definition: kvstore.hpp:35
dodo::persist::sqlite::DML::DML
DML(const Database &db)
Constructor.
Definition: sqlite.cpp:400
dodo::persist::sqlite::sqlite_ext_ceil
static void sqlite_ext_ceil(sqlite3_context *context, int argc, sqlite3_value **argv)
Ceiling function extension for SQLite.
Definition: sqlite.cpp:89
dodo::persist::sqlite::DML::bind
void bind(int position, double value)
Bind a double value to the bind at position.
Definition: sqlite.cpp:411
dodo::persist::sqlite::Statement::prepare
void prepare(const std::string &sql)
Prepare a SQL statement.
Definition: sqlite.cpp:357
dodo::persist::sqlite::Statement::Statement
Statement(const Database &db)
Constructor.
Definition: sqlite.cpp:348
dodo::common::Octet
uint8_t Octet
Octet aka 'byte'.
Definition: bytes.hpp:34
dodo::persist::sqlite::DML::execute
int execute()
Execute and return the number of rows affected.
Definition: sqlite.cpp:403
dodo::persist::sqlite::Database::getUserVersion
int getUserVersion() const
get the current user_version pragma (a user defined database schema version)
Definition: sqlite.cpp:334
dodo::persist::sqlite::Query::getInt64
int64_t getInt64(int col) const
Get int64_t value from select list.
Definition: sqlite.cpp:496
exception.hpp
dodo::persist::sqlite::Statement::reset
void reset(bool clear=true)
Reset a SQL statement for re-execute or even re-prepare.
Definition: sqlite.cpp:368
dodo::persist::sqlite::Database::releaseSavepoint
void releaseSavepoint(const std::string &sp)
Release a savepoint.
Definition: sqlite.cpp:271
dodo::persist::sqlite::Database::beginImmediateTransaction
void beginImmediateTransaction()
Begin an immediate transaction.
Definition: sqlite.cpp:231
dodo::persist::sqlite::Database
A STL friendly wrapper around the great sqlite3.
Definition: sqlite.hpp:52
dodo::persist::sqlite::Database::database_
sqlite3 * database_
The SQLite database handle.
Definition: sqlite.hpp:204
dodo::persist::sqlite::DDL
Data Definition Language, SQL that takes no parameters, returns no data such as CREATE TABLE.
Definition: sqlite.hpp:261
dodo::persist::sqlite::Query::getDouble
double getDouble(int col) const
Get double value from select list.
Definition: sqlite.cpp:500
dodo::persist::sqlite::Database::Database
Database(const std::string &filename, WaitHandler handler=0)
Constructor with explicit wait handler.
Definition: sqlite.cpp:131
dodo::persist::sqlite::DDL::execute
void execute()
execute, throws Oops on error.
Definition: sqlite.cpp:389
dodo::common::Bytes::getSize
size_t getSize() const
Return the array size.
Definition: bytes.hpp:192
dodo::persist::sqlite::Query::getBytes
void getBytes(int col, common::Bytes &bytes) const
Get Bytes value from select list.
Definition: sqlite.cpp:509
dodo::persist::sqlite::Statement::stmt_
sqlite3_stmt * stmt_
statement handle.
Definition: sqlite.hpp:250
dodo::persist::sqlite::Database::checkPointFull
void checkPointFull()
Issue a full checpoint.
Definition: sqlite.cpp:295
dodo::persist::sqlite::Query::getInt
int getInt(int col) const
Get int value from select list.
Definition: sqlite.cpp:492
util.hpp
dodo::persist::sqlite::sqlite_ext_pow
static void sqlite_ext_pow(sqlite3_context *context, int argc, sqlite3_value **argv)
Power function extension for SQLite.
Definition: sqlite.cpp:44
dodo::persist::sqlite::Database::createSavepoint
void createSavepoint(const std::string &sp)
Create a named savepoint.
Definition: sqlite.cpp:263