From: imeevma@tarantool.org
To: vdavydov.dev@gmail.com
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2 1/3] sql: allocate memory for index_id in VDBE
Date: Wed, 3 Apr 2019 19:58:32 +0300 [thread overview]
Message-ID: <67e2542a83b9db776d04af47af4cbb78f95b8711.1554310018.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1554310018.git.imeevma@gmail.com>
Currently, the memory for index_id is not allocated in VDBE code
in the sql_code_drop_table() and sql_drop_index() functions. This
may lead to SEGMENTATION FAULT.
Needed for #2843
---
src/box/sql/build.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 7724e94..c475b34 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -1473,6 +1473,7 @@ sql_code_drop_table(struct Parse *parse_context, struct space *space,
*/
int idx_rec_reg = ++parse_context->nMem;
int space_id_reg = ++parse_context->nMem;
+ int index_id_reg = ++parse_context->nMem;
int space_id = space->def->id;
sqlVdbeAddOp2(v, OP_Integer, space_id, space_id_reg);
sqlVdbeAddOp1(v, OP_CheckViewReferences, space_id_reg);
@@ -1523,7 +1524,7 @@ sql_code_drop_table(struct Parse *parse_context, struct space *space,
for (uint32_t i = 1; i < index_count; ++i) {
sqlVdbeAddOp2(v, OP_Integer,
space->index[i]->def->iid,
- space_id_reg + 1);
+ index_id_reg);
sqlVdbeAddOp3(v, OP_MakeRecord,
space_id_reg, 2, idx_rec_reg);
sqlVdbeAddOp2(v, OP_SDelete, BOX_INDEX_ID,
@@ -1533,7 +1534,7 @@ sql_code_drop_table(struct Parse *parse_context, struct space *space,
space->index[i]->def->iid));
}
}
- sqlVdbeAddOp2(v, OP_Integer, 0, space_id_reg + 1);
+ sqlVdbeAddOp2(v, OP_Integer, 0, index_id_reg);
sqlVdbeAddOp3(v, OP_MakeRecord, space_id_reg, 2,
idx_rec_reg);
sqlVdbeAddOp2(v, OP_SDelete, BOX_INDEX_ID, idx_rec_reg);
@@ -2560,8 +2561,9 @@ sql_drop_index(struct Parse *parse_context)
sql_clear_stat_spaces(parse_context, table_name, index->def->name);
int record_reg = ++parse_context->nMem;
int space_id_reg = ++parse_context->nMem;
+ int index_id_reg = ++parse_context->nMem;
sqlVdbeAddOp2(v, OP_Integer, space->def->id, space_id_reg);
- sqlVdbeAddOp2(v, OP_Integer, index_id, space_id_reg + 1);
+ sqlVdbeAddOp2(v, OP_Integer, index_id, index_id_reg);
sqlVdbeAddOp3(v, OP_MakeRecord, space_id_reg, 2, record_reg);
sqlVdbeAddOp2(v, OP_SDelete, BOX_INDEX_ID, record_reg);
sqlVdbeChangeP5(v, OPFLAG_NCHANGE);
--
2.7.4
next prev parent reply other threads:[~2019-04-03 16:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-03 16:58 [PATCH v2 0/3] box: drop _sql_stat1 and _sql_stat4 tables imeevma
2019-04-03 16:58 ` imeevma [this message]
2019-04-04 16:00 ` [PATCH v2 1/3] sql: allocate memory for index_id in VDBE Vladimir Davydov
2019-04-03 16:58 ` [PATCH v2 2/3] sql: remove space_by_id() from analyze.c imeevma
2019-04-04 16:03 ` Vladimir Davydov
2019-04-04 17:41 ` Vladimir Davydov
2019-04-03 16:58 ` [PATCH v2 3/3] box: remove _sql_stat1 and _sql_stat4 system tables imeevma
2019-04-03 17:19 ` Vladimir Davydov
2019-04-03 17:38 ` Re[2]: " Мерген Имеев
2019-04-03 17:58 ` Vladimir Davydov
2019-04-03 18:04 ` [tarantool-patches] Re: [tarantool-patches] " Мерген Имеев
2019-04-04 16:11 ` Vladimir Davydov
2019-04-04 18:18 ` Mergen Imeev
2019-04-05 11:36 ` [tarantool-patches] [PATCH v2 0/3] box: drop _sql_stat1 and _sql_stat4 tables 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=67e2542a83b9db776d04af47af4cbb78f95b8711.1554310018.git.imeevma@gmail.com \
--to=imeevma@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH v2 1/3] sql: allocate memory for index_id in VDBE' \
/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