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 2750B2A328 for ; Tue, 20 Mar 2018 06:54:57 -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 lKWL2axlb16g for ; Tue, 20 Mar 2018 06:54:57 -0400 (EDT) Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 844E02A132 for ; Tue, 20 Mar 2018 06:54:56 -0400 (EDT) Date: Tue, 20 Mar 2018 13:54:53 +0300 From: Kirill Yukhin Subject: [tarantool-patches] Re: [PATCH 2/4] sql: rework OP_Clear internals Message-ID: <20180320105452.2oln3bfvc4uhkuhg@tarantool.org> References: <48d971ed5d65bb116a6b6719cbf5f13b6328b136.1521479592.git.korablev@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <48d971ed5d65bb116a6b6719cbf5f13b6328b136.1521479592.git.korablev@tarantool.org> 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: Nikita Pettik Hello, My comments are inlined. On 19 мар 21:10, Nikita Pettik wrote: > This patch makes OP_Clear use pointer to space instead of space id. > Moreover, in order to avoid excess function calls (such as box_delete() -> > box_process1(), which in its turn makes additional space lookup), > sql_execute_dml() function is introduced. It is an analogue of > process_rw() from BOX internals. Its purpose is to handle transaction > routine and call DML executor. This function will be also used later as > well during insertion and deletion. > > Part of #3122 > --- > src/box/sql.c | 54 +++++++++++++++++++++++++++++++--------------- > src/box/sql/opcodes.c | 2 +- > src/box/sql/opcodes.h | 2 +- > src/box/sql/tarantoolInt.h | 2 +- > src/box/sql/vdbe.c | 28 ++++++++++-------------- > 5 files changed, 51 insertions(+), 37 deletions(-) > > diff --git a/src/box/sql.c b/src/box/sql.c > index 256985793..4f8b39810 100644 > --- a/src/box/sql.c > +++ b/src/box/sql.c > @@ -191,6 +191,27 @@ is_tarantool_error(int rc) > rc == SQL_TARANTOOL_INSERT_FAIL); > } > > +/** > + * This function is analogue of process_rw() from box module. > + * Apart of calling space_execute_dml(), it handles transaction > + * routine. > + */ Could you pls describe params as well? > +static int > +sql_execute_dml(struct request *request, struct space *space) > +{ > + struct txn *txn = txn_begin_stmt(space); > + if (txn == NULL) > + return -1; > + struct tuple *unused = NULL; > + if (space_execute_dml(space, txn, request, &unused) != 0) { > + txn_rollback_stmt(); > + return -1; > + } > + if (txn_commit_stmt(txn, request) != 0) > + return -1; > + return 0; > +} So, you've copied process_rw, removing statitics udpate and access checks? I think, this won't work. The only concern I see here is that process_rw returns a tuple, which is useless for SQL so far. > @@ -670,30 +689,31 @@ int tarantoolSqlite3ClearTable(int iTable) > } > } > - box_iterator_free(iter); > - } else if (box_truncate(space_id) != 0) { > + iterator_delete(iter); > + } else if (box_truncate(space->def->id) != 0) { I think we should block box_truncate sp far: too much complications this DDL operation introduce. We'll re-implement it as optimization in furture. Also, we'll support ANSI SQL's TRUNCATE TABLE. -- Kirill