diff options
author | unknown <tsmith/tim@siva.hindu.god> | 2006-12-19 15:54:12 -0700 |
---|---|---|
committer | unknown <tsmith/tim@siva.hindu.god> | 2006-12-19 15:54:12 -0700 |
commit | f8920dd59f87f488435f7f60939ed63e0a4b6b52 (patch) | |
tree | 89900974ccbb4037ff8369409ce963c4679ea606 /mysql-test | |
parent | 9d8c9e9d96dc85cfac055b6014ac65d867152edf (diff) | |
download | mariadb-git-f8920dd59f87f488435f7f60939ed63e0a4b6b52.tar.gz |
Bug #24947: REPEAT function returns NULL when passed a field as the count parameter
Handling of large signed/unsigned values was not consistent, so some string functions could return bogus results.
The current fix is to simply patch up the val_str() methods for those string items.
It would be good clean this code up in general, to make similar problems much harder to make. This is left as an exercise for the reader.
mysql-test/r/func_str.result:
Update test results for bug #24947
mysql-test/t/func_str.test:
Add test case for bug #24947
sql/item_strfunc.cc:
Adjust some string function Items' val_str() methods to handle large signed/unsigned arguments properly
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/func_str.result | 12 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 14c61a2dd93..b5a9d4de105 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1916,4 +1916,16 @@ CHAR(0xff,0x8f USING utf8) IS NULL Warnings: Error 1300 Invalid utf8 character string: 'FF8F' SET SQL_MODE=@orig_sql_mode; +select substring('abc', cast(2 as unsigned int)); +substring('abc', cast(2 as unsigned int)) +bc +select repeat('a', cast(2 as unsigned int)); +repeat('a', cast(2 as unsigned int)) +aa +select rpad('abc', cast(5 as unsigned integer), 'x'); +rpad('abc', cast(5 as unsigned integer), 'x') +abcxx +select lpad('abc', cast(5 as unsigned integer), 'x'); +lpad('abc', cast(5 as unsigned integer), 'x') +xxabc End of 5.0 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index af4f8b9a9d2..a55b633b91e 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -991,5 +991,13 @@ SELECT CHAR(0xff,0x8f USING utf8) IS NULL; SET SQL_MODE=@orig_sql_mode; +# +# Bug #24947: problem with some string function with unsigned int parameters +# + +select substring('abc', cast(2 as unsigned int)); +select repeat('a', cast(2 as unsigned int)); +select rpad('abc', cast(5 as unsigned integer), 'x'); +select lpad('abc', cast(5 as unsigned integer), 'x'); --echo End of 5.0 tests |