[MDEV-8847] Redundant warnings for LEFT('a','b') Created: 2015-09-25  Updated: 2018-06-13

Status: Open
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0, 10.1, 10.2
Fix Version/s: 10.2

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

PREPARE stmt FROM "SELECT LEFT('a','b')";
SHOW WARNINGS;
EXECUTE stmt;
SHOW WARNINGS;

returns the following:

Query OK, 0 rows affected, 1 warning (0.00 sec)
Statement prepared
 
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'b' |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)
 
+---------------+
| LEFT('a','b') |
+---------------+
|               |
+---------------+
1 row in set, 2 warnings (0.00 sec)
 
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'b' |
| Warning | 1292 | Truncated incorrect INTEGER value: 'b' |
+---------+------+----------------------------------------+
2 rows in set (0.00 sec)

Notice, one warning is sent during PREPARE.
Then two warnings are sent during EXECUTE:

  • one warning during fix_length_and_dec()
  • another warning during the actual query execution

There could be less warnings.
Serg proposed that fix_length_and_dec() could put args[1] into either of these:

  • Item_int
  • Item_cache_int
  • Item_int_with_ref

This would fix redundant warnings and help to avoid unnecessary strtoll10() calls per every row.

The problem is also repeatable with:

PREPARE stmt FROM "SELECT LPAD('a','b','c')";
SHOW WARNINGS;
EXECUTE stmt;
SHOW WARNINGS


Generated at Thu Feb 08 07:30:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.