Commit 6c2329c5 authored by unknown's avatar unknown

Merge gleb.loc:/home/uchum/work/bk/5.0

into  gleb.loc:/home/uchum/work/bk/5.0-opt
parents 54dc0c68 7fa2e683
...@@ -130,3 +130,21 @@ t ...@@ -130,3 +130,21 @@ t
2005-01-01 08:00:00 2005-01-01 08:00:00
drop table t1, t2; drop table t1, t2;
set global time_zone= @my_time_zone; set global time_zone= @my_time_zone;
End of 4.1 tests
CREATE TABLE t1 (a INT, b TIMESTAMP);
INSERT INTO t1 VALUES (1, NOW());
SET @@session.time_zone='Japan';
UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1;
Warnings:
Warning 1264 Out of range value adjusted for column 'b' at row 1
SELECT * FROM t1 ORDER BY a;
a b
1 0000-00-00 00:00:00
SET @@session.time_zone='Japan';
SELECT * FROM t1 ORDER BY a;
a b
1 0000-00-00 00:00:00
SET @@session.time_zone = default;
DROP TABLE t1;
SET @@session.time_zone = default;
End of 5.0 tests
...@@ -3995,4 +3995,14 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -3995,4 +3995,14 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index 1 SIMPLE f1 index inx inx 10 NULL 7 Using where; Using index
1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index 1 SIMPLE f2 ref inx inx 5 test.f1.b 1 Using where; Using index
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (c1 INT, c2 INT);
INSERT INTO t1 VALUES (1,11), (2,22), (2,22);
EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2)))))))))))))))))))))))))))))))) > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
31 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
32 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
EXPLAIN SELECT c1 FROM t1 WHERE (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT COUNT(c2))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) > 0;
ERROR HY000: Too high level of nesting for select
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
...@@ -618,4 +618,28 @@ bit_field int_field ...@@ -618,4 +618,28 @@ bit_field int_field
 2  2
