[tarantool-patches] Re: [PATCH 2/8] sql: use field type instead of affinity for type_def

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Dec 29 20:42:34 MSK 2018


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.
>    *




More information about the Tarantool-patches mailing list