Skip to content

change implicit cast for assignment #1409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TarantoolBot opened this issue Jul 16, 2020 · 1 comment
Closed

change implicit cast for assignment #1409

TarantoolBot opened this issue Jul 16, 2020 · 1 comment
Assignees
Labels
feature A new functionality sql [location] SQL manual

Comments

@TarantoolBot
Copy link
Collaborator

After this patch, these rules will apply during the implicit cast:

STRING BINARY BOOLEAN INTEGER UNSIGNED DOUBLE
STRING A N N N N N
BINARY N A N N N N
BOOLEAN N N A N N N
INTEGER N N N A S Aa
UNSIGNED N N N A A Aa
DOUBLE N N N Sa Sa A

In this table, the types of the assigned value are on the left,
and the types that should be after the assignment are at the top.

'A' - the assignment will be completed.
'N' - the assignment won't be completed.
'S' - the appointment may be unsuccessful.
'a' - after assignment, the resulting value may be approximated.

Rules for numeric values are these:

  1. Loss of significant digits (overflow) is an error.
  2. Loss of insignificant digits is not an error.

Example:

tarantool> box.execute([[CREATE TABLE t1(i INT PRIMARY KEY);]])
tarantool> box.execute([[INSERT INTO t1 VALUES ('1');]])
---
- null
- 'Type mismatch: can not convert 1 to integer'
...

tarantool> box.execute('INSERT INTO t1 VALUES (1.2345);')
tarantool> box.execute('SELECT * FROM t1;')
---
- metadata:
  - name: I
    type: integer
  rows:
  - [1]
...

tarantool> box.execute([[CREATE TABLE t2(t text PRIMARY KEY);]])
tarantool> box.execute([[INSERT INTO t2 VALUES (1);]])
---
- null
- 'Type mismatch: can not convert 1 to string'
...

Requested by @ImeevMA in tarantool/tarantool@30c57bb.

@ImeevMA ImeevMA changed the title change implicit cast for comparison change implicit cast for assignment Jul 17, 2020
@lenkis lenkis added feature A new functionality sql [location] SQL manual 2.5 labels Jul 24, 2020
@pgulutzan
Copy link
Contributor

@lenkis: The significant matter is that implicit casts to/from
STRING/number are no longer legal.
I made the change in the version 2.5 manual.
I added a deprecation warning in the version 2.4 manual,
but only in the SQL section. I did not add a deprecation
warning elsewhere, because I expect that will happen
when the Release Notes section is updated.
This is correctly described in the Tarantool release announcement for 2.5.1 beta
"[Breaking change] Define new rules for implicit cast for assignment operation in SQL (gh-3809)."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality sql [location] SQL manual
Projects
None yet
Development

No branches or pull requests

3 participants