[Tarantool-patches] [PATCH v4 2/3] sql: fix implicit cast from STRING to INTEGER

Nikita Pettik korablev at tarantool.org
Fri Apr 10 15:57:57 MSK 2020


On 10 Apr 13:41, Mergen Imeev wrote:
> On Fri, Mar 27, 2020 at 04:54:17PM +0000, Nikita Pettik wrote:
> > On 27 Mar 14:33, imeevma at tarantool.org wrote:
> > > Prior to this patch, STRING, which contains the DOUBLE value,
> > > could be implicitly cast to INTEGER. This was done by converting
> > > STRING to DOUBLE and then converting this DOUBLE value to INTEGER.
> > > This may affect the accuracy of CAST(), so it was forbidden.
> > > 
> > > Example:
> > > box.execute("CREATE TABLE t(i INT PRIMARY KEY);")
> > > 
> > > Before patch:
> > > box.execute("INSERT INTO t VALUES ('111.1');")
> > > box.execute("SELECT * FROM t;")
> > > Result: 111
> > > 
> > > After patch:
> > > box.execute("INSERT INTO t VALUES ('1.1');")
> > > Result: 'Type mismatch: can not convert 1.1 to integer'
> > > 
> > > box.execute("INSERT INTO t VALUES ('1.0');")
> > > Result: 'Type mismatch: can not convert 1.0 to integer'
> > > 
> > > box.execute("INSERT INTO t VALUES ('1.');")
> > > Result: 'Type mismatch: can not convert 1. to integer'
> > 
> > Is comparison predicat affected?
> > 
> No, since all implicit casts in case of comparison executed
> inside of comparisons opcodes.

You should have mentioned this fact in commit message.

LGTM otherwise.
 


More information about the Tarantool-patches mailing list