summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-01-14 14:25:44 +0100
committerSergei Golubchik <serg@mariadb.org>2022-01-14 14:25:44 +0100
commit6e615c62b8817a218be64597de50be615e10e10a (patch)
treed4d034aedd244773020f57a27f88c866be280982
parent58799965c2a69d80e9d23debdda8ae7bd8943ca6 (diff)
downloadmariadb-git-preview-10.8-MDEV-27265-misc.tar.gz
make crc32() behave consistently with other functions that take an INTpreview-10.8-MDEV-27265-misc
-rw-r--r--mysql-test/main/func_math.result33
-rw-r--r--mysql-test/main/func_math.test10
-rw-r--r--sql/item_strfunc.cc20
3 files changed, 27 insertions, 36 deletions
diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result
index f6d2fc42c4a..031db0d3685 100644
--- a/mysql-test/main/func_math.result
+++ b/mysql-test/main/func_math.result
@@ -1887,21 +1887,30 @@ SELECT * FROM t;
a i c
DB 1253907744 809606978
DROP TEMPORARY TABLE t;
-SELECT
-crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'') a,
-crc32c(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'') b,
-crc32(-1, '') c, crc32c(-1, '') d;
-a b c d
-4294967295 4294967295 4294967295 4294967295
+select crc32(4294967296,''), hex(char(4294967296));
+crc32(4294967296,'') hex(char(4294967296))
+0 00
+select crc32(1e100,''), hex(char(1e100));
+crc32(1e100,'') hex(char(1e100))
+4294967295 FFFFFFFF
+select crc32(10.11,''), hex(char(10.11));
+crc32(10.11,'') hex(char(10.11))
+10 0A
+select crc32(-1,''), hex(char(-1));
+crc32(-1,'') hex(char(-1))
+4294967295 FFFFFFFF
+select crc32('',''), hex(char(''));
+crc32('','') hex(char(''))
+0 00
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: ''
+Warning 1292 Truncated incorrect INTEGER value: ''
+select crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'a') as x;
+x
+3310005809
Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
-Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
-Warning 1916 Got overflow when converting '99999999999999999999999999999999999999999999999999999999999999999' to INT. Value truncated
-Warning 1917 Truncated value '9223372036854775807' when converting to INT UNSIGNED
Warning 1916 Got overflow when converting '99999999999999999999999999999999999999999999999999999999999999999' to INT. Value truncated
-Warning 1917 Truncated value '9223372036854775807' when converting to INT UNSIGNED
-Warning 1917 Truncated value '-1' when converting to INT UNSIGNED
-Warning 1917 Truncated value '-1' when converting to INT UNSIGNED
DROP TABLE IF EXISTS t;
Warnings:
Note 1051 Unknown table 'test.t'
diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test
index 6a884c95ba8..a01b25363f7 100644
--- a/mysql-test/main/func_math.test
+++ b/mysql-test/main/func_math.test
@@ -865,10 +865,12 @@ INSERT INTO t (a,i) VALUES ('DB',CRC32C('Maria'));
SELECT * FROM t;
DROP TEMPORARY TABLE t;
-SELECT
-crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'') a,
-crc32c(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'') b,
-crc32(-1, '') c, crc32c(-1, '') d;
+select crc32(4294967296,''), hex(char(4294967296));
+select crc32(1e100,''), hex(char(1e100));
+select crc32(10.11,''), hex(char(10.11));
+select crc32(-1,''), hex(char(-1));
+select crc32('',''), hex(char(''));
+select crc32(429496729656755555555555555555555555555555555555555555555555555555555555555555555555555,'a') as x;
# Test cases for using the function in aggregate functions, group-by, having
# and order-by clauses
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 52921273d89..22ac86517fc 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -62,24 +62,6 @@ C_MODE_END
size_t username_char_length= USERNAME_CHAR_LENGTH;
-/**
- Issue a warning for an out-of-bounds INT UNSIGNED value.
-*/
-
-ATTRIBUTE_COLD static void uint32_truncate_warning(longlong val, bool unsigned_flag)
-{
- char value[21];
- if (unsigned_flag)
- snprintf(value, sizeof value, "%llu", static_cast<ulonglong>(val));
- else
- snprintf(value, sizeof value, "%lld", val);
- THD *thd= current_thd;
- push_warning_printf(thd,
- Sql_condition::WARN_LEVEL_WARN,
- ER_DATA_TRUNCATED, ER_THD(thd, ER_DATA_TRUNCATED),
- value, "INT UNSIGNED");
-}
-
/*
Calculate max length of string from length argument to LEFT and RIGHT
*/
@@ -4404,8 +4386,6 @@ longlong Item_func_crc32::val_int()
null_value= args[0]->null_value;
if (null_value)
return 0;
- if (unlikely(crc != longlong{static_cast<uint32_t>(crc)}))
- uint32_truncate_warning(crc, args[0]->unsigned_flag);
res= args[1]->val_str(&value);
}
else