summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <gshchepa/uchum@gleb.loc>2007-07-28 21:24:19 +0500
committerunknown <gshchepa/uchum@gleb.loc>2007-07-28 21:24:19 +0500
commitbb2d58f5e41c27d02a6d9ff8148b734a9408351d (patch)
tree364927abeae19868e9eaf6066b74ae21f313b83f
parent766725c5025cc53a510487454be09238c849ac77 (diff)
parent0ce785538fceba117441dea5fe2751098ad4ea89 (diff)
downloadmariadb-git-bb2d58f5e41c27d02a6d9ff8148b734a9408351d.tar.gz
Merge gleb.loc:/home/uchum/work/bk/5.0
into gleb.loc:/home/uchum/work/bk/5.0-opt
-rw-r--r--mysql-test/r/bdb.result2
-rw-r--r--mysql-test/r/rpl_insert_delayed.result23
-rw-r--r--mysql-test/r/rpl_session_var.result10
-rw-r--r--mysql-test/t/rpl_insert_delayed.test30
-rw-r--r--mysql-test/t/rpl_session_var.test22
-rw-r--r--sql/ha_berkeley.cc6
-rw-r--r--sql/item.cc52
-rw-r--r--sql/item.h6
-rw-r--r--sql/item_strfunc.h4
-rw-r--r--sql/sql_insert.cc9
-rw-r--r--sql/sql_select.cc1
-rw-r--r--sql/table.cc3
12 files changed, 145 insertions, 23 deletions
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result
index 91c385112b4..3356d23053f 100644
--- a/mysql-test/r/bdb.result
+++ b/mysql-test/r/bdb.result
@@ -136,8 +136,8 @@ update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102 order by parent_id,id;
id parent_id level
1008 102 2
-1010 102 2
1015 102 2
+1010 102 2
explain select level from t1 where level=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref level level 1 const X Using index
diff --git a/mysql-test/r/rpl_insert_delayed.result b/mysql-test/r/rpl_insert_delayed.result
index 38e2cddd650..6815a727fd7 100644
--- a/mysql-test/r/rpl_insert_delayed.result
+++ b/mysql-test/r/rpl_insert_delayed.result
@@ -29,3 +29,26 @@ id name
10 my name
20 is Bond
drop table t1;
+CREATE TABLE t1(a int, UNIQUE(a));
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+flush table t1;
+show binlog events limit 11,100;
+Log_name Pos Event_type Server_id End_log_pos Info
+x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+x x x x x use `test`; flush table t1
+select * from t1;
+a
+1
+On slave
+show binlog events limit 12,100;
+Log_name Pos Event_type Server_id End_log_pos Info
+x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+x x x x x use `test`; INSERT DELAYED IGNORE INTO t1 VALUES(1)
+x x x x x use `test`; flush table t1
+select * from t1;
+a
+1
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/rpl_session_var.result b/mysql-test/r/rpl_session_var.result
index b5b4b815ade..787899932d6 100644
--- a/mysql-test/r/rpl_session_var.result
+++ b/mysql-test/r/rpl_session_var.result
@@ -41,3 +41,13 @@ select * from t2 order by b;
b a
1 1
drop table t1,t2;
+CREATE TABLE t1 (
+`id` int(11) NOT NULL auto_increment,
+`data` varchar(100),
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM;
+INSERT INTO t1(data) VALUES(SESSION_USER());
+SELECT * FROM t1;
+id data
+1
+drop table t1;
diff --git a/mysql-test/t/rpl_insert_delayed.test b/mysql-test/t/rpl_insert_delayed.test
index 3f72f3a3625..09e0c5cc2e9 100644
--- a/mysql-test/t/rpl_insert_delayed.test
+++ b/mysql-test/t/rpl_insert_delayed.test
@@ -65,3 +65,33 @@ connection master;
drop table t1;
sync_slave_with_master;
connection master;
+
+#
+# Bug #29571: INSERT DELAYED IGNORE written to binary log on the master but
+# on the slave
+#
+CREATE TABLE t1(a int, UNIQUE(a));
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+INSERT DELAYED IGNORE INTO t1 VALUES(1);
+flush table t1; # to wait for INSERT DELAYED to be done
+
+#must show two INSERT DELAYED
+--replace_column 1 x 2 x 3 x 4 x 5 x
+show binlog events limit 11,100;
+select * from t1;
+
+sync_slave_with_master;
+echo On slave;
+#must show two INSERT DELAYED
+--replace_column 1 x 2 x 3 x 4 x 5 x
+show binlog events limit 12,100;
+select * from t1;
+
+
+# clean up
+connection master;
+drop table t1;
+sync_slave_with_master;
+connection master;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/rpl_session_var.test b/mysql-test/t/rpl_session_var.test
index a6f4b496a23..8231a0dbefd 100644
--- a/mysql-test/t/rpl_session_var.test
+++ b/mysql-test/t/rpl_session_var.test
@@ -40,3 +40,25 @@ drop table t1,t2;
save_master_pos;
connection slave;
sync_with_master;
+
+#
+# Bug #29878 Garbage data generation when executing SESSION_USER() on a slave.
+#
+
+connection master;
+CREATE TABLE t1 (
+ `id` int(11) NOT NULL auto_increment,
+ `data` varchar(100),
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM;
+
+INSERT INTO t1(data) VALUES(SESSION_USER());
+save_master_pos;
+connection slave;
+sync_with_master;
+SELECT * FROM t1;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index 2a5fe775ca6..fbfd5031656 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -2646,7 +2646,11 @@ ha_rows ha_berkeley::estimate_rows_upper_bound()
int ha_berkeley::cmp_ref(const byte *ref1, const byte *ref2)
{
if (hidden_primary_key)
- return memcmp(ref1, ref2, BDB_HIDDEN_PRIMARY_KEY_LENGTH);
+ {
+ ulonglong a=uint5korr((char*) ref1);
+ ulonglong b=uint5korr((char*) ref2);
+ return a < b ? -1 : (a > b ? 1 : 0);
+ }
int result;
Field *field;
diff --git a/sql/item.cc b/sql/item.cc
index 2fc58eebe75..bd47fb706a6 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -336,6 +336,37 @@ int Item::save_date_in_field(Field *field)
}
+/*
+ Store the string value in field directly
+
+ SYNOPSIS
+ Item::save_str_value_in_field()
+ field a pointer to field where to store
+ result the pointer to the string value to be stored
+
+ DESCRIPTION
+ The method is used by Item_*::save_in_field implementations
+ when we don't need to calculate the value to store
+ See Item_string::save_in_field() implementation for example
+
+ IMPLEMENTATION
+ Check if the Item is null and stores the NULL or the
+ result value in the field accordingly.
+
+ RETURN
+ Nonzero value if error
+*/
+
+int Item::save_str_value_in_field(Field *field, String *result)
+{
+ if (null_value)
+ return set_field_to_null(field);
+ field->set_notnull();
+ return field->store(result->ptr(), result->length(),
+ collation.collation);
+}
+
+
Item::Item():
rsize(0), name(0), orig_name(0), name_length(0), fixed(0),
is_autogenerated_name(TRUE),
@@ -3009,16 +3040,6 @@ my_decimal *Item_copy_string::val_decimal(my_decimal *decimal_value)
}
-
-int Item_copy_string::save_in_field(Field *field, bool no_conversions)
-{
- if (null_value)
- return set_field_to_null(field);
- field->set_notnull();
- return field->store(str_value.ptr(),str_value.length(),
- collation.collation);
-}
-
/*
Functions to convert item to field (for send_fields)
*/
@@ -4417,6 +4438,12 @@ int Item_null::save_safe_in_field(Field *field)
}
+/*
+ This implementation can lose str_value content, so if the
+ Item uses str_value to store something, it should
+ reimplement it's ::save_in_field() as Item_string, for example, does
+*/
+
int Item::save_in_field(Field *field, bool no_conversions)
{
int error;
@@ -4474,10 +4501,7 @@ int Item_string::save_in_field(Field *field, bool no_conversions)
{
String *result;
result=val_str(&str_value);
- if (null_value)
- return set_field_to_null(field);
- field->set_notnull();
- return field->store(result->ptr(),result->length(),collation.collation);
+ return save_str_value_in_field(field, result);
}
diff --git a/sql/item.h b/sql/item.h
index 5b1a80a5f03..72236cb5e63 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -612,6 +612,7 @@ public:
int save_time_in_field(Field *field);
int save_date_in_field(Field *field);
+ int save_str_value_in_field(Field *field, String *result);
virtual Field *get_tmp_table_field() { return 0; }
/* This is also used to create fields in CREATE ... SELECT: */
@@ -2166,7 +2167,10 @@ public:
my_decimal *val_decimal(my_decimal *);
void make_field(Send_field *field) { item->make_field(field); }
void copy();
- int save_in_field(Field *field, bool no_conversions);
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_str_value_in_field(field, &str_value);
+ }
table_map used_tables() const { return (table_map) 1L; }
bool const_item() const { return 0; }
bool is_null() { return null_value; }
diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h
index d7c4a3eddef..6ca0b89a22b 100644
--- a/sql/item_strfunc.h
+++ b/sql/item_strfunc.h
@@ -434,6 +434,10 @@ public:
}
const char *func_name() const { return "user"; }
const char *fully_qualified_func_name() const { return "user()"; }
+ int save_in_field(Field *field, bool no_conversions)
+ {
+ return save_str_value_in_field(field, &str_value);
+ }
};
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 19c9360b0ed..5ba1e766947 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -560,6 +560,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
int error, res;
bool transactional_table, joins_freed= FALSE;
bool changed;
+ bool was_insert_delayed= (table_list->lock_type == TL_WRITE_DELAYED);
uint value_count;
ulong counter = 1;
ulonglong id;
@@ -859,14 +860,16 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
transactional_table= table->file->has_transactions();
- if ((changed= (info.copied || info.deleted || info.updated)))
+ if ((changed= (info.copied || info.deleted || info.updated)) ||
+ was_insert_delayed)
{
/*
Invalidate the table in the query cache if something changed.
For the transactional algorithm to work the invalidation must be
before binlog writing and ha_autocommit_or_rollback
*/
- query_cache_invalidate3(thd, table_list, 1);
+ if (changed)
+ query_cache_invalidate3(thd, table_list, 1);
if (error <= 0 || !transactional_table)
{
if (mysql_bin_log.is_open())
@@ -904,7 +907,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
if (mysql_bin_log.write(&qinfo) && transactional_table)
error=1;
}
- if (!transactional_table)
+ if (!transactional_table && changed)
thd->no_trans_update.all= TRUE;
}
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2d9d261bb31..d82a0fdcf41 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -12033,7 +12033,6 @@ static int test_if_order_by_key(ORDER *order, TABLE *table, uint idx,
*/
if (!on_primary_key &&
(table->file->table_flags() & HA_PRIMARY_KEY_IN_READ_INDEX) &&
- table->s->db_type == DB_TYPE_INNODB &&
table->s->primary_key != MAX_KEY)
{
on_primary_key= TRUE;
diff --git a/sql/table.cc b/sql/table.cc
index ce894e6910f..18a395d69af 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -782,8 +782,7 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX)
{
field->part_of_key= share->keys_in_use;
- if (share->db_type == DB_TYPE_INNODB &&
- field->part_of_sortkey.is_set(key))
+ if (field->part_of_sortkey.is_set(key))
field->part_of_sortkey= share->keys_in_use;
}
}