From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Yukhin <kyukhin@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 1/2] sql: after table rename properly update indexes
Date: Tue, 21 Aug 2018 23:38:39 +0300 [thread overview]
Message-ID: <5C92CDEF-15F0-4394-970F-608B9B59F333@tarantool.org> (raw)
In-Reply-To: <20180821122038.zlyjqxk5nzpj755l@tarantool.org>
[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]
> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
> index dc5146f..821c7a9 100644
> --- a/src/box/sql/vdbe.c
> +++ b/src/box/sql/vdbe.c
> @@ -4625,13 +4625,35 @@ case OP_RenameTable: {
> db->init.busy = 1;
> init.rc = SQLITE_OK;
> sql_init_callback(&init, zNewTableName, space_id, 0, zSqlStmt);
> - db->init.busy = 0;
> rc = init.rc;
> - if (rc) {
> + if (rc != SQLITE_OK) {
> sqlite3CommitInternalChanges();
> + db->init.busy = 0;
> goto abort_due_to_error;
> }
>
> + /* Space was altered, refetch the pointer. */
> + space = space_by_id(space_id);
> + for (uint32_t i = 0; i < space->index_count; ++i) {
> + struct index_def *def = space->index[i]->def;
> + if (def->opts.sql == NULL)
> + continue;
> + char *sql_stmt;
> + rc = sql_index_update_table_name(def, zNewTableName, &sql_stmt);
Where do you free memory for sql_stmt? table_rename allocates new
string using sqlite3DbMalloc AFAIK.
> + if (rc != SQLITE_OK)
rc != 0 (or better: if (sql_index_update_table_name() != 0)).
> + goto abort_due_to_error;
> + space = space_by_id(space_id);
> + sql_init_callback(&init, zNewTableName, space_id,
> + space->index[i]->def->iid, sql_stmt);
> + rc = init.rc;
> + if (rc != SQLITE_OK) {
rc != 0 (or better: if (init.rc != 0)
The rest seems to be ok.
[-- Attachment #2: Type: text/html, Size: 41498 bytes --]
next prev parent reply other threads:[~2018-08-21 20:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 16:49 [tarantool-patches] [PATCH 0/2] sql: update inexes after table rename Kirill Yukhin
2018-08-20 16:49 ` [tarantool-patches] [PATCH 1/2] sql: after table rename properly update indexes Kirill Yukhin
2018-08-21 10:26 ` [tarantool-patches] " n.pettik
2018-08-21 12:20 ` Kirill Yukhin
2018-08-21 20:38 ` n.pettik [this message]
2018-08-22 6:39 ` Kirill Yukhin
2018-08-20 16:49 ` [tarantool-patches] [PATCH 2/2] sql: take sql field in index_opts_cmp Kirill Yukhin
2018-08-21 10:26 ` [tarantool-patches] " n.pettik
2018-08-21 12:30 ` Kirill Yukhin
2018-08-21 20:41 ` n.pettik
2018-08-22 6:47 ` [tarantool-patches] Re: [PATCH 0/2] sql: update inexes after table rename Kirill Yukhin
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=5C92CDEF-15F0-4394-970F-608B9B59F333@tarantool.org \
--to=korablev@tarantool.org \
--cc=kyukhin@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH 1/2] sql: after table rename properly update indexes' \
/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