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 0DCB329275 for ; Fri, 1 Jun 2018 14:00:52 -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 zqF42Nb-PJXL for ; Fri, 1 Jun 2018 14:00:51 -0400 (EDT) Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (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 BDF4829270 for ; Fri, 1 Jun 2018 14:00:51 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/3] sql: fetch primary index for affinity only References: From: Vladislav Shpilevoy Message-ID: <5bc1cc0b-529b-62b7-6ed3-36f657db1cd2@tarantool.org> Date: Fri, 1 Jun 2018 21:00:49 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Kirill Yukhin Cc: tarantool-patches@freelists.org Hello. Thanks for the patch! See 2 comments below. On 01/06/2018 18:16, Kirill Yukhin wrote: > This small patch removes usages of primary index throughout > code sql_table_delete_from, limiting use to fetching of > affinities only. We cannot use space_def here, since primary > index might contain calculated columns. 1. What are calculated columns? > > Part of #3235 > --- > src/box/sql/delete.c | 54 ++++++++++++++++++++++++++++++++++++---------------- > 1 file changed, 38 insertions(+), 16 deletions(-) > > diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c > index ddad54b..28713c8 100644 > --- a/src/box/sql/delete.c > +++ b/src/box/sql/delete.c > @@ -183,6 +183,16 @@ sql_table_delete_from(struct Parse *parse, struct SrcList *tab_list, > struct NameContext nc; > memset(&nc, 0, sizeof(nc)); > nc.pParse = parse; > + if (tab_list->a[0].pTab == NULL) { > + struct Table *t = malloc(sizeof(struct Table)); > + if (t == NULL) { > + sqlite3OomFault(parse->db); > + goto delete_from_cleanup; > + } > + assert(space != NULL); > + t->def = space->def; > + tab_list->a[0].pTab = t; 2. Why can not you declare struct Table on the stack at the top of this function, and here use its address? Can this pTab be used out of sql_table_delete_from()? And I do not see where do you delete this table. > + } > nc.pSrcList = tab_list; > if (sqlite3ResolveExprNames(&nc, where)) > goto delete_from_cleanup;