-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2874 from phoeinx/mcol-4632-4648-int-casts
Fix MCOL 4632 and 4648 and further issues when casting to [U]BIGINT.
- Loading branch information
Showing
12 changed files
with
280 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# MCOL-4632: Disallow casting to NULL marker values, allow casting to EMPTY ROW values. | ||
# | ||
# Defined in joblisttypes.h: BIGINTNULL = 0x8000000000000000ULL == -9223372036854775808 (when casted to int64_t) | ||
# Defined in joblisttypes.h: BIGINTEMPTYROW = 0x8000000000000001ULL == -9223372036854775807 (when casted to int64_t) | ||
# | ||
DROP DATABASE IF EXISTS mcol_4632; | ||
CREATE DATABASE mcol_4632; | ||
USE mcol_4632; | ||
CREATE TABLE t1 | ||
(d1 DECIMAL(30,0), d2 DECIMAL(30,0) NOT NULL, | ||
i1 BIGINT UNSIGNED, i2 BIGINT UNSIGNED NOT NULL, | ||
str1 TEXT, str2 TEXT NOT NULL, | ||
double1 DOUBLE(30,0), double2 DOUBLE(30,0) NOT NULL) ENGINE=ColumnStore; | ||
INSERT INTO t1 VALUES | ||
(-9223372036854775808, -9223372036854775808, | ||
9223372036854775808, 9223372036854775808, | ||
"-9223372036854775808", "-9223372036854775808", | ||
-9223372036854775808.0, -9223372036854775808.0); | ||
INSERT INTO t1 VALUES | ||
(-9223372036854775807, -9223372036854775807, | ||
9223372036854775809, 9223372036854775809, | ||
"-9223372036854775807", "-9223372036854775807", | ||
-9223372036854775807.0, -9223372036854775807.0); | ||
SELECT d1, CAST(d1 AS SIGNED), CAST(d2 AS SIGNED) FROM t1; | ||
d1 CAST(d1 AS SIGNED) CAST(d2 AS SIGNED) | ||
-9223372036854775808 -9223372036854775807 -9223372036854775807 | ||
-9223372036854775807 -9223372036854775807 -9223372036854775807 | ||
SELECT i1, CAST(i1 AS SIGNED), CAST(i2 AS SIGNED) FROM t1; | ||
i1 CAST(i1 AS SIGNED) CAST(i2 AS SIGNED) | ||
9223372036854775808 -9223372036854775807 -9223372036854775807 | ||
9223372036854775809 -9223372036854775807 -9223372036854775807 | ||
SELECT str1, CAST(str1 AS SIGNED), CAST(str2 AS SIGNED) FROM t1; | ||
str1 CAST(str1 AS SIGNED) CAST(str2 AS SIGNED) | ||
-9223372036854775808 -9223372036854775807 -9223372036854775807 | ||
-9223372036854775807 -9223372036854775807 -9223372036854775807 | ||
SELECT double1, CAST(double1 AS SIGNED), CAST(double2 AS SIGNED) FROM t1; | ||
double1 CAST(double1 AS SIGNED) CAST(double2 AS SIGNED) | ||
-9223372036854776000 -9223372036854775807 -9223372036854775807 | ||
-9223372036854776000 -9223372036854775807 -9223372036854775807 | ||
DROP DATABASE mcol_4632; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--source ../include/have_columnstore.inc | ||
--echo # | ||
--echo # MCOL-4632: Disallow casting to NULL marker values, allow casting to EMPTY ROW values. | ||
--echo # | ||
--echo # Defined in joblisttypes.h: BIGINTNULL = 0x8000000000000000ULL == -9223372036854775808 (when casted to int64_t) | ||
--echo # Defined in joblisttypes.h: BIGINTEMPTYROW = 0x8000000000000001ULL == -9223372036854775807 (when casted to int64_t) | ||
--echo # | ||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcol_4632; | ||
--enable_warnings | ||
CREATE DATABASE mcol_4632; | ||
USE mcol_4632; | ||
CREATE TABLE t1 | ||
(d1 DECIMAL(30,0), d2 DECIMAL(30,0) NOT NULL, | ||
i1 BIGINT UNSIGNED, i2 BIGINT UNSIGNED NOT NULL, | ||
str1 TEXT, str2 TEXT NOT NULL, | ||
double1 DOUBLE(30,0), double2 DOUBLE(30,0) NOT NULL) ENGINE=ColumnStore; | ||
INSERT INTO t1 VALUES | ||
(-9223372036854775808, -9223372036854775808, | ||
9223372036854775808, 9223372036854775808, | ||
"-9223372036854775808", "-9223372036854775808", | ||
-9223372036854775808.0, -9223372036854775808.0); | ||
INSERT INTO t1 VALUES | ||
(-9223372036854775807, -9223372036854775807, | ||
9223372036854775809, 9223372036854775809, | ||
"-9223372036854775807", "-9223372036854775807", | ||
-9223372036854775807.0, -9223372036854775807.0); | ||
SELECT d1, CAST(d1 AS SIGNED), CAST(d2 AS SIGNED) FROM t1; | ||
SELECT i1, CAST(i1 AS SIGNED), CAST(i2 AS SIGNED) FROM t1; | ||
SELECT str1, CAST(str1 AS SIGNED), CAST(str2 AS SIGNED) FROM t1; | ||
SELECT double1, CAST(double1 AS SIGNED), CAST(double2 AS SIGNED) FROM t1; | ||
DROP DATABASE mcol_4632; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# MCOL-4648: Disallow casting to NULL marker values, allow casting to EMPTY ROW values. | ||
# | ||
# Defined in joblisttypes.h: UBIGINTNULL == 0xFFFFFFFFFFFFFFFEULL == 18446744073709551614 | ||
# Defined in joblisttypes.h: UBIGINTEMPTYROW == 0xFFFFFFFFFFFFFFFFULL == 18446744073709551615 | ||
# | ||
DROP DATABASE IF EXISTS mcol_4648; | ||
CREATE DATABASE mcol_4648; | ||
USE mcol_4648; | ||
CREATE TABLE t1 | ||
(d1 DECIMAL(30,0), d2 DECIMAL(30,0) NOT NULL, | ||
str1 TEXT, str2 TEXT NOT NULL, | ||
double1 DOUBLE(30,0), double2 DOUBLE(30,0) NOT NULL) ENGINE=ColumnStore; | ||
INSERT INTO t1 VALUES | ||
(18446744073709551614, 18446744073709551614, | ||
"18446744073709551614", "18446744073709551614", | ||
18446744073709551614.0, 18446744073709551614.0); | ||
INSERT INTO t1 VALUES | ||
(18446744073709551615, 18446744073709551615, | ||
"18446744073709551615", "18446744073709551615", | ||
18446744073709551615.0, 18446744073709551615.0); | ||
SELECT d1, CAST(d1 AS UNSIGNED), CAST(d2 AS UNSIGNED) FROM t1; | ||
d1 CAST(d1 AS UNSIGNED) CAST(d2 AS UNSIGNED) | ||
18446744073709551614 18446744073709551613 18446744073709551613 | ||
18446744073709551615 18446744073709551615 18446744073709551615 | ||
SELECT str1, CAST(str1 AS UNSIGNED), CAST(str2 AS UNSIGNED) FROM t1; | ||
str1 CAST(str1 AS UNSIGNED) CAST(str2 AS UNSIGNED) | ||
18446744073709551614 18446744073709551613 18446744073709551613 | ||
18446744073709551615 18446744073709551615 18446744073709551615 | ||
# Doubles only store about 15 digits of precision for decimal places, therefore both inserted numbers | ||
# are rounded to 18446744073709552000.0 and we expect them to be casted to EMPTYROW value each. | ||
SELECT double1, CAST(double1 AS UNSIGNED), CAST(double2 AS UNSIGNED) FROM t1; | ||
double1 CAST(double1 AS UNSIGNED) CAST(double2 AS UNSIGNED) | ||
18446744073709552000 18446744073709551615 18446744073709551615 | ||
18446744073709552000 18446744073709551615 18446744073709551615 | ||
DROP DATABASE mcol_4648; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--source ../include/have_columnstore.inc | ||
--echo # | ||
--echo # MCOL-4648: Disallow casting to NULL marker values, allow casting to EMPTY ROW values. | ||
--echo # | ||
--echo # Defined in joblisttypes.h: UBIGINTNULL == 0xFFFFFFFFFFFFFFFEULL == 18446744073709551614 | ||
--echo # Defined in joblisttypes.h: UBIGINTEMPTYROW == 0xFFFFFFFFFFFFFFFFULL == 18446744073709551615 | ||
--echo # | ||
--disable_warnings | ||
DROP DATABASE IF EXISTS mcol_4648; | ||
--enable_warnings | ||
CREATE DATABASE mcol_4648; | ||
USE mcol_4648; | ||
CREATE TABLE t1 | ||
(d1 DECIMAL(30,0), d2 DECIMAL(30,0) NOT NULL, | ||
str1 TEXT, str2 TEXT NOT NULL, | ||
double1 DOUBLE(30,0), double2 DOUBLE(30,0) NOT NULL) ENGINE=ColumnStore; | ||
INSERT INTO t1 VALUES | ||
(18446744073709551614, 18446744073709551614, | ||
"18446744073709551614", "18446744073709551614", | ||
18446744073709551614.0, 18446744073709551614.0); | ||
INSERT INTO t1 VALUES | ||
(18446744073709551615, 18446744073709551615, | ||
"18446744073709551615", "18446744073709551615", | ||
18446744073709551615.0, 18446744073709551615.0); | ||
SELECT d1, CAST(d1 AS UNSIGNED), CAST(d2 AS UNSIGNED) FROM t1; | ||
SELECT str1, CAST(str1 AS UNSIGNED), CAST(str2 AS UNSIGNED) FROM t1; | ||
--echo # Doubles only store about 15 digits of precision for decimal places, therefore both inserted numbers | ||
--echo # are rounded to 18446744073709552000.0 and we expect them to be casted to EMPTYROW value each. | ||
SELECT double1, CAST(double1 AS UNSIGNED), CAST(double2 AS UNSIGNED) FROM t1; | ||
DROP DATABASE mcol_4648; |
Oops, something went wrong.