[Tarantool-patches] [PATCH 2/3] sql: CAST(<boolean> AS TEXT) returns lowercase

Nikita Pettik korablev at tarantool.org
Mon Oct 28 17:08:51 MSK 2019


On 27 Oct 22:35, Vladislav Shpilevoy wrote:
> Implicit cast uses lowercase, and the patch makes the
> explicit cast the same.
> 
> No any special reason behind that. Lower case is
> already used much more often, so it is easier to drop
> the upper case.
> 
> Part of #4462
> ---

Oh, unfortunately I've remembered the reason of using uppercase: it is
said so by ANSI (2011):

6.13 <cast specification>

...

11) If TD is variable-length character string or large object character
string, then let MLTD be the maximum length in characters of TD.

...

e) If SD is boolean, then

Case:

i) If SV is True and MLTD is not less than 4, then TV is 'TRUE'.

ii) If SV is False and MLTD is not less than 5, then TV is 'FALSE'

...

As for implicit cast - it is allowed neither in ANSI nor in Tarantool SQL.
However, some functions (like length or group_concat) anyway provide implicit
conversion from boolean to string. Why not simply disallow that?
Earlier I suggested to remove all dispatching logic from built-ins
implementations and instead generate OP_ApplyType with function's argument
and its assumed type. AfAIR Mergen faced some problems with that, but I
believe it is likely to be most general and correct solution.



More information about the Tarantool-patches mailing list