Skip to content

Commit

Permalink
sqlite3gen: use sqlite3_exec for schema setup
Browse files Browse the repository at this point in the history
executing the multiple statements in the schema, we
also get the indeces created.

Signed-off-by: Adrian Negreanu <groleo@gmail.com>
  • Loading branch information
groleo committed Oct 25, 2017
1 parent 5596fcd commit 1ec8f0e
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/sqlite3gen.cpp
Expand Up @@ -733,20 +733,13 @@ static int initializeSchema(sqlite3* db)
for (unsigned int k = 0; k < sizeof(schema_queries) / sizeof(schema_queries[0]); k++)
{
const char *q = schema_queries[k][1];
// create table
rc = sqlite3_prepare_v2(db, q, -1, &stmt, 0);
char *errmsg;
rc = sqlite3_exec(db, q, NULL, NULL, &errmsg);
if (rc != SQLITE_OK)
{
msg("failed to prepare query: %s\n\t%s\n", q, sqlite3_errmsg(db));
msg("failed to execute query: %s\n\t%s\n", q, errmsg);
return -1;
}
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE)
{
msg("failed to execute query: %s\n\t%s\n", q, sqlite3_errmsg(db));
return -1;
}
sqlite3_finalize(stmt);
}
return 0;
}
Expand Down

0 comments on commit 1ec8f0e

Please sign in to comment.