Below is the list of changes that have just been committed into a local
5.0 repository of gluh. When gluh 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, 2007-01-23 12:34:59+04:00, gluh@stripped +19 -0
Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into mysql.com:/home/gluh/MySQL/Merge/5.0-opt
MERGE: 1.2341.4.47
mysql-test/r/func_in.result@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.29.1.1
mysql-test/r/range.result@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.51.1.1
mysql-test/r/select.result@stripped, 2007-01-23 12:34:58+04:00, gluh@stripped +6 -6
manual merge
MERGE: 1.143.2.1
mysql-test/r/sp-code.result@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.7.1.1
mysql-test/r/view.result@stripped, 2007-01-23 12:34:58+04:00, gluh@stripped +17 -17
manual merge
MERGE: 1.184.1.2
mysql-test/t/func_in.test@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.23.1.1
mysql-test/t/range.test@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.43.1.1
mysql-test/t/select.test@stripped, 2007-01-23 12:34:58+04:00, gluh@stripped +10 -11
manual merge
MERGE: 1.117.2.1
mysql-test/t/trigger.test@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.57.1.1
mysql-test/t/view.test@stripped, 2007-01-23 12:29:45+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.170.1.1
sql/item.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.248.1.1
sql/item_func.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.321.1.1
sql/mysql_priv.h@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.425.1.4
sql/sql_insert.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.211.1.1
sql/sql_lex.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.206.2.5
sql/sql_lex.h@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.235.1.1
sql/sql_prepare.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.189.1.1
sql/sql_select.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.478.1.1
sql/sql_table.cc@stripped, 2007-01-23 12:29:46+04:00, gluh@stripped +0 -0
Auto merged
MERGE: 1.329.1.1
# 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: gluh
# Host: eagle.(none)
# Root: /home/gluh/MySQL/Merge/5.0-opt/RESYNC
--- 1.249/sql/item.cc 2007-01-12 00:17:37 +04:00
+++ 1.250/sql/item.cc 2007-01-23 12:29:46 +04:00
@@ -4572,18 +4572,31 @@ my_decimal *Item_hex_string::val_decimal
int Item_hex_string::save_in_field(Field *field, bool no_conversions)
{
- int error;
field->set_notnull();
if (field->result_type() == STRING_RESULT)
+ return field->store(str_value.ptr(), str_value.length(),
+ collation.collation);
+
+ ulonglong nr;
+ uint32 length= str_value.length();
+ if (length > 8)
{
- error=field->store(str_value.ptr(),str_value.length(),collation.collation);
+ nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX;
+ goto warn;
}
- else
+ nr= (ulonglong) val_int();
+ if ((length == 8) && !(field->flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX))
{
- longlong nr=val_int();
- error=field->store(nr, TRUE); // Assume hex numbers are unsigned
+ nr= LONGLONG_MAX;
+ goto warn;
}
- return error;
+ return field->store((longlong) nr, TRUE); // Assume hex numbers are unsigned
+
+warn:
+ if (!field->store((longlong) nr, TRUE))
+ field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
+ 1);
+ return 1;
}
--- 1.322/sql/item_func.cc 2007-01-12 22:59:11 +04:00
+++ 1.323/sql/item_func.cc 2007-01-23 12:29:46 +04:00
@@ -2729,25 +2729,28 @@ udf_handler::fix_fields(THD *thd, Item_r
if (arguments[i]->const_item())
{
- if (arguments[i]->null_value)
- continue;
-
switch (arguments[i]->result_type())
{
case STRING_RESULT:
case DECIMAL_RESULT:
{
String *res= arguments[i]->val_str(&buffers[i]);
+ if (arguments[i]->null_value)
+ continue;
f_args.args[i]= (char*) res->ptr();
break;
}
case INT_RESULT:
*((longlong*) to)= arguments[i]->val_int();
+ if (arguments[i]->null_value)
+ continue;
f_args.args[i]= to;
to+= ALIGN_SIZE(sizeof(longlong));
break;
case REAL_RESULT:
*((double*) to)= arguments[i]->val_real();
+ if (arguments[i]->null_value)
+ continue;
f_args.args[i]= to;
to+= ALIGN_SIZE(sizeof(double));
break;
--- 1.429/sql/mysql_priv.h 2007-01-17 22:43:41 +04:00
+++ 1.430/sql/mysql_priv.h 2007-01-23 12:29:46 +04:00
@@ -414,7 +414,11 @@ MY_LOCALE *my_locale_by_number(uint numb
#define UNCACHEABLE_EXPLAIN 8
/* Don't evaluate subqueries in prepare even if they're not correlated */
#define UNCACHEABLE_PREPARE 16
+/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
+#define UNCACHEABLE_UNITED 32
+/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
+#define UNDEF_POS (-1)
#ifdef EXTRA_DEBUG
/*
Sync points allow us to force the server to reach a certain line of code
--- 1.213/sql/sql_insert.cc 2007-01-15 14:11:58 +04:00
+++ 1.214/sql/sql_insert.cc 2007-01-23 12:29:46 +04:00
@@ -80,6 +80,65 @@ static bool check_view_insertability(THD
#define my_safe_afree(ptr, size, min_length) if (size > min_length) my_free(ptr,MYF(0))
#endif
+/*
+ Check that insert/update fields are from the same single table of a view.
+
+ SYNOPSIS
+ check_view_single_update()
+ fields The insert/update fields to be checked.
+ view The view for insert.
+ map [in/out] The insert table map.
+
+ DESCRIPTION
+ This function is called in 2 cases:
+ 1. to check insert fields. In this case *map will be set to 0.
+ Insert fields are checked to be all from the same single underlying
+ table of the given view. Otherwise the error is thrown. Found table
+ map is returned in the map parameter.
+ 2. to check update fields of the ON DUPLICATE KEY UPDATE clause.
+ In this case *map contains table_map found on the previous call of
+ the function to check insert fields. Update fields are checked to be
+ from the same table as the insert fields.
+
+ RETURN
+ 0 OK
+ 1 Error
+*/
+
+bool check_view_single_update(List<Item> &fields, TABLE_LIST *view,
+ table_map *map)
+{
+ /* it is join view => we need to find the table for update */
+ List_iterator_fast<Item> it(fields);
+ Item *item;
+ TABLE_LIST *tbl= 0; // reset for call to check_single_table()
+ table_map tables= 0;
+
+ while ((item= it++))
+ tables|= item->used_tables();
+
+ /* Check found map against provided map */
+ if (*map)
+ {
+ if (tables != *map)
+ goto error;
+ return FALSE;
+ }
+
+ if (view->check_single_table(&tbl, tables, view) || tbl == 0)
+ goto error;
+
+ view->table= tbl->table;
+ *map= tables;
+
+ return FALSE;
+
+error:
+ my_error(ER_VIEW_MULTIUPDATE, MYF(0),
+ view->view_db.str, view->view_name.str);
+ return TRUE;
+}
+
/*
Check if insert fields are correct.
@@ -104,7 +163,7 @@ static bool check_view_insertability(THD
static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
List<Item> &fields, List<Item> &values,
- bool check_unique)
+ bool check_unique, table_map *map)
{
TABLE *table= table_list->table;
@@ -177,21 +236,9 @@ static int check_insert_fields(THD *thd,
if (table_list->effective_algorithm == VIEW_ALGORITHM_MERGE)
{
- /* it is join view => we need to find table for update */
- List_iterator_fast<Item> it(fields);
- Item *item;
- TABLE_LIST *tbl= 0; // reset for call to check_single_table()
- table_map map= 0;
-
- while ((item= it++))
- map|= item->used_tables();
- if (table_list->check_single_table(&tbl, map, table_list) || tbl == 0)
- {
- my_error(ER_VIEW_MULTIUPDATE, MYF(0),
- table_list->view_db.str, table_list->view_name.str);
+ if (check_view_single_update(fields, table_list, map))
return -1;
- }
- table_list->table= table= tbl->table;
+ table= table_list->table;
}
if (check_unique && thd->dupp_field)
@@ -241,7 +288,7 @@ static int check_insert_fields(THD *thd,
*/
static int check_update_fields(THD *thd, TABLE_LIST *insert_table_list,
- List<Item> &update_fields)
+ List<Item> &update_fields, table_map *map)
{
TABLE *table= insert_table_list->table;
query_id_t timestamp_query_id;
@@ -264,6 +311,10 @@ static int check_update_fields(THD *thd,
if (setup_fields(thd, 0, update_fields, 1, 0, 0))
return -1;
+ if (insert_table_list->effective_algorithm == VIEW_ALGORITHM_MERGE &&
+ check_view_single_update(update_fields, insert_table_list, map))
+ return -1;
+
if (table->timestamp_field)
{
/* Don't set timestamp column if this is modified. */
@@ -910,6 +961,7 @@ bool mysql_prepare_insert(THD *thd, TABL
Name_resolution_context_state ctx_state;
bool insert_into_view= (table_list->view != 0);
bool res= 0;
+ table_map map= 0;
DBUG_ENTER("mysql_prepare_insert");
DBUG_PRINT("enter", ("table_list 0x%lx, table 0x%lx, view %d",
(ulong)table_list, (ulong)table,
@@ -959,12 +1011,12 @@ bool mysql_prepare_insert(THD *thd, TABL
/* Prepare the fields in the statement. */
if (values &&
!(res= check_insert_fields(thd, context->table_list, fields, *values,
- !insert_into_view) ||
+ !insert_into_view, &map) ||
setup_fields(thd, 0, *values, 0, 0, 0)) &&
duplic == DUP_UPDATE)
{
select_lex->no_wrap_view_item= TRUE;
- res= check_update_fields(thd, context->table_list, update_fields);
+ res= check_update_fields(thd, context->table_list, update_fields, &map);
select_lex->no_wrap_view_item= FALSE;
/*
When we are not using GROUP BY we can refer to other tables in the
@@ -2286,6 +2338,7 @@ select_insert::prepare(List<Item> &value
{
LEX *lex= thd->lex;
int res;
+ table_map map= 0;
SELECT_LEX *lex_current_select_save= lex->current_select;
DBUG_ENTER("select_insert::prepare");
@@ -2297,7 +2350,7 @@ select_insert::prepare(List<Item> &value
*/
lex->current_select= &lex->select_lex;
res= check_insert_fields(thd, table_list, *fields, values,
- !insert_into_view) ||
+ !insert_into_view, &map) ||
setup_fields(thd, 0, values, 0, 0, 0);
if (info.handle_duplicates == DUP_UPDATE)
@@ -2315,7 +2368,7 @@ select_insert::prepare(List<Item> &value
lex->select_lex.no_wrap_view_item= TRUE;
res= res || check_update_fields(thd, context->table_list,
- *info.update_fields);
+ *info.update_fields, &map);
lex->select_lex.no_wrap_view_item= FALSE;
/*
When we are not using GROUP BY we can refer to other tables in the
--- 1.209/sql/sql_lex.cc 2007-01-15 14:06:10 +04:00
+++ 1.210/sql/sql_lex.cc 2007-01-23 12:29:46 +04:00
@@ -1190,6 +1190,8 @@ void st_select_lex::init_select()
offset_limit= 0; /* denotes the default offset = 0 */
with_sum_func= 0;
is_correlated= 0;
+ cur_pos_in_select_list= UNDEF_POS;
+ non_agg_fields.empty();
}
/*
@@ -1379,9 +1381,17 @@ void st_select_lex::mark_as_dependent(SE
if (!(s->uncacheable & UNCACHEABLE_DEPENDENT))
{
// Select is dependent of outer select
- s->uncacheable|= UNCACHEABLE_DEPENDENT;
+ s->uncacheable= (s->uncacheable & ~UNCACHEABLE_UNITED) |
+ UNCACHEABLE_DEPENDENT;
SELECT_LEX_UNIT *munit= s->master_unit();
- munit->uncacheable|= UNCACHEABLE_DEPENDENT;
+ munit->uncacheable= (munit->uncacheable & ~UNCACHEABLE_UNITED) |
+ UNCACHEABLE_DEPENDENT;
+ for (SELECT_LEX *sl= munit->first_select(); sl ; sl= sl->next_select())
+ {
+ if (sl != s &&
+ !(sl->uncacheable & (UNCACHEABLE_DEPENDENT | UNCACHEABLE_UNITED)))
+ sl->uncacheable|= UNCACHEABLE_UNITED;
+ }
}
is_correlated= TRUE;
this->master_unit()->item->is_correlated= TRUE;
--- 1.237/sql/sql_lex.h 2007-01-15 14:06:10 +04:00
+++ 1.238/sql/sql_lex.h 2007-01-23 12:29:46 +04:00
@@ -580,6 +580,10 @@ public:
bool no_wrap_view_item;
/* exclude this select from check of unique_table() */
bool exclude_from_table_unique_test;
+ /* List of fields that aren't under an aggregate function */
+ List<Item_field> non_agg_fields;
+ /* index in the select list of the expression currently being fixed */
+ int cur_pos_in_select_list;
List<udf_func> udf_list; /* udf function calls stack */
--- 1.482/sql/sql_select.cc 2007-01-23 00:04:03 +04:00
+++ 1.483/sql/sql_select.cc 2007-01-23 12:29:46 +04:00
@@ -10433,6 +10433,7 @@ evaluate_join_record(JOIN *join, JOIN_TA
*/
join->examined_rows++;
join->thd->row_count++;
+ join_tab->read_record.file->unlock_row();
}
return NESTED_LOOP_OK;
}
--- 1.331/sql/sql_table.cc 2007-01-15 14:12:29 +04:00
+++ 1.332/sql/sql_table.cc 2007-01-23 12:29:46 +04:00
@@ -3910,7 +3910,7 @@ copy_data_between_tables(TABLE *from,TAB
Copy_field *copy,*copy_end;
ulong found_count,delete_count;
THD *thd= current_thd;
- uint length;
+ uint length= 0;
SORT_FIELD *sortorder;
READ_RECORD info;
TABLE_LIST tables;
--- 1.186/mysql-test/r/view.result 2007-01-11 22:52:55 +04:00
+++ 1.187/mysql-test/r/view.result 2007-01-23 12:34:58 +04:00
@@ -834,14 +834,14 @@ show create view v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1`
drop view v1;
+create table tü (cü char);
+create view vü as select cü from tü;
+insert into vü values ('ü');
+select * from vü;
+cü
+ü
+drop view vü;
+drop table tü;
create table t1 (a int, b int);
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
create view v1(c) as select a+1 from t1 where b >= 4;
@@ -3023,4 +3023,15 @@ SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
DROP VIEW v1;
+CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
+SHOW CREATE VIEW v;
+View Create View
+v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((not(0)) * 5) AS `x`
+SELECT !0 * 5 AS x FROM DUAL;
+x
+5
+SELECT * FROM v;
+x
+5
+DROP VIEW v;
End of 5.0 tests.
--- 1.171/mysql-test/t/view.test 2006-12-19 16:32:01 +04:00
+++ 1.172/mysql-test/t/view.test 2007-01-23 12:29:45 +04:00
@@ -2959,6 +2959,17 @@ SELECT * FROM t1;
DROP VIEW v1, v2;
DROP TABLE t1;
+#
+# Bug #25580: !0 as an operand in a select expression of a view
+#
+
+CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
+SHOW CREATE VIEW v;
+
+SELECT !0 * 5 AS x FROM DUAL;
+SELECT * FROM v;
+
+DROP VIEW v;
#
# BUG#24293: '\Z' token is not handled correctly in views
--- 1.58/mysql-test/t/trigger.test 2007-01-11 18:43:42 +04:00
+++ 1.59/mysql-test/t/trigger.test 2007-01-23 12:29:45 +04:00
@@ -1554,4 +1554,50 @@ select * from t1;
drop table t1;
+#
+# Bug#25398: crash when a trigger contains a SELECT with
+# trigger fields in the select list under DISTINCT
+#
+
+CREATE TABLE t1 (
+ id int NOT NULL DEFAULT '0',
+ a varchar(10) NOT NULL,
+ b varchar(10),
+ c varchar(10),
+ d timestamp NOT NULL,
+ PRIMARY KEY (id, a)
+);
+
+CREATE TABLE t2 (
+ fubar_id int unsigned NOT NULL DEFAULT '0',
+ last_change_time datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (fubar_id)
+);
+
+DELIMITER |;
+
+CREATE TRIGGER fubar_change
+ AFTER UPDATE ON t1
+ FOR EACH ROW
+ BEGIN
+ INSERT INTO t2 (fubar_id, last_change_time)
+ SELECT DISTINCT NEW.id AS fubar_id, NOW() AS last_change_time
+ FROM t1 WHERE (id = NEW.id) AND (OLD.c != NEW.c)
+ ON DUPLICATE KEY UPDATE
+ last_change_time =
+ IF((fubar_id = NEW.id)AND(OLD.c != NEW.c),NOW(),last_change_time);
+ END
+|
+
+DELIMITER ;|
+
+INSERT INTO t1 (id,a, b,c,d) VALUES
+ (1,'a','b','c',now()),(2,'a','b','c',now());
+
+UPDATE t1 SET c='Bang!' WHERE id=1;
+
+SELECT fubar_id FROM t2;
+
+DROP TABLE t1,t2;
+
--echo End of 5.0 tests
--- 1.30/mysql-test/r/func_in.result 2006-12-08 23:37:59 +04:00
+++ 1.31/mysql-test/r/func_in.result 2007-01-23 12:29:45 +04:00
@@ -355,4 +355,47 @@ some_id
1
2
drop table t1;
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1);
+CREATE TABLE t2 (a int, b int, PRIMARY KEY (a));
+INSERT INTO t2 VALUES (3,2),(4,2);
+CREATE TABLE t3 (a int PRIMARY KEY);
+INSERT INTO t3 VALUES (1),(2),(3),(4);
+CREATE TABLE t4 (a int PRIMARY KEY);
+INSERT INTO t4 VALUES (1),(2);
+EXPLAIN SELECT STRAIGHT_JOIN * FROM t3
+JOIN t1 ON t3.a=t1.a
+JOIN t2 ON t3.a=t2.a
+JOIN t4 WHERE t4.a IN (t1.b, t2.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index PRIMARY PRIMARY 4 NULL 4 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
+1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 2 Range checked for each record (index map: 0x1)
+SELECT STRAIGHT_JOIN * FROM t3
+JOIN t1 ON t3.a=t1.a
+JOIN t2 ON t3.a=t2.a
+JOIN t4 WHERE t4.a IN (t1.b, t2.b);
+a a b a b a
+3 3 1 3 2 1
+3 3 1 3 2 2
+4 4 1 4 2 1
+4 4 1 4 2 2
+EXPLAIN SELECT STRAIGHT_JOIN
+(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
+FROM t3, t1, t2
+WHERE t3.a=t1.a AND t3.a=t2.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 index PRIMARY PRIMARY 4 NULL 4 Using index
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
+1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t3.a 1
+2 DEPENDENT SUBQUERY t4 index NULL PRIMARY 4 NULL 2 Using where; Using index
+SELECT STRAIGHT_JOIN
+(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
+FROM t3, t1, t2
+WHERE t3.a=t1.a AND t3.a=t2.a;
+(SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
+3
+3
+DROP TABLE t1,t2,t3,t4;
End of 5.0 tests
--- 1.53/mysql-test/r/range.result 2007-01-16 02:01:35 +04:00
+++ 1.54/mysql-test/r/range.result 2007-01-23 12:29:45 +04:00
@@ -521,8 +521,8 @@ select count(*) from t1 where x = 184467
count(*)
1
create table t2 (x bigint not null);
-insert into t2(x) values (cast(0xfffffffffffffff0+0 as signed));
-insert into t2(x) values (cast(0xfffffffffffffff1+0 as signed));
+insert into t2(x) values (-16);
+insert into t2(x) values (-15);
select * from t2;
x
-16
--- 1.145/mysql-test/r/select.result 2007-01-19 08:55:52 +04:00
+++ 1.146/mysql-test/r/select.result 2007-01-23 12:34:58 +04:00
@@ -3634,3 +3634,11 @@ INSERT into t1 values (1), (2), (3);
SELECT * FROM t1 LIMIT 2, -1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1
DROP TABLE t1;
+CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);
+CREATE TABLE t2 ( f11 int PRIMARY KEY );
+INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0);
+INSERT INTO t2 VALUES (62);
+SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1;
+f1 f2 f3 f4 f5 f6 checked_out f11
+1 1 1 0 0 0 0 NULL
+DROP TABLE t1, t2;
--- 1.24/mysql-test/t/func_in.test 2006-12-08 23:37:59 +04:00
+++ 1.25/mysql-test/t/func_in.test 2007-01-23 12:29:45 +04:00
@@ -261,5 +261,41 @@ select some_id from t1 where some_id not
drop table t1;
+#
+# BUG#20420: optimizer reports wrong keys on left join with IN
+#
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1);
+
+CREATE TABLE t2 (a int, b int, PRIMARY KEY (a));
+INSERT INTO t2 VALUES (3,2),(4,2);
+
+CREATE TABLE t3 (a int PRIMARY KEY);
+INSERT INTO t3 VALUES (1),(2),(3),(4);
+
+CREATE TABLE t4 (a int PRIMARY KEY);
+INSERT INTO t4 VALUES (1),(2);
+
+EXPLAIN SELECT STRAIGHT_JOIN * FROM t3
+ JOIN t1 ON t3.a=t1.a
+ JOIN t2 ON t3.a=t2.a
+ JOIN t4 WHERE t4.a IN (t1.b, t2.b);
+
+SELECT STRAIGHT_JOIN * FROM t3
+ JOIN t1 ON t3.a=t1.a
+ JOIN t2 ON t3.a=t2.a
+ JOIN t4 WHERE t4.a IN (t1.b, t2.b);
+
+EXPLAIN SELECT STRAIGHT_JOIN
+ (SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
+ FROM t3, t1, t2
+ WHERE t3.a=t1.a AND t3.a=t2.a;
+
+SELECT STRAIGHT_JOIN
+ (SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b))
+ FROM t3, t1, t2
+ WHERE t3.a=t1.a AND t3.a=t2.a;
+
+DROP TABLE t1,t2,t3,t4;
--echo End of 5.0 tests
--- 1.44/mysql-test/t/range.test 2007-01-15 22:09:55 +04:00
+++ 1.45/mysql-test/t/range.test 2007-01-23 12:29:45 +04:00
@@ -406,8 +406,8 @@ select count(*) from t1 where x = 184467
create table t2 (x bigint not null);
-insert into t2(x) values (cast(0xfffffffffffffff0+0 as signed));
-insert into t2(x) values (cast(0xfffffffffffffff1+0 as signed));
+insert into t2(x) values (-16);
+insert into t2(x) values (-15);
select * from t2;
select count(*) from t2 where x>0;
select count(*) from t2 where x=0;
--- 1.119/mysql-test/t/select.test 2007-01-19 08:55:52 +04:00
+++ 1.120/mysql-test/t/select.test 2007-01-23 12:34:58 +04:00
@@ -3122,4 +3122,14 @@ INSERT into t1 values (1), (2), (3);
SELECT * FROM t1 LIMIT 2, -1;
DROP TABLE t1;
+
+#
+# Bug#25172: Not checked buffer size leads to a server crash
+#
+CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int);
+CREATE TABLE t2 ( f11 int PRIMARY KEY );
+INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0);
+INSERT INTO t2 VALUES (62);
+SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1;
+DROP TABLE t1, t2;
--- 1.8/mysql-test/r/sp-code.result 2006-11-17 23:14:27 +04:00
+++ 1.9/mysql-test/r/sp-code.result 2007-01-23 12:29:45 +04:00
@@ -187,7 +187,7 @@ Pos Instruction
32 set v_dig@4 (v_dig@4 + 1)
33 stmt 4 "update sudoku_work set dig = v_dig wh..."
34 set v_tcounter@6 (v_tcounter@6 + 1)
-35 jump_if_not 37(37) not(`test`.`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4))
+35 jump_if_not 37(37) (not(`test`.`sudoku_digit_ok`(v_row@7,v_col@8,v_dig@4)))
36 jump 15
37 set v_i@3 (v_i@3 + 1)
38 jump 15
--- 1.190/sql/sql_prepare.cc 2007-01-11 22:52:56 +04:00
+++ 1.191/sql/sql_prepare.cc 2007-01-23 12:29:46 +04:00
@@ -1676,7 +1676,7 @@ static bool check_prepared_statement(Pre
case SQLCOM_INSERT:
res= mysql_test_insert(stmt, tables, lex->field_list,
lex->many_values,
- select_lex->item_list, lex->value_list,
+ lex->update_list, lex->value_list,
lex->duplicates);
break;
| Thread |
|---|
| • bk commit into 5.0 tree (gluh:1.2383) | gluh | 23 Jan |