From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 799EA26365 for ; Thu, 14 Jun 2018 13:32:31 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Esp17HLFKoDa for ; Thu, 14 Jun 2018 13:32:31 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C45E52635D for ; Thu, 14 Jun 2018 13:32:30 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v3 01/10] box: move db->pShchema init to sql_init Date: Thu, 14 Jun 2018 20:32:18 +0300 Message-Id: <730c027f3f7c5191df0816d9be2efe7314649ba7.1528997527.git.kshcherbatov@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Kirill Shcherbatov 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. --- src/box/sql.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/box/sql.c b/src/box/sql.c index 7379cb4..93fca68 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -77,11 +77,22 @@ sql_init() panic("failed to initialize SQL subsystem"); assert(db != NULL); + /* + * Initialize pSchema to use SQL parser on initialization: + * e.g. Trigger objects (compiled from SQL on tuple + * insertion in _trigger) need to refer it. + */ + 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 @@ -89,7 +100,6 @@ sql_load_schema() assert(db->init.busy == 0); db->init.busy = 1; - db->pSchema = sqlite3SchemaCreate(db); rc = sqlite3InitDatabase(db); if (rc != SQLITE_OK) { sqlite3SchemaClear(db); -- 2.7.4