MCPcopy Create free account
hub / github.com/acl-dev/acl / prepare

Method prepare

lib_acl_cpp/src/db/db_sqlite.cpp:902–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

900}
901
902bool db_sqlite::prepare(sqlite_cursor& cursor)
903{
904 const string& sql = cursor.get_sql();
905 int ret = __sqlite3_prepare_v2(db_, sql.c_str(), -1,
906 &cursor.stmt_, NULL);
907 if (ret != SQLITE_OK) {
908 logger_error("prepare error=%s, sql=%s",
909 get_error(), sql.c_str());
910 return false;
911 }
912
913 cursor.free_callback = __sqlite3_finalize;
914
915 int n = __sqlite3_column_count(cursor.stmt_);
916 if (n <= 0) {
917 logger_error("invalid column count=%d", n);
918 return false;
919 }
920 for (int i = 0; i < n; i++) {
921 const char* name = __sqlite3_column_name(cursor.stmt_, i);
922 if (name == NULL) {
923 logger_error("column name null, i=%d, sql=%s",
924 i, cursor.get_sql().c_str());
925 return false;
926 }
927 cursor.add_column_name(name);
928 }
929 cursor.create_row();
930 return true;
931}
932
933bool db_sqlite::next(sqlite_cursor& cursor, bool* done)
934{

Callers

nothing calls this directly

Calls 4

add_column_nameMethod · 0.80
create_rowMethod · 0.80
get_errorFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected