MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:sergeyv Date:November 11 2005 6:02pm
Subject:bk commit into 5.0 tree (SergeyV:1.1958) BUG#14569
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of sergeyv. When sergeyv does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1958 05/11/11 21:01:48 SergeyV@selena. +4 -0
  Fixes bug #14569. When no db is selected as current and we do create procedure db.sp()...
  we changing current db temporarily and restore it when sp is created. however thd->db
  in this case becomes empty string rather than NULL and so all checks of thd->db == NULL 
  will be false. So if after this we'll issue create procedure sp2()... without specifying
  db it will succeed and create sp with db=NULL, which causes mysqldto crash on 
  show procedure status statement.
  
  This patch fixes the problem.

  sql/sql_parse.cc
    1.511 05/11/11 21:01:39 SergeyV@selena. +1 -1
    Fixes bug #14569. Reverted from initial patch to check thd->db for null values only.

  sql/sql_db.cc
    1.120 05/11/11 21:01:38 SergeyV@selena. +11 -2
    Fixes bug #14569. When no db is selected as current and we do create procedure db.sp()...
    we changing current db temporarily and restore it when sp is created. however thd->db
    in this case becomes empty string rather than NULL and so all checks of thd->db == NULL 
    will be false. This patch fixes this issue.

  mysql-test/t/sp-error.test
    1.93 05/11/11 21:01:37 SergeyV@selena. +16 -0
    Test for bug #14569.

  mysql-test/r/sp-error.result
    1.89 05/11/11 21:01:37 SergeyV@selena. +13 -0
    Result for bug #14569.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	SergeyV
# Host:	selena.
# Root:	H:/MYSQL/src/#14569-mysql-5.0

--- 1.119/sql/sql_db.cc	2005-09-30 18:51:29 +04:00
+++ 1.120/sql/sql_db.cc	2005-11-11 21:01:38 +03:00
@@ -1163,8 +1163,17 @@
   }
 end:
   x_free(thd->db);
-  thd->db=dbname;				// THD::~THD will free this
-  thd->db_length=db_length;
+  if (dbname && dbname[0] == 0)
+  {
+    x_free(dbname);
+    thd->db= NULL;
+    thd->db_length= 0;
+  }
+  else
+  {
+    thd->db= dbname;				// THD::~THD will free this
+    thd->db_length= db_length;
+  }
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
   if (!no_access_check)
     sctx->db_access= db_access;

--- 1.510/sql/sql_parse.cc	2005-11-11 19:06:09 +03:00
+++ 1.511/sql/sql_parse.cc	2005-11-11 21:01:39 +03:00
@@ -4099,7 +4099,7 @@
 
     if (!lex->sphead->m_db.str || !lex->sphead->m_db.str[0])
     {
-      if (!thd->db || thd->db[0] == 0)
+      if (!thd->db)
       {
         my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
         delete lex->sphead;

--- 1.88/mysql-test/r/sp-error.result	2005-10-25 13:02:41 +04:00
+++ 1.89/mysql-test/r/sp-error.result	2005-11-11 21:01:37 +03:00
@@ -916,3 +916,16 @@
 DROP PROCEDURE bug13037_p1;
 DROP PROCEDURE bug13037_p2;
 DROP PROCEDURE bug13037_p3;
+create database mysqltest1;
+create database mysqltest2;
+use mysqltest1;
+drop database mysqltest1;
+create procedure mysqltest2.p1() select version();
+create procedure p2() select version();
+ERROR 3D000: No database selected
+use mysqltest2;
+show procedure status;
+Db	Name	Type	Definer	Modified	Created	Security_type	Comment
+mysqltest2	p1	PROCEDURE	root@localhost	0000-00-00 00:00:00	0000-00-00 00:00:00	DEFINER	
+drop database mysqltest2;
+use test;

--- 1.92/mysql-test/t/sp-error.test	2005-10-25 13:02:41 +04:00
+++ 1.93/mysql-test/t/sp-error.test	2005-11-11 21:01:37 +03:00
@@ -1337,6 +1337,22 @@
 DROP PROCEDURE bug13037_p2;
 DROP PROCEDURE bug13037_p3;
 
+#
+# Bug#14569 "editing a stored procedure kills mysqld-nt"
+#
+create database mysqltest1;
+create database mysqltest2;
+use mysqltest1;
+drop database mysqltest1;
+create procedure mysqltest2.p1() select version();
+--error ER_NO_DB_ERROR 
+create procedure p2() select version();
+use mysqltest2;
+--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
+show procedure status;
+drop database mysqltest2;
+use test;
+
 
 # BUG#NNNN: New bug synopsis
 #
Thread
bk commit into 5.0 tree (SergeyV:1.1958) BUG#14569sergeyv11 Nov