[tarantool-patches] Re: [PATCH v1 1/1] sql: invalid integer type in arithmetic operations

Kirill Shcherbatov kshcherbatov at tarantool.org
Thu Apr 25 14:21:34 MSK 2019


> Please do a table. You already have a branching hell, and UNSIGNED
> arithmetics is raising questions. In particular, 

> I disagree that unsigned + unsigned should give you number - it should give you unsigned. 
It is not so, look (master, ff8462554d33d971e6d6df3c6e8913785e7d9d61):

-       if (sql_type_is_numeric(lhs) || sql_type_is_numeric(rhs))
-               return FIELD_TYPE_NUMBER;
+       if (sql_type_is_numeric(lhs) || sql_type_is_numeric(rhs)) {
+               if (lhs == FIELD_TYPE_NUMBER || rhs == FIELD_TYPE_NUMBER)
+                       return FIELD_TYPE_NUMBER;
+               if (lhs == FIELD_TYPE_INTEGER || rhs == FIELD_TYPE_INTEGER)
+                       return FIELD_TYPE_INTEGER;
+               assert(lhs == FIELD_TYPE_UNSIGNED ||
+                      rhs == FIELD_TYPE_UNSIGNED);
+               return FIELD_TYPE_UNSIGNED;
+       }




More information about the Tarantool-patches mailing list