summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/extra/rpl_tests/rpl_insert_id.test22
-rw-r--r--mysql-test/r/information_schema.result14
-rw-r--r--mysql-test/r/rpl_insert_id.result1
-rw-r--r--mysql-test/r/select.result2
-rw-r--r--mysql-test/r/union.result14
-rw-r--r--mysql-test/t/rpl_insert_id.test21
-rw-r--r--mysql-test/t/select.test39
-rw-r--r--sql/field.cc11
-rw-r--r--sql/field.h7
-rw-r--r--sql/item.cc9
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_insert.cc10
-rw-r--r--sql/sql_select.cc7
13 files changed, 84 insertions, 74 deletions
diff --git a/mysql-test/extra/rpl_tests/rpl_insert_id.test b/mysql-test/extra/rpl_tests/rpl_insert_id.test
index 652ff8881c5..79f8c39e152 100644
--- a/mysql-test/extra/rpl_tests/rpl_insert_id.test
+++ b/mysql-test/extra/rpl_tests/rpl_insert_id.test
@@ -84,9 +84,28 @@ SET FOREIGN_KEY_CHECKS=0;
--error 1022, 1062
INSERT INTO t1 VALUES (1),(1);
sync_slave_with_master;
+connection master;
+drop table t1;
+sync_slave_with_master;
# End of 4.1 tests
-
+
+#
+# Bug#14553: NULL in WHERE resets LAST_INSERT_ID
+#
+connection master;
+create table t1(a int auto_increment, key(a));
+create table t2(a int);
+insert into t1 (a) values (null);
+insert into t2 (a) select a from t1 where a is null;
+insert into t2 (a) select a from t1 where a is null;
+select * from t2;
+sync_slave_with_master;
+connection slave;
+select * from t2;
+connection master;
+drop table t1;
+drop table t2;
#
# BUG#15728: LAST_INSERT_ID function inside a stored function returns 0
@@ -274,3 +293,4 @@ drop table t1, t2;
drop function insid;
sync_slave_with_master;
+
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 32ef2000cf2..9e6a3f298c1 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -1238,7 +1238,14 @@ COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
COLUMN_PRIVILEGES TABLE_SCHEMA
+ENGINES ENGINE
+EVENTS EVENT_SCHEMA
+FILES TABLE_SCHEMA
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
+PARTITIONS TABLE_SCHEMA
+PLUGINS PLUGIN_NAME
+PROCESSLIST ID
+REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
ROUTINES ROUTINE_SCHEMA
SCHEMATA SCHEMA_NAME
SCHEMA_PRIVILEGES TABLE_SCHEMA
@@ -1269,7 +1276,14 @@ COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
COLUMN_PRIVILEGES TABLE_SCHEMA
+ENGINES ENGINE
+EVENTS EVENT_SCHEMA
+FILES TABLE_SCHEMA
KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
+PARTITIONS TABLE_SCHEMA
+PLUGINS PLUGIN_NAME
+PROCESSLIST ID
+REFERENTIAL_CONSTRAINTS CONSTRAINT_SCHEMA
ROUTINES ROUTINE_SCHEMA
SCHEMATA SCHEMA_NAME
SCHEMA_PRIVILEGES TABLE_SCHEMA
diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result
index 6252d8b8292..3c33fe1be2b 100644
--- a/mysql-test/r/rpl_insert_id.result
+++ b/mysql-test/r/rpl_insert_id.result
@@ -73,6 +73,7 @@ CREATE TABLE t1 ( a INT UNIQUE );
SET FOREIGN_KEY_CHECKS=0;
INSERT INTO t1 VALUES (1),(1);
Got one of the listed errors
+drop table t1;
create table t1(a int auto_increment, key(a));
create table t2(a int);
insert into t1 (a) values (null);
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 4ea73009d35..72f2cd9a3d0 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -3475,7 +3475,7 @@ SELECT 0.9888889889 * 1.011111411911;
0.9998769417899202067879
prepare stmt from 'select 1 as " a "';
Warnings:
-Warning 1466 Leading spaces are removed from name ' a '
+Warning 1546 Leading spaces are removed from name ' a '
execute stmt;
a
1
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index f1eff937e1a..1c53f45b698 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1311,14 +1311,14 @@ create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
- `f1` char(1) default NULL,
- `f2` char(5) default NULL,
- `f3` binary(1) default NULL,
- `f4` binary(5) default NULL,
- `f5` timestamp NOT NULL default '0000-00-00 00:00:00',
- `f6` varchar(1) character set utf8 default NULL,
+ `f1` char(1) DEFAULT NULL,
+ `f2` char(5) DEFAULT NULL,
+ `f3` binary(1) DEFAULT NULL,
+ `f4` binary(5) DEFAULT NULL,
+ `f5` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `f6` varchar(1) CHARACTER SET utf8 DEFAULT NULL,
`f7` text,
- `f8` text character set utf8
+ `f8` text CHARACTER SET utf8
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2;
(select avg(1)) union (select avg(1)) union (select avg(1)) union
diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test
index 11e4ec1c712..bfd66431d3c 100644
--- a/mysql-test/t/rpl_insert_id.test
+++ b/mysql-test/t/rpl_insert_id.test
@@ -9,24 +9,3 @@
-- source include/have_innodb.inc
let $engine_type=innodb;
-- source extra/rpl_tests/rpl_insert_id.test
-
-connection master;
-drop table t1;
-sync_slave_with_master;
-
-#
-# Bug#14553: NULL in WHERE resets LAST_INSERT_ID
-#
-connection master;
-create table t1(a int auto_increment, key(a));
-create table t2(a int);
-insert into t1 (a) values (null);
-insert into t2 (a) select a from t1 where a is null;
-insert into t2 (a) select a from t1 where a is null;
-select * from t2;
-sync_slave_with_master;
-connection slave;
-select * from t2;
-connection master;
-drop table t1;
-drop table t2;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 197d89d02d5..27c5a327ac8 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2286,25 +2286,6 @@ EXPLAIN SELECT * FROM t1 FORCE INDEX (a);
DROP TABLE t1;
#
-# Bug #18759 "Incorrect string to numeric conversion"
-#
-# This test is here so that the behavior will not be changed to 4.1
-# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string
-# will be converted internally to real (double) value and it is not
-# as accurate as bigint (longlong) for integers. Thus the results may
-# vary. In 5.1 internally it is decimal, which is a string type and
-# will be more accurate. Due to rather big changes needed to fix this
-# in 4.1 or 5.0 it is not desired to do it in the stable versions.
-#
-# This test is here only to make sure that behavior is not changed in
-# 4.1 and 5.0
-#
-CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
-INSERT INTO t1 VALUES (10);
-SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
-DROP TABLE t1;
-
-#
# Bug #21019: First result of SELECT COUNT(*) different than consecutive runs
#
CREATE TABLE t1 (a int, b int);
@@ -2319,6 +2300,7 @@ SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NUL
EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
DROP TABLE IF EXISTS t1,t2;
+
#
# Bug #20954 "avg(keyval) retuns 0.38 but max(keyval) returns an empty set"
#
@@ -2349,6 +2331,25 @@ select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
DROP TABLE t1,t2;
--enable_ps_protocol
+#
+# Bug #18759 "Incorrect string to numeric conversion"
+#
+# This test is here so that the behavior will not be changed to 4.1
+# and not to 5.0 either. In 4.1 and 5.0 sending an integer as a string
+# will be converted internally to real (double) value and it is not
+# as accurate as bigint (longlong) for integers. Thus the results may
+# vary. In 5.1 internally it is decimal, which is a string type and
+# will be more accurate. Due to rather big changes needed to fix this
+# in 4.1 or 5.0 it is not desired to do it in the stable versions.
+#
+# This test is here only to make sure that behavior is not changed in
+# 4.1 and 5.0
+#
+CREATE TABLE t1 (i BIGINT UNSIGNED NOT NULL);
+INSERT INTO t1 VALUES (10);
+SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
+DROP TABLE t1;
+
# End of 4.1 tests
#
diff --git a/sql/field.cc b/sql/field.cc
index fc08ce7eb60..4a9487ff7a9 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4587,19 +4587,12 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg,
Field_timestamp::Field_timestamp(bool maybe_null_arg,
const char *field_name_arg,
- struct st_table *table_arg, CHARSET_INFO *cs)
+ CHARSET_INFO *cs)
:Field_str((char*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0,
- NONE, field_name_arg, table_arg, cs)
+ NONE, field_name_arg, cs)
{
/* For 4.0 MYD and 4.0 InnoDB compatibility */
flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
- if (table && !table->timestamp_field &&
- unireg_check != NONE)
- {
- /* This timestamp has auto-update */
- table->timestamp_field= this;
- flags|=TIMESTAMP_FLAG;
- }
}
diff --git a/sql/field.h b/sql/field.h
index b38c81971e3..3fba0ffbb00 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -793,10 +793,9 @@ public:
Field_timestamp(char *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
- struct st_table *table_arg,
TABLE_SHARE *share, CHARSET_INFO *cs);
Field_timestamp(bool maybe_null_arg, const char *field_name_arg,
- struct st_table *table_arg, CHARSET_INFO *cs);
+ CHARSET_INFO *cs);
enum_field_types type() const { return FIELD_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
enum Item_result cmp_type () const { return INT_RESULT; }
@@ -1148,9 +1147,9 @@ public:
flags|= BLOB_FLAG;
}
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
- struct st_table *table_arg, CHARSET_INFO *cs, bool set_packlength)
+ CHARSET_INFO *cs, bool set_packlength)
:Field_longstr((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
- NONE, field_name_arg, table_arg, cs)
+ NONE, field_name_arg, cs)
{
flags|= BLOB_FLAG;
packlength= 4;
diff --git a/sql/item.cc b/sql/item.cc
index e38142fdb0d..1afe25b1990 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -4037,7 +4037,8 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
field= new Field_time(maybe_null, name, &my_charset_bin);
break;
case MYSQL_TYPE_TIMESTAMP:
- return new Field_timestamp(maybe_null, name, table, &my_charset_bin);
+ field= new Field_timestamp(maybe_null, name, &my_charset_bin);
+ break;
case MYSQL_TYPE_DATETIME:
field= new Field_datetime(maybe_null, name, &my_charset_bin);
break;
@@ -4072,10 +4073,10 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_GEOMETRY:
if (this->type() == Item::TYPE_HOLDER)
- field= new Field_blob(max_length, maybe_null, name, table,
- collation.collation, 1);
+ field= new Field_blob(max_length, maybe_null, name, collation.collation,
+ 1);
else
- field= new Field_blob(max_length, maybe_null, name, table, collation.collation);
+ field= new Field_blob(max_length, maybe_null, name, collation.collation);
break; // Blob handled outside of case
}
if (field)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index e0ad74887f8..7b2fcefe16c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -639,6 +639,7 @@ void THD::cleanup_after_query()
first_successful_insert_id_in_prev_stmt=
first_successful_insert_id_in_cur_stmt;
first_successful_insert_id_in_cur_stmt= 0;
+ substitute_null_with_insert_id= TRUE;
}
arg_of_last_insert_id_function= 0;
/* Free Items that were created during this execution */
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 966fe45e690..fae79ba58c5 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -730,7 +730,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
uint used_fields_buff_size= bitmap_buffer_size(table->s->fields);
uint32 *used_fields_buff= (uint32*)thd->alloc(used_fields_buff_size);
MY_BITMAP used_fields;
- bool save_set_query_id= thd->set_query_id;
+ enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
DBUG_ENTER("check_key_in_view");
if (!used_fields_buff)
@@ -746,20 +746,20 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
we must not set query_id for fields as they're not
really used in this context
*/
- thd->set_query_id= 0;
+ thd->mark_used_columns= MARK_COLUMNS_NONE;
/* check simplicity and prepare unique test of view */
for (trans= trans_start; trans != trans_end; trans++)
{
if (!trans->item->fixed && trans->item->fix_fields(thd, &trans->item))
{
- thd->set_query_id= save_set_query_id;
+ thd->mark_used_columns= save_mark_used_columns;
DBUG_RETURN(TRUE);
}
Item_field *field;
/* simple SELECT list entry (field without expression) */
if (!(field= trans->item->filed_for_view_update()))
{
- thd->set_query_id= save_set_query_id;
+ thd->mark_used_columns= save_mark_used_columns;
DBUG_RETURN(TRUE);
}
if (field->field->unireg_check == Field::NEXT_NUMBER)
@@ -771,7 +771,7 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
*/
trans->item= field;
}
- thd->set_query_id= save_set_query_id;
+ thd->mark_used_columns= save_mark_used_columns;
/* unique test */
for (trans= trans_start; trans != trans_end; trans++)
{
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 2e86b1e4d24..25887d4f344 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1095,7 +1095,7 @@ JOIN::optimize()
for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
{
Item *item= *tmp_order->item;
- if (item->walk(&Item::is_expensive_processor,(byte*)0))
+ if (item->walk(&Item::is_expensive_processor, 0, (byte*)0))
{
/* Force tmp table without sort */
need_tmp=1; simple_order=simple_group=0;
@@ -7963,7 +7963,8 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
Field *field=((Item_field*) args[0])->field;
if (field->flags & AUTO_INCREMENT_FLAG && !field->table->maybe_null &&
(thd->options & OPTION_AUTO_IS_NULL) &&
- (thd->first_successful_insert_id_in_prev_stmt > 0))
+ (thd->first_successful_insert_id_in_prev_stmt > 0 &&
+ thd->substitute_null_with_insert_id))
{
#ifdef HAVE_QUERY_CACHE
query_cache_abort(&thd->net);
@@ -7986,7 +7987,7 @@ remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value)
IS NULL should be mapped to LAST_INSERT_ID only for first row, so
clear for next row
*/
- thd->first_successful_insert_id_in_prev_stmt= 0;
+ thd->substitute_null_with_insert_id= FALSE;
}
/* fix to replace 'NULL' dates with '0' (shreeve@uci.edu) */
else if (((field->type() == FIELD_TYPE_DATE) ||