List:Commits« Previous MessageNext Message »
From:Patrick Galbraith Date:August 8 2006 4:53am
Subject:bk commit into 5.1 tree (pgalbraith:1.2266)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of patg. When patg 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-08 00:53:06-04:00, pgalbraith@stripped +3 -0
  Post hand-merge fixes
  
  federated.result:
    new test results - no changes to test, just additions
  ha_federated.cc:
    Post hand merge fixes. table->s->fields can't be used to say "does this have fields that are set and should be included in the update SQL statement"
  field.cc:
    added back Field::clone that was removed in a 5.0 cset that I hand merged

  mysql-test/r/federated.result@stripped, 2006-08-08 00:50:53-04:00, pgalbraith@stripped +38 -67
    new test results - no changes to test, just additions

  sql/field.cc@stripped, 2006-08-08 00:50:27-04:00, pgalbraith@stripped +13 -0
    added back Field::clone that was removed in a 5.0 cset that I hand merged

  sql/ha_federated.cc@stripped, 2006-08-08 00:49:25-04:00, pgalbraith@stripped +38 -26
    Post hand merge fixes. table->s->fields can't be used to say "does this have fields that are set and should be included in the update SQL statement"

# 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:	pgalbraith
# Host:	buffy.netfrastructure.com
# Root:	/home/patg/mysql-build/mysql-5.1-5.0-merge

--- 1.330/sql/field.cc	2006-08-08 00:53:25 -04:00
+++ 1.331/sql/field.cc	2006-08-08 00:53:25 -04:00
@@ -1571,6 +1571,19 @@
   return tmp;
 }
 
+/* This is used to generate a field in TABLE from TABLE_SHARE */
+
+Field *Field::clone(MEM_ROOT *root, struct st_table *new_table)
+{
+  Field *tmp;
+  if ((tmp= (Field*) memdup_root(root,(char*) this,size_of())))
+  {
+    tmp->init(new_table);
+    tmp->move_field_offset((my_ptrdiff_t) (new_table->record[0] -
+                                           new_table->s->default_values));
+  }
+  return tmp;
+}
 
 /****************************************************************************
   Field_null, a field that always return NULL

--- 1.40/mysql-test/r/federated.result	2006-08-08 00:53:25 -04:00
+++ 1.41/mysql-test/r/federated.result	2006-08-08 00:53:25 -04:00
@@ -1603,6 +1603,44 @@
 5	Torkel	0	0
 DROP TABLE federated.t1;
 DROP TABLE federated.bug_17377_table;
+DROP TABLE IF EXISTS federated.test;
+CREATE TABLE federated.test (
+`id` int(11) NOT NULL,
+`val1` varchar(255) NOT NULL,
+`val2` varchar(255) NOT NULL,
+PRIMARY KEY  (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS federated.test_local;
+DROP TABLE IF EXISTS federated.test_remote;
+CREATE TABLE federated.test_local (
+`id` int(11) NOT NULL,
+`val1` varchar(255) NOT NULL,
+`val2` varchar(255) NOT NULL,
+PRIMARY KEY  (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO federated.test_local VALUES (1, 'foo', 'bar'),
+(2, 'bar', 'foo');
+CREATE TABLE federated.test_remote (
+`id` int(11) NOT NULL,
+`val1` varchar(255) NOT NULL,
+`val2` varchar(255) NOT NULL,
+PRIMARY KEY  (`id`)
+) ENGINE=FEDERATED DEFAULT CHARSET=latin1
+CONNECTION='mysql://root@stripped:SLAVE_PORT/federated/test';
+insert into federated.test_remote select * from federated.test_local;
+select * from federated.test_remote;
+id	val1	val2
+1	foo	bar
+2	bar	foo
+delete from federated.test_remote where id in (1,2);
+insert into federated.test_remote select * from federated.test_local;
+select * from federated.test_remote;
+id	val1	val2
+2	bar	foo
+1	foo	bar
+DROP TABLE federated.test_local;
+DROP TABLE federated.test_remote;
+DROP TABLE federated.test;
 drop table if exists federated.t1;
 create table federated.t1 (a int, b int, c int);
 drop table if exists federated.t1;
@@ -1717,72 +1755,6 @@
 9	abc	ppc
 drop table federated.t1, federated.t2;
 drop table federated.t1, federated.t2;
-DROP TABLE IF EXISTS federated.test;
-CREATE TABLE federated.test (
-`id` int(11) NOT NULL,
-`val1` varchar(255) NOT NULL,
-`val2` varchar(255) NOT NULL,
-PRIMARY KEY  (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-DROP TABLE IF EXISTS federated.test_local;
-DROP TABLE IF EXISTS federated.test_remote;
-CREATE TABLE federated.test_local (
-`id` int(11) NOT NULL,
-`val1` varchar(255) NOT NULL,
-`val2` varchar(255) NOT NULL,
-PRIMARY KEY  (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-INSERT INTO federated.test_local VALUES (1, 'foo', 'bar'),
-(2, 'bar', 'foo');
-CREATE TABLE federated.test_remote (
-`id` int(11) NOT NULL,
-`val1` varchar(255) NOT NULL,
-`val2` varchar(255) NOT NULL,
-PRIMARY KEY  (`id`)
-) ENGINE=FEDERATED DEFAULT CHARSET=latin1
-CONNECTION='mysql://root@stripped:SLAVE_PORT/federated/test';
-insert into federated.test_remote select * from federated.test_local;
-select * from federated.test_remote;
-id	val1	val2
-1	foo	bar
-2	bar	foo
-delete from federated.test_remote where id in (1,2);
-insert into federated.test_remote select * from federated.test_local;
-select * from federated.test_remote;
-id	val1	val2
-2	bar	foo
-1	foo	bar
-DROP TABLE federated.test_local;
-DROP TABLE federated.test_remote;
-DROP TABLE federated.test;
-drop table if exists federated.t1;
-create table federated.t1 (a int, b int, c int);
-drop table if exists federated.t1;
-drop table if exists federated.t2;
-create table federated.t1 (a int,  b int, c int) engine=federated connection='mysql://root@stripped:SLAVE_PORT/federated/t1';
-create trigger federated.t1_bi before insert on federated.t1 for each row set new.c= new.a * new.b;
-create table federated.t2 (a int, b int);
-insert into federated.t2 values (13, 17), (19, 23);
-insert into federated.t1 (a, b) values (1, 2), (3, 5), (7, 11);
-select * from federated.t1;
-a	b	c
-1	2	2
-3	5	15
-7	11	77
-delete from federated.t1;
-insert into federated.t1 (a, b) select * from federated.t2;
-select * from federated.t1;
-a	b	c
-13	17	221
-19	23	437
-delete from federated.t1;
-load data infile '../std_data_ln/loaddata5.dat' into table federated.t1 fields terminated by '' enclosed by '' ignore 1 lines (a, b);
-select * from federated.t1;
-a	b	c
-3	4	12
-5	6	30
-drop tables federated.t1, federated.t2;
-drop table federated.t1;
 create table t1 (id int not null auto_increment primary key, val int);
 create table t1
 (id int not null auto_increment primary key, val int) engine=federated
@@ -1812,7 +1784,6 @@
 5000
 drop table t1;
 drop table t1;
-
 End of 5.0 tests
 DROP TABLE IF EXISTS federated.t1;
 DROP DATABASE IF EXISTS federated;

--- 1.71/sql/ha_federated.cc	2006-08-08 00:53:25 -04:00
+++ 1.72/sql/ha_federated.cc	2006-08-08 00:53:25 -04:00
@@ -1563,6 +1563,7 @@
 
 int ha_federated::write_row(byte *buf)
 {
+  my_bool commas_added= FALSE;
   char insert_buffer[FEDERATED_QUERY_BUFFER_SIZE];
   char values_buffer[FEDERATED_QUERY_BUFFER_SIZE];
   char insert_field_value_buffer[STRING_BUFFER_USUAL_SIZE];
@@ -1589,13 +1590,13 @@
   /*
     start both our field and field values strings
   */
