Skip to content

Commit

Permalink
box: move db->pShchema init to sql_init
Browse files Browse the repository at this point in the history
As we are going to call parser on box.cfg() to recreate triggers
from SQL, we should initialize Schema as it used in sqlite3BeginTrigger.

Part of #3273.
  • Loading branch information
kshcherbatov committed May 31, 2018
1 parent 9a54320 commit 9c68415
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/box/sql.c
Expand Up @@ -77,19 +77,25 @@ sql_init()
panic("failed to initialize SQL subsystem");

assert(db != NULL);
/* Initialize pSchema to use SQL parser. */
db->pSchema = sqlite3SchemaCreate(db);
if (db->pSchema == NULL) {
sqlite3_close(db);
panic("failed to initialize SQL Schema subsystem");
}
}

void
sql_load_schema()
{
assert(db->pSchema != NULL);
int rc;
struct session *user_session = current_session();
int commit_internal = !(user_session->sql_flags
& SQLITE_InternChanges);

assert(db->init.busy == 0);
db->init.busy = 1;
db->pSchema = sqlite3SchemaCreate(db);
rc = sqlite3InitDatabase(db);
if (rc != SQLITE_OK) {
sqlite3SchemaClear(db);
Expand Down

0 comments on commit 9c68415

Please sign in to comment.