Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram 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.2490 06/06/07 14:01:10 ramil@stripped +5 -0
Fix for bug #6880: LAST_INSERT_ID() within a statement
sql/item_func.cc
1.262 06/06/07 14:01:05 ramil@stripped +4 -3
Fix for bug #6880: LAST_INSERT_ID() within a statement
- return the first thd->last_insert_id set (within a query)
mysql-test/t/rpl_log.test
1.25 06/06/07 14:01:05 ramil@stripped +14 -0
Fix for bug #6880: LAST_INSERT_ID() within a statement
- test case
mysql-test/t/auto_increment.test
1.25 06/06/07 14:01:05 ramil@stripped +17 -0
Fix for bug #6880: LAST_INSERT_ID() within a statement
- test case
mysql-test/r/rpl_log.result
1.55 06/06/07 14:01:05 ramil@stripped +17 -0
Fix for bug #6880: LAST_INSERT_ID() within a statement
- test result
mysql-test/r/auto_increment.result
1.33 06/06/07 14:01:05 ramil@stripped +22 -0
Fix for bug #6880: LAST_INSERT_ID() within a statement
- test result
# 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: ramil
# Host: myoffice.izhnet.ru
# Root: /usr/home/ram/work/4.1.b6880
--- 1.261/sql/item_func.cc 2006-05-07 13:43:22 +05:00
+++ 1.262/sql/item_func.cc 2006-06-07 14:01:05 +05:00
@@ -2233,15 +2233,16 @@ longlong Item_func_release_lock::val_int
longlong Item_func_last_insert_id::val_int()
{
DBUG_ASSERT(fixed == 1);
+ THD* thd= current_thd;
if (arg_count)
{
longlong value=args[0]->val_int();
- current_thd->insert_id(value);
+ thd->insert_id(value);
null_value=args[0]->null_value;
}
else
- current_thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
- return current_thd->insert_id();
+ thd->lex->uncacheable(UNCACHEABLE_SIDEEFFECT);
+ return thd->last_insert_id_used ? thd->current_insert_id : thd->insert_id();
}
/* This function is just used to test speed of different functions */
--- 1.32/mysql-test/r/auto_increment.result 2006-05-04 06:12:47 +05:00
+++ 1.33/mysql-test/r/auto_increment.result 2006-06-07 14:01:05 +05:00
@@ -378,4 +378,26 @@ t1 CREATE TABLE `t1` (
KEY `t1_name` (`t1_name`)
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
DROP TABLE `t1`;
+create table t1(a int not null auto_increment primary key);
+create table t2(a int not null auto_increment primary key, t1a int);
+insert into t1 values(NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
+insert into t1 values (NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
+(NULL, LAST_INSERT_ID());
+insert into t1 values (NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
+(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
+select * from t2;
+a t1a
+1 1
+2 1
+3 2
+4 2
+5 2
+6 3
+7 3
+8 3
+9 3
+drop table t1, t2;
End of 4.1 tests
--- 1.24/mysql-test/t/auto_increment.test 2006-05-04 06:12:47 +05:00
+++ 1.25/mysql-test/t/auto_increment.test 2006-06-07 14:01:05 +05:00
@@ -238,4 +238,21 @@ SHOW CREATE TABLE `t1`;
DROP TABLE `t1`;
+#
+# Bug #6880: LAST_INSERT_ID() within a statement
+#
+
+create table t1(a int not null auto_increment primary key);
+create table t2(a int not null auto_increment primary key, t1a int);
+insert into t1 values(NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
+insert into t1 values (NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
+(NULL, LAST_INSERT_ID());
+insert into t1 values (NULL);
+insert into t2 values (NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID()),
+(NULL, LAST_INSERT_ID()), (NULL, LAST_INSERT_ID());
+select * from t2;
+drop table t1, t2;
+
--echo End of 4.1 tests
--- 1.54/mysql-test/r/rpl_log.result 2005-07-18 17:46:48 +05:00
+++ 1.55/mysql-test/r/rpl_log.result 2006-06-07 14:01:05 +05:00
@@ -99,3 +99,20 @@ Slave_IO_State Master_Host Master_User M
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000003 214 master-bin.000002 Yes Yes 0 0 276 214 None 0 No #
show binlog events in 'slave-bin.000005' from 4;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
+create table t1(a int auto_increment primary key, b int);
+insert into t1 values (NULL, 1);
+reset master;
+set insert_id=5;
+insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
+show binlog events;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+slave-bin.000001 4 Start 2 4 Server ver: VERSION, Binlog ver: 3
+slave-bin.000001 79 Intvar 2 79 LAST_INSERT_ID=1
+slave-bin.000001 107 Intvar 2 107 INSERT_ID=5
+slave-bin.000001 135 Query 2 135 use `test`; insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id())
+select * from t1;
+a b
+1 1
+5 1
+6 1
+drop table t1;
--- 1.24/mysql-test/t/rpl_log.test 2005-07-28 05:21:48 +05:00
+++ 1.25/mysql-test/t/rpl_log.test 2006-06-07 14:01:05 +05:00
@@ -108,4 +108,18 @@ show slave status;
--error 1220
show binlog events in 'slave-bin.000005' from 4;
+#
+# Bug #6880: LAST_INSERT_ID() within a statement
+#
+
+create table t1(a int auto_increment primary key, b int);
+insert into t1 values (NULL, 1);
+reset master;
+set insert_id=5;
+insert into t1 values (NULL, last_insert_id()), (NULL, last_insert_id());
+--replace_result $VERSION VERSION
+show binlog events;
+select * from t1;
+drop table t1;
+
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (ramil:1.2490) BUG#6880 | ramil | 7 Jun |