-  insert_string.append(STRING_WITH_LEN("INSERT `"));
+  insert_string.append(STRING_WITH_LEN("INSERT INTO `"));
   insert_string.append(share->table_name, share->table_name_length);
-  insert_string.append(FEDERATED_BTICK);
-  insert_string.append(FEDERATED_OPENPAREN);
+  insert_string.append('`');
+  insert_string.append(STRING_WITH_LEN(" ("));
 
-  values_string.append(FEDERATED_VALUES);
-  values_string.append(FEDERATED_OPENPAREN);
+  values_string.append(STRING_WITH_LEN(" VALUES "));
+  values_string.append(STRING_WITH_LEN(" ("));
 
   /*
     loop through the field pointer array, add any fields to both the values
@@ -1605,6 +1606,7 @@
   {
     if (bitmap_is_set(table->write_set, (*field)->field_index))
     {
+      commas_added= TRUE;
       if ((*field)->is_null())
         insert_field_value_string.append(STRING_WITH_LEN(" NULL "));
       else
@@ -1629,8 +1631,8 @@
         make the following appends conditional as we don't know if the
         next field is in the write set
       */
-      insert_string.append(FEDERATED_COMMA);
-      values_string.append(FEDERATED_COMMA);
+      insert_string.append(STRING_WITH_LEN(", "));
+      values_string.append(STRING_WITH_LEN(", "));
     }
   }
   dbug_tmp_restore_column_map(table->read_set, old_map);
