MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Konstantin Osipov Date:February 7 2006 9:33pm
Subject:bk commit into 5.1 tree (konstantin:1.2088)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kostja. When kostja 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.2088 06/02/08 00:33:31 konstantin@stripped +3 -0
  Merge mysql.com:/home/kostja/mysql/tmp_merge
  into  mysql.com:/home/kostja/mysql/mysql-5.1-merge

  sql/ha_federated.h
    1.26 06/02/08 00:33:23 konstantin@stripped +0 -0
    Auto merged

  sql/ha_federated.cc
    1.52 06/02/08 00:33:23 konstantin@stripped +0 -0
    Auto merged

  mysql-test/t/federated.test
    1.21 06/02/08 00:33:23 konstantin@stripped +0 -0
    Auto merged

# 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:	konstantin
# Host:	oak.local
# Root:	/home/kostja/mysql/mysql-5.1-merge/RESYNC

--- 1.20/mysql-test/t/federated.test	2006-01-04 13:18:53 +03:00
+++ 1.21/mysql-test/t/federated.test	2006-02-08 00:33:23 +03:00
@@ -1226,4 +1226,34 @@
 connection slave;
 drop table federated.t1;
 
+#
+# BUG# 14768 test auto_increment last_insert_id()
+#
+connection slave;
+DROP TABLE IF EXISTS federated.t1;
+CREATE TABLE federated.t1 (
+    `id` int(20) NOT NULL auto_increment,
+    PRIMARY KEY  (`id`));
+
+connection master;
+DROP TABLE IF EXISTS federated.t1;
+eval CREATE TABLE federated.t1 (
+    `id` int(20) NOT NULL auto_increment,
+    PRIMARY KEY  (`id`)
+    )
+  ENGINE="FEDERATED" DEFAULT CHARSET=latin1
+  CONNECTION='mysql://root@stripped:$SLAVE_MYPORT/federated/t1';
+
+INSERT INTO federated.t1 VALUES ();
+SELECT LAST_INSERT_ID();
+INSERT INTO federated.t1 VALUES ();
+SELECT LAST_INSERT_ID();
+INSERT INTO federated.t1 VALUES ();
+SELECT LAST_INSERT_ID();
+INSERT INTO federated.t1 VALUES ();
+SELECT LAST_INSERT_ID();
+INSERT INTO federated.t1 VALUES ();
+SELECT LAST_INSERT_ID();
+SELECT * FROM federated.t1;
+
 source include/federated_cleanup.inc;

--- 1.51/sql/ha_federated.cc	2006-01-28 06:16:18 +03:00
+++ 1.52/sql/ha_federated.cc	2006-02-08 00:33:23 +03:00
@@ -1409,6 +1409,12 @@
     hash_delete(&federated_open_tables, (byte*) share);
     my_free((gptr) share->scheme, MYF(MY_ALLOW_ZERO_PTR));
     share->scheme= 0;
+    if (share->socket)
+    {
+      my_free((gptr) share->socket, MYF(MY_ALLOW_ZERO_PTR));
+      share->socket= 0;
+    }
+
     thr_lock_delete(&share->lock);
     VOID(pthread_mutex_destroy(&share->mutex));
     my_free((gptr) share, MYF(0));
@@ -1688,10 +1694,34 @@
   {
     DBUG_RETURN(stash_remote_error());
   }
+  /*
+    If the table we've just written a record to contains an auto_increment field,
+    then store the last_insert_id() value from the foreign server
+  */
+  if (table->next_number_field)
+    update_auto_increment();
 
   DBUG_RETURN(0);
 }
 
+/*
+  ha_federated::update_auto_increment
+
+  This method ensures that last_insert_id() works properly. What it simply does
+  is calls last_insert_id() on the foreign database immediately after insert
+  (if the table has an auto_increment field) and sets the insert id via
+  thd->insert_id(ID) (as well as storing thd->prev_insert_id)
+*/
+void ha_federated::update_auto_increment(void)
+{
+  THD *thd= current_thd;
+  DBUG_ENTER("ha_federated::update_auto_increment");
+
+  thd->insert_id(mysql->last_used_con->insert_id);
+  DBUG_PRINT("info",("last_insert_id %d", auto_increment_value));
+
+  DBUG_VOID_RETURN;
+}
 
 int ha_federated::optimize(THD* thd, HA_CHECK_OPT* check_opt)
 {

--- 1.25/sql/ha_federated.h	2005-11-23 23:47:26 +03:00
+++ 1.26/sql/ha_federated.h	2006-02-08 00:33:23 +03:00
@@ -286,6 +286,7 @@
   void position(const byte *record);                            //required
   void info(uint);                                              //required
 
+  void update_auto_increment(void);
   int repair(THD* thd, HA_CHECK_OPT* check_opt);
   int optimize(THD* thd, HA_CHECK_OPT* check_opt);
 
Thread
bk commit into 5.1 tree (konstantin:1.2088)Konstantin Osipov7 Feb