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 8DF251FFAE for ; Sat, 9 Jun 2018 05:37:01 -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 iJLGC7Ur76Af for ; Sat, 9 Jun 2018 05:37:01 -0400 (EDT) Received: from fallback.mail.ru (fallback7.mail.ru [94.100.181.128]) (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 41CAA1FCA3 for ; Sat, 9 Jun 2018 05:37:01 -0400 (EDT) Received: from [10.161.100.15] (port=53948 helo=smtpng3.m.smailru.net) by fallback7.mail.ru with esmtp (envelope-from ) id 1fRaEZ-0001FO-91 for tarantool-patches@freelists.org; Sat, 09 Jun 2018 12:32:31 +0300 From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 02/11] box: move db->pShchema init to sql_init Date: Sat, 9 Jun 2018 12:32:15 +0300 Message-Id: <090e06be9317fc8a1f0816dd2c80c6cf0818dcb8.1528535873.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