@@ -1640,16 +1642,21 @@
     AND, we don't want to chop off the last char '('
     insert will be "INSERT INTO t1 VALUES ();"
   */
-  if (table->s->fields)
+  if (commas_added)
   {
+    insert_string.length(insert_string.length() - sizeof_trailing_comma);
     /* chops off leading commas */
-    values_string.length(values_string.length() - strlen(FEDERATED_COMMA));
-    insert_string.length(insert_string.length() - strlen(FEDERATED_COMMA));
-    insert_string.append(FEDERATED_CLOSEPAREN);
+    values_string.length(values_string.length() - sizeof_trailing_comma);
+    insert_string.append(STRING_WITH_LEN(") "));
+  }
+  else
+  {
+    /* chops off trailing ) */
+    insert_string.length(insert_string.length() - sizeof_trailing_closeparen);
   }
 
   /* we always want to append this, even if there aren't any fields */
-  values_string.append(FEDERATED_CLOSEPAREN);
+  values_string.append(STRING_WITH_LEN(") "));
 
   /* add the values */
   insert_string.append(values_string);
@@ -1770,6 +1777,7 @@
     this.
   */
   bool has_a_primary_key= test(table->s->primary_key != MAX_KEY);
+  
   /*
     buffers for following strings
   */
@@ -1815,48 +1823,52 @@
     if (bitmap_is_set(table->write_set, (*field)->field_index))
     {
       update_string.append((*field)->field_name);
-      update_string.append(FEDERATED_EQ);
+      update_string.append(STRING_WITH_LEN(" = "));
 
       if ((*field)->is_null())
-        update_string.append(FEDERATED_NULL);
+        update_string.append(STRING_WITH_LEN(" NULL "));
       else
       {
         my_bitmap_map *old_map= tmp_use_all_columns(table, table->read_set);
         /* otherwise = */
+	(*field)->val_str(&field_value);
         update_string.append('\'');
         field_value.print(&update_string);
         update_string.append('\'');
         field_value.length(0);
         tmp_restore_column_map(table->read_set, old_map);
       }
-      update_string.append(STRING_WITH_LEN(FEDERATED_COMMA));
+      update_string.append(STRING_WITH_LEN(", "));
     }
 
     if (bitmap_is_set(table->read_set, (*field)->field_index))
     {
       where_string.append((*field)->field_name);
       if (field_in_record_is_null(table, *field, (char*) old_data))
-        where_string.append(STR_WITH_LEN(FEDERATED_ISNULL));
+        where_string.append(STRING_WITH_LEN(" IS NULL "));
       else
       {
-        where_string.append(STR_WITH_LEN(FEDERATED_EQ));
+        where_string.append(STRING_WITH_LEN(" = "));
         (*field)->val_str(&field_value,
                           (char*) (old_data + (*field)->offset()));
-        (*field)->quote_data(&field_value);
-        where_string.append(field_value);
+	where_string.append('\'');
+        field_value.print(&where_string);
+	where_string.append('\'');
         field_value.length(0);
       }
-      where_string.append(STR_WITH_LEN(FEDERATED_AND));
+      where_string.append(STRING_WITH_LEN(" AND "));
     }
   }
 
   /* Remove last ', '. This works as there must be at least on updated field */
   update_string.length(update_string.length() - sizeof_trailing_comma);
+
+  DBUG_PRINT("info", ("update_string %s", update_string.c_ptr_quick()));
   if (where_string.length())
   {
     /* chop off trailing AND */
     where_string.length(where_string.length() - sizeof_trailing_and);
-    update_string.append(STRING_WITH_LEN(FEDERATED_WHERE));
+    update_string.append(STRING_WITH_LEN(" WHERE "));
     update_string.append(where_string);
   }
 
@@ -1865,7 +1877,7 @@
     update multiple rows. We want to make sure to only update one!
   */
   if (!has_a_primary_key)
-    update_string.append(STRING_WITH_LEN(FEDERATED_LIMIT1));
+    update_string.append(STRING_WITH_LEN(" LIMIT 1"));
 
   if (mysql_real_query(mysql, update_string.ptr(), update_string.length()))
   {
@@ -1913,17 +1925,17 @@
       delete_string.append(cur_field->field_name);
       if (cur_field->is_null())
       {
-        delete_string.append(STRING_WITH_LEN(FEDERATED_ISNULL));
+        delete_string.append(STRING_WITH_LEN(" IS NULL "));
       }
       else
       {
-      delete_string.append(STRING_WITH_LEN(FEDERATED_EQ));
+      delete_string.append(STRING_WITH_LEN(" = "));
       cur_field->val_str(&data_string);
       delete_string.append('\'');
       data_string.print(&delete_string);
       delete_string.append('\'');
       }
-      delete_string.append(STRING_WITH_LEN(FEDERATED_AND));
+      delete_string.append(STRING_WITH_LEN(" AND "));
     }
   }
 
@@ -1932,7 +1944,7 @@
   if (!found)
     delete_string.length(delete_string.length() - sizeof_trailing_where);
 
-  delete_string.append(STRING_WITH_LEN(FEDERATED_LIMIT1));
+  delete_string.append(STRING_WITH_LEN(" LIMIT 1"));
   DBUG_PRINT("info",
              ("Delete sql: %s", delete_string.c_ptr_quick()));
   if (mysql_real_query(mysql, delete_string.ptr(), delete_string.length()))
Thread
bk commit into 5.1 tree (pgalbraith:1.2266)Patrick Galbraith8 Aug