Bug #26028 CREATE DATABASE if already existing crashes client (5.0 with 5.1 lib)
Submitted: 1 Feb 2007 19:55 Modified: 3 Sep 2007 21:22
Reporter: Christian Hammers (Silver Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 and 5.1 mixed OS:Linux (Debian GNU/Linux)
Assigned to: CPU Architecture:Any
Tags: qc

[1 Feb 2007 19:55] Christian Hammers
Description:
Hello

It seems that using client binaries linked against 5.0 on host systems running 5.1 libraries can sometimes lead to crashes.

This affects only certain commands (e.g. CREATE DATABASE) and in fact, the
database is even created, it seems to be the client that crashes after getting
the response from the server. strace/ltrace attached.

Of course, I know that this is in no way recommended, but as long as the client binary just says "I need libmysqlclient.so.15" it should be sufficient.

Used versions:
5.0.32 /usr/bin/mysql
5.0.32 /usr/bin/mysqladmin 
5.0.32 /usr/sbin/mysqld
5.1.14 /usr/lib/libmysqlclient.so.15

This is probably related to the Debian bug report http://bugs.debian.org/409152

bye,

-christian-

How to repeat:
#
# Versions
#

$ mysqladmin --version
mysqladmin  Ver 8.41 Distrib 5.0.32, for pc-linux-gnu on x86_64

$ mysql --version
mysql  Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (x86_64) using readline 5.2

#
# Using the CLI works
#

$ mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.0.32-Debian_3-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE test8; 
Query OK, 1 row affected (0.00 sec)

mysql> CREATE DATABASE test8;
ERROR 1007 (HY000): Can't create database 'test8'; database exists
mysql> 
mysql> Bye

#
# Using the mysql client as pipe works only with non-existing databases
#

$ echo "CREATE DATABASE test8;" | mysql
ERROR 1007 (HY000) at line 1: Can't create database 'test8'; database exists
Segmentation fault

$ echo "CREATE DATABASE test10;" | mysql
$

#
# Using mysqladmin does not work at all
#

$ mysqladmin create test8
mysqladmin: CREATE DATABASE failed; error: 'Can't create database 'test8'; database exists'
Segmentation fault

$ mysqladmin create test999
Segmentation fault

#
# Oh, interesting, the real work was done just reporting it back didn't
# 

$ mysqlshow
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| test               |
| test10             |
| test2              |
| test3              |
| test4              |
| test5              |
| test8              |
| test9              |
| test999            |
+--------------------+

#
# Other commands work fine...
#

$ echo "CREATE TABLE t (i int); INSERT INTO t SET i=42; SELECT * FROM t; DROP TABLE t;" | mysql test
i
42

Suggested fix:
Don't know.
[1 Feb 2007 19:56] Christian Hammers
ltrace

Attachment: t.ltrace (application/octet-stream, text), 7.15 KiB.

[1 Feb 2007 19:57] Christian Hammers
strace

Attachment: t.strace (application/octet-stream, text), 25.67 KiB.

[2 Feb 2007 14:37] Valeriy Kravchuk
Thank you for a problem report. Please, send the results of ldd command for your mysql, mysqladmin command line utilities from 5.0.32 and that libmysqlclient.so.15 from 5.1.14. 

This may also have something to do with readline version, 5.2.
[3 Mar 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[14 Mar 2007 0:24] Christian Hammers
Hello

As requested the ldd output:

$ mysql --version
mysql  Ver 14.12 Distrib 5.0.32, for pc-linux-gnu (x86_64) using readline 5.2

$ ldd /usr/bin/mysql
        libreadline.so.5 => /lib/libreadline.so.5 (0x00002b9d3eab2000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x00002b9d3ebf0000)
        libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15 (0x00002b9d3ed4c000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00002b9d3f054000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x00002b9d3f169000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00002b9d3f29e000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00002b9d3f3b5000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00002b9d3f4cb000)
        libm.so.6 => /lib/libm.so.6 (0x00002b9d3f6ca000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00002b9d3f84c000)
        libc.so.6 => /lib/libc.so.6 (0x00002b9d3f959000)
        libdl.so.2 => /lib/libdl.so.2 (0x00002b9d3fb97000)
        /lib64/ld-linux-x86-64.so.2 (0x00002b9d3e99a000)

$ mysqladmin --version
mysqladmin  Ver 8.41 Distrib 5.0.32, for pc-linux-gnu on x86_64

$ ldd /usr/bin/mysqladmin 
        libmysqlclient.so.15 => /usr/lib/libmysqlclient.so.15 (0x00002ba001b0a000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00002ba001e12000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x00002ba001f28000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00002ba00205c000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00002ba002173000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00002ba00228a000)
        libm.so.6 => /lib/libm.so.6 (0x00002ba002488000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00002ba00260a000)
        libc.so.6 => /lib/libc.so.6 (0x00002ba002718000)
        /lib64/ld-linux-x86-64.so.2 (0x00002ba0019f2000)

$ ldd /usr/lib/libmysqlclient.so.15 
        libpthread.so.0 => /lib/libpthread.so.0 (0x00002b272071c000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x00002b2720832000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x00002b2720966000)
        libm.so.6 => /lib/libm.so.6 (0x00002b2720a7d000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00002b2720c00000)
        libc.so.6 => /lib/libc.so.6 (0x00002b2720d16000)
        /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)

Debian Package Versions:
ii  mysql-server-5.0     5.0.32-3       mysql database server binaries
ii  mysql-client-5.0     5.0.32-3       mysql database client binaries
ii  libmysqlclient15off  5.1.14beta-2   mysql database client library

The bug is still reproducible.

bye,

-christian-
[4 May 2007 6:58] Valeriy Kravchuk
Sorry for a delay with this bug report. Please, check with a newer versions, 5.1.17 and 5.0.37/5.0.38 or 5.0.40, and inform about the results.
[4 Jun 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[14 Aug 2007 11:20] Sveta Smirnova
Thank you for the report.

Please check with current version 5.0.45/5.1.20 if bug is still actual and if you can repeat provide instructions how you compile binaries.
[3 Sep 2007 21:22] Christian Hammers
As 5.1.21-beta starts using libmysqlclient.so.16 the problem can no longer occur.
This bug can therefore be closed.