|
I don't get the warning:
MariaDB [test]> select SUBSTR("MariaDB", 1, 1);
|
+-------------------------+
|
| SUBSTR("MariaDB", 1, 1) |
|
+-------------------------+
|
| M |
|
+-------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [test]> show warnings;
|
Empty set (0.00 sec)
|
Please attach your cnf file(s) or paste the output of SHOW VARIABLES from the very same session where you are getting the warning.
Is it possible that what you see is a left-over warning from a previous activity? Something like this can cause it:
MariaDB [test]> select cast('M' as double);
|
+---------------------+
|
| cast('M' as double) |
|
+---------------------+
|
| 0 |
|
+---------------------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [test]> show warnings;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'M' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [test]> select SUBSTR("MariaDB", 1, 1);
|
+-------------------------+
|
| SUBSTR("MariaDB", 1, 1) |
|
+-------------------------+
|
| M |
|
+-------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [test]> show warnings;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'M' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
|
|
show_variables_maria01.txt
Hi @Elena, attached the file with the show variables .
|
|
diegohellas, thanks.
I don't see in the variables anything that would cause the problem.
Could you please paste the complete unabridged output of the following:
show warnings;
|
select SUBSTR("MariaDB", 1, 1);
|
show warnings;
|
from MySQL client when you are getting the warning.
|
|
Now i know simulate the problem.
Here dosen't have problem.
show warnings;
|
select SUBSTR("MariaDB", 1, 1);
|
show warnings;
|
The problem is here.
show warnings;
|
select SUBSTR("MariaDB", 1, 1) = 1;
|
show warnings;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'M' |
|
+---------+------+---------------------------------------+
|
I need check if the first character is 1(number 1). But my column have values with number and string.
I solved my problem so
MariaDB [(none)]> select SUBSTR("MariaDB", 1, 1) = '1';
|
+-------------------------------+
|
| SUBSTR("MariaDB", 1, 1) = '1' |
|
+-------------------------------+
|
| 0 |
|
+-------------------------------+
|
1 row in set (0.00 sec)
|
|
MariaDB [(none)]> show warnings;
|
Empty set (0.00 sec)
|
But anyway, MySQL does not return warnings.
|
|
Thanks. This way I can reproduce it easily, but I don't think it's a bug.
You can just as well run this:
MariaDB [test]> select 'M' = 1;
|
+---------+
|
| 'M' = 1 |
|
+---------+
|
| 0 |
|
+---------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MariaDB [test]> show warnings;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'M' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
And in this case the warning is produced by MySQL as well:
MySQL [test]> select 'M' = 1;
|
+---------+
|
| 'M' = 1 |
|
+---------+
|
| 0 |
|
+---------+
|
1 row in set, 1 warning (0.00 sec)
|
|
MySQL [test]> show warnings;
|
+---------+------+---------------------------------------+
|
| Level | Code | Message |
|
+---------+------+---------------------------------------+
|
| Warning | 1292 | Truncated incorrect DOUBLE value: 'M' |
|
+---------+------+---------------------------------------+
|
1 row in set (0.00 sec)
|
|
MySQL [test]> select @@version;
|
+--------------+
|
| @@version |
|
+--------------+
|
| 5.6.30-debug |
|
+--------------+
|
1 row in set (0.00 sec)
|
The warning itself seems to be justified in this case.
But the query that you identified, indeed, only produces the warning on MariaDB, but not MySQL.
So, I think MariaDB behaves more consistently here; but I might be wrong, so I will assign it to the datatype conversion expert bar to confirm.
|
|
Elena, I hope I've helped.
If you need anything let me know.
|
|
The warning is valid here. Not a bug.
Comparison between a string and a number is done as double.
|