Bug #47302 mysqltest client only outputs the first error generated by the server
Submitted: 14 Sep 2009 8:45 Modified: 1 Sep 2011 14:36
Reporter: Tor Didriksen Email Updates:
Status: Closed Impact on me:
None 
Category:Tools: MTR / mysql-test-run Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Bjørn Munch CPU Architecture:Any

[14 Sep 2009 8:45] Tor Didriksen
Description:
The query "select 3230303430323231303134383334 div 1;" 
returns one warning, and two errors when executed through the mysql client.
The test client does not output the second error.

See http://bugs.mysql.com/bug.php?id=46606
We actually already have a test case for this problem,
added when this bug was fixed: http://bugs.mysql.com/bug.php?id=8457

mysql> select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
ERROR 1264 (22003): Out of range value for column 'x' at row 1
Warning (Code 1292): Truncated incorrect DECIMAL value: ''
Error (Code 1264): Out of range value for column 'x' at row 1
Error (Code 1041): Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space

However, in func_math.test we only have one expected error:
--error ER_WARN_DATA_OUT_OF_RANGE
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;

The second error goes undetected.

How to repeat:
mysql> select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
[14 Sep 2009 8:51] Susanne Ebrecht
Which MySQL version do you use here?
[14 Sep 2009 9:16] Sergei Golubchik
There can be only one error from any statement.

If a statement fails a protocol packet "error" is sent, with the error code in it. There's place only for one error code in that packet, and fundamentally any statement either succeeds or fails with an error - one error.

But a statement can generate any number of warning during the execution. Warnings can be of different severity. What you see in mysql client is one error and three warnings. To see warnings one usually has to do 'SHOW WARNINGS' (try it!). mysql client does it for you automatically because you've started it with --show-warnings command line switch.
[14 Sep 2009 9:17] Sergei Golubchik
start mysql with --disable-show-warnings
run your statement, you'll see only one error. run SHOW WARNINGS and you'll see your three warnings
[14 Sep 2009 10:23] Tor Didriksen
Looks like one warning, and two errors to me, but I guess the server picks one of them as the returned error. 

| Level   | Code | Message                                                                                                                                                                                |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1292 | Truncated incorrect DECIMAL value: ''                                                                                                                                                  |
| Error   | 1264 | Out of range value for column 'x' at row 1                                                                                                                                             |
| Error   | 1041 | Out of memory; check if mysqld or some other process uses all available memory; if not, you may have to use 'ulimit' to allow mysqld to use more memory or you can add more swap space |