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 558F221227 for ; Sat, 29 Dec 2018 12:42:36 -0500 (EST) 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 SsZkTGf7kaug for ; Sat, 29 Dec 2018 12:42:36 -0500 (EST) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 183EC1FFDA for ; Sat, 29 Dec 2018 12:42:36 -0500 (EST) Subject: [tarantool-patches] Re: [PATCH 2/8] sql: use field type instead of affinity for type_def References: From: Vladislav Shpilevoy Message-ID: Date: Sat, 29 Dec 2018 20:42:34 +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: tarantool-patches@freelists.org, Nikita Pettik Thanks for the patch! See 1 comment below. On 28/12/2018 12:34, Nikita Pettik wrote: > Also, this allows to delay affinity assignment to field def until > encoding of table format. > > Part of #3698 > --- > src/box/sql.c | 4 +++- > src/box/sql/build.c | 23 +++++++++++++++++++++-- > src/box/sql/parse.y | 26 +++++++++++++------------- > src/box/sql/sqliteInt.h | 5 ++++- > test/sql/types.result | 4 ++-- > 5 files changed, 43 insertions(+), 19 deletions(-) > > diff --git a/src/box/sql/build.c b/src/box/sql/build.c > index 49b90b5d0..beaafe1bc 100644 > --- a/src/box/sql/build.c > +++ b/src/box/sql/build.c > @@ -501,6 +501,26 @@ sql_affinity_to_field_type(enum affinity_type affinity) > } > } > > +enum affinity_type > +sql_field_type_to_affinity(enum field_type field_type) If I were you, I would moved this function to field_def.c/.h, but taking into account that it is a temporary crutch anyway, it is up to you. > +{ > + switch (field_type) { > + case FIELD_TYPE_INTEGER: > + case FIELD_TYPE_UNSIGNED: > + return AFFINITY_INTEGER; > + case FIELD_TYPE_NUMBER: > + return AFFINITY_REAL; > + case FIELD_TYPE_STRING: > + return AFFINITY_TEXT; > + case FIELD_TYPE_SCALAR: > + return AFFINITY_BLOB; > + case FIELD_TYPE_ANY: > + return AFFINITY_UNDEFINED; > + default: > + unreachable(); > + } > +} > + > /* > * Add a new column to the table currently being constructed. > *