From 884663662b6c546d18e9bcaa2b21d8a94b372ca6 Mon Sep 17 00:00:00 2001
From: "guilhem@mysql.com" <>
Date: Fri, 17 Dec 2004 23:37:43 +0100
Subject: [PATCH] Fix for BUG#7358: removing warning reporting of mysqldump
 4.1.8 when calling SHOW CREATE DATABASE, as we deal almost gracefully with it
 (back to behaviour of 4.1.7). Warning was not fatal: mysqldump continued. And
 the good thing is that it helped spot that starting from 4.1.7, SHOW CREATE
 DATABASE failed (if --single-transaction and first db has non-empty InnoDB
 table and there is a second db) and thus mysqldump produced CREATE DATABASE
 statements missing the CHARACTER SET clause. Removing the bug which was in
 the server, and the warning reporting in mysqldump (compatibility with old
 servers).

---
 client/mysqldump.c                     | 2 +-
 mysql-test/r/flush_block_commit.result | 8 ++++++++
 mysql-test/t/flush_block_commit.test   | 8 ++++++++
 sql/sql_parse.cc                       | 5 -----
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/client/mysqldump.c b/client/mysqldump.c
index 11892a3458..c36f9d3e23 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1914,7 +1914,7 @@ static int init_dumping(char *database)
         sprintf(qbuf,"SHOW CREATE DATABASE IF NOT EXISTS %s",
 		qdatabase);
 
-        if (mysql_query_with_error_report(sock, &dbinfo, qbuf))
+        if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock)))
         {
           /* Old server version, dump generic CREATE DATABASE */
 	  fprintf(md_result_file,
diff --git a/mysql-test/r/flush_block_commit.result b/mysql-test/r/flush_block_commit.result
index 4a7575d8f7..2e9f192093 100644
--- a/mysql-test/r/flush_block_commit.result
+++ b/mysql-test/r/flush_block_commit.result
@@ -28,4 +28,12 @@ commit;
 unlock tables;
 flush tables with read lock;
 unlock tables;
+begin;
+select * from t1;
+a
+1
+10
+show create database test;
+Database	Create Database
+test	CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
 drop table t1;
diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test
index ac14b7b98b..8771545208 100644
--- a/mysql-test/t/flush_block_commit.test
+++ b/mysql-test/t/flush_block_commit.test
@@ -1,6 +1,7 @@
 # Let's see if FLUSH TABLES WITH READ LOCK blocks COMMIT of existing
 # transactions.
 # We verify that we did not introduce a deadlock.
+# This is intended to mimick how mysqldump and innobackup work.
 
 -- source include/have_innodb.inc
 
@@ -63,4 +64,11 @@ unlock tables;
 connection con2;
 flush tables with read lock; # bug caused hang here
 unlock tables;
+
+# BUG#7358 SHOW CREATE DATABASE fails if open transaction
+
+begin;
+select * from t1;
+show create database test;
+
 drop table t1;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 8dc1339993..55d26a6811 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3249,11 +3249,6 @@ purposes internal to the MySQL server", MYF(0));
     }
     if (check_access(thd,SELECT_ACL,lex->name,0,1,0))
       break;
-    if (thd->locked_tables || thd->active_transaction())
-    {
-      send_error(thd,ER_LOCK_OR_ACTIVE_TRANSACTION);
-      goto error;
-    }
     res=mysqld_show_create_db(thd,lex->name,&lex->create_info);
     break;
   }
-- 
2.30.9