diff options
65 files changed, 638 insertions, 1368 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index cf9c8c0e3c5..dff3b22ecec 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -665,6 +665,41 @@ AC_DEFINE(STRUCT_DIRENT_HAS_D_INO, [1], fi ]) +AC_DEFUN(MYSQL_STRUCT_DIRENT_D_NAMLEN, +[AC_REQUIRE([AC_HEADER_DIRENT]) +AC_MSG_CHECKING(if struct dirent has a d_namlen member) +AC_CACHE_VAL(mysql_cv_dirent_has_dnamlen, +[AC_TRY_COMPILE([ +#include <stdio.h> +#include <sys/types.h> +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include <dirent.h> +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include <ndir.h> +# endif +#endif /* HAVE_DIRENT_H */ +],[ +struct dirent d; int z; z = (int)d.d_namlen; +], mysql_cv_dirent_has_dnamlen=yes, mysql_cv_dirent_has_dnamlen=no)]) +AC_MSG_RESULT($mysql_cv_dirent_has_dnamlen) +if test "$mysql_cv_dirent_has_dnamlen" = "yes"; then +AC_DEFINE(STRUCT_DIRENT_HAS_D_NAMLEN, [1], + [d_namlen member present in struct dirent]) +fi +]) + + AC_DEFUN(MYSQL_TYPE_SIGHANDLER, [AC_MSG_CHECKING([whether signal handlers are of type void]) AC_CACHE_VAL(mysql_cv_void_sighandler, diff --git a/client/mysql.cc b/client/mysql.cc index 51c84152298..8de9995f173 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -607,7 +607,7 @@ static struct my_option my_long_options[] = {"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif diff --git a/client/mysqladmin.c b/client/mysqladmin.c index 9e5c698bb93..d8842d98c6b 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -151,7 +151,7 @@ static struct my_option my_long_options[] = "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 882efff37a2..904b234be64 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -125,7 +125,7 @@ static struct my_option my_long_options[] = "Can fix almost anything except unique keys that aren't unique.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif diff --git a/client/mysqldump.c b/client/mysqldump.c index 77c93e126e7..631f328a2f7 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -276,7 +276,7 @@ static struct my_option my_long_options[] = "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 201bf51b1bd..73f7e0a9006 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -123,7 +123,7 @@ static struct my_option my_long_options[] = {"replace", 'r', "If duplicate unique key was found, replace old row.", (gptr*) &replace, (gptr*) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 35d61f1fa2f..5d64c94ef1a 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -188,7 +188,7 @@ static struct my_option my_long_options[] = {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM - {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, + {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am index 625f6431da1..c6f9ccf06ff 100644 --- a/cmd-line-utils/libedit/Makefile.am +++ b/cmd-line-utils/libedit/Makefile.am @@ -30,7 +30,7 @@ EXTRA_DIST = makelist.sh np/unvis.c np/strlcpy.c np/vis.c np/vis.h np/strlcat.c CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c -DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR '-D__RCSID(x)=' '-D__COPYRIGHT(x)=' '-D__RENAME(x)=' '-D_DIAGASSERT(x)=' +DEFS = -DUNDEF_THREADS_HACK -DHAVE_CONFIG_H -DNO_KILL_INTR SUFFIXES = .sh diff --git a/cmd-line-utils/libedit/chared.c b/cmd-line-utils/libedit/chared.c index 559e714d9fd..62a407e66a8 100644 --- a/cmd-line-utils/libedit/chared.c +++ b/cmd-line-utils/libedit/chared.c @@ -62,13 +62,13 @@ cv_undo(EditLine *el) { c_undo_t *vu = &el->el_chared.c_undo; c_redo_t *r = &el->el_chared.c_redo; - uint size; + int size; /* Save entire line for undo */ size = el->el_line.lastchar - el->el_line.buffer; vu->len = size; vu->cursor = el->el_line.cursor - el->el_line.buffer; - memcpy(vu->buf, el->el_line.buffer, size); + memcpy(vu->buf, el->el_line.buffer, (size_t)size); /* save command info for redo */ r->count = el->el_state.doingarg ? el->el_state.argument : 0; diff --git a/cmd-line-utils/libedit/config.h b/cmd-line-utils/libedit/config.h index 966cd1bedc0..b6f002d5b9e 100644 --- a/cmd-line-utils/libedit/config.h +++ b/cmd-line-utils/libedit/config.h @@ -1,3 +1,14 @@ #include "my_config.h" #include "sys.h" + +#define __RCSID(x) +#define __COPYRIGHT(x) +#define __RENAME(x) +#define _DIAGASSERT(x) + +#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) +#define __attribute__(A) +#endif + + diff --git a/cmd-line-utils/libedit/np/unvis.c b/cmd-line-utils/libedit/np/unvis.c index 01056c776e9..895ff2059ac 100644 --- a/cmd-line-utils/libedit/np/unvis.c +++ b/cmd-line-utils/libedit/np/unvis.c @@ -33,6 +33,7 @@ * SUCH DAMAGE. */ +#include "config.h" #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; diff --git a/cmd-line-utils/libedit/np/vis.c b/cmd-line-utils/libedit/np/vis.c index 9abc2e6e478..db42443800b 100644 --- a/cmd-line-utils/libedit/np/vis.c +++ b/cmd-line-utils/libedit/np/vis.c @@ -34,12 +34,12 @@ * SUCH DAMAGE. */ +#include "config.h" + #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: vis.c,v 1.22 2002/03/23 17:38:27 christos Exp $"); #endif /* LIBC_SCCS and not lint */ -#include "config.h" - #include <sys/types.h> #include <assert.h> #ifdef HAVE_ALLOCA_H diff --git a/cmd-line-utils/libedit/readline.c b/cmd-line-utils/libedit/readline.c index 13b0369de96..5b40ade582c 100644 --- a/cmd-line-utils/libedit/readline.c +++ b/cmd-line-utils/libedit/readline.c @@ -1345,7 +1345,7 @@ filename_completion_function(const char *text, int state) /* otherwise, get first entry where first */ /* filename_len characters are equal */ if (entry->d_name[0] == filename[0] -#if defined(__SVR4) || defined(__linux__) +#ifndef STRUCT_DIRENT_HAS_D_NAMLEN && strlen(entry->d_name) >= filename_len #else && entry->d_namlen >= filename_len @@ -1358,7 +1358,7 @@ filename_completion_function(const char *text, int state) if (entry) { /* match found */ struct stat stbuf; -#if defined(__SVR4) || defined(__linux__) +#ifndef STRUCT_DIRENT_HAS_D_NAMLEN len = strlen(entry->d_name) + #else len = entry->d_namlen + diff --git a/configure.in b/configure.in index 3bee418a270..7dfa7ae5e09 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.1.4-gamma) +AM_INIT_AUTOMAKE(mysql, 4.1.5-gamma) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -970,8 +970,8 @@ MAX_CXX_OPTIMIZE="-O3" # workaround for Sun Forte/x86 see BUG#4681 case $SYSTEM_TYPE-$MACHINE_TYPE-$ac_cv_prog_gcc in *solaris*-i?86-no) - CFLAGS="$CFLAGS -DBIG_FILES" - CXXFLAGS="$CXXFLAGS -DBIG_FILES" + CFLAGS="$CFLAGS -DBIG_TABLES" + CXXFLAGS="$CXXFLAGS -DBIG_TABLES" ;; *) ;; esac @@ -1863,6 +1863,7 @@ MYSQL_HAVE_TIOCGWINSZ MYSQL_HAVE_FIONREAD MYSQL_HAVE_TIOCSTAT MYSQL_STRUCT_DIRENT_D_INO +MYSQL_STRUCT_DIRENT_D_NAMLEN MYSQL_TYPE_SIGHANDLER if test "$with_named_curses" = "no" then @@ -2400,7 +2401,7 @@ dnl you must also create strings/ctype-$charset_name.c AC_DIVERT_PUSH(0) define(CHARSETS_AVAILABLE0,binary) -define(CHARSETS_AVAILABLE1,ascii armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257) +define(CHARSETS_AVAILABLE1,armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257) define(CHARSETS_AVAILABLE2,cp850 cp852 cp866 dec8 euckr gb2312 gbk geostd8) define(CHARSETS_AVAILABLE3,greek hebrew hp8 keybcs2 koi8r koi8u) define(CHARSETS_AVAILABLE4,latin1 latin2 latin5 latin7 macce macroman) diff --git a/myisam/ftdefs.h b/myisam/ftdefs.h index e23bc3b75ac..e7a0829e140 100644 --- a/myisam/ftdefs.h +++ b/myisam/ftdefs.h @@ -27,7 +27,7 @@ #define misc_word_char(X) ((X)=='\'') #define word_char(s,X) (true_word_char(s,X) || misc_word_char(X)) -#define FT_MAX_WORD_LEN_FOR_SORT 20 +#define FT_MAX_WORD_LEN_FOR_SORT 31 #define COMPILE_STOPWORDS_IN diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 052fa55a559..a1c3698b3e9 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -2020,12 +2020,14 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, if (sort_param.keyinfo->flag & HA_FULLTEXT) { + uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT* + sort_param.keyinfo->seg->charset->mbmaxlen; sort_info.max_records= - (ha_rows) (sort_info.filelength/FT_MAX_WORD_LEN_FOR_SORT+1); + (ha_rows) (sort_info.filelength/ft_max_word_len_for_sort+1); sort_param.key_read=sort_ft_key_read; sort_param.key_write=sort_ft_key_write; - sort_param.key_length+=FT_MAX_WORD_LEN_FOR_SORT-HA_FT_MAXBYTELEN; + sort_param.key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN; } else { @@ -2425,7 +2427,11 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, total_key_length+=sort_param[i].key_length; if (sort_param[i].keyinfo->flag & HA_FULLTEXT) - sort_param[i].key_length+=FT_MAX_WORD_LEN_FOR_SORT-HA_FT_MAXBYTELEN; + { + uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT* + sort_param[i].keyinfo->seg->charset->mbmaxlen; + sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN; + } } sort_info.total_keys=i; sort_param[0].master= 1; @@ -2634,7 +2640,6 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key) DBUG_RETURN(sort_write_record(sort_param)); } /* sort_key_read */ - static int sort_ft_key_read(MI_SORT_PARAM *sort_param, void *key) { int error; @@ -3950,25 +3955,28 @@ static ha_checksum mi_byte_checksum(const byte *buf, uint length) return crc; } -/* - Deactive all not unique index that can be recreated fast - These include packed keys on which sorting will use more temporary - space than the max allowed file length or for which the unpacked keys - will take much more space than packed keys. - Note that 'rows' may be zero for the case when we don't know how many - rows we will put into the file. - */ - static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) { uint key_maxlength=key->maxlength; if (key->flag & HA_FULLTEXT) - key_maxlength+=FT_MAX_WORD_LEN_FOR_SORT-HA_FT_MAXBYTELEN; + { + uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT* + key->seg->charset->mbmaxlen; + key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN; + } return (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) && ((ulonglong) rows * key_maxlength > (ulonglong) myisam_max_temp_length)); } +/* + Deactivate all not unique index that can be recreated fast + These include packed keys on which sorting will use more temporary + space than the max allowed file length or for which the unpacked keys + will take much more space than packed keys. + Note that 'rows' may be zero for the case when we don't know how many + rows we will put into the file. + */ void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows) { diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 24f5db1401d..bc8be9c2732 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -451,9 +451,8 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page, /* We have to compare k and vseg as if they where space extended */ for (end=vseg + (len-cmplen) ; vseg < end && *vseg == (uchar) ' '; - vseg++) ; - if (vseg == end) - goto cmp_rest; /* should never happen */ + vseg++, matched++) ; + DBUG_ASSERT(vseg < end); if (*vseg > (uchar) ' ') { diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 5a6717833c5..649b28a93e3 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -154,7 +154,7 @@ enum options_mc { OPT_KEY_CACHE_BLOCK_SIZE, OPT_MYISAM_BLOCK_SIZE, OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE, OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN, - OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT, OPT_FT_STOPWORD_FILE, + OPT_FT_MAX_WORD_LEN, OPT_FT_STOPWORD_FILE, OPT_MAX_RECORD_LENGTH }; diff --git a/myisam/sort.c b/myisam/sort.c index 509365b89a5..3dc066e877c 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -204,7 +204,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, reinit_io_cache(&tempfile,READ_CACHE,0L,0,0)) goto err; /* purecov: inspected */ if (!no_messages) - puts(" - Last merge and dumping keys\n"); /* purecov: tested */ + printf(" - Last merge and dumping keys\n"); /* purecov: tested */ if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *), maxbuffer,&tempfile)) goto err; /* purecov: inspected */ @@ -219,6 +219,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, uint keyno=info->key; uint key_length, ref_length=index->s->rec_reflength; + if (!no_messages) + printf(" - Adding exceptions\n"); /* purecov: tested */ if (flush_io_cache(&tempfile_for_exceptions) || reinit_io_cache(&tempfile_for_exceptions,READ_CACHE,0L,0,0)) goto err; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 354675cd4d4..26dcce43d08 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -428,6 +428,22 @@ select * from t1 where a='807780' and b='477' and c='165'; a b c 807780 477 165 drop table t1; +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); +INSERT t1 VALUES ("can \tcan"); +INSERT t1 VALUES ("can can"); +INSERT t1 VALUES ("can"); +SELECT * FROM t1; +a +can can +can +can can +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; create table t1 (a blob); insert into t1 values('a '),('a'); select concat(a,'.') from t1 where a='a'; diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index e42485a1548..f5815cc11d9 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -234,1011 +234,18 @@ select * from t4 where a = 7 and b = 17 order by a; a b c d select * from t4 where a = 7 and b != 16 order by b; a b c d +delete from t2 where a > 5; select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; a b 1 10 3 12 5 14 -7 16 -9 18 -11 20 -13 22 -15 24 -17 26 -19 28 -21 30 -23 32 -25 34 -27 36 -29 38 -31 40 -33 42 -35 44 -37 46 -39 48 -41 50 -43 52 -45 54 -47 56 -49 58 -51 60 -53 62 -55 64 -57 66 -59 68 -61 70 -63 72 -65 74 -67 76 -69 78 -71 80 -73 82 -75 84 -77 86 -79 88 -81 90 -83 92 -85 94 -87 96 -89 98 -91 100 -93 102 -95 104 -97 106 -99 108 -101 110 -103 112 -105 114 -107 116 -109 118 -111 120 -113 122 -115 124 -117 126 -119 128 -121 130 -123 132 -125 134 -127 136 -129 138 -131 140 -133 142 -135 144 -137 146 -139 148 -141 150 -143 152 -145 154 -147 156 -149 158 -151 160 -153 162 -155 164 -157 166 -159 168 -161 170 -163 172 -165 174 -167 176 -169 178 -171 180 -173 182 -175 184 -177 186 -179 188 -181 190 -183 192 -185 194 -187 196 -189 198 -191 200 -193 202 -195 204 -197 206 -199 208 -201 210 -203 212 -205 214 -207 216 -209 218 -211 220 -213 222 -215 224 -217 226 -219 228 -221 230 -223 232 -225 234 -227 236 -229 238 -231 240 -233 242 -235 244 -237 246 -239 248 -241 250 -243 252 -245 254 -247 256 -249 258 -251 260 -253 262 -255 264 -257 266 -259 268 -261 270 -263 272 -265 274 -267 276 -269 278 -271 280 -273 282 -275 284 -277 286 -279 288 -281 290 -283 292 -285 294 -287 296 -289 298 -291 300 -293 302 -295 304 -297 306 -299 308 -301 310 -303 312 -305 314 -307 316 -309 318 -311 320 -313 322 -315 324 -317 326 -319 328 -321 330 -323 332 -325 334 -327 336 -329 338 -331 340 -333 342 -335 344 -337 346 -339 348 -341 350 -343 352 -345 354 -347 356 -349 358 -351 360 -353 362 -355 364 -357 366 -359 368 -361 370 -363 372 -365 374 -367 376 -369 378 -371 380 -373 382 -375 384 -377 386 -379 388 -381 390 -383 392 -385 394 -387 396 -389 398 -391 400 -393 402 -395 404 -397 406 -399 408 -401 410 -403 412 -405 414 -407 416 -409 418 -411 420 -413 422 -415 424 -417 426 -419 428 -421 430 -423 432 -425 434 -427 436 -429 438 -431 440 -433 442 -435 444 -437 446 -439 448 -441 450 -443 452 -445 454 -447 456 -449 458 -451 460 -453 462 -455 464 -457 466 -459 468 -461 470 -463 472 -465 474 -467 476 -469 478 -471 480 -473 482 -475 484 -477 486 -479 488 -481 490 -483 492 -485 494 -487 496 -489 498 -491 500 -493 502 -495 504 -497 506 -499 508 -501 510 -503 512 -505 514 -507 516 -509 518 -511 520 -513 522 -515 524 -517 526 -519 528 -521 530 -523 532 -525 534 -527 536 -529 538 -531 540 -533 542 -535 544 -537 546 -539 548 -541 550 -543 552 -545 554 -547 556 -549 558 -551 560 -553 562 -555 564 -557 566 -559 568 -561 570 -563 572 -565 574 -567 576 -569 578 -571 580 -573 582 -575 584 -577 586 -579 588 -581 590 -583 592 -585 594 -587 596 -589 598 -591 600 -593 602 -595 604 -597 606 -599 608 -601 610 -603 612 -605 614 -607 616 -609 618 -611 620 -613 622 -615 624 -617 626 -619 628 -621 630 -623 632 -625 634 -627 636 -629 638 -631 640 -633 642 -635 644 -637 646 -639 648 -641 650 -643 652 -645 654 -647 656 -649 658 -651 660 -653 662 -655 664 -657 666 -659 668 -661 670 -663 672 -665 674 -667 676 -669 678 -671 680 -673 682 -675 684 -677 686 -679 688 -681 690 -683 692 -685 694 -687 696 -689 698 -691 700 -693 702 -695 704 -697 706 -699 708 -701 710 -703 712 -705 714 -707 716 -709 718 -711 720 -713 722 -715 724 -717 726 -719 728 -721 730 -723 732 -725 734 -727 736 -729 738 -731 740 -733 742 -735 744 -737 746 -739 748 -741 750 -743 752 -745 754 -747 756 -749 758 -751 760 -753 762 -755 764 -757 766 -759 768 -761 770 -763 772 -765 774 -767 776 -769 778 -771 780 -773 782 -775 784 -777 786 -779 788 -781 790 -783 792 -785 794 -787 796 -789 798 -791 800 -793 802 -795 804 -797 806 -799 808 -801 810 -803 812 -805 814 -807 816 -809 818 -811 820 -813 822 -815 824 -817 826 -819 828 -821 830 -823 832 -825 834 -827 836 -829 838 -831 840 -833 842 -835 844 -837 846 -839 848 -841 850 -843 852 -845 854 -847 856 -849 858 -851 860 -853 862 -855 864 -857 866 -859 868 -861 870 -863 872 -865 874 -867 876 -869 878 -871 880 -873 882 -875 884 -877 886 -879 888 -881 890 -883 892 -885 894 -887 896 -889 898 -891 900 -893 902 -895 904 -897 906 -899 908 -901 910 -903 912 -905 914 -907 916 -909 918 -911 920 -913 922 -915 924 -917 926 -919 928 -921 930 -923 932 -925 934 -927 936 -929 938 -931 940 -933 942 -935 944 -937 946 -939 948 -941 950 -943 952 -945 954 -947 956 -949 958 -951 960 -953 962 -955 964 -957 966 -959 968 -961 970 -963 972 -965 974 -967 976 -969 978 -971 980 -973 982 -975 984 -977 986 -979 988 -981 990 -983 992 -985 994 -987 996 -989 998 -991 1000 -993 1002 -995 1004 -997 1006 -999 1008 select a, b FROM t2 outer_table where a = (select a from t2 where b = outer_table.b ) order by a; a b 1 10 3 12 5 14 -7 16 -9 18 -11 20 -13 22 -15 24 -17 26 -19 28 -21 30 -23 32 -25 34 -27 36 -29 38 -31 40 -33 42 -35 44 -37 46 -39 48 -41 50 -43 52 -45 54 -47 56 -49 58 -51 60 -53 62 -55 64 -57 66 -59 68 -61 70 -63 72 -65 74 -67 76 -69 78 -71 80 -73 82 -75 84 -77 86 -79 88 -81 90 -83 92 -85 94 -87 96 -89 98 -91 100 -93 102 -95 104 -97 106 -99 108 -101 110 -103 112 -105 114 -107 116 -109 118 -111 120 -113 122 -115 124 -117 126 -119 128 -121 130 -123 132 -125 134 -127 136 -129 138 -131 140 -133 142 -135 144 -137 146 -139 148 -141 150 -143 152 -145 154 -147 156 -149 158 -151 160 -153 162 -155 164 -157 166 -159 168 -161 170 -163 172 -165 174 -167 176 -169 178 -171 180 -173 182 -175 184 -177 186 -179 188 -181 190 -183 192 -185 194 -187 196 -189 198 -191 200 -193 202 -195 204 -197 206 -199 208 -201 210 -203 212 -205 214 -207 216 -209 218 -211 220 -213 222 -215 224 -217 226 -219 228 -221 230 -223 232 -225 234 -227 236 -229 238 -231 240 -233 242 -235 244 -237 246 -239 248 -241 250 -243 252 -245 254 -247 256 -249 258 -251 260 -253 262 -255 264 -257 266 -259 268 -261 270 -263 272 -265 274 -267 276 -269 278 -271 280 -273 282 -275 284 -277 286 -279 288 -281 290 -283 292 -285 294 -287 296 -289 298 -291 300 -293 302 -295 304 -297 306 -299 308 -301 310 -303 312 -305 314 -307 316 -309 318 -311 320 -313 322 -315 324 -317 326 -319 328 -321 330 -323 332 -325 334 -327 336 -329 338 -331 340 -333 342 -335 344 -337 346 -339 348 -341 350 -343 352 -345 354 -347 356 -349 358 -351 360 -353 362 -355 364 -357 366 -359 368 -361 370 -363 372 -365 374 -367 376 -369 378 -371 380 -373 382 -375 384 -377 386 -379 388 -381 390 -383 392 -385 394 -387 396 -389 398 -391 400 -393 402 -395 404 -397 406 -399 408 -401 410 -403 412 -405 414 -407 416 -409 418 -411 420 -413 422 -415 424 -417 426 -419 428 -421 430 -423 432 -425 434 -427 436 -429 438 -431 440 -433 442 -435 444 -437 446 -439 448 -441 450 -443 452 -445 454 -447 456 -449 458 -451 460 -453 462 -455 464 -457 466 -459 468 -461 470 -463 472 -465 474 -467 476 -469 478 -471 480 -473 482 -475 484 -477 486 -479 488 -481 490 -483 492 -485 494 -487 496 -489 498 -491 500 -493 502 -495 504 -497 506 -499 508 -501 510 -503 512 -505 514 -507 516 -509 518 -511 520 -513 522 -515 524 -517 526 -519 528 -521 530 -523 532 -525 534 -527 536 -529 538 -531 540 -533 542 -535 544 -537 546 -539 548 -541 550 -543 552 -545 554 -547 556 -549 558 -551 560 -553 562 -555 564 -557 566 -559 568 -561 570 -563 572 -565 574 -567 576 -569 578 -571 580 -573 582 -575 584 -577 586 -579 588 -581 590 -583 592 -585 594 -587 596 -589 598 -591 600 -593 602 -595 604 -597 606 -599 608 -601 610 -603 612 -605 614 -607 616 -609 618 -611 620 -613 622 -615 624 -617 626 -619 628 -621 630 -623 632 -625 634 -627 636 -629 638 -631 640 -633 642 -635 644 -637 646 -639 648 -641 650 -643 652 -645 654 -647 656 -649 658 -651 660 -653 662 -655 664 -657 666 -659 668 -661 670 -663 672 -665 674 -667 676 -669 678 -671 680 -673 682 -675 684 -677 686 -679 688 -681 690 -683 692 -685 694 -687 696 -689 698 -691 700 -693 702 -695 704 -697 706 -699 708 -701 710 -703 712 -705 714 -707 716 -709 718 -711 720 -713 722 -715 724 -717 726 -719 728 -721 730 -723 732 -725 734 -727 736 -729 738 -731 740 -733 742 -735 744 -737 746 -739 748 -741 750 -743 752 -745 754 -747 756 -749 758 -751 760 -753 762 -755 764 -757 766 -759 768 -761 770 -763 772 -765 774 -767 776 -769 778 -771 780 -773 782 -775 784 -777 786 -779 788 -781 790 -783 792 -785 794 -787 796 -789 798 -791 800 -793 802 -795 804 -797 806 -799 808 -801 810 -803 812 -805 814 -807 816 -809 818 -811 820 -813 822 -815 824 -817 826 -819 828 -821 830 -823 832 -825 834 -827 836 -829 838 -831 840 -833 842 -835 844 -837 846 -839 848 -841 850 -843 852 -845 854 -847 856 -849 858 -851 860 -853 862 -855 864 -857 866 -859 868 -861 870 -863 872 -865 874 -867 876 -869 878 -871 880 -873 882 -875 884 -877 886 -879 888 -881 890 -883 892 -885 894 -887 896 -889 898 -891 900 -893 902 -895 904 -897 906 -899 908 -901 910 -903 912 -905 914 -907 916 -909 918 -911 920 -913 922 -915 924 -917 926 -919 928 -921 930 -923 932 -925 934 -927 936 -929 938 -931 940 -933 942 -935 944 -937 946 -939 948 -941 950 -943 952 -945 954 -947 956 -949 958 -951 960 -953 962 -955 964 -957 966 -959 968 -961 970 -963 972 -965 974 -967 976 -969 978 -971 980 -973 982 -975 984 -977 986 -979 988 -981 990 -983 992 -985 994 -987 996 -989 998 -991 1000 -993 1002 -995 1004 -997 1006 -999 1008 delete from t2; delete from t3; delete from t4; diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 1441e53e935..2f1ad251e40 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -212,3 +212,48 @@ select count(*) from t1 where b = 1; count(*) 1 drop table t1; +CREATE TABLE t1 ( +a int unsigned NOT NULL PRIMARY KEY, +b int unsigned, +c int unsigned, +KEY bc(b,c) +) engine = ndb; +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL; +a b c +3 NULL NULL +2 NULL 2 +select * from t1 use index (bc)order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (bc) order by a; +a b c +1 1 1 +2 NULL 2 +3 NULL NULL +4 4 NULL +select * from t1 use index (PRIMARY) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL order by a; +a b c +2 NULL 2 +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +a b c +3 NULL NULL +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +a b c +2 NULL 2 +select * from t1 use index (bc) where b < 4 order by a; +a b c +1 1 1 +select * from t1 use index (bc) where b IS NOT NULL order by a; +a b c +1 1 1 +4 4 NULL +drop table t1; diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index 7ec2ef3a2f1..4362de94b48 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -109,6 +109,68 @@ a b c 3 4 6 drop table t3; CREATE TABLE t1 ( +pk int NOT NULL PRIMARY KEY, +a int unsigned, +UNIQUE KEY (a) +) engine=ndbcluster; +insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); +select * from t1 order by pk; +pk a +-1 NULL +0 0 +1 NULL +2 2 +3 NULL +4 4 +insert into t1 values (5,0); +ERROR 23000: Can't write, because of unique constraint, to table 't1' +select * from t1 order by pk; +pk a +-1 NULL +0 0 +1 NULL +2 2 +3 NULL +4 4 +delete from t1 where a = 0; +insert into t1 values (5,0); +select * from t1 order by pk; +pk a +-1 NULL +1 NULL +2 2 +3 NULL +4 4 +5 0 +CREATE TABLE t2 ( +pk int NOT NULL PRIMARY KEY, +a int unsigned, +b tinyint NOT NULL, +c VARCHAR(10), +UNIQUE KEY si(a, c) +) engine=ndbcluster; +insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); +select * from t2 order by pk; +pk a b c +-1 1 17 NULL +0 NULL 18 NULL +1 3 19 abc +insert into t2 values(2,3,19,'abc'); +ERROR 23000: Can't write, because of unique constraint, to table 't2' +select * from t2 order by pk; +pk a b c +-1 1 17 NULL +0 NULL 18 NULL +1 3 19 abc +delete from t2 where c IS NOT NULL; +insert into t2 values(2,3,19,'abc'); +select * from t2 order by pk; +pk a b c +-1 1 17 NULL +0 NULL 18 NULL +2 3 19 abc +drop table t1, t2; +CREATE TABLE t1 ( cid smallint(5) unsigned NOT NULL default '0', cv varchar(250) NOT NULL default '', PRIMARY KEY (cid), diff --git a/mysql-test/r/ndb_replace.result b/mysql-test/r/ndb_replace.result index 45af0f7fcb5..63fd8b55c8e 100644 --- a/mysql-test/r/ndb_replace.result +++ b/mysql-test/r/ndb_replace.result @@ -11,7 +11,7 @@ insert into t1 (gesuchnr, benutzer_id) value (3,2); replace into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); insert into t1 (gesuchnr,benutzer_id) values (1,1); -ERROR 23000: Can't write; duplicate key in table 't1' +ERROR 23000: Duplicate entry '1-1' for key 1 replace into t1 (gesuchnr,benutzer_id) values (1,1); select * from t1 order by gesuchnr; gesuchnr benutzer_id diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 98095930669..e161904cd6f 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -241,3 +241,21 @@ prepare stmt1 from "select * from t1 into outfile 'f1.txt'"; execute stmt1; deallocate prepare stmt1; drop table t1; +prepare stmt1 from 'select 1'; +prepare STMT1 from 'select 2'; +execute sTmT1; +2 +2 +deallocate prepare StMt1; +deallocate prepare Stmt1; +ERROR HY000: Unknown prepared statement handler (Stmt1) given to DEALLOCATE PREPARE +set names utf8; +prepare `ü` from 'select 1234'; +execute `ü` ; +1234 +1234 +set names latin1; +execute ``; +1234 +1234 +set names default; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index e6d47b5c570..f9081e8769b 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -423,6 +423,18 @@ select * from t1 where a='807780' and b='477' and c='165'; drop table t1; # +# space-stripping in _mi_prefix_search: BUG#5284 +# +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); +INSERT t1 VALUES ("can \tcan"); +INSERT t1 VALUES ("can can"); +INSERT t1 VALUES ("can"); +SELECT * FROM t1; +CHECK TABLE t1; +DROP TABLE t1; + +# # Verify blob handling # create table t1 (a blob); diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index a24891ab814..448db0a9165 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -206,10 +206,6 @@ select * from t4 where a = 7 and b = 16 order by a; select * from t4 where a = 7 and b = 17 order by a; select * from t4 where a = 7 and b != 16 order by b; -select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; -select a, b FROM t2 outer_table where -a = (select a from t2 where b = outer_table.b ) order by a; - # # update records # @@ -225,6 +221,12 @@ while ($1) } enable_query_log; +delete from t2 where a > 5; +select x1.a, x1.b from t2 x1, t2 x2 where x1.b = x2.b order by x1.a; +select a, b FROM t2 outer_table where +a = (select a from t2 where b = outer_table.b ) order by a; + + delete from t2; delete from t3; delete from t4; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index cffe9236fb5..00807bfcb98 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -122,18 +122,22 @@ drop table t1; # Indexing NULL values # -#CREATE TABLE t1 ( -# a int unsigned NOT NULL PRIMARY KEY, -# b int unsigned, -# c int unsigned, -# KEY bc(b,c) -#) engine = ndb; - -#insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); -#select * from t1 use index (bc); -#select count(*) from t1 use index (bc); -#select count(*) from t1 use index (PRIMARY) where b IS NULL; -#select count(*) from t1 use index (bc) where b IS NULL; -#select count(*) from t1 use index (bc) where b IS NULL and c = 2; -#select count(*) from t1 use index (bc) where b IS NOT NULL; -#drop table t1; +CREATE TABLE t1 ( + a int unsigned NOT NULL PRIMARY KEY, + b int unsigned, + c int unsigned, + KEY bc(b,c) +) engine = ndb; + +insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL); +select * from t1 use index (bc) where b IS NULL; + +select * from t1 use index (bc)order by a; +select * from t1 use index (bc) order by a; +select * from t1 use index (PRIMARY) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c IS NULL order by a; +select * from t1 use index (bc) where b IS NULL and c = 2 order by a; +select * from t1 use index (bc) where b < 4 order by a; +select * from t1 use index (bc) where b IS NOT NULL order by a; +drop table t1; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 96abc842639..4a0c689bafb 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -82,43 +82,43 @@ drop table t3; # Indexes on NULL-able columns # -#CREATE TABLE t1 ( -# pk int NOT NULL PRIMARY KEY, -# a int unsigned, -# UNIQUE KEY (a) -#) engine=ndbcluster; +CREATE TABLE t1 ( + pk int NOT NULL PRIMARY KEY, + a int unsigned, + UNIQUE KEY (a) +) engine=ndbcluster; -#insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); - -#select * from t1 order by pk; - -#--error 1169 -#insert into t1 values (5,0); -#select * from t1 order by pk; -#delete from t1 where a = 0; -#insert into t1 values (5,0); -#select * from t1 order by pk; - -#CREATE TABLE t2 ( -# pk int NOT NULL PRIMARY KEY, -# a int unsigned, -# b tinyint NOT NULL, -# c VARCHAR(10), -# UNIQUE KEY si(a, c) -#) engine=ndbcluster; - -#insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); - -#select * from t2 order by pk; - -#--error 1169 -#insert into t2 values(2,3,19,'abc'); -#select * from t2 order by pk; -#delete from t2 where c IS NOT NULL; -#insert into t2 values(2,3,19,'abc'); -#select * from t2 order by pk; +insert into t1 values (-1,NULL), (0,0), (1,NULL),(2,2),(3,NULL),(4,4); + +select * from t1 order by pk; + +--error 1169 +insert into t1 values (5,0); +select * from t1 order by pk; +delete from t1 where a = 0; +insert into t1 values (5,0); +select * from t1 order by pk; + +CREATE TABLE t2 ( + pk int NOT NULL PRIMARY KEY, + a int unsigned, + b tinyint NOT NULL, + c VARCHAR(10), + UNIQUE KEY si(a, c) +) engine=ndbcluster; + +insert into t2 values (-1,1,17,NULL),(0,NULL,18,NULL),(1,3,19,'abc'); + +select * from t2 order by pk; + +--error 1169 +insert into t2 values(2,3,19,'abc'); +select * from t2 order by pk; +delete from t2 where c IS NOT NULL; +insert into t2 values(2,3,19,'abc'); +select * from t2 order by pk; -#drop table t1, t2; +drop table t1, t2; # # More complex tables diff --git a/mysql-test/t/ndb_replace.test b/mysql-test/t/ndb_replace.test index 8ba332fc7af..59454b5a9fa 100644 --- a/mysql-test/t/ndb_replace.test +++ b/mysql-test/t/ndb_replace.test @@ -20,7 +20,7 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1); insert into t1 (gesuchnr, benutzer_id) value (3,2); replace into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); ---error 1022 +--error 1062 insert into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); select * from t1 order by gesuchnr; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 8b9704f2a06..e54bf8076e0 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -240,3 +240,24 @@ prepare stmt1 from "select * from t1 into outfile 'f1.txt'"; execute stmt1; deallocate prepare stmt1; drop table t1; + +# +# BUG#5242 "Prepared statement names are case sensitive" +# +prepare stmt1 from 'select 1'; +prepare STMT1 from 'select 2'; +execute sTmT1; +deallocate prepare StMt1; + +--error 1243 +deallocate prepare Stmt1; + +# also check that statement names are in right charset. +set names utf8; +prepare `ü` from 'select 1234'; +execute `ü` ; +set names latin1; +execute ``; +set names default; + + diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 8146426fed0..324b42036ad 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -144,6 +144,7 @@ static int ndb_to_mysql_error(const NdbError *err) int ha_ndbcluster::ndb_err(NdbConnection *trans) { + int res; const NdbError err= trans->getNdbError(); if (!err.code) return 0; // Don't log things to DBUG log if no error @@ -161,7 +162,13 @@ int ha_ndbcluster::ndb_err(NdbConnection *trans) default: break; } - DBUG_RETURN(ndb_to_mysql_error(&err)); + res= ndb_to_mysql_error(&err); + DBUG_PRINT("info", ("transformed ndbcluster error %d to mysql error %d", + err.code, res)); + if (res == HA_ERR_FOUND_DUPP_KEY) + dupkey= table->primary_key; + + DBUG_RETURN(res); } @@ -1075,11 +1082,13 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, const key_range *key, int bound) { - uint i, tot_len; + uint key_len, key_store_len, tot_len, key_tot_len; byte *key_ptr; KEY* key_info= table->key_info + active_index; KEY_PART_INFO* key_part= key_info->key_part; KEY_PART_INFO* end= key_part+key_info->key_parts; + Field* field; + bool key_nullable, key_null; DBUG_ENTER("set_bounds"); DBUG_PRINT("enter", ("bound: %d", bound)); @@ -1089,29 +1098,37 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, // Set bounds using key data tot_len= 0; - key_ptr= (byte *) key->key; + key_ptr= (byte *) key->key; + key_tot_len= key->length; for (; key_part != end; key_part++) { - Field* field= key_part->field; - uint32 field_len= field->pack_length(); - tot_len+= field_len; + field= key_part->field; + key_len= key_part->length; + key_store_len= key_part->store_length; + key_nullable= (bool) key_part->null_bit; + key_null= (field->maybe_null() && *key_ptr); + tot_len+= key_store_len; const char* bounds[]= {"LE", "LT", "GE", "GT", "EQ"}; DBUG_ASSERT(bound >= 0 && bound <= 4); - DBUG_PRINT("info", ("Set Bound%s on %s", + DBUG_PRINT("info", ("Set Bound%s on %s %s %s %s", bounds[bound], - field->field_name)); - DBUG_DUMP("key", (char*)key_ptr, field_len); + field->field_name, + key_nullable ? "NULLABLE" : "", + key_null ? "NULL":"")); + DBUG_PRINT("info", ("Total length %ds", tot_len)); + + DBUG_DUMP("key", (char*) key_ptr, key_store_len); if (op->setBound(field->field_name, bound, - field->is_null() ? 0 : key_ptr, - field->is_null() ? 0 : field_len) != 0) + key_null ? 0 : (key_nullable ? key_ptr + 1 : key_ptr), + key_null ? 0 : key_len) != 0) ERR_RETURN(op->getNdbError()); - key_ptr+= field_len; - - if (tot_len >= key->length) + key_ptr+= key_store_len; + + if (tot_len >= key_tot_len) break; /* @@ -2157,7 +2174,10 @@ void ha_ndbcluster::info(uint flag) if (flag & HA_STATUS_VARIABLE) DBUG_PRINT("info", ("HA_STATUS_VARIABLE")); if (flag & HA_STATUS_ERRKEY) + { DBUG_PRINT("info", ("HA_STATUS_ERRKEY")); + errkey= dupkey; + } if (flag & HA_STATUS_AUTO) DBUG_PRINT("info", ("HA_STATUS_AUTO")); DBUG_VOID_RETURN; @@ -2615,7 +2635,7 @@ int ndbcluster_commit(THD *thd, void *ndb_transaction) const NdbOperation *error_op= trans->getNdbErrorOperation(); ERR_PRINT(err); res= ndb_to_mysql_error(&err); - if (res != -1) + if (res != -1) ndbcluster_print_error(res, error_op); } ndb->closeTransaction(trans); @@ -3108,7 +3128,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_ndb(NULL), m_table(NULL), m_table_flags(HA_REC_NOT_IN_SEQ | - //HA_NULL_IN_KEY | + HA_NULL_IN_KEY | HA_NOT_EXACT_COUNT | HA_NO_PREFIX_CHAR_KEYS), m_use_write(false), @@ -3120,7 +3140,8 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): ops_pending(0), skip_auto_increment(true), blobs_buffer(0), - blobs_buffer_size(0) + blobs_buffer_size(0), + dupkey((uint) -1) { int i; diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index 0d9c28723ce..c49a6078e7a 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -237,6 +237,7 @@ class ha_ndbcluster: public handler // memory for blobs in one tuple char *blobs_buffer; uint32 blobs_buffer_size; + uint dupkey; }; bool ndbcluster_init(void); diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 1949ecf26dc..dcc39f30c69 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -783,10 +783,10 @@ int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length); bool init_errmessage(void); void sql_perror(const char *message); -void vprint_msg_to_log( enum loglevel level, const char *format, va_list args ); -void sql_print_error( const char *format, ... ); -void sql_print_warning( const char *format, ...); -void sql_print_information( const char *format, ...); +void vprint_msg_to_log(enum loglevel level, const char *format, va_list args); +void sql_print_error(const char *format, ...); +void sql_print_warning(const char *format, ...); +void sql_print_information(const char *format, ...); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 11397736555..e7638f13526 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -762,7 +762,7 @@ void kill_mysql(void) abort_loop=1; if (pthread_create(&tmp,&connection_attrib, kill_server_thread, (void*) 0)) - sql_print_error("Error: Can't create thread to kill server"); + sql_print_error("Can't create thread to kill server"); } #endif DBUG_VOID_RETURN; @@ -791,7 +791,7 @@ static void __cdecl kill_server(int sig_ptr) abort_loop=1; // This should be set signal(sig,SIG_IGN); if (sig == MYSQL_KILL_SIGNAL || sig == 0) - sql_print_error(ER(ER_NORMAL_SHUTDOWN),my_progname); + sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname); else sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */ @@ -806,7 +806,7 @@ static void __cdecl kill_server(int sig_ptr) #ifdef __NETWARE__ pthread_join(select_thread, NULL); // wait for main thread #endif /* __NETWARE__ */ - + pthread_exit(0); /* purecov: deadcode */ #endif /* EMBEDDED_LIBRARY */ @@ -834,7 +834,7 @@ extern "C" sig_handler print_signal_warning(int sig) if (!DBUG_IN_USE) { if (global_system_variables.log_warnings) - sql_print_error("Warning: Got signal %d from thread %d", + sql_print_warning("Got signal %d from thread %d", sig,my_thread_id()); } #ifdef DONT_REMEMBER_SIGNAL @@ -961,7 +961,7 @@ void clean_up(bool print_message) #endif if (print_message && errmesg) - sql_print_error(ER(ER_SHUTDOWN_COMPLETE),my_progname); + sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname); #if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY) if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(0)); // This may not always exist @@ -1062,8 +1062,8 @@ static void set_user(const char *user) struct passwd *user_info= getpwnam(user); if ((!user_info || user_id != user_info->pw_uid) && global_system_variables.log_warnings) - fprintf(stderr, - "Warning: One can only use the --user switch if running as root\n"); + sql_print_warning( + "One can only use the --user switch if running as root\n"); } return; } @@ -1183,7 +1183,7 @@ static void server_init(void) if (listen(ip_sock,(int) back_log) < 0) { sql_perror("Can't start server: listen() on TCP/IP port"); - sql_print_error("Error: listen() on TCP/IP failed with error %d", + sql_print_error("listen() on TCP/IP failed with error %d", socket_errno); unireg_abort(1); } @@ -1278,7 +1278,7 @@ static void server_init(void) (void) chmod(mysqld_unix_port,S_IFSOCK); /* Fix solaris 2.6 bug */ #endif if (listen(unix_sock,(int) back_log) < 0) - sql_print_error("Warning: listen() on Unix socket failed with error %d", + sql_print_warning("listen() on Unix socket failed with error %d", socket_errno); } #endif @@ -1870,7 +1870,7 @@ static void init_signals(void) struct rlimit rl; rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings) - sql_print_error("Warning: setrlimit could not change the size of core files to 'infinity'; We may not be able to generate a core file on signals"); + sql_print_warning("setrlimit could not change the size of core files to 'infinity'; We may not be able to generate a core file on signals"); } #endif (void) sigemptyset(&set); @@ -2024,7 +2024,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) case SIGQUIT: case SIGKILL: #ifdef EXTRA_DEBUG - sql_print_error("Got signal %d to shutdown mysqld",sig); + sql_print_information("Got signal %d to shutdown mysqld",sig); #endif DBUG_PRINT("info",("Got signal: %d abort_loop: %d",sig,abort_loop)); if (!abort_loop) @@ -2036,7 +2036,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR); if (pthread_create(&tmp,&connection_attrib, kill_server_thread, (void*) sig)) - sql_print_error("Error: Can't create thread to kill server"); + sql_print_error("Can't create thread to kill server"); #else kill_server((void*) sig); // MIT THREAD has a alarm thread #endif @@ -2060,7 +2060,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) #endif default: #ifdef EXTRA_DEBUG - sql_print_error("Warning: Got signal: %d error: %d",sig,error); /* purecov: tested */ + sql_print_warning("Got signal: %d error: %d",sig,error); /* purecov: tested */ #endif break; /* purecov: tested */ } @@ -2339,11 +2339,11 @@ static int init_common_variables(const char *conf_file_name, int argc, ("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", files, max_connections, table_cache_size)); if (global_system_variables.log_warnings) - sql_print_error("Warning: Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", + sql_print_warning("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", files, max_connections, table_cache_size); } else if (global_system_variables.log_warnings) - sql_print_error("Warning: Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); + sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); } open_files_limit= files; } @@ -2523,8 +2523,8 @@ static int init_server_components() } else if (opt_log_slave_updates) { - sql_print_error("\ -Warning: you need to use --log-bin to make --log-slave-updates work. \ + sql_print_warning("\ +you need to use --log-bin to make --log-slave-updates work. \ Now disabling --log-slave-updates."); } @@ -2532,7 +2532,7 @@ Now disabling --log-slave-updates."); if (opt_log_slave_updates && replicate_same_server_id) { sql_print_error("\ -Error: using --replicate-same-server-id in conjunction with \ +using --replicate-same-server-id in conjunction with \ --log-slave-updates is impossible, it would lead to infinite loops in this \ server."); unireg_abort(1); @@ -2561,12 +2561,12 @@ server."); if (opt_innodb_safe_binlog) { if (have_innodb != SHOW_OPTION_YES) - sql_print_error("Warning: --innodb-safe-binlog is meaningful only if " + sql_print_warning("--innodb-safe-binlog is meaningful only if " "the InnoDB storage engine is enabled in the server."); #ifdef HAVE_INNOBASE_DB if (innobase_flush_log_at_trx_commit != 1) { - sql_print_error("Warning: --innodb-safe-binlog is meaningful only if " + sql_print_warning("--innodb-safe-binlog is meaningful only if " "innodb_flush_log_at_trx_commit is 1; now setting it " "to 1."); innobase_flush_log_at_trx_commit= 1; @@ -2578,14 +2578,14 @@ server."); good (especially "littlesync", and on Windows... see srv/srv0start.c). */ - sql_print_error("Warning: --innodb-safe-binlog requires that " + sql_print_warning("--innodb-safe-binlog requires that " "the innodb_flush_method actually synchronizes the " "InnoDB log to disk; it is your responsibility " "to verify that the method you chose does it."); } if (sync_binlog_period != 1) { - sql_print_error("Warning: --innodb-safe-binlog is meaningful only if " + sql_print_warning("--innodb-safe-binlog is meaningful only if " "the global sync_binlog variable is 1; now setting it " "to 1."); sync_binlog_period= 1; @@ -2624,7 +2624,7 @@ server."); if (mlockall(MCL_CURRENT)) { if (global_system_variables.log_warnings) - sql_print_error("Warning: Failed to lock memory. Errno: %d\n",errno); + sql_print_warning("Failed to lock memory. Errno: %d\n",errno); locked_in_memory= 0; } } @@ -2650,7 +2650,7 @@ static void create_maintenance_thread() { pthread_t hThread; if (pthread_create(&hThread,&connection_attrib,handle_manager,0)) - sql_print_error("Warning: Can't create thread to manage maintenance"); + sql_print_warning("Can't create thread to manage maintenance"); } } @@ -2662,7 +2662,7 @@ static void create_shutdown_thread() hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name); pthread_t hThread; if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0)) - sql_print_error("Warning: Can't create thread to handle shutdown requests"); + sql_print_warning("Can't create thread to handle shutdown requests"); // On "Stop Service" we have to do regular shutdown Service.SetShutdownEvent(hEventShutdown); @@ -2671,7 +2671,7 @@ static void create_shutdown_thread() pthread_cond_init(&eventShutdown, NULL); pthread_t hThread; if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0)) - sql_print_error("Warning: Can't create thread to handle shutdown requests"); + sql_print_warning("Can't create thread to handle shutdown requests"); #endif #endif // EMBEDDED_LIBRARY } @@ -2702,7 +2702,7 @@ static void handle_connections_methods() if (pthread_create(&hThread,&connection_attrib, handle_connections_namedpipes, 0)) { - sql_print_error("Warning: Can't create thread to handle named pipes"); + sql_print_warning("Can't create thread to handle named pipes"); handler_count--; } } @@ -2713,7 +2713,7 @@ static void handle_connections_methods() if (pthread_create(&hThread,&connection_attrib, handle_connections_sockets, 0)) { - sql_print_error("Warning: Can't create thread to handle TCP/IP"); + sql_print_warning("Can't create thread to handle TCP/IP"); handler_count--; } } @@ -2724,7 +2724,7 @@ static void handle_connections_methods() if (pthread_create(&hThread,&connection_attrib, handle_connections_shared_memory, 0)) { - sql_print_error("Warning: Can't create thread to handle shared memory"); + sql_print_warning("Can't create thread to handle shared memory"); handler_count--; } } @@ -2784,7 +2784,7 @@ int main(int argc, char **argv) if (stack_size && stack_size < thread_stack) { if (global_system_variables.log_warnings) - sql_print_error("Warning: Asked for %ld thread stack, but got %ld", + sql_print_warning("Asked for %ld thread stack, but got %ld", thread_stack, stack_size); thread_stack= stack_size; } @@ -2807,8 +2807,8 @@ int main(int argc, char **argv) if (lower_case_table_names_used) { if (global_system_variables.log_warnings) - sql_print_error("\ -Warning: You have forced lower_case_table_names to 0 through a command-line \ + sql_print_warning("\ +You have forced lower_case_table_names to 0 through a command-line \ option, even though your file system '%s' is case insensitive. This means \ that you can corrupt a MyISAM table by accessing it with different cases. \ You should consider changing lower_case_table_names to 1 or 2", @@ -2817,7 +2817,7 @@ You should consider changing lower_case_table_names to 1 or 2", else { if (global_system_variables.log_warnings) - sql_print_error("Warning: Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home); + sql_print_warning("Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home); lower_case_table_names= 2; } } @@ -2850,14 +2850,14 @@ You should consider changing lower_case_table_names to 1 or 2", #ifdef EXTRA_DEBUG switch (server_id) { case 1: - sql_print_error("\ -Warning: You have enabled the binary log, but you haven't set server-id to \ + sql_print_warning("\ +You have enabled the binary log, but you haven't set server-id to \ a non-zero value: we force server id to 1; updates will be logged to the \ binary log, but connections from slaves will not be accepted."); break; case 2: - sql_print_error("\ -Warning: You should set server-id to a non-0 value if master_host is set; \ + sql_print_warning("\ +You should set server-id to a non-0 value if master_host is set; \ we force server id to 2, but this MySQL server will not act as a slave."); break; } @@ -3197,7 +3197,7 @@ static int bootstrap(FILE *file) if (pthread_create(&thd->real_id,&connection_attrib,handle_bootstrap, (void*) thd)) { - sql_print_error("Warning: Can't create thread to handle bootstrap"); + sql_print_warning("Can't create thread to handle bootstrap"); DBUG_RETURN(-1); } /* Wait for thread to die */ @@ -5606,7 +5606,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), if (!mysqld_user || !strcmp(mysqld_user, argument)) mysqld_user= argument; else - fprintf(stderr, "Warning: Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user); + sql_print_warning("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user); break; case 'L': strmake(language, argument, sizeof(language)-1); @@ -6391,7 +6391,7 @@ static int test_if_case_insensitive(const char *dir_name) (void) my_delete(buff2, MYF(0)); if ((file= my_create(buff, 0666, O_RDWR, MYF(0))) < 0) { - sql_print_error("Warning: Can't create test file %s", buff); + sql_print_warning("Can't create test file %s", buff); DBUG_RETURN(-1); } my_close(file, MYF(0)); diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 9769ec1a55d..047db57c86c 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -314,4 +314,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 31715354101..168cddec81d 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -308,4 +308,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 06e47e006f5..32d8a2ba168 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -316,4 +316,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index a2e74460380..3303cd0666a 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -305,4 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index df29f08e752..cdfb5e9d170 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -310,4 +310,4 @@ character-set=latin7 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index f0435278440..72c2381dc70 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -305,4 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index af11e09f2f6..0818895dacb 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -317,4 +317,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 7c921beba75..4ee82d91566 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -305,4 +305,4 @@ character-set=greek "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index e961b72a38e..6be3add430e 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -307,4 +307,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 02c719fd7c0..fd2d33c5e2e 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -305,4 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 9674f690183..7ebce1cf662 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -307,4 +307,4 @@ character-set=ujis "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 417d9976b7c..f389feb7e40 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -305,4 +305,4 @@ character-set=euckr "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index ae0b307439d..088adb43c96 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -307,4 +307,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 246333af497..0e92867a201 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -307,4 +307,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 417757b2aea..c61db27cd58 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -309,4 +309,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 344860280cb..66b3d9a516b 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -306,4 +306,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 6b64d103e61..43c669cb4f9 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -309,4 +309,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 642b792a24f..311cfd35cb5 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -307,4 +307,4 @@ character-set=koi8r "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 8c8bc6e9729..45b56c8269c 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -311,4 +311,4 @@ character-set=cp1250 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 23814b2cbc2..e45858805db 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -313,4 +313,4 @@ character-set=latin2 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 113157858ad..9a3296cb405 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -307,4 +307,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 8b43ea8ed0e..85271f81b2b 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -305,4 +305,4 @@ character-set=latin1 "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 4c762bf5313..87789018185 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -310,4 +310,4 @@ character-set=koi8u "Invalid TIMESTAMP value in column '%s' at row %ld", "Invalid %s character string: '%.64s'", "Result of %s() was larger than max_allowed_packet (%ld) - truncated" -"Conflicting declarations: '%s' and '%s'" +"Conflicting declarations: '%s%s' and '%s%s'" diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index fd3d27099ed..9c6853187f6 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -251,9 +251,9 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) { global_system_variables.old_passwords= 1; pthread_mutex_unlock(&LOCK_global_system_variables); - sql_print_error("mysql.user table is not updated to new password format; " - "Disabling new password usage until " - "mysql_fix_privilege_tables is run"); + sql_print_warning("mysql.user table is not updated to new password format; " + "Disabling new password usage until " + "mysql_fix_privilege_tables is run"); } thd->variables.old_passwords= 1; } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 26e2cebb909..84821cb8748 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1323,7 +1323,7 @@ void select_dumpvar::cleanup() Item_arena::Item_arena(THD* thd) :free_list(0), - state((int)INITIALIZED) + state(INITIALIZED) { init_sql_alloc(&mem_root, thd->variables.query_alloc_block_size, @@ -1335,7 +1335,7 @@ Item_arena::Item_arena(THD* thd) Item_arena::Item_arena() :free_list(0), - state((int)CONVENTIONAL_EXECUTION) + state(CONVENTIONAL_EXECUTION) { clear_alloc_root(&mem_root); } @@ -1343,7 +1343,7 @@ Item_arena::Item_arena() Item_arena::Item_arena(bool init_mem_root) :free_list(0), - state((int)INITIALIZED) + state(INITIALIZED) { if (init_mem_root) clear_alloc_root(&mem_root); @@ -1503,7 +1503,7 @@ Statement_map::Statement_map() : hash_init(&st_hash, default_charset_info, START_STMT_HASH_SIZE, 0, 0, get_statement_id_as_hash_key, delete_statement_as_hash_key, MYF(0)); - hash_init(&names_hash, &my_charset_bin, START_NAME_HASH_SIZE, 0, 0, + hash_init(&names_hash, system_charset_info, START_NAME_HASH_SIZE, 0, 0, (hash_get_key) get_stmt_name_hash_key, NULL,MYF(0)); } diff --git a/sql/sql_class.h b/sql/sql_class.h index 198e06bb3bd..a8035cffd96 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -427,13 +427,13 @@ public: */ Item *free_list; MEM_ROOT mem_root; - enum + enum enum_state { INITIALIZED= 0, PREPARED= 1, EXECUTED= 3, CONVENTIONAL_EXECUTION= 2, ERROR= -1 }; - int state; + enum_state state; /* We build without RTTI, so dynamic_cast can't be used. */ enum Type @@ -447,8 +447,8 @@ public: virtual Type type() const; virtual ~Item_arena(); - inline bool is_stmt_prepare() const { return state < (int)PREPARED; } - inline bool is_first_stmt_execute() const { return state == (int)PREPARED; } + inline bool is_stmt_prepare() const { return (int)state < (int)PREPARED; } + inline bool is_first_stmt_execute() const { return state == PREPARED; } inline gptr alloc(unsigned int size) { return alloc_root(&mem_root,size); } inline gptr calloc(unsigned int size) { diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index baff7bd604d..708ca3a516f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -132,7 +132,7 @@ find_prepared_statement(THD *thd, ulong id, const char *where, { Statement *stmt= thd->stmt_map.find(id); - if (stmt == 0 || stmt->type() != (int)Item_arena::PREPARED_STATEMENT) + if (stmt == 0 || stmt->type() != Item_arena::PREPARED_STATEMENT) { char llbuf[22]; my_error(ER_UNKNOWN_STMT_HANDLER, MYF(0), 22, llstr(id, llbuf), where); @@ -1619,7 +1619,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, { sl->prep_where= sl->where; } - stmt->state= (int)Prepared_statement::PREPARED; + stmt->state= Item_arena::PREPARED; } DBUG_RETURN(!stmt); @@ -1736,7 +1736,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) DBUG_PRINT("exec_query:", ("%s", stmt->query)); /* Check if we got an error when sending long data */ - if (stmt->state == (int)Item_arena::ERROR) + if (stmt->state == Item_arena::ERROR) { send_error(thd, stmt->last_errno, stmt->last_error); DBUG_VOID_RETURN; @@ -1853,7 +1853,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, transformations of the query tree (i.e. negations elimination). This should be done permanently on the parse tree of this statement. */ - if (stmt->state == (int)Item_arena::PREPARED) + if (stmt->state == Item_arena::PREPARED) thd->current_arena= stmt; if (!(specialflag & SPECIAL_NO_PRIOR)) @@ -1866,10 +1866,10 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, /* Free Items that were created during this execution of the PS. */ free_items(thd->free_list); thd->free_list= 0; - if (stmt->state == (int)Item_arena::PREPARED) + if (stmt->state == Item_arena::PREPARED) { thd->current_arena= thd; - stmt->state= (int)Item_arena::EXECUTED; + stmt->state= Item_arena::EXECUTED; } cleanup_items(stmt->free_list); reset_stmt_params(stmt); @@ -1908,7 +1908,7 @@ void mysql_stmt_reset(THD *thd, char *packet) SEND_ERROR))) DBUG_VOID_RETURN; - stmt->state= (int)Item_arena::PREPARED; + stmt->state= Item_arena::PREPARED; /* Clear parameters from data which could be set by @@ -1996,7 +1996,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) if (param_number >= stmt->param_count) { /* Error will be sent in execute call */ - stmt->state= (int)Item_arena::ERROR; + stmt->state= Item_arena::ERROR; stmt->last_errno= ER_WRONG_ARGUMENTS; sprintf(stmt->last_error, ER(ER_WRONG_ARGUMENTS), "mysql_stmt_send_long_data"); @@ -2012,7 +2012,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) if (param->set_longdata(thd->extra_data, thd->extra_length)) #endif { - stmt->state= (int)Item_arena::ERROR; + stmt->state= Item_arena::ERROR; stmt->last_errno= ER_OUTOFMEMORY; sprintf(stmt->last_error, ER(ER_OUTOFMEMORY), 0); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1c057e03a11..7194cc72c04 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1215,12 +1215,9 @@ default_charset: cinfo->default_table_charset && $4 && !my_charset_same(cinfo->default_table_charset,$4)) { - char cs1[32]; - char cs2[32]; - my_snprintf(cs1, sizeof(cs1), "CHARACTER SET %s", - cinfo->default_table_charset->csname); - my_snprintf(cs2, sizeof(cs2), "CHARACTER SET %s", $4->csname); - net_printf(YYTHD, ER_CONFLICTING_DECLARATIONS, cs1, cs2); + net_printf(YYTHD, ER_CONFLICTING_DECLARATIONS, + "CHARACTER SET ", cinfo->default_table_charset->csname, + "CHARACTER SET ", $4->csname); YYABORT; } Lex->create_info.default_table_charset= $4; diff --git a/sql/tztime.cc b/sql/tztime.cc index 610f75f1643..af9af530fec 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -1560,8 +1560,8 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) if (open_tables(thd, tables_buff, &counter) || lock_tables(thd, tables_buff, counter)) { - sql_print_error("Warning: Can't open and lock time zone table: %s " - "trying to live without them", thd->net.last_error); + sql_print_warning("Can't open and lock time zone table: %s " + "trying to live without them", thd->net.last_error); /* We will try emulate that everything is ok */ return_val= time_zone_tables_exist= 0; goto end_with_setting_default_tz; @@ -1740,8 +1740,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) if (!(alloc_buff= alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) + tz_name->length() + 1))) { - sql_print_error("Error: Out of memory while loading time zone " - "description"); + sql_print_error("Out of memory while loading time zone description"); return 0; } tz_info= (TIME_ZONE_INFO *)alloc_buff; @@ -1757,7 +1756,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) Let us find out time zone id by its name (there is only one index and it is specifically for this purpose). */ - table= tz_tables->table; + table= tz_tables->table; tz_tables= tz_tables->next; table->field[0]->store(tz_name->ptr(), tz_name->length(), &my_charset_latin1); /* @@ -1770,7 +1769,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 0, HA_READ_KEY_EXACT)) { - sql_print_error("Error: Can't find description of time zone."); + sql_print_error("Can't find description of time zone."); goto end; } @@ -1783,7 +1782,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) understand whenever this timezone uses leap seconds (again we are using the only index in this table). */ - table= tz_tables->table; + table= tz_tables->table; tz_tables= tz_tables->next; table->field[0]->store((longlong)tzid); (void)table->file->ha_index_init(0); @@ -1791,7 +1790,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, 0, HA_READ_KEY_EXACT)) { - sql_print_error("Error: Can't find description of time zone."); + sql_print_error("Can't find description of time zone."); goto end; } @@ -1810,7 +1809,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) only for our time zone guess what are we doing? Right - using special index. */ - table= tz_tables->table; + table= tz_tables->table; tz_tables= tz_tables->next; table->field[0]->store((longlong)tzid); (void)table->file->ha_index_init(0); @@ -1948,8 +1947,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) #endif sizeof(TRAN_TYPE_INFO) * tz_info->typecnt))) { - sql_print_error("Error: Out of memory while loading time zone " - "description"); + sql_print_error("Out of memory while loading time zone description"); goto end; } @@ -1974,12 +1972,12 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ if (tz_info->typecnt < 1) { - sql_print_error("Error: loading time zone without transition types"); + sql_print_error("loading time zone without transition types"); goto end; } if (prepare_tz_info(tz_info, &tz_storage)) { - sql_print_error("Error: Unable to build mktime map for time zone"); + sql_print_error("Unable to build mktime map for time zone"); goto end; } @@ -1991,7 +1989,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) &my_charset_latin1), my_hash_insert(&tz_names, (const byte *)tmp_tzname))) { - sql_print_error("Error: Out of memory while loading time zone"); + sql_print_error("Out of memory while loading time zone"); goto end; } diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 7c3baac3c39..5e339725b1a 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1,15 +1,15 @@ /* Copyright (C) 2000 MySQL AB - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -1524,7 +1524,7 @@ MY_UNICASE_INFO *uni_plane[256]={ #ifdef HAVE_CHARSET_utf8 -/* +/* We consider bytes with code more than 127 as a letter. This garantees that word boundaries work fine with regular expressions. Note, there is no need to mark byte 255 as a @@ -1590,99 +1590,108 @@ static uchar to_upper_utf8[] = { 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 }; +static inline int bincmp(const uchar *s, const uchar *se, + const uchar *t, const uchar *te) +{ + int slen=se-s, tlen=te-t; + int len=min(slen,tlen); + int cmp= memcmp(s,t,len); + return cmp ? cmp : slen-tlen; +} + static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t * pwc, const uchar *s, const uchar *e) + my_wc_t * pwc, const uchar *s, const uchar *e) { unsigned char c; - + if (s >= e) return MY_CS_TOOFEW(0); c= s[0]; - if (c < 0x80) + if (c < 0x80) { *pwc = c; return 1; - } - else if (c < 0xc2) + } + else if (c < 0xc2) return MY_CS_ILSEQ; - else if (c < 0xe0) + else if (c < 0xe0) { - if (s+2 > e) /* We need 2 characters */ + if (s+2 > e) /* We need 2 characters */ return MY_CS_TOOFEW(0); - + if (!((s[1] ^ 0x80) < 0x40)) return MY_CS_ILSEQ; - + *pwc = ((my_wc_t) (c & 0x1f) << 6) | (my_wc_t) (s[1] ^ 0x80); return 2; - } - else if (c < 0xf0) + } + else if (c < 0xf0) { if (s+3 > e) /* We need 3 characters */ return MY_CS_TOOFEW(0); - + if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0))) return MY_CS_ILSEQ; - - *pwc = ((my_wc_t) (c & 0x0f) << 12) | - ((my_wc_t) (s[1] ^ 0x80) << 6) | + + *pwc = ((my_wc_t) (c & 0x0f) << 12) | + ((my_wc_t) (s[1] ^ 0x80) << 6) | (my_wc_t) (s[2] ^ 0x80); - + return 3; - } + } #ifdef UNICODE_32BIT - else if (c < 0xf8 && sizeof(my_wc_t)*8 >= 32) + else if (c < 0xf8 && sizeof(my_wc_t)*8 >= 32) { if (s+4 > e) /* We need 4 characters */ return MY_CS_TOOFEW(0); - - if (!((s[1] ^ 0x80) < 0x40 && - (s[2] ^ 0x80) < 0x40 && - (s[3] ^ 0x80) < 0x40 && + + if (!((s[1] ^ 0x80) < 0x40 && + (s[2] ^ 0x80) < 0x40 && + (s[3] ^ 0x80) < 0x40 && (c >= 0xf1 || s[1] >= 0x90))) return MY_CS_ILSEQ; - - *pwc = ((my_wc_t) (c & 0x07) << 18) | - ((my_wc_t) (s[1] ^ 0x80) << 12) | - ((my_wc_t) (s[2] ^ 0x80) << 6) | + + *pwc = ((my_wc_t) (c & 0x07) << 18) | + ((my_wc_t) (s[1] ^ 0x80) << 12) | + ((my_wc_t) (s[2] ^ 0x80) << 6) | (my_wc_t) (s[3] ^ 0x80); - + return 4; } - else if (c < 0xfc && sizeof(my_wc_t)*8 >= 32) + else if (c < 0xfc && sizeof(my_wc_t)*8 >= 32) { if (s+5 >e) /* We need 5 characters */ return MY_CS_TOOFEW(0); - - if (!((s[1] ^ 0x80) < 0x40 && - (s[2] ^ 0x80) < 0x40 && - (s[3] ^ 0x80) < 0x40 && - (s[4] ^ 0x80) < 0x40 && + + if (!((s[1] ^ 0x80) < 0x40 && + (s[2] ^ 0x80) < 0x40 && + (s[3] ^ 0x80) < 0x40 && + (s[4] ^ 0x80) < 0x40 && (c >= 0xf9 || s[1] >= 0x88))) return MY_CS_ILSEQ; - - *pwc = ((my_wc_t) (c & 0x03) << 24) | + + *pwc = ((my_wc_t) (c & 0x03) << 24) | ((my_wc_t) (s[1] ^ 0x80) << 18) | ((my_wc_t) (s[2] ^ 0x80) << 12) | ((my_wc_t) (s[3] ^ 0x80) << 6) | (my_wc_t) (s[4] ^ 0x80); return 5; - } - else if (c < 0xfe && sizeof(my_wc_t)*8 >= 32) + } + else if (c < 0xfe && sizeof(my_wc_t)*8 >= 32) { if ( s+6 >e ) /* We need 6 characters */ return MY_CS_TOOFEW(0); - - if (!((s[1] ^ 0x80) < 0x40 && - (s[2] ^ 0x80) < 0x40 && - (s[3] ^ 0x80) < 0x40 && - (s[4] ^ 0x80) < 0x40 && - (s[5] ^ 0x80) < 0x40 && + + if (!((s[1] ^ 0x80) < 0x40 && + (s[2] ^ 0x80) < 0x40 && + (s[3] ^ 0x80) < 0x40 && + (s[4] ^ 0x80) < 0x40 && + (s[5] ^ 0x80) < 0x40 && (c >= 0xfd || s[1] >= 0x84))) return MY_CS_ILSEQ; - + *pwc = ((my_wc_t) (c & 0x01) << 30) | ((my_wc_t) (s[1] ^ 0x80) << 24) | ((my_wc_t) (s[2] ^ 0x80) << 18) @@ -1702,12 +1711,12 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) , if (r >= e) return MY_CS_TOOSMALL; - - if (wc < 0x80) + + if (wc < 0x80) count = 1; - else if (wc < 0x800) + else if (wc < 0x800) count = 2; - else if (wc < 0x10000) + else if (wc < 0x10000) count = 3; #ifdef UNICODE_32BIT else if (wc < 0x200000) @@ -1718,15 +1727,15 @@ static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) , count = 6; #endif else return MY_CS_ILUNI; - - /* - e is a character after the string r, not the last character of it. + + /* + e is a character after the string r, not the last character of it. Because of it (r+count > e), not (r+count-1 >e ) */ - if ( r+count > e ) + if ( r+count > e ) return MY_CS_TOOSMALL; - - switch (count) { + + switch (count) { /* Fall through all cases!!! */ #ifdef UNICODE_32BIT case 6: r[5] = (uchar) (0x80 | (wc & 0x3f)); wc = wc >> 6; wc |= 0x4000000; @@ -1806,8 +1815,8 @@ static void my_casedn_str_utf8(CHARSET_INFO *cs, char * s) } -static int my_strnncoll_utf8(CHARSET_INFO *cs, - const uchar *s, uint slen, +static int my_strnncoll_utf8(CHARSET_INFO *cs, + const uchar *s, uint slen, const uchar *t, uint tlen, my_bool t_is_prefix) { @@ -1821,13 +1830,13 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, int plane; s_res=my_utf8_uni(cs,&s_wc, s, se); t_res=my_utf8_uni(cs,&t_wc, t, te); - + if ( s_res <= 0 || t_res <= 0 ) { - /* Incorrect string, compare by char value */ - return ((int)s[0]-(int)t[0]); + /* Incorrect string, compare byte by byte value */ + return bincmp(s, se, t, te); } - + plane=(s_wc>>8) & 0xFF; s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].sort : s_wc; plane=(t_wc>>8) & 0xFF; @@ -1836,7 +1845,7 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, { return ((int) s_wc) - ((int) t_wc); } - + s+=s_res; t+=t_res; } @@ -1850,11 +1859,11 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, SYNOPSIS my_strnncollsp_utf8() - cs character set handler - a First string to compare - a_length Length of 'a' - b Second string to compare - b_length Length of 'b' + cs character set handler + a First string to compare + a_length Length of 'a' + b Second string to compare + b_length Length of 'b' IMPLEMENTATION If one string is shorter as the other, then we space extend the other @@ -1867,32 +1876,32 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, "a\0" < "a " RETURN - < 0 a < b - = 0 a == b - > 0 a > b + < 0 a < b + = 0 a == b + > 0 a > b */ -static int my_strnncollsp_utf8(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) +static int my_strnncollsp_utf8(CHARSET_INFO *cs, + const uchar *s, uint slen, + const uchar *t, uint tlen) { int s_res,t_res; my_wc_t s_wc,t_wc; const uchar *se= s+slen; const uchar *te= t+tlen; - + while ( s < se && t < te ) { int plane; s_res=my_utf8_uni(cs,&s_wc, s, se); t_res=my_utf8_uni(cs,&t_wc, t, te); - + if ( s_res <= 0 || t_res <= 0 ) { - /* Incorrect string, compare by char value */ - return ((int)s[0]-(int)t[0]); + /* Incorrect string, compare byte by byte value */ + return bincmp(s, se, t, te); } - + plane=(s_wc>>8) & 0xFF; s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].sort : s_wc; plane=(t_wc>>8) & 0xFF; @@ -1901,14 +1910,14 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, { return ((int) s_wc) - ((int) t_wc); } - + s+=s_res; t+=t_res; } - + slen= se-s; tlen= te-t; - + if (slen != tlen) { int swap= 0; @@ -1940,35 +1949,35 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, static int my_strncasecmp_utf8(CHARSET_INFO *cs, - const char *s, const char *t, uint len) + const char *s, const char *t, uint len) { int s_res,t_res; my_wc_t s_wc,t_wc; const char *se=s+len; const char *te=t+len; - + while ( s < se && t < te ) { int plane; - + s_res=my_utf8_uni(cs,&s_wc, (const uchar*)s, (const uchar*)se); t_res=my_utf8_uni(cs,&t_wc, (const uchar*)t, (const uchar*)te); - + if ( s_res <= 0 || t_res <= 0 ) { - /* Incorrect string, compare by char value */ - return ((int)s[0]-(int)t[0]); + /* Incorrect string, compare byte by byte value */ + return bincmp(s, se, t, te); } - + plane=(s_wc>>8) & 0xFF; s_wc = uni_plane[plane] ? uni_plane[plane][s_wc & 0xFF].tolower : s_wc; plane=(t_wc>>8) & 0xFF; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].tolower : t_wc; - + if ( s_wc != t_wc ) return ((int) s_wc) - ((int) t_wc); - + s+=s_res; t+=t_res; } @@ -1983,9 +1992,9 @@ static int my_strcasecmp_utf8(CHARSET_INFO *cs, const char *s, const char *t) return my_strncasecmp_utf8(cs, s, t, len); } -static int my_strnxfrm_utf8(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static int my_strnxfrm_utf8(CHARSET_INFO *cs, + uchar *dst, uint dstlen, + const uchar *src, uint srclen) { my_wc_t wc; int res; @@ -2002,10 +2011,10 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, } src+=res; srclen-=res; - + plane=(wc>>8) & 0xFF; wc = uni_plane[plane] ? uni_plane[plane][wc & 0xFF].sort : wc; - + if ((res=my_uni_utf8(cs,wc,dst,de)) <0) { break; @@ -2026,18 +2035,18 @@ static int my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)) , uint c) { if (c < 0x80) return 1; - else if (c < 0xc2) + else if (c < 0xc2) return 0; /* Illegal mb head */ - else if (c < 0xe0) + else if (c < 0xe0) return 2; - else if (c < 0xf0) + else if (c < 0xf0) return 3; #ifdef UNICODE_32BIT - else if (c < 0xf8) + else if (c < 0xf8) return 4; - else if (c < 0xfc) + else if (c < 0xfc) return 5; - else if (c < 0xfe) + else if (c < 0xfe) return 6; #endif return 0; /* Illegal mb head */; @@ -2046,7 +2055,7 @@ static int my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)) , uint c) static MY_COLLATION_HANDLER my_collation_ci_handler = { - NULL, /* init */ + NULL, /* init */ my_strnncoll_utf8, my_strnncollsp_utf8, my_strnxfrm_utf8, @@ -2059,7 +2068,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = MY_CHARSET_HANDLER my_charset_utf8_handler= { - NULL, /* init */ + NULL, /* init */ my_ismbchar_utf8, my_mbcharlen_utf8, my_numchars_mb, @@ -2089,27 +2098,27 @@ MY_CHARSET_HANDLER my_charset_utf8_handler= CHARSET_INFO my_charset_utf8_general_ci= { - 33,0,0, /* number */ - MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE, /* state */ - "utf8", /* cs name */ - "utf8_general_ci", /* name */ - "", /* comment */ - NULL, /* tailoring */ - ctype_utf8, /* ctype */ - to_lower_utf8, /* to_lower */ - to_upper_utf8, /* to_upper */ - to_upper_utf8, /* sort_order */ - NULL, /* contractions */ - NULL, /* sort_order_big*/ - NULL, /* tab_to_uni */ - NULL, /* tab_from_uni */ - NULL, /* state_map */ - NULL, /* ident_map */ - 1, /* strxfrm_multiply */ - 1, /* mbminlen */ - 3, /* mbmaxlen */ - 0, /* min_sort_char */ - 255, /* max_sort_char */ + 33,0,0, /* number */ + MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM|MY_CS_UNICODE, /* state */ + "utf8", /* cs name */ + "utf8_general_ci", /* name */ + "", /* comment */ + NULL, /* tailoring */ + ctype_utf8, /* ctype */ + to_lower_utf8, /* to_lower */ + to_upper_utf8, /* to_upper */ + to_upper_utf8, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* mbminlen */ + 3, /* mbmaxlen */ + 0, /* min_sort_char */ + 255, /* max_sort_char */ &my_charset_utf8_handler, &my_collation_ci_handler }; @@ -2117,27 +2126,27 @@ CHARSET_INFO my_charset_utf8_general_ci= CHARSET_INFO my_charset_utf8_bin= { - 83,0,0, /* number */ - MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE, /* state */ - "utf8", /* cs name */ - "utf8_bin", /* name */ - "", /* comment */ - NULL, /* tailoring */ - ctype_utf8, /* ctype */ - to_lower_utf8, /* to_lower */ - to_upper_utf8, /* to_upper */ - NULL, /* sort_order */ - NULL, /* contractions */ - NULL, /* sort_order_big*/ - NULL, /* tab_to_uni */ - NULL, /* tab_from_uni */ - NULL, /* state_map */ - NULL, /* ident_map */ - 1, /* strxfrm_multiply */ - 1, /* mbminlen */ - 3, /* mbmaxlen */ - 0, /* min_sort_char */ - 255, /* max_sort_char */ + 83,0,0, /* number */ + MY_CS_COMPILED|MY_CS_BINSORT|MY_CS_UNICODE, /* state */ + "utf8", /* cs name */ + "utf8_bin", /* name */ + "", /* comment */ + NULL, /* tailoring */ + ctype_utf8, /* ctype */ + to_lower_utf8, /* to_lower */ + to_upper_utf8, /* to_upper */ + NULL, /* sort_order */ + NULL, /* contractions */ + NULL, /* sort_order_big*/ + NULL, /* tab_to_uni */ + NULL, /* tab_from_uni */ + NULL, /* state_map */ + NULL, /* ident_map */ + 1, /* strxfrm_multiply */ + 1, /* mbminlen */ + 3, /* mbmaxlen */ + 0, /* min_sort_char */ + 255, /* max_sort_char */ &my_charset_utf8_handler, &my_collation_mb_bin_handler }; @@ -2155,8 +2164,8 @@ static void test_mb(CHARSET_INFO *cs, uchar *s) int len=my_mbcharlen_utf8(cs,*s); while(len--) { - printf("%c",*s); - s++; + printf("%c",*s); + s++; } printf("\n"); } @@ -2172,23 +2181,23 @@ int main() { char str[1024]=" utf8 test проба ПЕРА по-РУССКИ"; CHARSET_INFO *cs; - + test_mb(cs,(uchar*)str); - + printf("orig :'%s'\n",str); - + my_caseup_utf8(cs,str,15); printf("caseup :'%s'\n",str); - + my_caseup_str_utf8(cs,str); printf("caseup_str:'%s'\n",str); - + my_casedn_utf8(cs,str,15); printf("casedn :'%s'\n",str); - + my_casedn_str_utf8(cs,str); printf("casedn_str:'%s'\n",str); - + return 0; } |