Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: "v.shpilevoy@tarantool.org" <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 03/11] sql: fix leak on CREATE TABLE and resolve self ref
Date: Thu, 14 Jun 2018 19:12:34 +0300	[thread overview]
Message-ID: <9a4a8bff-d71f-ac19-73ae-bf52626a6f73@tarantool.org> (raw)
In-Reply-To: <65a27aff-8334-7651-fc74-d72de9a2a8e4@tarantool.org>


> Why do you need snprintf("%s", str)? It is the same as just 'str'.
> is enough to set an error. If zErrMsg was not terminated by zero, snprintf("%s")
> would not work as well. But zErrMsg is terminated.
I  wasn't sure that this diag_set build print string object. It doesn't matter. I've fixed this. 

> And why do you destroy zErrMsg here? Why not in sql_parser_destroy()?
> zErrMsg is struct Parse member.
Ok, done.

--- a/src/box/sql/prepare.c
+++ b/src/box/sql/prepare.c
@@ -453,5 +453,6 @@ sql_parser_destroy(Parse *parser)
                db->lookaside.bDisable -= parser->disableLookaside;
        }
        parser->disableLookaside = 0;
+       sqlite3DbFree(db, parser->zErrMsg);
        region_destroy(&parser->region);
 }


--- a/src/box/sql/trigger.c
+++ b/src/box/sql/trigger.c
@@ -815,6 +815,7 @@ transferParseError(Parse * pTo, Parse * pFrom)
        } else {
                sqlite3DbFree(pFrom->db, pFrom->zErrMsg);
        }
+       pFrom->zErrMsg = NULL;
 }
 

--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -1856,13 +1856,13 @@ sql_checks_resolve_space_def_reference(ExprList *expr_list,
 
        sql_resolve_self_reference(&parser, &dummy_table, NC_IsCheck, NULL,
                                   expr_list);
-
-       sql_parser_destroy(&parser);
+       int rc = 0;
        if (parser.rc != SQLITE_OK) {
                /* Tarantool error may be already set with diag. */
                if (parser.rc != SQL_TARANTOOL_ERROR)
                        diag_set(ClientError, ER_SQL, parser.zErrMsg);
-               return -1;
+               rc = -1;
        }
-       return 0;
+       sql_parser_destroy(&parser);
+       return rc;
 }

  reply	other threads:[~2018-06-14 16:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-09  9:58 [tarantool-patches] [PATCH v2 00/11] sql: remove Triggers to server Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 10/11] sql: move " Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-28  7:18   ` Konstantin Osipov
2018-06-28  7:33     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 11/11] sql: VDBE tests for trigger existence Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 02/11] box: move db->pShchema init to sql_init Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 04/11] sql: fix sql len in tarantoolSqlite3RenameTrigger Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 06/11] sql: refactor sql_expr_compile to return AST Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 07/11] sql: move sqlite3DeleteTrigger to sql.h Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 08/11] box: sort error codes in misc.test Kirill Shcherbatov
2018-06-09  9:32 ` [tarantool-patches] [PATCH v2 09/11] sql: new _trigger space format with space_id Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov
2018-06-09  9:58 ` [tarantool-patches] [PATCH v2 01/11] box: remove migration from alpha 1.8.2 and 1.8.4 Kirill Shcherbatov
2018-06-09  9:58 ` [tarantool-patches] [PATCH v2 03/11] sql: fix leak on CREATE TABLE and resolve self ref Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov [this message]
2018-06-09  9:58 ` [tarantool-patches] [PATCH v2 05/11] box: port schema_find_id to C Kirill Shcherbatov
2018-06-13 18:53   ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12     ` Kirill Shcherbatov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a4a8bff-d71f-ac19-73ae-bf52626a6f73@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH v2 03/11] sql: fix leak on CREATE TABLE and resolve self ref' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox