MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kroki Date:August 6 2006 2:37pm
Subject:bk commit into 5.0 tree (kroki:1.2241) BUG#18914
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of tomash. When tomash 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@stripped, 2006-08-06 18:37:50+04:00, kroki@stripped +3 -0
  BUG#18914: Calling certain SPs from triggers fail.
  
  The problem was that when a procedure that creates a table was used in a
  function or a trigger the table that wasn't yet created was added to the
  list of tables for prelocking, thus giving the error "Table doesn't
  exist".
  
  The solution is to not try to prelock such non-existent tables.

  mysql-test/r/sp-error.result@stripped, 2006-08-06 18:37:43+04:00, kroki@stripped +13 -0
    Add result for bug#18914: Calling certain SPs from triggers fail.

  mysql-test/t/sp-error.test@stripped, 2006-08-06 18:37:44+04:00, kroki@stripped +29 -0
    Add test case for bug#18914: Calling certain SPs from triggers fail.

  sql/sp_head.cc@stripped, 2006-08-06 18:37:44+04:00, kroki@stripped +7 -6
    Rename SP_TABLE::temp to SP_TABLE::create, and use it to mark tables
    that are yet to be created.  Skip over such tables in
    sp_head::add_used_tables_to_table_list().

# 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:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-5.0-bug18914

--- 1.107/mysql-test/r/sp-error.result	2006-08-06 18:38:00 +04:00
+++ 1.108/mysql-test/r/sp-error.result	2006-08-06 18:38:00 +04:00
@@ -1187,3 +1187,16 @@ END;
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS bug14702()
 BEGIN
 END' at line 1
+DROP PROCEDURE IF EXISTS bug18914;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (i INT);
+CREATE PROCEDURE bug18914() CREATE TABLE t2 (i INT);
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+CALL bug18914();
+INSERT INTO t1 VALUES (1);
+ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger.
+SELECT * FROM t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+DROP TABLE t1;
+DROP PROCEDURE bug18914;

--- 1.107/mysql-test/t/sp-error.test	2006-08-06 18:38:00 +04:00
+++ 1.108/mysql-test/t/sp-error.test	2006-08-06 18:38:00 +04:00
@@ -1729,6 +1729,35 @@ END;
 
 
 #
+# BUG#18914: Calling certain SPs from triggers fail
+#
+# Failing to call a procedure that does implicit commit from a trigger
+# is a correct behaviour, however the error message was misleading.
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug18914;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+CREATE PROCEDURE bug18914() CREATE TABLE t2 (i INT);
+
+CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW
+  CALL bug18914();
+
+--error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG
+INSERT INTO t1 VALUES (1);
+
+--error ER_NO_SUCH_TABLE
+SELECT * FROM t2;
+
+DROP TABLE t1;
+DROP PROCEDURE bug18914;
+
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings

--- 1.219/sql/sp_head.cc	2006-08-06 18:38:00 +04:00
+++ 1.220/sql/sp_head.cc	2006-08-06 18:38:00 +04:00
@@ -3337,7 +3337,7 @@ typedef struct st_sp_table
   */
   LEX_STRING qname;
   uint db_length, table_name_length;
-  bool temp;               /* true if corresponds to a temporary table */
+  bool create;             /* true if corresponds to a table to be created */
   thr_lock_type lock_type; /* lock type used for prelocking */
   uint lock_count;
   uint query_lock_count;
@@ -3412,7 +3412,7 @@ sp_head::merge_table_list(THD *thd, TABL
       if ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname, tlen)) ||
           ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname,
                                         tlen - alen - 1)) &&
-           tab->temp))
+           tab->create))
       {
         if (tab->lock_type < table->lock_type)
           tab->lock_type= table->lock_type; // Use the table with the highest lock type
@@ -3425,10 +3425,9 @@ sp_head::merge_table_list(THD *thd, TABL
 	if (!(tab= (SP_TABLE *)thd->calloc(sizeof(SP_TABLE))))
 	  return FALSE;
 	if (lex_for_tmp_check->sql_command == SQLCOM_CREATE_TABLE &&
-	    lex_for_tmp_check->query_tables == table &&
-	    lex_for_tmp_check->create_info.options & HA_LEX_CREATE_TMP_TABLE)
+	    lex_for_tmp_check->query_tables == table)
         {
-	  tab->temp= TRUE;
+          tab->create= TRUE;
           tab->qname.length= tlen - alen - 1;
         }
         else
@@ -3495,7 +3494,9 @@ sp_head::add_used_tables_to_table_list(T
     char *tab_buff, *key_buff;
     TABLE_LIST *table;
     SP_TABLE *stab= (SP_TABLE *)hash_element(&m_sptabs, i);
-    if (stab->temp)
+
+    /* Skip over tables that are yet to be created. */
+    if (stab->create)
       continue;
 
     if (!(tab_buff= (char *)thd->calloc(ALIGN_SIZE(sizeof(TABLE_LIST)) *
Thread
bk commit into 5.0 tree (kroki:1.2241) BUG#18914kroki6 Aug