handler t1 close; handler t1 close;
drop table t1; drop table t1;
CREATE TABLE t1 (b BIT(2), a VARCHAR(5));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
b+0 COUNT(DISTINCT a)
0 1
1 1
3 2
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
b+0 COUNT(DISTINCT a)
0 1
1 1
3 2
DROP TABLE t1;
CREATE TABLE t1 (a INT, b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
b+0 COUNT(DISTINCT a)
0 1
1 1
3 2
DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
...@@ -14,6 +14,22 @@ connection slave; ...@@ -14,6 +14,22 @@ connection slave;
reset slave; reset slave;
start slave io_thread; start slave io_thread;
# Give the I/O thread time to block. # Give the I/O thread time to block.
let $run= 1;
let $counter= 300;
while ($run)
{
let $io_state= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1);
if (`SELECT '$io_state' = 'Waiting for the slave SQL thread to free enough relay log space'`){
let $run= 0;
}
sleep 0.1;
if (!$counter){
--echo "Failed while waiting for slave IO thread block"
SHOW SLAVE STATUS;
exit;
}
dec $counter;
}
sleep 2; sleep 2;
# A bug caused the I/O thread to refuse stopping. # A bug caused the I/O thread to refuse stopping.
stop slave io_thread; stop slave io_thread;
......
...@@ -126,8 +126,33 @@ connection master; ...@@ -126,8 +126,33 @@ connection master;
drop table t1, t2; drop table t1, t2;
sync_slave_with_master; sync_slave_with_master;
# End of 4.1 tests
# Restore original timezone # Restore original timezone
connection master; connection master;
set global time_zone= @my_time_zone; set global time_zone= @my_time_zone;
--echo End of 4.1 tests
#
# Bug #29536: timestamp inconsistent in replication around 1970
#
connection master;
CREATE TABLE t1 (a INT, b TIMESTAMP);
INSERT INTO t1 VALUES (1, NOW());
SET @@session.time_zone='Japan';
UPDATE t1 SET b= '1970-01-01 08:59:59' WHERE a= 1;
SELECT * FROM t1 ORDER BY a;
sync_slave_with_master;
SET @@session.time_zone='Japan';
# must procdure the same result as the SELECT on the master
SELECT * FROM t1 ORDER BY a;
SET @@session.time_zone = default;
connection master;
DROP TABLE t1;
SET @@session.time_zone = default;
--echo End of 5.0 tests
...@@ -3370,4 +3370,34 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2 ...@@ -3370,4 +3370,34 @@ EXPLAIN SELECT COUNT(*) FROM t1 f1 INNER JOIN t1 f2
WHERE 1 AND f1.b NOT IN (100,2232,3343,51111); WHERE 1 AND f1.b NOT IN (100,2232,3343,51111);
DROP TABLE t1; DROP TABLE t1;
#
# Bug #27352: Incorrect result of nested selects instead of error reporting
#
CREATE TABLE t1 (c1 INT, c2 INT);
INSERT INTO t1 VALUES (1,11), (2,22), (2,22);
let $n= 31;
let $q= COUNT(c2);
while ($n)
{
let $q= (SELECT $q);
dec $n;
}
--disable_warnings
eval EXPLAIN SELECT c1 FROM t1 WHERE $q > 0;
--enable_warnings
let $n= 64;
let $q= COUNT(c2);
while ($n)
{
let $q= (SELECT $q);
dec $n;
}
--error ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
eval EXPLAIN SELECT c1 FROM t1 WHERE $q > 0;
DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -272,4 +272,23 @@ handler t1 read a=(1); ...@@ -272,4 +272,23 @@ handler t1 read a=(1);
handler t1 close; handler t1 close;
drop table t1; drop table t1;
#
# Bug #30219: GROUP BY a column of the BIT type
#
CREATE TABLE t1 (b BIT(2), a VARCHAR(5));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, "x"), (3, "zz"), (0, "y"), (3, "z");
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
DROP TABLE t1;
CREATE TABLE t1 (a INT, b BIT(2));
INSERT INTO t1 (b, a) VALUES (1, 1), (3, 2), (0, 3), (3, 4);
SELECT b+0, COUNT(DISTINCT a) FROM t1 GROUP BY b;
DROP TABLE t1;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -4462,6 +4462,7 @@ longlong Field_timestamp::val_int(void) ...@@ -4462,6 +4462,7 @@ longlong Field_timestamp::val_int(void)
MYSQL_TIME time_tmp; MYSQL_TIME time_tmp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
thd->time_zone_used= 1;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table && table->s->db_low_byte_first) if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr); temp=uint4korr(ptr);
...@@ -4473,7 +4474,6 @@ longlong Field_timestamp::val_int(void) ...@@ -4473,7 +4474,6 @@ longlong Field_timestamp::val_int(void)
return(0); /* purecov: inspected */ return(0); /* purecov: inspected */
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp); thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp, (my_time_t)temp);
thd->time_zone_used= 1;
return time_tmp.year * LL(10000000000) + time_tmp.month * LL(100000000) + return time_tmp.year * LL(10000000000) + time_tmp.month * LL(100000000) +
time_tmp.day * 1000000L + time_tmp.hour * 10000L + time_tmp.day * 1000000L + time_tmp.hour * 10000L +
...@@ -4492,6 +4492,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) ...@@ -4492,6 +4492,7 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
to= (char*) val_buffer->ptr(); to= (char*) val_buffer->ptr();
val_buffer->length(field_length); val_buffer->length(field_length);
thd->time_zone_used= 1;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table && table->s->db_low_byte_first) if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr); temp=uint4korr(ptr);
...@@ -4507,7 +4508,6 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr) ...@@ -4507,7 +4508,6 @@ String *Field_timestamp::val_str(String *val_buffer, String *val_ptr)
val_buffer->set_charset(&my_charset_bin); // Safety val_buffer->set_charset(&my_charset_bin); // Safety
thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp); thd->variables.time_zone->gmt_sec_to_TIME(&time_tmp,(my_time_t)temp);
thd->time_zone_used= 1;
temp= time_tmp.year % 100; temp= time_tmp.year % 100;
if (temp < YY_PART_YEAR - 1) if (temp < YY_PART_YEAR - 1)
...@@ -4557,6 +4557,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) ...@@ -4557,6 +4557,7 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate)
{ {
long temp; long temp;
THD *thd= table ? table->in_use : current_thd; THD *thd= table ? table->in_use : current_thd;
thd->time_zone_used= 1;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table && table->s->db_low_byte_first) if (table && table->s->db_low_byte_first)
temp=uint4korr(ptr); temp=uint4korr(ptr);
...@@ -4572,7 +4573,6 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate) ...@@ -4572,7 +4573,6 @@ bool Field_timestamp::get_date(MYSQL_TIME *ltime, uint fuzzydate)
else else
{ {
thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp); thd->variables.time_zone->gmt_sec_to_TIME(ltime, (my_time_t)temp);
thd->time_zone_used= 1;
} }
return 0; return 0;
} }
......
...@@ -231,9 +231,9 @@ class Field ...@@ -231,9 +231,9 @@ class Field
if (null_ptr) if (null_ptr)
null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*); null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*);
} }
inline void get_image(char *buff,uint length, CHARSET_INFO *cs) virtual void get_image(char *buff, uint length, CHARSET_INFO *cs)
{ memcpy(buff,ptr,length); } { memcpy(buff,ptr,length); }
inline void set_image(char *buff,uint length, CHARSET_INFO *cs) virtual void set_image(char *buff,uint length, CHARSET_INFO *cs)
{ memcpy(ptr,buff,length); } { memcpy(ptr,buff,length); }
...@@ -1430,13 +1430,20 @@ class Field_bit :public Field { ...@@ -1430,13 +1430,20 @@ class Field_bit :public Field {
String *val_str(String*, String *); String *val_str(String*, String *);
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
int cmp(const char *a, const char *b) int cmp(const char *a, const char *b)
{ return cmp_binary(a, b); } {
DBUG_ASSERT(ptr == a);
return Field_bit::key_cmp((const byte *) b, bytes_in_rec+test(bit_len));
}
int key_cmp(const byte *a, const byte *b) int key_cmp(const byte *a, const byte *b)
{ return cmp_binary((char *) a, (char *) b); } { return cmp_binary((char *) a, (char *) b); }
int key_cmp(const byte *str, uint length); int key_cmp(const byte *str, uint length);
int cmp_offset(uint row_offset); int cmp_offset(uint row_offset);
int cmp_binary_offset(uint row_offset) int cmp_binary_offset(uint row_offset)
{ return cmp_offset(row_offset); } { return cmp_offset(row_offset); }
void get_image(char *buff, uint length, CHARSET_INFO *cs)
{ get_key_image(buff, length, itRAW); }
void set_image(char *buff,uint length, CHARSET_INFO *cs)
{ Field_bit::store(buff, length, cs); }
uint get_key_image(char *buff, uint length, imagetype type); uint get_key_image(char *buff, uint length, imagetype type);
void set_key_image(char *buff, uint length) void set_key_image(char *buff, uint length)
{ Field_bit::store(buff, length, &my_charset_bin); } { Field_bit::store(buff, length, &my_charset_bin); }
......
...@@ -4828,7 +4828,8 @@ enum options_mysqld ...@@ -4828,7 +4828,8 @@ enum options_mysqld
OPT_PORT_OPEN_TIMEOUT, OPT_PORT_OPEN_TIMEOUT,
OPT_MERGE, OPT_MERGE,
OPT_INNODB_ROLLBACK_ON_TIMEOUT, OPT_INNODB_ROLLBACK_ON_TIMEOUT,
OPT_SECURE_FILE_PRIV OPT_SECURE_FILE_PRIV,
OPT_KEEP_FILES_ON_CREATE
}; };
...@@ -5830,6 +5831,11 @@ log and this option does nothing anymore.", ...@@ -5830,6 +5831,11 @@ log and this option does nothing anymore.",
(gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG, (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG,
REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD,
IO_SIZE, 0}, IO_SIZE, 0},
{"keep_files_on_create", OPT_KEEP_FILES_ON_CREATE,
"Don't overwrite stale .MYD and .MYI even if no directory is specified.",
(gptr*) &global_system_variables.keep_files_on_create,
(gptr*) &max_system_variables.keep_files_on_create,
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"key_buffer_size", OPT_KEY_BUFFER_SIZE, {"key_buffer_size", OPT_KEY_BUFFER_SIZE,
"The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.",
(gptr*) &dflt_key_cache_var.param_buff_size, (gptr*) &dflt_key_cache_var.param_buff_size,
......
...@@ -5635,3 +5635,5 @@ ER_NON_INSERTABLE_TABLE ...@@ -5635,3 +5635,5 @@ ER_NON_INSERTABLE_TABLE
eng "The target table %-.100s of the %s is not insertable-into" eng "The target table %-.100s of the %s is not insertable-into"
ER_ADMIN_WRONG_MRG_TABLE ER_ADMIN_WRONG_MRG_TABLE
eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist" eng "Table '%-.64s' is differently defined or of non-MyISAM type or doesn't exist"
ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT
eng "Too high level of nesting for select"
...@@ -5892,6 +5892,11 @@ mysql_new_select(LEX *lex, bool move_down) ...@@ -5892,6 +5892,11 @@ mysql_new_select(LEX *lex, bool move_down)
select_lex->init_query(); select_lex->init_query();
select_lex->init_select(); select_lex->init_select();
lex->nest_level++; lex->nest_level++;
if (lex->nest_level > (int) MAX_SELECT_NESTING)
{
my_error(ER_TOO_HIGH_LEVEL_OF_NESTING_FOR_SELECT,MYF(0),MAX_SELECT_NESTING);
DBUG_RETURN(1);
}
select_lex->nest_level= lex->nest_level; select_lex->nest_level= lex->nest_level;
/* /*
Don't evaluate this subquery during statement prepare even if Don't evaluate this subquery during statement prepare even if
......
...@@ -256,8 +256,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -256,8 +256,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
drop_locked_tables(thd, db, table->table_name); drop_locked_tables(thd, db, table->table_name);
if (thd->killed) if (thd->killed)
{ {
thd->no_warnings_for_error= 0; error=-1;
DBUG_RETURN(-1); goto err_with_placeholders;
} }
alias= (lower_case_table_names == 2) ? table->alias : table->table_name; alias= (lower_case_table_names == 2) ? table->alias : table->table_name;
/* remove form file and isam files */ /* remove form file and isam files */
...@@ -338,6 +338,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, ...@@ -338,6 +338,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
} }
} }
err_with_placeholders:
if (!drop_temporary) if (!drop_temporary)
unlock_table_names(thd, tables, (TABLE_LIST*) 0); unlock_table_names(thd, tables, (TABLE_LIST*) 0);
thd->no_warnings_for_error= 0; thd->no_warnings_for_error= 0;
......
...@@ -228,11 +228,11 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_ ...@@ -228,11 +228,11 @@ my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, my_bool *in_dst_time_
my_time_t timestamp; my_time_t timestamp;
*in_dst_time_gap= 0; *in_dst_time_gap= 0;
thd->time_zone_used= 1;
timestamp= thd->variables.time_zone->TIME_to_gmt_sec(t, in_dst_time_gap); timestamp= thd->variables.time_zone->TIME_to_gmt_sec(t, in_dst_time_gap);
if (timestamp) if (timestamp)
{ {
thd->time_zone_used= 1;
return timestamp; return timestamp;
} }
......
...@@ -81,6 +81,8 @@ ...@@ -81,6 +81,8 @@
RAND_TABLE_BIT) RAND_TABLE_BIT)
#define MAX_FIELDS 4096 /* Limit in the .frm file */ #define MAX_FIELDS 4096 /* Limit in the .frm file */
#define MAX_SELECT_NESTING (sizeof(nesting_map)*8-1)
#define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD) #define MAX_SORT_MEMORY (2048*1024-MALLOC_OVERHEAD)
#define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD) #define MIN_SORT_MEMORY (32*1024-MALLOC_OVERHEAD)
......
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