Commit 358567df authored by mhansson@dl145s.mysql.com's avatar mhansson@dl145s.mysql.com

Merge bk-internal:/home/bk/mysql-5.1-opt

into  dl145s.mysql.com:/dev/shm/mhansson/my51-bug27741-mpush
parents aa1abcf9 b642eb12
...@@ -1103,3 +1103,17 @@ Field Type Null Key Default Extra ...@@ -1103,3 +1103,17 @@ Field Type Null Key Default Extra
unsigned_int_field bigint(20) unsigned NO MUL unsigned_int_field bigint(20) unsigned NO MUL
char_field char(10) YES NULL char_field char(10) YES NULL
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
INSERT INTO t1 VALUES (1, 2, NULL);
SELECT * FROM t1;
f1 f2 f3
1 2 NULL
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1;
SELECT * FROM t1;
f1 f3 f2
1 NULL 2
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2;
SELECT * FROM t1;
f1 f2 f3
1 2 NULL
DROP TABLE t1;
...@@ -317,10 +317,39 @@ SHOW COUNT(*) WARNINGS; ...@@ -317,10 +317,39 @@ SHOW COUNT(*) WARNINGS;
SHOW COUNT(*) ERRORS; SHOW COUNT(*) ERRORS;
@@session.error_count @@session.error_count
1 1
create table t1(f1 int); create table t1(f1 int, f2 varchar(2), f3 float, f4 decimal(2,1));
insert into t1 values(1),(1),(2); insert into t1 values
select @a:=f1, count(f1) from t1 group by 1 order by 1; (1, "a", 1.5, 1.6), (1, "a", 1.5, 1.6), (2, "b", 2.5, 2.6),
(3, "c", 3.5, 3.6), (4, "d", 4.5, 4.6), (1, "a", 1.5, 1.6),
(3, "c", 3.5, 3.6), (1, "a", 1.5, 1.6);
select @a:=f1, count(f1) from t1 group by 1 desc;
@a:=f1 count(f1) @a:=f1 count(f1)
1 2 4 1
3 2
2 1 2 1
1 4
select @a:=f1, count(f1) from t1 group by 1 asc;
@a:=f1 count(f1)
1 4
2 1
3 2
4 1
select @a:=f2, count(f2) from t1 group by 1 desc;
@a:=f2 count(f2)
d 1
c 2
b 1
a 4
select @a:=f3, count(f3) from t1 group by 1 desc;
@a:=f3 count(f3)
4.5 1
3.5 2
2.5 1
1.5 4
select @a:=f4, count(f4) from t1 group by 1 desc;
@a:=f4 count(f4)
4.6 1
3.6 2
2.6 1
1.6 4
drop table t1; drop table t1;
...@@ -839,3 +839,15 @@ ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL; ...@@ -839,3 +839,15 @@ ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
DESCRIBE t2; DESCRIBE t2;
DROP TABLE t2; DROP TABLE t2;
#
# Bug#28427: Columns were renamed instead of moving by ALTER TABLE.
#
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
INSERT INTO t1 VALUES (1, 2, NULL);
SELECT * FROM t1;
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1;
SELECT * FROM t1;
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2;
SELECT * FROM t1;
DROP TABLE t1;
...@@ -226,7 +226,14 @@ SHOW COUNT(*) ERRORS; ...@@ -226,7 +226,14 @@ SHOW COUNT(*) ERRORS;
# #
# Bug#28494: Grouping by Item_func_set_user_var produces incorrect result. # Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
# #
create table t1(f1 int); create table t1(f1 int, f2 varchar(2), f3 float, f4 decimal(2,1));
insert into t1 values(1),(1),(2); insert into t1 values
select @a:=f1, count(f1) from t1 group by 1 order by 1; (1, "a", 1.5, 1.6), (1, "a", 1.5, 1.6), (2, "b", 2.5, 2.6),
(3, "c", 3.5, 3.6), (4, "d", 4.5, 4.6), (1, "a", 1.5, 1.6),
(3, "c", 3.5, 3.6), (1, "a", 1.5, 1.6);
select @a:=f1, count(f1) from t1 group by 1 desc;
select @a:=f1, count(f1) from t1 group by 1 asc;
select @a:=f2, count(f2) from t1 group by 1 desc;
select @a:=f3, count(f3) from t1 group by 1 desc;
select @a:=f4, count(f4) from t1 group by 1 desc;
drop table t1; drop table t1;
...@@ -3799,6 +3799,23 @@ Item_func_set_user_var::fix_length_and_dec() ...@@ -3799,6 +3799,23 @@ Item_func_set_user_var::fix_length_and_dec()
} }
/*
Mark field in read_map
NOTES
This is used by filesort to register used fields in a a temporary
column read set or to register used fields in a view
*/
bool Item_func_set_user_var::register_field_in_read_map(uchar *arg)
{
TABLE *table= (TABLE *) arg;
if (result_field->table == table || !table)
bitmap_set_bit(result_field->table->read_set, result_field->field_index);
return 0;
}
/* /*
Set value to user variable. Set value to user variable.
...@@ -4035,7 +4052,8 @@ bool ...@@ -4035,7 +4052,8 @@ bool
Item_func_set_user_var::check(bool use_result_field) Item_func_set_user_var::check(bool use_result_field)
{ {
DBUG_ENTER("Item_func_set_user_var::check"); DBUG_ENTER("Item_func_set_user_var::check");
DBUG_ASSERT(!use_result_field || result_field); if (use_result_field && !result_field)
use_result_field= FALSE;
switch (cached_result_type) { switch (cached_result_type) {
case REAL_RESULT: case REAL_RESULT:
...@@ -4179,6 +4197,40 @@ my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val) ...@@ -4179,6 +4197,40 @@ my_decimal *Item_func_set_user_var::val_decimal(my_decimal *val)
} }
double Item_func_set_user_var::val_result()
{
DBUG_ASSERT(fixed == 1);
check(TRUE);
update(); // Store expression
return entry->val_real(&null_value);
}
longlong Item_func_set_user_var::val_int_result()
{
DBUG_ASSERT(fixed == 1);
check(TRUE);
update(); // Store expression
return entry->val_int(&null_value);
}
String *Item_func_set_user_var::str_result(String *str)
{
DBUG_ASSERT(fixed == 1);
check(TRUE);
update(); // Store expression
return entry->val_str(&null_value, str, decimals);
}
my_decimal *Item_func_set_user_var::val_decimal_result(my_decimal *val)
{
DBUG_ASSERT(fixed == 1);
check(TRUE);
update(); // Store expression
return entry->val_decimal(&null_value, val);
}
void Item_func_set_user_var::print(String *str) void Item_func_set_user_var::print(String *str)
{ {
str->append(STRING_WITH_LEN("(@")); str->append(STRING_WITH_LEN("(@"));
......
...@@ -1236,6 +1236,10 @@ class Item_func_set_user_var :public Item_func ...@@ -1236,6 +1236,10 @@ class Item_func_set_user_var :public Item_func
longlong val_int(); longlong val_int();
String *val_str(String *str); String *val_str(String *str);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
double val_result();
longlong val_int_result();
String *str_result(String *str);
my_decimal *val_decimal_result(my_decimal *);
bool update_hash(void *ptr, uint length, enum Item_result type, bool update_hash(void *ptr, uint length, enum Item_result type,
CHARSET_INFO *cs, Derivation dv, bool unsigned_arg); CHARSET_INFO *cs, Derivation dv, bool unsigned_arg);
bool send(Protocol *protocol, String *str_arg); bool send(Protocol *protocol, String *str_arg);
...@@ -1255,6 +1259,7 @@ class Item_func_set_user_var :public Item_func ...@@ -1255,6 +1259,7 @@ class Item_func_set_user_var :public Item_func
return save_in_field(field, no_conversions, 1); return save_in_field(field, no_conversions, 1);
} }
void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); } void save_org_in_field(Field *field) { (void)save_in_field(field, 1, 0); }
bool register_field_in_read_map(uchar *arg);
}; };
......
...@@ -3805,6 +3805,11 @@ we force server id to 2, but this MySQL server will not act as a slave."); ...@@ -3805,6 +3805,11 @@ we force server id to 2, but this MySQL server will not act as a slave.");
freopen(log_error_file,"a+",stderr); freopen(log_error_file,"a+",stderr);
FreeConsole(); // Remove window FreeConsole(); // Remove window
} }
else
{
/* Don't show error dialog box when on foreground: it stops the server */
SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
}
#endif #endif
/* /*
......
...@@ -5932,6 +5932,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -5932,6 +5932,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
goto err; goto err;
} }
find_it.after(def); // Put element after this find_it.after(def); // Put element after this
need_copy_table= ALTER_TABLE_DATA_CHANGED;
} }
} }
if (alter_info->alter_list.elements) if (alter_info->alter_list.elements)
...@@ -6170,12 +6171,14 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -6170,12 +6171,14 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
(uint*) thd->alloc(sizeof(uint) * prepared_key_list.elements))) (uint*) thd->alloc(sizeof(uint) * prepared_key_list.elements)))
goto err; goto err;
/* Check how much the tables differ. */ /* Check how much the tables differ. */
need_copy_table= compare_tables(table, &prepared_create_list, uint res= compare_tables(table, &prepared_create_list,
key_info_buffer, key_count, key_info_buffer, key_count,
create_info, alter_info, order_num, create_info, alter_info, order_num,
index_drop_buffer, &index_drop_count, index_drop_buffer, &index_drop_count,
index_add_buffer, &index_add_count, index_add_buffer, &index_add_count,
varchar); varchar);
if (!need_copy_table)
need_copy_table= res;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment