summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authortsmith/tim@siva.hindu.god <>2006-12-19 15:54:12 -0700
committertsmith/tim@siva.hindu.god <>2006-12-19 15:54:12 -0700
commit2bc45899c02d31937d77d47f3e09ae01d5639e04 (patch)
tree89900974ccbb4037ff8369409ce963c4679ea606 /mysql-test
parent3cc1a4251aac06024f9f2346bbb411d90f7c4aa8 (diff)
downloadmariadb-git-2bc45899c02d31937d77d47f3e09ae01d5639e04.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.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/func_str.result12
-rw-r--r--mysql-test/t/func_str.test8
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