Bug #25146 Some warnings/errors not shown when using --show-warnings
Submitted: 18 Dec 2006 15:19 Modified: 4 Dec 2007 21:15
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.1 OS:Linux (Linux)
Assigned to: Geert Vanderkelen CPU Architecture:Any
Tags: client, show-warnings

[18 Dec 2006 15:19] Geert Vanderkelen
Description:
Some warnings are not shown when the --show-warnings option is set. See the 'How to repeat'.

It's helpful when debugging and multiple errors are return to see them all. An example is setting up storage on disk for Cluster:

mysql> \W
mysql> CREATE TABLESPACE ts_1 ADD DATAFILE 'data_1.dat' USE LOGFILE GROUP lg_1 INITIAL_SIZE 32M ENGINE NDB;
ERROR 1515 (HY000): Failed to create TABLESPACE
Error (Code 1296): Got error 721 'Table or index with given name already exists' from NDB
Error (Code 1515): Failed to create TABLESPACE

The last two lines are currently not return. The patch in the Suggested fix is fixing this.

How to repeat:
CREATE LOGFILE GROUP lg_1 ADD UNDOFILE 'undo_1.dat' INITIAL_SIZE 16M undo_buffer_size 2M ENGINE NDB;

CREATE TABLESPACE ts_1 ADD DATAFILE 'data_1.dat' USE LOGFILE GROUP lg_1 INITIAL_SIZE 32M ENGINE NDB;

-- Note the incorrect talbespace name t1_1 used in the CREATE TABLE:
CREATE TABLE t1 (id INT KEY, name VARCHAR(20)) TABLESPACE t1_1 STORAGE DISK ENGINE NDB;

-- Gives following error:
-- ERROR 1005 (HY000): Can't create table 'testndb.t1' (errno: 140)

-- Enable the --show-warnings option
\W
-- Show warnings enabled.
CREATE TABLE t1 (id INT KEY, name VARCHAR(20)) TABLESPACE t1_1 STORAGE DISK ENGINE NDB;
-- Gives following error, but not the warnings/errors:
-- ERROR 1005 (HY000): Can't create table 'testndb.t1' (errno: 140)

Suggested fix:
===== mysql.cc 1.248 vs edited =====
--- 1.248/client/mysql.cc       2006-12-04 20:02:28 +01:00
+++ edited/mysql.cc     2006-12-18 16:04:22 +01:00
@@ -1798,6 +1798,12 @@
     if (!mysql_real_query(&mysql,buf,length))
       return 0;
     error= put_error(&mysql);
+    if (show_warnings == 1) /* Show warnings if any */
+    {
+      init_pager();
+      print_warnings();
+      end_pager();
+    }
     if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR || retry > 1 ||
         !opt_reconnect)
       return error;
[18 Dec 2006 15:21] Geert Vanderkelen
Verified using latest 5.1 from bk. Patch works :)
[12 Nov 2007 14:28] Chad MILLER
The suggested patch is sufficient.

It's slightly more elegant to add "&& warnings >= 1" to the condition, but it's not required.
[13 Nov 2007 19:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37693

ChangeSet@1.2607, 2007-11-13 12:30:53-07:00, tsmith@ramayana.hindu.god +1 -0
  Bug #25146: Some warnings/errors not shown when using --show-warnings
  
  In several cases, an error when processing the query would cause mysql to
  return to the top level without printing warnings.  Fix is to always
  print any available warnings before returning to the top level.
[15 Nov 2007 2:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/37817

ChangeSet@1.2608, 2007-11-14 19:02:13-07:00, tsmith@ramayana.hindu.god +3 -0
  Bug #25146: Some warnings/errors not shown when using --show-warnings
  
  In several cases, an error when processing the query would cause mysql to
  return to the top level without printing warnings.  Fix is to always
  print any available warnings before returning to the top level.
[21 Nov 2007 0:04] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38177

ChangeSet@1.2607, 2007-11-20 17:03:56-07:00, tsmith@ramayana.hindu.god +3 -0
  Bug #25146: Some warnings/errors not shown when using --show-warnings
  
  In several cases, an error when processing the query would cause mysql to
  return to the top level without printing warnings.  Fix is to always
  print any available warnings before returning to the top level.
[21 Nov 2007 7:09] Timothy Smith
Patch is queued to 5.1-build and up team trees.
[21 Nov 2007 18:55] Bugs System
Pushed into 5.1.23-rc
[21 Nov 2007 18:55] Bugs System
Pushed into 6.0.4-alpha
[26 Nov 2007 18:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38554

ChangeSet@1.2646, 2007-11-26 19:50:43+01:00, msvensson@pilot.mysql.com +3 -0
  Bug#25146 Some warnings/errors not shown when using --show-warnings
   - Additional patch to fix compiler warnings
[27 Nov 2007 10:51] Bugs System
Pushed into 5.1.23-rc
[27 Nov 2007 10:54] Bugs System
Pushed into 6.0.4-alpha
[4 Dec 2007 21:15] Paul Dubois
Noted in 5.1.23, 6.0.4 changelogs.

For mysql --show-warnings, warnings were in some cases not displayed.