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
sql: support -2^63 .. 2^64-1 integer type #3810
Comments
@kostja says it should be INT, so it seems we'll going with the first way. |
Due to this feature we may observe strange behaviour during Lua-SQL interaction:
|
Let's do this:
|
Note re ODBC:
AFAIR, there is also a document around JDBC that provide some recommendations for mapping SQL types to Java ones that recommends to map INTEGER into long or int (don't sure), but it seems it is not mandatory. (TBD: find the document.) However ODBC wording looks as requirement rather then recommendation. There is the sense here: we have native BigInteger in Java, but have no a native (and standard) type in C broader then int64_t / uint64_t. |
upd.: I've banned opportunity to operate on integers in range [INT64_MAX, UINT64_MAX] in scope of this issue: #3735, even if they are fetched from space tuples. So examples like:
now are resulting in If this is enough for 2.1.1, I suggest to move this ticket to 2.2. |
I suggest changing the error message from "integer is overflowed" to "integer overflow". |
Fixes an error in the conversion functions. The cast to integer didn't take into account the 'unsigned' bit. Fixes the error in overflow check inside the sqlMulInt64(). Makes the overflow check more precisely in sql_atoi64(). Fixes the error message, and affected tests. Part of #3810
Adds functions setting and retrieving unsigned value. Adds a new member to struct sql_bind and struct Mem to keep an unsigned value atoi functions return 0 on success and -1 on error and return the signed/unsigned property by pointer. The cast operations take the unsigned into account. Fixes the affected tests. The sql function avg() uses uint64. Part of #3810
Returns correct text name for unsigned data type. Applies a coding standard. Improves mapping of vdbe data types to sql data types. Part of #3810
Adapts auxiliary functions for supporting arithmetic operations with unsigned integers. VDBE distinguishes signed and unsigned integers. SELECT query correctly returns values greater than INT64_MAX. Part of #3810
Fixes an error in the conversion functions. The cast to integer didn't take into account the 'unsigned' bit. Fixes the error in overflow check inside the sqlMulInt64(). Makes the overflow check more precisely in sql_atoi64(). Fixes the error message, and affected tests. Part of #3810
We are going to allow using unsigned values in SQL and extend range of INTEGER type. Hence, we should be able to parse and operate on integers in range of [2^63, 2^64 - 1]. Current mechanism which involves sql_atoi64() function doesn't allow this. Let's refactor this function: firstly, get rid of manual parsing and use strtoll() and strtoull() functions from standard library. Then, let's return sign of parsed literal. In case of success now function returns 0, -1 otherwise. This patch also inlines sql_dec_or_hex_to_i64() to place of its only usage: it makes code cleaner and more straightforward. Needed for #3810 Needed for #4015
As it was stated in the previous commit message, we are going to support operations on unsigned values. Since unsigned and signed integers have different memory representations, to provide correct results of arithmetic operations we should be able to tell whether value is signed or not. This patch introduces new type of value placed in VDBE memory cell - MEM_UInt. This flag means that value is integer and greater than zero, hence can be fitted in range [0, 2^64 - 1]. Such approach would make further replacing MEM_* flags with MP_ format types quite easy: during decoding and encoding msgpack we assume that negative integers have MP_INT type and positive - MP_UINT. We also add and refactor several auxiliary helpers to operate on integers. Note that current changes don't add ability to operate on unsigned integers - it is still unavailable. Needed for #3810 Needed for #4015
This patch allows to operate on integer values in range [2^63, 2^64 - 1] It means that: - One can use literals from 9223372036854775808 to 18446744073709551615 - One can pass values from mentioned range to bindings - One can insert and select values from mentioned range Support of built-in functions and operators has been introduced in previous patches. Closes #3810 Part of #4015
As it was stated in the previous commit message, we are going to support operations on unsigned values. Since unsigned and signed integers have different memory representations, to provide correct results of arithmetic operations we should be able to tell whether value is signed or not. This patch introduces new type of value placed in VDBE memory cell - MEM_UInt. This flag means that value is integer and greater than zero, hence can be fitted in range [0, 2^64 - 1]. Such approach would make further replacing MEM_* flags with MP_ format types quite easy: during decoding and encoding msgpack we assume that negative integers have MP_INT type and positive - MP_UINT. We also add and refactor several auxiliary helpers to operate on integers. Note that current changes don't add ability to operate on unsigned integers - it is still unavailable. Needed for #3810 Needed for #4015
This patch allows to operate on integer values in range [2^63, 2^64 - 1] It means that: - One can use literals from 9223372036854775808 to 18446744073709551615 - One can pass values from mentioned range to bindings - One can insert and select values from mentioned range Support of built-in functions and operators has been introduced in previous patches. Closes #3810 Part of #4015
As it was stated in the previous commit message, we are going to support operations on unsigned values. Since unsigned and signed integers have different memory representations, to provide correct results of arithmetic operations we should be able to tell whether value is signed or not. This patch introduces new type of value placed in VDBE memory cell - MEM_UInt. This flag means that value is integer and greater than zero, hence can be fitted in range [0, 2^64 - 1]. Such approach would make further replacing MEM_* flags with MP_ format types quite easy: during decoding and encoding msgpack we assume that negative integers have MP_INT type and positive - MP_UINT. We also add and refactor several auxiliary helpers to operate on integers. Note that current changes don't add ability to operate on unsigned integers - it is still unavailable. Needed for #3810 Needed for #4015
This patch allows to operate on integer values in range [2^63, 2^64 - 1] It means that: - One can use literals from 9223372036854775808 to 18446744073709551615 - One can pass values from mentioned range to bindings - One can insert and select values from mentioned range Support of built-in functions and operators has been introduced in previous patches. Closes #3810 Part of #4015
As it was stated in the previous commit message, we are going to support operations on unsigned values. Since unsigned and signed integers have different memory representations, to provide correct results of arithmetic operations we should be able to tell whether value is signed or not. This patch introduces new type of value placed in VDBE memory cell - MEM_UInt. This flag means that value is integer and greater than zero, hence can be fitted in range [0, 2^64 - 1]. Such approach would make further replacing MEM_* flags with MP_ format types quite easy: during decoding and encoding msgpack we assume that negative integers have MP_INT type and positive - MP_UINT. We also add and refactor several auxiliary helpers to operate on integers. Note that current changes don't add ability to operate on unsigned integers - it is still unavailable. Needed for #3810 Needed for #4015
This patch allows to operate on integer values in range [2^63, 2^64 - 1] It means that: - One can use literals from 9223372036854775808 to 18446744073709551615 - One can pass values from mentioned range to bindings - One can insert and select values from mentioned range Support of built-in functions and operators has been introduced in previous patches. Closes #3810 Part of #4015
We are going to allow using unsigned values in SQL and extend range of INTEGER type. Hence, we should be able to parse and operate on integers in range of [2^63, 2^64 - 1]. Current mechanism which involves sql_atoi64() function doesn't allow this. Let's refactor this function: firstly, get rid of manual parsing and use strtoll() and strtoull() functions from standard library. Then, let's return sign of parsed literal. In case of success now function returns 0, -1 otherwise. This patch also inlines sql_dec_or_hex_to_i64() to place of its only usage: it makes code cleaner and more straightforward. Needed for #3810 Needed for #4015
As it was stated in the previous commit message, we are going to support operations on unsigned values. Since unsigned and signed integers have different memory representations, to provide correct results of arithmetic operations we should be able to tell whether value is signed or not. This patch introduces new type of value placed in VDBE memory cell - MEM_UInt. This flag means that value is integer and greater than zero, hence can be fitted in range [0, 2^64 - 1]. Such approach would make further replacing MEM_* flags with MP_ format types quite easy: during decoding and encoding msgpack we assume that negative integers have MP_INT type and positive - MP_UINT. We also add and refactor several auxiliary helpers to operate on integers. Note that current changes don't add ability to operate on unsigned integers - it is still unavailable. Needed for #3810 Needed for #4015
This patch allows to operate on integer values in range [2^63, 2^64 - 1] It means that: - One can use literals from 9223372036854775808 to 18446744073709551615 - One can pass values from mentioned range to bindings - One can insert and select values from mentioned range Support of built-in functions and operators has been introduced in previous patches. Closes #3810 Part of #4015
We are going to allow using unsigned values in SQL and extend range of INTEGER type. Hence, we should be able to parse and operate on integers in range of [2^63, 2^64 - 1]. Current mechanism which involves sql_atoi64() function doesn't allow this. Let's refactor this function: firstly, get rid of manual parsing and use strtoll() and strtoull() functions from standard library. Then, let's return sign of parsed literal. In case of success now function returns 0, -1 otherwise. This patch also inlines sql_dec_or_hex_to_i64() to place of its only usage: it makes code cleaner and more straightforward. Needed for #3810 Needed for #4015
As it was stated in the previous commit message, we are going to support operations on unsigned values. Since unsigned and signed integers have different memory representations, to provide correct results of arithmetic operations we should be able to tell whether value is signed or not. This patch introduces new type of value placed in VDBE memory cell - MEM_UInt. This flag means that value is integer and greater than zero, hence can be fitted in range [0, 2^64 - 1]. Such approach would make further replacing MEM_* flags with MP_ format types quite easy: during decoding and encoding msgpack we assume that negative integers have MP_INT type and positive - MP_UINT. We also add and refactor several auxiliary helpers to operate on integers. Note that current changes don't add ability to operate on unsigned integers - it is still unavailable. Needed for #3810 Needed for #4015
We need a SQL type to match native Tarantool's 'integer' space format / index format type, which represents -2^63 .. 2^64-1 range of integral numbers. Those number are encoded as int64 or uint64 msgpack type depending of value.
Now we support the following integral number types in Tarantool/SQL: INT / INTEGER. SMALLINT and BIGINT intended to be supported after #3687.
There are the following ways to implement SQL type for the -2^63 .. 2^64-1 range:
I vote for the first way, because Tarantool/SQL type INTEGER is expected to represent the same range as native Tarantool's 'integer'.
The text was updated successfully, but these errors were encountered: