List:Commits« Previous MessageNext Message »
From:pem Date:April 25 2006 3:44pm
Subject:bk commit into 5.1 tree (pem:1.2368)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of pem. When pem 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.2368 06/04/25 17:44:35 pem@stripped +2 -0
  Post-merge fixes from 5.0.

  sql/sql_yacc.yy
    1.473 06/04/25 17:44:25 pem@stripped +1 -97
    Post-merge fix. Removed GOTO/LABEL from parser.

  mysql-test/extra/rpl_tests/rpl_insert_id.test
    1.5 06/04/25 17:44:25 pem@stripped +70 -0
    Post-merge fix. Added new 5.0 test case manually.

# 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:	pem
# Host:	pem.mysql.com
# Root:	/extern/mysql/5.1/generic/mysql-5.1-new

--- 1.472/sql/sql_yacc.yy	2006-04-25 16:20:39 +02:00
+++ 1.473/sql/sql_yacc.yy	2006-04-25 17:44:25 +02:00
@@ -365,7 +365,6 @@
 %token  KEYS
 %token  KEY_SYM
 %token  KILL_SYM
-%token  LABEL_SYM
 %token  LANGUAGE_SYM
 %token  LAST_INSERT_ID
 %token  LAST_SYM
@@ -893,7 +892,7 @@
 %type <NONE> sp_proc_stmt_statement sp_proc_stmt_return
 %type <NONE> sp_proc_stmt_if sp_proc_stmt_case_simple sp_proc_stmt_case
 %type <NONE> sp_labeled_control sp_proc_stmt_unlabeled sp_proc_stmt_leave
-%type <NONE> sp_proc_stmt_iterate sp_proc_stmt_label sp_proc_stmt_goto
+%type <NONE> sp_proc_stmt_iterate
 %type <NONE> sp_proc_stmt_open sp_proc_stmt_fetch sp_proc_stmt_close
 
 %type <num>  sp_decl_idents sp_opt_inout sp_handler_type sp_hcond_list
@@ -1554,8 +1553,6 @@
         | sp_proc_stmt_unlabeled
         | sp_proc_stmt_leave
         | sp_proc_stmt_iterate
-        | sp_proc_stmt_label
-        | sp_proc_stmt_goto
         | sp_proc_stmt_open
         | sp_proc_stmt_fetch
         | sp_proc_stmt_close
@@ -2242,8 +2239,6 @@
 	| sp_proc_stmt_unlabeled
 	| sp_proc_stmt_leave
 	| sp_proc_stmt_iterate
-	| sp_proc_stmt_label
-	| sp_proc_stmt_goto
 	| sp_proc_stmt_open
 	| sp_proc_stmt_fetch
         | sp_proc_stmt_close
@@ -2443,97 +2438,6 @@
 	      i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
               sp->add_instr(i);
 	    }
