Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 1/2] sql: derive collation for built-in functions
Date: Mon, 25 Feb 2019 15:58:35 +0300	[thread overview]
Message-ID: <92715853-76c0-36ca-1bae-84a8a8939f7e@tarantool.org> (raw)
In-Reply-To: <f1fd4382738c37594b1f7ece5e153237f08e5be1.1550768589.git.korablev@tarantool.org>

Hi! Thanks for the patch!

On 21/02/2019 21:01, Nikita Pettik wrote:
> Functions such as trim(), substr() etc should return result with
> collation derived from their arguments. So, lets add flag indicating
> that collation of first argument must be applied to function's result to
> SQL function definition. Using this flag, we can derive appropriate
> collation in sql_expr_coll().
> 
> Part of #3932
> ---
>   src/box/sql/analyze.c       |  6 +++---
>   src/box/sql/expr.c          | 23 +++++++++++++++++++++++
>   src/box/sql/func.c          | 22 +++++++++++-----------
>   src/box/sql/sqlInt.h        | 31 +++++++++++++++++++++++--------
>   test/sql/collation.result   | 28 ++++++++++++++++++++++++++++
>   test/sql/collation.test.lua | 11 +++++++++++
>   6 files changed, 99 insertions(+), 22 deletions(-)
> 
> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
> index 2830ab639..5fb7285d8 100644
> --- a/src/box/sql/sqlInt.h
> +++ b/src/box/sql/sqlInt.h
> @@ -1633,6 +1633,13 @@ struct FuncDef {
>   	} u;
>   	/* Return type. */
>   	enum field_type ret_type;
> +	/**
> +	 * If function returns string, it may require collation
> +	 * to be applied on its result. For instance, result of
> +	 * substr() built-in function must have the same collation
> +	 * as its first argument.
> +	 */
> +	bool is_coll_derived;
>   };

This way works only for builtin functions taking not a
bind parameter ('?'). For user-defined functions and for
bind parameters it does not fit. How can you determine
a function's result collation, if it is not builtin, and
does not depend on arguments?

Does SQL standard allow to define user functions without
a runtime defined collation? If SQL standard does not define
SQL functions at all, then what other vendors do with that
problem?

  reply	other threads:[~2019-02-25 12:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 18:01 [tarantool-patches] [PATCH 0/2] Add collation to built-in funcs and fix HAVING clause with aggregate Nikita Pettik
2019-02-21 18:01 ` [tarantool-patches] [PATCH 1/2] sql: derive collation for built-in functions Nikita Pettik
2019-02-25 12:58   ` Vladislav Shpilevoy [this message]
2019-02-25 18:32     ` [tarantool-patches] " n.pettik
2019-03-07 14:40       ` Vladislav Shpilevoy
2019-03-11  8:04         ` Konstantin Osipov
2019-02-21 18:01 ` [tarantool-patches] [PATCH 2/2] sql: fix code generation for aggregate in HAVING clause Nikita Pettik
2019-02-25 12:58   ` [tarantool-patches] " Vladislav Shpilevoy
2019-02-25 18:33     ` n.pettik
2019-03-04 12:14       ` n.pettik
2019-03-04 12:52         ` Vladislav Shpilevoy
2019-03-07 14:40 ` [tarantool-patches] Re: [PATCH 0/2] Add collation to built-in funcs and fix HAVING clause with aggregate Vladislav Shpilevoy
2019-03-11 15:49 ` 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=92715853-76c0-36ca-1bae-84a8a8939f7e@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 1/2] sql: derive collation for built-in functions' \
    /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