diff options
author | Michael Widenius <monty@askmonty.org> | 2011-05-11 02:41:02 +0300 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2011-05-11 02:41:02 +0300 |
commit | 052d1bfb1a215d927e31bbe521a7e29d5da8a384 (patch) | |
tree | 0181353047727b1dee0e785d3412f0d14d1e1757 /mysql-test | |
parent | 03483e7bfd21a61fca796a163376b77cd965870e (diff) | |
download | mariadb-git-052d1bfb1a215d927e31bbe521a7e29d5da8a384.tar.gz |
Fixed all reported bugs for dynamic columns.
Bugs fixed:
- Added automatic detection of unsigned arguments to COLUMN_CREATE()
- If string length is not know for COLUMN_GET() use MAX_DYNAMIC_COLUMN_LENGTH instead of MAX_FIELD_BLOBLENGTH
- null_value flag was not propery reset for COLUMN_LIST() and COLUMN_CREATE() which could lead to crashes later:
- lp:778905 Assertion `value->year <= 9999' failed in dynamic_column_date_store
- lp:778912 Assertion `field_pos < field_count' failed in Protocol_text::store in maria-5.3-mwl34
include/ma_dyncol.h:
Added define for max dynamic column length.
mysql-test/r/cast.result:
Added test of cast big unsigned int to signed (this test case was missing)
mysql-test/r/dyncol.result:
Added tests from reported bugs
Added testing of automatic store of signed/unsigned integers
mysql-test/t/cast.test:
Added test of cast big unsigned int to signed (this test case was missing)
mysql-test/t/dyncol.test:
Added tests from reported bugs
Added testing of automatic store of signed/unsigned integers
sql/item.cc:
Added assert to catch cases where null_value is not set properly
sql/item_strfunc.cc:
Added automatic detection of unsigned arguments to COLUMN_CREATE()
COLUMN_GET() returned wrong value for illegal strings which lead to assert later
null_value flag was not propery reset for COLUMN_LIST() and COLUMN_CREATE() which could lead to crashes later.
sql/item_strfunc.h:
If string length is not know for COLUMN_GET() use MAX_DYNAMIC_COLUMN_LENGTH
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/cast.result | 3 | ||||
-rw-r--r-- | mysql-test/r/dyncol.result | 43 | ||||
-rw-r--r-- | mysql-test/t/cast.test | 1 | ||||
-rw-r--r-- | mysql-test/t/dyncol.test | 32 |
4 files changed, 79 insertions, 0 deletions
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 094ccce76c2..a45aca67694 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -33,6 +33,9 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)` +select cast(18446744073709551615 as signed); +cast(18446744073709551615 as signed) +-1 select cast(5 as unsigned) -6.0; cast(5 as unsigned) -6.0 -1.0 diff --git a/mysql-test/r/dyncol.result b/mysql-test/r/dyncol.result index b6584a6fe55..a8480599129 100644 --- a/mysql-test/r/dyncol.result +++ b/mysql-test/r/dyncol.result @@ -37,6 +37,12 @@ hex(COLUMN_CREATE(1, 128 AS unsigned int)) select hex(COLUMN_CREATE(1, 12.12 AS unsigned int)); hex(COLUMN_CREATE(1, 12.12 AS unsigned int)) 0001000100010C +select hex(COLUMN_CREATE(1, ~0)); +hex(COLUMN_CREATE(1, ~0)) +000100010001FFFFFFFFFFFFFFFF +select hex(COLUMN_CREATE(1, -1)); +hex(COLUMN_CREATE(1, -1)) +00010001000001 select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int)); hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int)) 000100010001FFFFFFFFFFFFFF7F @@ -323,6 +329,22 @@ column_get(column_create(1, "1212III" AS char), 1 as int) 1212 Warnings: Warning 1659 Encountered illegal value '1212III' when converting to INT +select column_get(COLUMN_CREATE(1, ~0), 1 as signed); +column_get(COLUMN_CREATE(1, ~0), 1 as signed) +-1 +Warnings: +Warning 1105 Cast to signed converted positive out-of-range integer to it's negative complement +select column_get(COLUMN_CREATE(1, ~0), 1 as unsigned); +column_get(COLUMN_CREATE(1, ~0), 1 as unsigned) +18446744073709551615 +select column_get(COLUMN_CREATE(1, -1), 1 as signed); +column_get(COLUMN_CREATE(1, -1), 1 as signed) +-1 +select column_get(COLUMN_CREATE(1, -1), 1 as unsigned); +column_get(COLUMN_CREATE(1, -1), 1 as unsigned) +18446744073709551615 +Warnings: +Warning 1105 Cast to unsigned converted negative integer to it's positive complement # #column get char # @@ -1185,3 +1207,24 @@ select id, column_list(str), length(str) from t1 where id=5; id column_list(str) length(str) 5 1,2,4,10 34 drop table t1; +# +# LP#778905: Assertion `value->year <= 9999' failed in +# dynamic_column_date_store +# +SELECT COLUMN_GET( 'a' , 2 AS DATE ); +ERROR HY000: Encountered illegal format of dynamic column string +SELECT COLUMN_CREATE( 1 , COLUMN_GET( 'a' , 2 AS DATE ) ); +ERROR HY000: Encountered illegal format of dynamic column string +# +# LP#778912: Assertion `field_pos < field_count' failed in +# Protocol_text::store in maria-5.3-mwl34 +# +CREATE TABLE t1 ( f1 blob ); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 SET f1 = COLUMN_CREATE( 2 , 'cde' ); +SELECT HEX(COLUMN_ADD(f1, 1, 'abc')), COLUMN_LIST(f1) FROM t1; +HEX(COLUMN_ADD(f1, 1, 'abc')) COLUMN_LIST(f1) +NULL NULL +0002000100030200230861626308636465 2 +SELECT COLUMN_ADD(f1, 1, 'abc'), COLUMN_LIST(f1) FROM t1; +DROP TABLE t1; diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index e128c86380b..0b81d4dbca5 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -9,6 +9,7 @@ select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1; select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1; select ~5, cast(~5 as signed); explain extended select ~5, cast(~5 as signed); +select cast(18446744073709551615 as signed); select cast(5 as unsigned) -6.0; select cast(NULL as signed), cast(1/0 as signed); select cast(1 as double(5,2)); diff --git a/mysql-test/t/dyncol.test b/mysql-test/t/dyncol.test index 8e1c99a48a4..b7c3697beaf 100644 --- a/mysql-test/t/dyncol.test +++ b/mysql-test/t/dyncol.test @@ -17,6 +17,8 @@ select hex(COLUMN_CREATE(1, 8 AS unsigned int)); select hex(COLUMN_CREATE(1, 127 AS unsigned int)); select hex(COLUMN_CREATE(1, 128 AS unsigned int)); select hex(COLUMN_CREATE(1, 12.12 AS unsigned int)); +select hex(COLUMN_CREATE(1, ~0)); +select hex(COLUMN_CREATE(1, -1)); select hex(COLUMN_CREATE(1, 99999999999999999999999999999 AS unsigned int)); select hex(COLUMN_CREATE(1, NULL AS int)); select hex(COLUMN_CREATE(1, 1212 AS int)); @@ -116,6 +118,10 @@ select column_get(column_create(1, 999.9 AS double), 1 as int); select column_get(column_create(1, -99999999999999999999999999999 AS double), 1 as int); select column_get(column_create(1, "-1212III" AS char), 1 as int); select column_get(column_create(1, "1212III" AS char), 1 as int); +select column_get(COLUMN_CREATE(1, ~0), 1 as signed); +select column_get(COLUMN_CREATE(1, ~0), 1 as unsigned); +select column_get(COLUMN_CREATE(1, -1), 1 as signed); +select column_get(COLUMN_CREATE(1, -1), 1 as unsigned); --echo # --echo #column get char @@ -460,3 +466,29 @@ update t1 set str=column_delete(str, 5) where id=5; select id, column_list(str), length(str) from t1 where id=5; drop table t1; + +--echo # +--echo # LP#778905: Assertion `value->year <= 9999' failed in +--echo # dynamic_column_date_store +--echo # + +--error ER_DYN_COL_WRONG_FORMAT +SELECT COLUMN_GET( 'a' , 2 AS DATE ); +--error ER_DYN_COL_WRONG_FORMAT +SELECT COLUMN_CREATE( 1 , COLUMN_GET( 'a' , 2 AS DATE ) ); + +--echo # +--echo # LP#778912: Assertion `field_pos < field_count' failed in +--echo # Protocol_text::store in maria-5.3-mwl34 +--echo # + +CREATE TABLE t1 ( f1 blob ); +INSERT INTO t1 VALUES (NULL); +INSERT INTO t1 SET f1 = COLUMN_CREATE( 2 , 'cde' ); +SELECT HEX(COLUMN_ADD(f1, 1, 'abc')), COLUMN_LIST(f1) FROM t1; + +# Don't print strange characters on screen +--disable_result_log +SELECT COLUMN_ADD(f1, 1, 'abc'), COLUMN_LIST(f1) FROM t1; +--enable_result_log +DROP TABLE t1; |