diff options
author | unknown <antony@pcg5ppc.xiphis.org> | 2008-03-07 13:41:11 -0800 |
---|---|---|
committer | unknown <antony@pcg5ppc.xiphis.org> | 2008-03-07 13:41:11 -0800 |
commit | 1e8b11c6565516f53375cbeed1641157f1d1981b (patch) | |
tree | e851576a5b589c485ef78c988888f15462c1446d | |
parent | 4d09306dd19820a742b003417d83f76f5d3633f3 (diff) | |
parent | e78f628499f52b57f1481950c15a433da556672d (diff) | |
download | mariadb-git-1e8b11c6565516f53375cbeed1641157f1d1981b.tar.gz |
Merge pcg5ppc.xiphis.org:/Network/Servers/anubis.xiphis.org/home/antony/work/mysql-5.0-engines
into pcg5ppc.xiphis.org:/Network/Servers/anubis.xiphis.org/home/antony/work/merge.20080307/mysql-5.0
sql/item.cc:
Auto merged
sql/item_func.cc:
Auto merged
34 files changed, 693 insertions, 64 deletions
diff --git a/cmd-line-utils/libedit/el.h b/cmd-line-utils/libedit/el.h index c4b6cff2186..d9379d7c8aa 100644 --- a/cmd-line-utils/libedit/el.h +++ b/cmd-line-utils/libedit/el.h @@ -136,6 +136,8 @@ struct editline { protected int el_editmode(EditLine *, int, const char **); +#define el_isprint(x) ((unsigned char) (x) < 0x80 ? isprint(x) : 1) + #ifdef DEBUG #define EL_ABORT(a) do { \ fprintf(el->el_errfile, "%s, %d: ", \ diff --git a/cmd-line-utils/libedit/key.c b/cmd-line-utils/libedit/key.c index 090a2684e92..35fcf0651b2 100644 --- a/cmd-line-utils/libedit/key.c +++ b/cmd-line-utils/libedit/key.c @@ -618,7 +618,7 @@ key__decode_char(char *buf, int cnt, int ch) } else if (ch == '\\') { buf[cnt++] = '\\'; buf[cnt] = '\\'; - } else if (ch == ' ' || (isprint(ch) && !isspace(ch))) { + } else if (ch == ' ' || (el_isprint(ch) && !isspace(ch))) { buf[cnt] = ch; } else { buf[cnt++] = '\\'; @@ -660,7 +660,7 @@ key__decode_str(const char *str, char *buf, const char *sep) } else if (*p == '^' || *p == '\\') { *b++ = '\\'; *b++ = *p; - } else if (*p == ' ' || (isprint((unsigned char) *p) && + } else if (*p == ' ' || (el_isprint((unsigned char) *p) && !isspace((unsigned char) *p))) { *b++ = *p; } else { diff --git a/cmd-line-utils/libedit/map.c b/cmd-line-utils/libedit/map.c index d99c36ff665..6be9279b5e5 100644 --- a/cmd-line-utils/libedit/map.c +++ b/cmd-line-utils/libedit/map.c @@ -961,7 +961,7 @@ map_init_nls(EditLine *el) el_action_t *map = el->el_map.key; for (i = 0200; i <= 0377; i++) - if (isprint(i)) + if (el_isprint(i)) map[i] = ED_INSERT; } diff --git a/cmd-line-utils/libedit/read.c b/cmd-line-utils/libedit/read.c index 051f3e8e42e..51848c2038e 100644 --- a/cmd-line-utils/libedit/read.c +++ b/cmd-line-utils/libedit/read.c @@ -508,7 +508,7 @@ el_gets(EditLine *el, int *nread) el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) { if (cmdnum == VI_DELETE_PREV_CHAR && el->el_chared.c_redo.pos != el->el_chared.c_redo.buf - && isprint((unsigned char)el->el_chared.c_redo.pos[-1])) + && el_isprint((unsigned char)el->el_chared.c_redo.pos[-1])) el->el_chared.c_redo.pos--; else *el->el_chared.c_redo.pos++ = ch; diff --git a/cmd-line-utils/libedit/refresh.c b/cmd-line-utils/libedit/refresh.c index b2833d215c5..46aca15ef08 100644 --- a/cmd-line-utils/libedit/refresh.c +++ b/cmd-line-utils/libedit/refresh.c @@ -88,7 +88,7 @@ private void re_addc(EditLine *el, int c) { - if (isprint(c)) { + if (el_isprint(c)) { re_putc(el, c, 1); return; } @@ -964,7 +964,7 @@ re_refresh_cursor(EditLine *el) h = 1; v++; } - } else if (!isprint((unsigned char) c)) { + } else if (!el_isprint((unsigned char) c)) { h += 3; if (h > th) { /* if overflow, compensate */ h = h - th; @@ -1057,7 +1057,7 @@ re_fastaddc(EditLine *el) char mc = (c == '\177') ? '?' : (c | 0100); re_fastputc(el, '^'); re_fastputc(el, mc); - } else if (isprint((unsigned char) c)) { /* normal char */ + } else if (el_isprint((unsigned char) c)) { /* normal char */ re_fastputc(el, c); } else { re_fastputc(el, '\\'); diff --git a/myisam/mi_open.c b/myisam/mi_open.c index ec169ac8785..d4d8458a669 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -270,6 +270,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) if (share->options & HA_OPTION_COMPRESS_RECORD) share->base.max_key_length+=2; /* For safety */ + /* Add space for node pointer */ + share->base.max_key_length+= share->base.key_reflength; + if (!my_multi_malloc(MY_WME, &share,sizeof(*share), &share->state.rec_per_key_part,sizeof(long)*key_parts, @@ -791,8 +794,17 @@ static void setup_key_functions(register MI_KEYDEF *keyinfo) keyinfo->get_key= _mi_get_pack_key; if (keyinfo->seg[0].flag & HA_PACK_KEY) { /* Prefix compression */ + /* + _mi_prefix_search() compares end-space against ASCII blank (' '). + It cannot be used for character sets, that do not encode the + blank character like ASCII does. UCS2 is an example. All + character sets with a fixed width > 1 or a mimimum width > 1 + cannot represent blank like ASCII does. In these cases we have + to use _mi_seq_search() for the search. + */ if (!keyinfo->seg->charset || use_strnxfrm(keyinfo->seg->charset) || - (keyinfo->seg->flag & HA_NULL_PART)) + (keyinfo->seg->flag & HA_NULL_PART) || + (keyinfo->seg->charset->mbminlen > 1)) keyinfo->bin_search=_mi_seq_search; else keyinfo->bin_search=_mi_prefix_search; diff --git a/mysql-test/include/ctype_common.inc b/mysql-test/include/ctype_common.inc index 89b7ceb0c72..7d92c3c7b8f 100644 --- a/mysql-test/include/ctype_common.inc +++ b/mysql-test/include/ctype_common.inc @@ -13,6 +13,8 @@ SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -62,8 +64,22 @@ select a sounds like a from t1; select 1 from t1 order by cast(a as char(1)); drop table t1; +# +# Bug#27580 SPACE() function collation bug? +# +set names utf8; +create table t1 ( + name varchar(10), + level smallint unsigned); +show create table t1; +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +drop table t1; + DROP DATABASE d1; # Restore settings USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index 8103e9b856f..0c7ffe87536 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -3,6 +3,8 @@ SET @test_character_set= 'big5'; SET @test_collation= 'big5_chinese_ci'; SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -69,10 +71,27 @@ select 1 from t1 order by cast(a as char(1)); 1 1 drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=big5 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; SET NAMES big5; SET collation_connection='big5_chinese_ci'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result index 73f415732cd..2ed22802805 100644 --- a/mysql-test/r/ctype_cp1250_ch.result +++ b/mysql-test/r/ctype_cp1250_ch.result @@ -2,6 +2,192 @@ DROP TABLE IF EXISTS t1; SHOW COLLATION LIKE 'cp1250_czech_cs'; Collation Charset Id Default Compiled Sortlen cp1250_czech_cs cp1250 34 Yes 2 +SET @test_character_set= 'cp1250'; +SET @test_collation= 'cp1250_general_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) cp1250_general_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) cp1250_general_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=cp1250 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; +SET @test_character_set= 'cp1250'; +SET @test_collation= 'cp1250_czech_cs'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) cp1250_czech_cs YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) cp1250_czech_cs YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) collate cp1250_czech_cs default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_czech_cs +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; CREATE TABLE t1 (a char(16)) character set cp1250 collate cp1250_czech_cs; INSERT INTO t1 VALUES (''); SELECT a, length(a), a='', a=' ', a=' ' FROM t1; diff --git a/mysql-test/r/ctype_cp932.result b/mysql-test/r/ctype_cp932.result index 8974a6a8594..63cd720746f 100755 --- a/mysql-test/r/ctype_cp932.result +++ b/mysql-test/r/ctype_cp932.result @@ -6,6 +6,8 @@ SET @test_character_set= 'cp932'; SET @test_collation= 'cp932_japanese_ci'; SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -72,10 +74,27 @@ select 1 from t1 order by cast(a as char(1)); 1 1 drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=cp932 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; set names cp932; set character_set_database = cp932; CREATE TABLE t1(c1 CHAR(1)) DEFAULT CHARACTER SET = cp932; diff --git a/mysql-test/r/ctype_euckr.result b/mysql-test/r/ctype_euckr.result index bb1b3f5995b..7a8cba634f7 100644 --- a/mysql-test/r/ctype_euckr.result +++ b/mysql-test/r/ctype_euckr.result @@ -3,6 +3,8 @@ SET @test_character_set= 'euckr'; SET @test_collation= 'euckr_korean_ci'; SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -69,10 +71,27 @@ select 1 from t1 order by cast(a as char(1)); 1 1 drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=euckr +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; SET NAMES euckr; SET collation_connection='euckr_korean_ci'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_gb2312.result b/mysql-test/r/ctype_gb2312.result index 95246525368..e0943b79c5c 100644 --- a/mysql-test/r/ctype_gb2312.result +++ b/mysql-test/r/ctype_gb2312.result @@ -3,6 +3,8 @@ SET @test_character_set= 'gb2312'; SET @test_collation= 'gb2312_chinese_ci'; SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -69,10 +71,27 @@ select 1 from t1 order by cast(a as char(1)); 1 1 drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=gb2312 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; SET NAMES gb2312; SET collation_connection='gb2312_chinese_ci'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index 8437e34be1e..b28ff761238 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -3,6 +3,8 @@ SET @test_character_set= 'gbk'; SET @test_collation= 'gbk_chinese_ci'; SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -69,10 +71,27 @@ select 1 from t1 order by cast(a as char(1)); 1 1 drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=gbk +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; SET NAMES gbk; SET collation_connection='gbk_chinese_ci'; create table t1 select repeat('a',4000) a; diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index 50be0ca53b2..34d8c7af791 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2538,6 +2538,8 @@ SET @test_character_set= 'utf8'; SET @test_collation= 'utf8_swedish_ci'; SET @safe_character_set_server= @@character_set_server; SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; SET character_set_server= @test_character_set; SET collation_server= @test_collation; CREATE DATABASE d1; @@ -2604,10 +2606,27 @@ select 1 from t1 order by cast(a as char(1)); 1 1 drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) collate utf8_swedish_ci default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; DROP DATABASE d1; USE test; SET character_set_server= @safe_character_set_server; SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; create table t1 (a varchar(1)) character set utf8 collate utf8_estonian_ci; insert into t1 values ('A'),('B'),('C'),('a'),('b'),('c'); select a, a regexp '[a]' from t1 order by binary a; diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index a6d6c604b9b..f1a2da6c6bb 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -1,4 +1,97 @@ DROP TABLE IF EXISTS t1; +SET @test_character_set= 'ucs2'; +SET @test_collation= 'ucs2_general_ci'; +SET @safe_character_set_server= @@character_set_server; +SET @safe_collation_server= @@collation_server; +SET @safe_character_set_client= @@character_set_client; +SET @safe_character_set_results= @@character_set_results; +SET character_set_server= @test_character_set; +SET collation_server= @test_collation; +CREATE DATABASE d1; +USE d1; +CREATE TABLE t1 (c CHAR(10), KEY(c)); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c char(10) ucs2_general_ci YES MUL NULL +INSERT INTO t1 VALUES ('aaa'),('aaaa'),('aaaaa'); +SELECT c as want3results FROM t1 WHERE c LIKE 'aaa%'; +want3results +aaa +aaaa +aaaaa +DROP TABLE t1; +CREATE TABLE t1 (c1 varchar(15), KEY c1 (c1(2))); +SHOW FULL COLUMNS FROM t1; +Field Type Collation Null Key Default Extra Privileges Comment +c1 varchar(15) ucs2_general_ci YES MUL NULL +INSERT INTO t1 VALUES ('location'),('loberge'),('lotre'),('boabab'); +SELECT c1 as want3results from t1 where c1 like 'l%'; +want3results +location +loberge +lotre +SELECT c1 as want3results from t1 where c1 like 'lo%'; +want3results +location +loberge +lotre +SELECT c1 as want1result from t1 where c1 like 'loc%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'loca%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locat%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locati%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'locatio%'; +want1result +location +SELECT c1 as want1result from t1 where c1 like 'location%'; +want1result +location +DROP TABLE t1; +create table t1 (a set('a') not null); +insert into t1 values (),(); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +select cast(a as char(1)) from t1; +cast(a as char(1)) + + +select a sounds like a from t1; +a sounds like a +1 +1 +select 1 from t1 order by cast(a as char(1)); +1 +1 +1 +drop table t1; +set names utf8; +create table t1 ( +name varchar(10), +level smallint unsigned); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `name` varchar(10) default NULL, + `level` smallint(5) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=ucs2 +insert into t1 values ('string',1); +select concat(name,space(level)), concat(name, repeat(' ',level)) from t1; +concat(name,space(level)) concat(name, repeat(' ',level)) +string string +drop table t1; +DROP DATABASE d1; +USE test; +SET character_set_server= @safe_character_set_server; +SET collation_server= @safe_collation_server; +SET character_set_client= @safe_character_set_client; +SET character_set_results= @safe_character_set_results; SET NAMES latin1; SET character_set_connection=ucs2; select 'a' = 'a', 'a' = 'a ', 'a ' = 'a'; diff --git a/mysql-test/r/ctype_ucs2_def.result b/mysql-test/r/ctype_ucs2_def.result index d838c5d66b0..1bbb354798b 100644 --- a/mysql-test/r/ctype_ucs2_def.result +++ b/mysql-test/r/ctype_ucs2_def.result @@ -21,4 +21,14 @@ INSERT INTO t1 VALUES('A', 'A'), ('B', 'B'), ('C', 'C'); INSERT INTO t1 VALUES('A ', 'A '); ERROR 23000: Duplicate entry '' for key 1 DROP TABLE t1; +CREATE TABLE t1 ( +c1 CHAR(255) CHARACTER SET UCS2 COLLATE UCS2_BIN NOT NULL, +KEY(c1) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('marshall\'s'); +INSERT INTO t1 VALUES ('marsh'); +CHECK TABLE t1 EXTENDED; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index a005db4deac..3a934e7fe3c 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -2045,6 +2045,30 @@ select 1 from t1 order by a; drop table t1; drop table t1; drop view v1; +CREATE TABLE t1 (a INT, b INT, KEY(a,b)); +INSERT INTO t1 VALUES(NULL,1),(1,NULL),(NULL,NULL),(1,1),(2,2); +CREATE TABLE t1 (a INT, b INT, KEY(a,b)) ENGINE=federated +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; +SELECT * FROM t1 WHERE a IS NULL; +a b +NULL NULL +NULL 1 +SELECT * FROM t1 WHERE a IS NOT NULL; +a b +1 NULL +1 1 +2 2 +SELECT * FROM t1 WHERE a=1 AND b=1; +a b +1 1 +SELECT * FROM t1 WHERE a IS NULL AND b=1; +a b +NULL 1 +SELECT * FROM t1 WHERE a IS NOT NULL AND b=1; +a b +1 1 +DROP TABLE t1; +DROP TABLE t1; DROP TABLE IF EXISTS federated.t1; DROP DATABASE IF EXISTS federated; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 4f6b6d3a0d8..fa9ca3539d6 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -225,4 +225,7 @@ select min(a) from t1 group by inet_ntoa(a); min(a) -2 drop table t1; +SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; +NAME_CONST('var', 'value') COLLATE latin1_general_cs +value End of 5.0 tests diff --git a/mysql-test/r/rpl_dual_pos_advance.result b/mysql-test/r/rpl_dual_pos_advance.result index 257baa81b74..97ca8101c33 100644 --- a/mysql-test/r/rpl_dual_pos_advance.result +++ b/mysql-test/r/rpl_dual_pos_advance.result @@ -8,15 +8,56 @@ reset master; change master to master_host="127.0.0.1",master_port=SLAVE_PORT,master_user="root"; start slave; create table t1 (n int); +stop slave; +create table t2 (n int); +show tables; +Tables_in_test +t1 +t2 +create table t3 (n int) engine=innodb; +set @a=1; +insert into t3 values(@a); +begin; +insert into t3 values(2); +insert into t3 values(3); +commit; +insert into t3 values(4); +start slave until master_log_file="slave-bin.000001",master_log_pos=195; +Warnings: +Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mysqld restart +select master_pos_wait("slave-bin.000001",137); +master_pos_wait("slave-bin.000001",137) +0 +show tables; +Tables_in_test +t1 +t2 +start slave until master_log_file="slave-bin.000001",master_log_pos=438; +Warnings: +Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mysqld restart +select * from t3; +n +1 +start slave until master_log_file="slave-bin.000001",master_log_pos=663; +Warnings: +Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mysqld restart +select * from t3; +n +1 +2 +3 +start slave; create table t4 (n int); create table t5 (n int); create table t6 (n int); show tables; Tables_in_test t1 +t2 +t3 t4 t5 t6 stop slave; reset slave; -drop table t1,t4,t5,t6; +drop table t1,t2,t3,t4,t5,t6; diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test index 86eb8c31d99..b3daa8a02a2 100644 --- a/mysql-test/t/ctype_cp1250_ch.test +++ b/mysql-test/t/ctype_cp1250_ch.test @@ -6,6 +6,16 @@ DROP TABLE IF EXISTS t1; SHOW COLLATION LIKE 'cp1250_czech_cs'; +SET @test_character_set= 'cp1250'; +SET @test_collation= 'cp1250_general_ci'; +-- source include/ctype_common.inc + +SET @test_character_set= 'cp1250'; +SET @test_collation= 'cp1250_czech_cs'; +-- source include/ctype_common.inc + + + # # Bugs: #8840: Empty string comparison and character set 'cp1250' # diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 3af5bfa54f9..b1c5f4aec6a 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -4,6 +4,10 @@ DROP TABLE IF EXISTS t1; --enable_warnings +SET @test_character_set= 'ucs2'; +SET @test_collation= 'ucs2_general_ci'; +-- source include/ctype_common.inc + SET NAMES latin1; SET character_set_connection=ucs2; -- source include/endspace.inc diff --git a/mysql-test/t/ctype_ucs2_def.test b/mysql-test/t/ctype_ucs2_def.test index c80444daddd..b146dc63626 100644 --- a/mysql-test/t/ctype_ucs2_def.test +++ b/mysql-test/t/ctype_ucs2_def.test @@ -39,4 +39,17 @@ INSERT INTO t1 VALUES('A', 'A'), ('B', 'B'), ('C', 'C'); INSERT INTO t1 VALUES('A ', 'A '); DROP TABLE t1; +# +# Bug#32705 - myisam corruption: Key in wrong position +# at page 1024 with ucs2_bin +# +CREATE TABLE t1 ( + c1 CHAR(255) CHARACTER SET UCS2 COLLATE UCS2_BIN NOT NULL, + KEY(c1) + ) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('marshall\'s'); +INSERT INTO t1 VALUES ('marsh'); +CHECK TABLE t1 EXTENDED; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index d4f22650a32..934db5cd68b 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -1716,5 +1716,26 @@ connection slave; drop table t1; drop view v1; +# +# BUG#33946 - Join on Federated tables with Unique index gives error 1430 +# from storage engine +# +connection slave; +CREATE TABLE t1 (a INT, b INT, KEY(a,b)); +INSERT INTO t1 VALUES(NULL,1),(1,NULL),(NULL,NULL),(1,1),(2,2); + +connection master; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE t1 (a INT, b INT, KEY(a,b)) ENGINE=federated +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1'; +SELECT * FROM t1 WHERE a IS NULL; +SELECT * FROM t1 WHERE a IS NOT NULL; +SELECT * FROM t1 WHERE a=1 AND b=1; +SELECT * FROM t1 WHERE a IS NULL AND b=1; +SELECT * FROM t1 WHERE a IS NOT NULL AND b=1; +DROP TABLE t1; + +connection slave; +DROP TABLE t1; source include/federated_cleanup.inc; diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index ccb59df5677..17a0dbe50a7 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -237,5 +237,11 @@ insert into t1 values (-1), (-2); select min(a) from t1 group by inet_ntoa(a); drop table t1; +# +# BUG#34289 - Incorrect NAME_CONST substitution in stored procedures breaks +# replication +# +SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; + --echo End of 5.0 tests diff --git a/mysql-test/t/rpl_dual_pos_advance-slave.opt b/mysql-test/t/rpl_dual_pos_advance-slave.opt new file mode 100644 index 00000000000..627becdbfb5 --- /dev/null +++ b/mysql-test/t/rpl_dual_pos_advance-slave.opt @@ -0,0 +1 @@ +--innodb diff --git a/mysql-test/t/rpl_dual_pos_advance.test b/mysql-test/t/rpl_dual_pos_advance.test index 518fa9df885..5e08284a2f2 100644 --- a/mysql-test/t/rpl_dual_pos_advance.test +++ b/mysql-test/t/rpl_dual_pos_advance.test @@ -7,6 +7,7 @@ # It also will test BUG#13861. source include/master-slave.inc; +source include/have_innodb.inc; # set up "dual head" @@ -30,45 +31,64 @@ save_master_pos; connection master; sync_with_master; -# Now test BUG#13861. This will be enabled when Guilhem fixes this -# bug. +# +# BUG#13861 - START SLAVE UNTIL may stop 1 evnt too late if +# log-slave-updates and circul repl +# +stop slave; -# stop slave +create table t2 (n int); # create one ignored event -# create table t2 (n int); # create one ignored event +save_master_pos; +connection slave; +sync_with_master; -# save_master_pos; -# connection slave; -# sync_with_master; +connection slave; -# connection slave; +show tables; -# show tables; +save_master_pos; -# save_master_pos; +create table t3 (n int) engine=innodb; +set @a=1; +insert into t3 values(@a); +begin; +insert into t3 values(2); +insert into t3 values(3); +commit; +insert into t3 values(4); -# create table t3 (n int); -# connection master; +connection master; # bug is that START SLAVE UNTIL may stop too late, we test that by # asking it to stop before creation of t3. -# start slave until master_log_file="slave-bin.000001",master_log_pos=195; +start slave until master_log_file="slave-bin.000001",master_log_pos=195; # wait until it's started (the position below is the start of "CREATE # TABLE t2") (otherwise wait_for_slave_to_stop may return at once) -# select master_pos_wait("slave-bin.000001",137); +select master_pos_wait("slave-bin.000001",137); -# wait_for_slave_to_stop; +wait_for_slave_to_stop; # then BUG#13861 causes t3 to show up below (because stopped too # late). -# show tables; +show tables; + +# ensure that we do not break set @a=1; insert into t3 values(@a); +start slave until master_log_file="slave-bin.000001",master_log_pos=438; +wait_for_slave_to_stop; +select * from t3; + +# ensure that we do not break transaction +start slave until master_log_file="slave-bin.000001",master_log_pos=663; +wait_for_slave_to_stop; +select * from t3; -# start slave; +start slave; # BUG#13023 is that Exec_master_log_pos may stay too low "forever": @@ -99,7 +119,7 @@ show tables; stop slave; reset slave; -drop table t1,t4,t5,t6; # add t2 and t3 later +drop table t1,t2,t3,t4,t5,t6; save_master_pos; connection slave; diff --git a/sql/ha_federated.cc b/sql/ha_federated.cc index ac1e0962ffb..c0743bd6c9a 100644 --- a/sql/ha_federated.cc +++ b/sql/ha_federated.cc @@ -1094,10 +1094,20 @@ bool ha_federated::create_where_from_key(String *to, { if (*ptr++) { + /* + We got "IS [NOT] NULL" condition against nullable column. We + distinguish between "IS NOT NULL" and "IS NULL" by flag. For + "IS NULL", flag is set to HA_READ_KEY_EXACT. + */ if (emit_key_part_name(&tmp, key_part) || - tmp.append(FEDERATED_ISNULL)) + tmp.append(ranges[i]->flag == HA_READ_KEY_EXACT ? + FEDERATED_ISNULL : " IS NOT NULL ")) DBUG_RETURN(1); - continue; + /* + We need to adjust pointer and length to be prepared for next + key part. As well as check if this was last key part. + */ + goto prepare_for_next_key_part; } } @@ -1199,12 +1209,18 @@ bool ha_federated::create_where_from_key(String *to, if (tmp.append(FEDERATED_CLOSEPAREN)) DBUG_RETURN(1); +prepare_for_next_key_part: if (store_length >= length) break; DBUG_PRINT("info", ("remainder %d", remainder)); DBUG_ASSERT(remainder > 1); length-= store_length; - ptr+= store_length; + /* + For nullable columns, null-byte is already skipped before, that is + ptr was incremented by 1. Since store_length still counts null-byte, + we need to subtract 1 from store_length. + */ + ptr+= store_length - test(key_part->null_bit); if (tmp.append(FEDERATED_AND)) DBUG_RETURN(1); diff --git a/sql/item.cc b/sql/item.cc index a9e99c65580..e2930d58b06 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1240,6 +1240,7 @@ bool Item_name_const::fix_fields(THD *thd, Item **ref) return TRUE; } set_name(item_name->ptr(), (uint) item_name->length(), system_charset_info); + collation.set(value_item->collation.collation, DERIVATION_IMPLICIT); max_length= value_item->max_length; decimals= value_item->decimals; fixed= 1; diff --git a/sql/item_create.cc b/sql/item_create.cc index 561613032bc..60a17c21521 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -361,13 +361,13 @@ Item *create_func_space(Item *a) if (cs->mbminlen > 1) { uint dummy_errors; - sp= new Item_string("",0,cs); + sp= new Item_string("", 0, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); if (sp) sp->str_value.copy(" ", 1, &my_charset_latin1, cs, &dummy_errors); } else { - sp= new Item_string(" ",1,cs); + sp= new Item_string(" ", 1, cs, DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII); } return sp ? new Item_func_repeat(sp, a) : 0; } diff --git a/sql/item_func.cc b/sql/item_func.cc index 84dd3e3ebc6..d47cb9c1ddd 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3729,6 +3729,18 @@ longlong Item_func_sleep::val_int() DBUG_ASSERT(fixed == 1); double time= args[0]->val_real(); + /* + On 64-bit OSX pthread_cond_timedwait() waits forever + if passed abstime time has already been exceeded by + the system time. + When given a very short timeout (< 10 mcs) just return + immediately. + We assume that the lines between this test and the call + to pthread_cond_timedwait() will be executed in less than 0.00001 sec. + */ + if (time < 0.00001) + return 0; + set_timespec_nsec(abstime, (ulonglong)(time * ULL(1000000000))); pthread_cond_init(&cond, NULL); diff --git a/sql/log_event.cc b/sql/log_event.cc index a950094a018..8e14a873fc6 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -373,6 +373,7 @@ Log_event::Log_event(const char* buf, #endif when = uint4korr(buf); server_id = uint4korr(buf + SERVER_ID_OFFSET); + data_written= uint4korr(buf + EVENT_LEN_OFFSET); if (description_event->binlog_version==1) { log_pos= 0; @@ -405,7 +406,7 @@ Log_event::Log_event(const char* buf, binlog, so which will cause problems if the user uses this value in CHANGE MASTER). */ - log_pos+= uint4korr(buf + EVENT_LEN_OFFSET); + log_pos+= data_written; } DBUG_PRINT("info", ("log_pos: %lu", (ulong) log_pos)); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 896315ec82f..f1826678c9f 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -109,11 +109,14 @@ void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status) } -#define get_object(p, obj) \ +#define get_object(p, obj, msg) \ {\ uint len = (uint)*p++; \ if (p + len > p_end || len >= sizeof(obj)) \ + {\ + errmsg= msg;\ goto err; \ + }\ strmake(obj,(char*) p,len); \ p+= len; \ }\ @@ -158,6 +161,7 @@ int register_slave(THD* thd, uchar* packet, uint packet_length) int res; SLAVE_INFO *si; uchar *p= packet, *p_end= packet + packet_length; + const char *errmsg= "Wrong parameters to function register_slave"; if (check_access(thd, REPL_SLAVE_ACL, any_db,0,0,0,0)) return 1; @@ -166,9 +170,9 @@ int register_slave(THD* thd, uchar* packet, uint packet_length) thd->server_id= si->server_id= uint4korr(p); p+= 4; - get_object(p,si->host); - get_object(p,si->user); - get_object(p,si->password); + get_object(p,si->host, "Failed to register slave: too long 'report-host'"); + get_object(p,si->user, "Failed to register slave: too long 'report-user'"); + get_object(p,si->password, "Failed to register slave; too long 'report-password'"); if (p+10 > p_end) goto err; si->port= uint2korr(p); @@ -187,8 +191,7 @@ int register_slave(THD* thd, uchar* packet, uint packet_length) err: my_free((gptr) si, MYF(MY_WME)); - my_message(ER_UNKNOWN_ERROR, "Wrong parameters to function register_slave", - MYF(0)); + my_message(ER_UNKNOWN_ERROR, errmsg, MYF(0)); err2: return 1; } diff --git a/sql/slave.cc b/sql/slave.cc index 8a3620080f2..500683e080d 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3115,6 +3115,11 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error) Check if condition stated in UNTIL clause of START SLAVE is reached. SYNOPSYS st_relay_log_info::is_until_satisfied() + master_beg_pos position of the beginning of to be executed event + (not log_pos member of the event that points to the + beginning of the following event) + + DESCRIPTION Checks if UNTIL condition is reached. Uses caching result of last comparison of current log file name and target log file name. So cached @@ -3139,7 +3144,7 @@ int check_expected_error(THD* thd, RELAY_LOG_INFO* rli, int expected_error) false - condition not met */ -bool st_relay_log_info::is_until_satisfied() +bool st_relay_log_info::is_until_satisfied(my_off_t master_beg_pos) { const char *log_name; ulonglong log_pos; @@ -3149,7 +3154,7 @@ bool st_relay_log_info::is_until_satisfied() if (until_condition == UNTIL_MASTER_POS) { log_name= group_master_log_name; - log_pos= group_master_log_pos; + log_pos= master_beg_pos; } else { /* until_condition == UNTIL_RELAY_POS */ @@ -3228,28 +3233,6 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) wait for something for example inside of next_event(). */ pthread_mutex_lock(&rli->data_lock); - /* - This tests if the position of the end of the last previous executed event - hits the UNTIL barrier. - We would prefer to test if the position of the start (or possibly) end of - the to-be-read event hits the UNTIL barrier, this is different if there - was an event ignored by the I/O thread just before (BUG#13861 to be - fixed). - */ - if (rli->until_condition!=RELAY_LOG_INFO::UNTIL_NONE && - rli->is_until_satisfied()) - { - char buf[22]; - sql_print_information("Slave SQL thread stopped because it reached its" - " UNTIL position %s", llstr(rli->until_pos(), buf)); - /* - Setting abort_slave flag because we do not want additional message about - error in query execution to be printed. - */ - rli->abort_slave= 1; - pthread_mutex_unlock(&rli->data_lock); - return 1; - } Log_event * ev = next_event(rli); @@ -3267,6 +3250,27 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) int exec_res; /* + This tests if the position of the beginning of the current event + hits the UNTIL barrier. + */ + if (rli->until_condition != RELAY_LOG_INFO::UNTIL_NONE && + rli->is_until_satisfied((thd->options & OPTION_BEGIN || !ev->log_pos) ? + rli->group_master_log_pos : + ev->log_pos - ev->data_written)) + { + char buf[22]; + sql_print_information("Slave SQL thread stopped because it reached its" + " UNTIL position %s", llstr(rli->until_pos(), buf)); + /* + Setting abort_slave flag because we do not want additional message about + error in query execution to be printed. + */ + rli->abort_slave= 1; + pthread_mutex_unlock(&rli->data_lock); + delete ev; + return 1; + } + /* Queries originating from this server must be skipped. Low-level events (Format_desc, Rotate, Stop) from this server must also be skipped. But for those we don't want to modify @@ -3977,6 +3981,22 @@ Slave SQL thread aborted. Can't execute init_slave query"); } } + /* + First check until condition - probably there is nothing to execute. We + do not want to wait for next event in this case. + */ + pthread_mutex_lock(&rli->data_lock); + if (rli->until_condition != RELAY_LOG_INFO::UNTIL_NONE && + rli->is_until_satisfied(rli->group_master_log_pos)) + { + char buf[22]; + sql_print_information("Slave SQL thread stopped because it reached its" + " UNTIL position %s", llstr(rli->until_pos(), buf)); + pthread_mutex_unlock(&rli->data_lock); + goto err; + } + pthread_mutex_unlock(&rli->data_lock); + /* Read queries from the IO/THREAD until this thread is killed */ while (!sql_slave_killed(thd,rli)) diff --git a/sql/slave.h b/sql/slave.h index c61787cdf3b..da548e145d3 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -348,7 +348,7 @@ typedef struct st_relay_log_info void close_temporary_tables(); /* Check if UNTIL condition is satisfied. See slave.cc for more. */ - bool is_until_satisfied(); + bool is_until_satisfied(my_off_t master_beg_pos); inline ulonglong until_pos() { return ((until_condition == UNTIL_MASTER_POS) ? group_master_log_pos : |