-	  }
-        ;
-
-sp_proc_stmt_label:
-	  LABEL_SYM IDENT
-	  {
-#ifdef SP_GOTO
-	    LEX *lex= Lex;
-	    sp_head *sp= lex->sphead;
-	    sp_pcontext *ctx= lex->spcont;
-	    sp_label_t *lab= ctx->find_label($2.str);
-
-	    if (lab)
-	    {
-	      my_error(ER_SP_LABEL_REDEFINE, MYF(0), $2.str);
-	      YYABORT;
-	    }
-	    else
-	    {
-	      lab= ctx->push_label($2.str, sp->instructions());
-	      lab->type= SP_LAB_GOTO;
-	      lab->ctx= ctx;
-              sp->backpatch(lab);
-	    }
-#else
-	    yyerror(ER(ER_SYNTAX_ERROR));
-	    YYABORT;
-#endif
-	  }
-        ;
-
-sp_proc_stmt_goto:
-	  GOTO_SYM IDENT
-	  {
-#ifdef SP_GOTO
-	    LEX *lex= Lex;
-	    sp_head *sp= lex->sphead;
-	    sp_pcontext *ctx= lex->spcont;
-	    uint ip= lex->sphead->instructions();
-	    sp_label_t *lab;
-	    sp_instr_jump *i;
-	    sp_instr_hpop *ih;
-	    sp_instr_cpop *ic;
-
-	    if (sp->m_in_handler)
-	    {
-	      my_message(ER_SP_GOTO_IN_HNDLR, ER(ER_SP_GOTO_IN_HNDLR), MYF(0));
-	      YYABORT;
-	    }
-	    lab= ctx->find_label($2.str);
-	    if (! lab)
-	    {
-	      lab= (sp_label_t *)YYTHD->alloc(sizeof(sp_label_t));
-	      lab->name= $2.str;
-	      lab->ip= 0;
-	      lab->type= SP_LAB_REF;
-	      lab->ctx= ctx;
-
-	      ih= new sp_instr_hpop(ip++, ctx, 0);
-	      sp->push_backpatch(ih, lab);
-	      sp->add_instr(ih);
-	      ic= new sp_instr_cpop(ip++, ctx, 0);
-	      sp->add_instr(ic);
-	      sp->push_backpatch(ic, lab);
-	      i= new sp_instr_jump(ip, ctx);
-	      sp->push_backpatch(i, lab);  /* Jumping forward */
-	      sp->add_instr(i);
-	    }
-	    else
-	    {
-	      uint n;
-
-	      n= ctx->diff_handlers(lab->ctx);
-	      if (n)
-	      {
-	        ih= new sp_instr_hpop(ip++, ctx, n);
-	        sp->add_instr(ih);
-	      }
-	      n= ctx->diff_cursors(lab->ctx);
-	      if (n)
-	      {
-	        ic= new sp_instr_cpop(ip++, ctx, n);
-	        sp->add_instr(ic);
-	      }
-	      i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
-	      sp->add_instr(i);
-	    }
-#else
-	    yyerror(ER(ER_SYNTAX_ERROR));
-	    YYABORT;
-#endif
 	  }
         ;
 

--- 1.4/mysql-test/extra/rpl_tests/rpl_insert_id.test	2006-02-08 16:47:06 +01:00
+++ 1.5/mysql-test/extra/rpl_tests/rpl_insert_id.test	2006-04-25 17:44:25 +02:00
@@ -86,3 +86,73 @@
 sync_slave_with_master;
 
 # End of 4.1 tests
+
+
+#
+# BUG#15728: LAST_INSERT_ID function inside a stored function returns 0
+#
+# The solution is not to reset last_insert_id on enter to sub-statement.
+#
+connection master;
+--disable_warnings
+drop function if exists bug15728;
+drop function if exists bug15728_insert;
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (
+  id int not null auto_increment,
+  last_id int,
+  primary key (id)
+);
+create function bug15728() returns int(11)
+  return last_insert_id();
+
+insert into t1 (last_id) values (0);
+insert into t1 (last_id) values (last_insert_id());
+insert into t1 (last_id) values (bug15728());
+
+# Check that nested call replicates too.
+create table t2 (
+  id int not null auto_increment,
+  last_id int,
+  primary key (id)
+);
+delimiter |;
+create function bug15728_insert() returns int(11) modifies sql data
+begin
+  insert into t2 (last_id) values (bug15728());
+  return bug15728();
+end|
+create trigger t1_bi before insert on t1 for each row
+begin
+  declare res int;
+  select bug15728_insert() into res;
+  set NEW.last_id = res;
+end|
+delimiter ;|
+
+insert into t1 (last_id) values (0);
+
+drop trigger t1_bi;
+
+# Check that nested call doesn't affect outer context.
+select last_insert_id();
+select bug15728_insert();
+select last_insert_id();
+insert into t1 (last_id) values (bug15728());
+# This should be exactly one greater than in the previous call.
+select last_insert_id();
+
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1;
+select * from t2;
+connection master;
+
+drop function bug15728;
+drop function bug15728_insert;
+drop table t1, t2;
+
+# End of 5.0 tests
Thread
bk commit into 5.1 tree (pem:1.2368)pem25 Apr