[Tarantool-discussions] Implicit cast in SQL
imeevma at tarantool.org
Sat Jan 11 16:33:21 MSK 2020
I have a question to discuss. I know that we have discussed this
issue quite a few times. But, since we have a few open issues on
github, I think the final answer has not yet been found. I want to
completely close the issue this time.
I would like to start with an implicit cast. Implicit cast
consists of implicit type conversion for COMPARISON and implicit
type conversion for ASSIGNMENT.
Currently, all types can be divided into four categories:
numeric (UNSIGNED, INTEGER, NUMBER, DOUBLE), string (STRING),
binary (VARBINARY) and boolean (BOOLEAN). We also have a scalar
type, but any value of a scalar type has some subtype that can be
placed in one of these four categories.
So, I suggest this:
Implicit type conversion for COMPARISON:
1) types of the same category can be implicitly cast to each
2) types of different categories cannot be implicitly cast to
Implicit type conversion for ASSIGNMENT:
1) If a user-defined cast function (UDCF) is defined, then this
function is used;
2) If UDCF is not defined, then types of the same category can be
implicitly cast to each other, and types of different categories
cannot be implicitly cast to each other.
I think this is what ANSI says.
We currently do not have such a thing as UDCF. I suggest to fill
an issue and use the same rules for ASSIGNMENT as for COMPARISON.
In fact, I think we can create a special option for assigning
UCDF during the rework of implicit type conversion for ASSIGNMENT.
What do you think about this?
More information about the Tarantool-discussions