]> git.pld-linux.org Git - packages/mysql.git/blob - mysql-bk-20071202.patch
This commit was manufactured by cvs2git to create branch 'MYSQL_4_1'.
[packages/mysql.git] / mysql-bk-20071202.patch
1 diff -urN mysql-4.1.23/BK/keys mysql-4.1/BK/keys
2 --- mysql-4.1.23/BK/keys        2007-12-02 20:38:52.000000000 +0100
3 +++ mysql-4.1/BK/keys   2007-11-29 23:23:39.000000000 +0100
4 @@ -1,2 +1,2 @@
5  ROOTKEY=3985cf0cwNRCED_XNSCA7RvkLPer2Q
6 -TIPKEY=466e5874F5N8tMqwd_kEmlTPE9UlnA
7 +TIPKEY=47448694WzdmhSoqwUkknsFfid9jmw
8 diff -urN mysql-4.1.23/client/mysqldump.c mysql-4.1/client/mysqldump.c
9 --- mysql-4.1.23/client/mysqldump.c     2007-12-02 20:38:26.000000000 +0100
10 +++ mysql-4.1/client/mysqldump.c        2007-10-04 08:27:01.000000000 +0200
11 @@ -2428,6 +2428,18 @@
12      need the REPEATABLE READ level (not anything lower, for example READ
13      COMMITTED would give one new consistent read per dumped table).
14    */
15 +  if ((mysql_get_server_version(mysql_con) < 40100) && opt_master_data)
16 +  {
17 +    fprintf(stderr, "-- %s: the combination of --single-transaction and "
18 +            "--master-data requires a MySQL server version of at least 4.1 "
19 +            "(current server's version is %s). %s\n",
20 +            ignore_errors ? "Warning" : "Error",
21 +            mysql_con->server_version ? mysql_con->server_version : "unknown",
22 +            ignore_errors ? "Continuing due to --force, backup may not be consistent across all tables!" : "Aborting.");
23 +    if (!ignore_errors)
24 +      exit(EX_MYSQLERR);
25 +  }
26 +
27    return (mysql_query_with_error_report(mysql_con, 0,
28                                          "SET SESSION TRANSACTION ISOLATION "
29                                          "LEVEL REPEATABLE READ") ||
30 diff -urN mysql-4.1.23/client/mysqltest.c mysql-4.1/client/mysqltest.c
31 --- mysql-4.1.23/client/mysqltest.c     2007-12-02 20:38:52.000000000 +0100
32 +++ mysql-4.1/client/mysqltest.c        2007-06-01 19:57:26.000000000 +0200
33 @@ -1125,6 +1125,50 @@
34  }
35  
36  
37 +/*
38 +   Remove surrounding chars from string
39 +
40 +   Return 1 if first character is found but not last
41 +*/
42 +static int strip_surrounding(char* str, char c1, char c2)
43 +{
44 +  char* ptr= str;
45 +
46 +  /* Check if the first non space character is c1 */
47 +  while(*ptr && my_isspace(charset_info, *ptr))
48 +    ptr++;
49 +  if (*ptr == c1)
50 +  {
51 +    /* Replace it with a space */
52 +    *ptr= ' ';
53 +
54 +    /* Last non space charecter should be c2 */
55 +    ptr= strend(str)-1;
56 +    while(*ptr && my_isspace(charset_info, *ptr))
57 +      ptr--;
58 +    if (*ptr == c2)
59 +    {
60 +      /* Replace it with \0 */
61 +      *ptr= 0;
62 +    }
63 +    else
64 +    {
65 +      /* Mismatch detected */
66 +      return 1;
67 +    }
68 +  }
69 +  return 0;
70 +}
71 +
72 +
73 +static void strip_parentheses(struct st_command *command)
74 +{
75 +  if (strip_surrounding(command->first_argument, '(', ')'))
76 +      die("%.*s - argument list started with '%c' must be ended with '%c'",
77 +          command->first_word_len, command->query, '(', ')');
78 +}
79 +
80 +
81  static byte *get_var_key(const byte* var, uint* len,
82                    my_bool __attribute__((unused)) t)
83  {
84 @@ -1380,12 +1424,11 @@
85    init_dynamic_string(&ds_query, 0, (end - query) + 32, 256);
86    do_eval(&ds_query, query, end, FALSE);
87  
88 -  if (mysql_real_query(mysql, ds_query.str, ds_query.length) ||
89 -      !(res = mysql_store_result(mysql)))
90 -  {
91 +  if (mysql_real_query(mysql, ds_query.str, ds_query.length))
92      die("Error running query '%s': %d %s", ds_query.str,
93         mysql_errno(mysql), mysql_error(mysql));
94 -  }
95 +  if (!(res= mysql_store_result(mysql)))
96 +    die("Query '%s' didn't return a result set", ds_query.str);
97    dynstr_free(&ds_query);
98  
99    if ((row = mysql_fetch_row(res)) && row[0])
100 @@ -1440,6 +1483,130 @@
101  }
102  
103  
104 +/*
105 +  Set variable from the result of a field in a query
106 +
107 +  This function is useful when checking for a certain value
108 +  in the output from a query that can't be restricted to only
109 +  return some values. A very good example of that is most SHOW
110 +  commands.
111 +
112 +  SYNOPSIS
113 +  var_set_query_get_value()
114 +
115 +  DESCRIPTION
116 +  let $variable= query_get_value(<query to run>,<column name>,<row no>);
117 +
118 +  <query to run> -    The query that should be sent to the server
119 +  <column name> -     Name of the column that holds the field be compared
120 +                      against the expected value
121 +  <row no> -          Number of the row that holds the field to be
122 +                      compared against the expected value
123 +
124 +*/
125 +
126 +void var_set_query_get_value(struct st_command *command, VAR *var)
127 +{
128 +  ulong row_no;
129 +  int col_no= -1;
130 +  MYSQL_RES* res;
131 +  MYSQL* mysql= &cur_con->mysql;
132 +
133 +  static DYNAMIC_STRING ds_query;
134 +  static DYNAMIC_STRING ds_col;
135 +  static DYNAMIC_STRING ds_row;
136 +  const struct command_arg query_get_value_args[] = {
137 +    "query", ARG_STRING, TRUE, &ds_query, "Query to run",
138 +    "column name", ARG_STRING, TRUE, &ds_col, "Name of column",
139 +    "row number", ARG_STRING, TRUE, &ds_row, "Number for row",
140 +  };
141 +
142 +  DBUG_ENTER("var_set_query_get_value");
143 +  LINT_INIT(res);
144 +
145 +  strip_parentheses(command);
146 +  DBUG_PRINT("info", ("query: %s", command->query));
147 +  check_command_args(command, command->first_argument, query_get_value_args,
148 +                     sizeof(query_get_value_args)/sizeof(struct command_arg),
149 +                     ',');
150 +
151 +  DBUG_PRINT("info", ("query: %s", ds_query.str));
152 +  DBUG_PRINT("info", ("col: %s", ds_col.str));
153 +
154 +  /* Convert row number to int */
155 +  if (!str2int(ds_row.str, 10, (long) 0, (long) INT_MAX, &row_no))
156 +    die("Invalid row number: '%s'", ds_row.str);
157 +  DBUG_PRINT("info", ("row: %s, row_no: %ld", ds_row.str, row_no));
158 +  dynstr_free(&ds_row);
159 +
160 +  /* Remove any surrounding "'s from the query - if there is any */
161 +  if (strip_surrounding(ds_query.str, '"', '"'))
162 +    die("Mismatched \"'s around query '%s'", ds_query.str);
163 +
164 +  /* Run the query */
165 +  if (mysql_real_query(mysql, ds_query.str, ds_query.length))
166 +    die("Error running query '%s': %d %s", ds_query.str,
167 +       mysql_errno(mysql), mysql_error(mysql));
168 +  if (!(res= mysql_store_result(mysql)))
169 +    die("Query '%s' didn't return a result set", ds_query.str);
170 +
171 +  {
172 +    /* Find column number from the given column name */
173 +    uint i;
174 +    uint num_fields= mysql_num_fields(res);
175 +    MYSQL_FIELD *fields= mysql_fetch_fields(res);
176 +
177 +    for (i= 0; i < num_fields; i++)
178 +    {
179 +      if (strcmp(fields[i].name, ds_col.str) == 0 &&
180 +          strlen(fields[i].name) == ds_col.length)
181 +      {
182 +        col_no= i;
183 +        break;
184 +      }
185 +    }
186 +    if (col_no == -1)
187 +    {
188 +      mysql_free_result(res);
189 +      die("Could not find column '%s' in the result of '%s'",
190 +          ds_col.str, ds_query.str);
191 +    }
192 +    DBUG_PRINT("info", ("Found column %d with name '%s'",
193 +                        i, fields[i].name));
194 +  }
195 +  dynstr_free(&ds_col);
196 +
197 +  {
198 +    /* Get the value */
199 +    MYSQL_ROW row;
200 +    ulong rows= 0;
201 +    const char* value= "No such row";
202 +
203 +    while ((row= mysql_fetch_row(res)))
204 +    {
205 +      if (++rows == row_no)
206 +      {
207 +
208 +        DBUG_PRINT("info", ("At row %ld, column %d is '%s'",
209 +                            row_no, col_no, row[col_no]));
210 +        /* Found the row to get */
211 +        if (row[col_no])
212 +          value= row[col_no];
213 +        else
214 +          value= "NULL";
215 +
216 +        break;
217 +      }
218 +    }
219 +    eval_expr(var, value, 0);
220 +  }
221 +  dynstr_free(&ds_query);
222 +  mysql_free_result(res);
223 +
224 +  DBUG_VOID_RETURN;
225 +}
226 +
227 +
228  void var_copy(VAR *dest, VAR *src)
229  {
230    dest->int_val= src->int_val;
231 @@ -1463,26 +1630,47 @@
232  
233  void eval_expr(VAR *v, const char *p, const char **p_end)
234  {
235 -  static int MIN_VAR_ALLOC= 32; /* MASV why 32? */
236 -  VAR *vp;
237 +
238 +  DBUG_ENTER("eval_expr");
239 +  DBUG_PRINT("enter", ("p: '%s'", p));
240 +
241    if (*p == '$')
242    {
243 +    VAR *vp;
244      if ((vp= var_get(p, p_end, 0, 0)))
245 -    {
246        var_copy(v, vp);
247 -      return;
248 -    }
249 +    DBUG_VOID_RETURN;
250    }
251 -  else if (*p == '`')
252 +
253 +  if (*p == '`')
254    {
255      var_query_set(v, p, p_end);
256 +    DBUG_VOID_RETURN;
257    }
258 -  else
259 +
260 +  {
261 +    /* Check if this is a "let $var= query_get_value()" */
262 +    const char* get_value_str= "query_get_value";
263 +    const size_t len= strlen(get_value_str);
264 +    if (strncmp(p, get_value_str, len)==0)
265 +    {
266 +      struct st_command command;
267 +      memset(&command, 0, sizeof(command));
268 +      command.query= (char*)p;
269 +      command.first_word_len= len;
270 +      command.first_argument= command.query + len;
271 +      command.end= (char*)*p_end;
272 +      var_set_query_get_value(&command, v);
273 +      DBUG_VOID_RETURN;
274 +    }
275 +  }
276 +
277    {
278      int new_val_len = (p_end && *p_end) ?
279        (int) (*p_end - p) : (int) strlen(p);
280      if (new_val_len + 1 >= v->alloced_len)
281      {
282 +      static int MIN_VAR_ALLOC= 32;
283        v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
284          MIN_VAR_ALLOC : new_val_len + 1;
285        if (!(v->str_val =
286 @@ -1495,9 +1683,10 @@
287      memcpy(v->str_val, p, new_val_len);
288      v->str_val[new_val_len] = 0;
289      v->int_val=atoi(p);
290 +    DBUG_PRINT("info", ("atoi on '%s', returns: %d", p, v->int_val));
291      v->int_dirty=0;
292    }
293 -  return;
294 +  DBUG_VOID_RETURN;
295  }
296  
297  
298 @@ -3432,7 +3621,6 @@
299    int con_port= port;
300    char *con_options;
301    bool con_ssl= 0, con_compress= 0;
302 -  char *ptr;
303  
304    static DYNAMIC_STRING ds_connection_name;
305    static DYNAMIC_STRING ds_host;
306 @@ -3460,20 +3648,7 @@
307    DBUG_ENTER("do_connect");
308    DBUG_PRINT("enter",("connect: %s", command->first_argument));
309  
310 -  /* Remove parenteses around connect arguments */
311 -  if ((ptr= strstr(command->first_argument, "(")))
312 -  {
313 -    /* Replace it with a space */
314 -    *ptr= ' ';
315 -    if ((ptr= strstr(command->first_argument, ")")))
316 -    {
317 -      /* Replace it with \0 */
318 -      *ptr= 0;
319 -    }
320 -    else
321 -      die("connect - argument list started with '(' must be ended with ')'");
322 -  }
323 -
324 +  strip_parentheses(command);
325    check_command_args(command, command->first_argument, connect_args,
326                       sizeof(connect_args)/sizeof(struct command_arg),
327                       ',');
328 @@ -4173,16 +4348,12 @@
329      DBUG_RETURN(0);
330    }
331    if (!(*command_ptr= command=
332 -        (struct st_command*) my_malloc(sizeof(*command), MYF(MY_WME))) ||
333 +        (struct st_command*) my_malloc(sizeof(*command),
334 +                                       MYF(MY_WME|MY_ZEROFILL))) ||
335        insert_dynamic(&q_lines, (gptr) &command))
336      die(NullS);
337 -
338 -  command->require_file[0]= 0;
339 -  command->first_word_len= 0;
340 -  command->query_len= 0;
341 -
342    command->type= Q_UNKNOWN;
343 -  command->query_buf= command->query= 0;
344 +
345    read_command_buf[0]= 0;
346    if (read_line(read_command_buf, sizeof(read_command_buf)))
347    {
348 diff -urN mysql-4.1.23/cmd-line-utils/libedit/el_term.h mysql-4.1/cmd-line-utils/libedit/el_term.h
349 --- mysql-4.1.23/cmd-line-utils/libedit/el_term.h       2007-12-02 20:38:26.000000000 +0100
350 +++ mysql-4.1/cmd-line-utils/libedit/el_term.h  2007-06-04 16:42:35.000000000 +0200
351 @@ -90,6 +90,16 @@
352  extern char* tgetstr(char*, char**);
353  #endif
354  
355 +
356 +#if !HAVE_DECL_TGOTO
357 +/*
358 +  'tgoto' is not declared in the system header files, this causes
359 +  problems on 64-bit systems. The function returns a 64 bit pointer
360 +  but caller see it as "int" and it's thus truncated to 32-bit
361 +*/
362 +extern char* tgoto(const char*, int, int);
363 +#endif
364 +
365  protected void term_move_to_line(EditLine *, int);
366  protected void term_move_to_char(EditLine *, int);
367  protected void term_clear_EOL(EditLine *, int);
368 diff -urN mysql-4.1.23/configure.in mysql-4.1/configure.in
369 --- mysql-4.1.23/configure.in   2007-12-02 20:38:26.000000000 +0100
370 +++ mysql-4.1/configure.in      2007-06-18 22:10:51.000000000 +0200
371 @@ -1960,6 +1960,19 @@
372  fi
373  AC_SUBST(TERMCAP_LIB)
374  
375 +# Check if the termcap function 'tgoto' is already declared in
376 +# system header files or if it need to be declared locally
377 +AC_CHECK_DECLS(tgoto,,,[
378 +#ifdef HAVE_CURSES_H
379 +# include <curses.h>
380 +#elif HAVE_NCURSES_H
381 +# include <ncurses.h>
382 +#endif
383 +#ifdef HAVE_TERM_H
384 +# include <term.h>
385 +#endif
386 +])
387 +
388  LIBEDIT_LOBJECTS=""
389  AC_CHECK_FUNC(strunvis, ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS unvis.o"])
390  AC_CHECK_FUNC(strvis,   ,[LIBEDIT_LOBJECTS="$LIBEDIT_LOBJECTS vis.o"])
391 diff -urN mysql-4.1.23/Docs/INSTALL-BINARY mysql-4.1/Docs/INSTALL-BINARY
392 --- mysql-4.1.23/Docs/INSTALL-BINARY    1970-01-01 01:00:00.000000000 +0100
393 +++ mysql-4.1/Docs/INSTALL-BINARY       2007-11-02 01:29:32.000000000 +0100
394 @@ -0,0 +1,8 @@
395 +
396 +You can find information about how to install binary distributions at
397 +
398 +  http://dev.mysql.com/doc/refman/4.1/en/quick-standard-installation.html
399 +
400 +The MySQL Reference Manual is also available in various formats on
401 +http://dev.mysql.com/doc; if you're interested in the DocBook XML
402 +sources go to http://svn.mysql.com.
403 diff -urN mysql-4.1.23/Docs/Makefile.am mysql-4.1/Docs/Makefile.am
404 --- mysql-4.1.23/Docs/Makefile.am       2007-12-02 20:38:26.000000000 +0100
405 +++ mysql-4.1/Docs/Makefile.am  2007-11-02 13:13:51.000000000 +0100
406 @@ -14,14 +14,7 @@
407  # along with this program; if not, write to the Free Software
408  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
409  
410 -noinst_SCRIPTS =       Support/generate-text-files.pl
411 -
412 -EXTRA_DIST =           $(noinst_SCRIPTS) mysql.info INSTALL-BINARY
413 -
414 -TXT_FILES=             ../INSTALL-SOURCE ../INSTALL-WIN-SOURCE \
415 -                       INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt
416 -
417 -all-local:             $(TXT_FILES)
418 +EXTRA_DIST =           mysql.info INSTALL-BINARY
419  
420  # make sure that "make install" installs the info page, too
421  # automake only seems to take care of this automatically,
422 @@ -33,26 +26,5 @@
423  uninstall-local:
424         @RM@ -f $(DESTDIR)$(infodir)/mysql.info
425  
426 -# This target is not used in builds, just for convinience
427 -CLEAN_FILES:           $(TXT_FILES)
428 -       touch $(TXT_FILES)
429 -
430 -GT = $(srcdir)/Support/generate-text-files.pl
431 -
432 -../INSTALL-SOURCE:     $(srcdir)/mysql.info $(GT)
433 -       perl -w $(GT) $(srcdir)/mysql.info "installing-source" "windows-source-build" > $@
434 -
435 -../INSTALL-WIN-SOURCE: $(srcdir)/mysql.info $(GT)
436 -       perl -w $(GT) $(srcdir)/mysql.info "windows-source-build" "post-installation" > $@
437 -
438 -# We put the description for the binary installation here so that
439 -# people who download source wont have to see it. It is moved up to
440 -# the toplevel by the script that makes the binary tar files.
441 -INSTALL-BINARY:        $(srcdir)/mysql.info $(GT)
442 -       perl -w $(GT) $(srcdir)/mysql.info "installing-binary" "installing-source" > $@
443 -
444 -../support-files/MacOSX/ReadMe.txt:    $(srcdir)/mysql.info $(GT)
445 -       perl -w $(GT) $(srcdir)/mysql.info "mac-os-x-installation" "netware-installation" > $@
446 -
447  # Don't update the files from bitkeeper
448  %::SCCS/s.%
449 diff -urN mysql-4.1.23/Docs/mysql.info mysql-4.1/Docs/mysql.info
450 --- mysql-4.1.23/Docs/mysql.info        2007-12-02 20:38:26.000000000 +0100
451 +++ mysql-4.1/Docs/mysql.info   2007-11-02 01:31:55.000000000 +0100
452 @@ -1,27 +1,4 @@
453 -This is mysql.info, produced by makeinfo version 4.8 from manual.texi.
454  
455 -START-INFO-DIR-ENTRY
456 -* mysql: (mysql).               MySQL documentation.
457 -END-INFO-DIR-ENTRY
458 -
459 -\1f
460 -File: mysql.info,  Node: Top,  Next: (dir),  Prev: (dir),  Up: (dir)
461 -
462 -This is an empty placeholder file for the MySQL manual.
463 -
464 -The MySQL manual is now maintained in a separate BitKeeper source tree!
465 -Please see `http://www.mysql.com/doc/en/Installing_source_tree.html'
466 -for more info on how to work with BitKeeper.
467 -
468 -This file will be replaced with the current `mysql.info' when building
469 -the official source distribution.
470 -
471 -You can find a specific manual for any older version of MySQL in the
472 -binary or source distribution for that version.
473 -
474 -
475 -\1f
476 -Tag Table:
477 -Node: Top\7f166
478 -\1f
479 -End Tag Table
480 +The MySQL Reference Manual is available in various formats on
481 +http://dev.mysql.com/doc; if you're interested in the DocBook XML
482 +sources go to http://svn.mysql.com.
483 diff -urN mysql-4.1.23/Docs/Support/generate-text-files.pl mysql-4.1/Docs/Support/generate-text-files.pl
484 --- mysql-4.1.23/Docs/Support/generate-text-files.pl    2007-12-02 20:38:25.000000000 +0100
485 +++ mysql-4.1/Docs/Support/generate-text-files.pl       1970-01-01 01:00:00.000000000 +0100
486 @@ -1,43 +0,0 @@
487 -#!/usr/bin/perl -w -*- perl -*-
488 -# Generate text files from top directory from the manual.
489 -
490 -$from = shift(@ARGV);
491 -$fnode = shift(@ARGV);
492 -$tnode = shift(@ARGV);
493 -
494 -open(IN, "$from") || die "Cannot open $from: $!";
495 -
496 -$in = 0;
497 -
498 -while (<IN>)
499 -{
500 -  if ($in)
501 -  {
502 -    if (/Node: $tnode,/ || /\[index/)
503 -    {
504 -      $in = 0;
505 -    }
506 -    elsif (/^File: mysql.info/ || (/^\1f/))
507 -    {
508 -      # Just Skip node beginnings
509 -    }
510 -    else
511 -    {
512 -      print;
513 -    }
514 -  }
515 -  else
516 -  {
517 -    if (/Node: $fnode,/)
518 -    {
519 -      $in = 1;
520 -      # Skip first empty line
521 -      <IN>;
522 -    }
523 -  }
524 -}
525 -
526 -close(IN);
527 -
528 -die "Could not find node \"$tnode\"" if ($in == 1);
529 -exit 0;
530 diff -urN mysql-4.1.23/heap/hp_delete.c mysql-4.1/heap/hp_delete.c
531 --- mysql-4.1.23/heap/hp_delete.c       2007-12-02 20:38:25.000000000 +0100
532 +++ mysql-4.1/heap/hp_delete.c  2007-09-13 12:39:15.000000000 +0200
533 @@ -73,10 +73,7 @@
534    int res;
535  
536    if (flag) 
537 -  {
538      info->last_pos= NULL; /* For heap_rnext/heap_rprev */
539 -    info->lastkey_len= 0;
540 -  }
541  
542    custom_arg.keyseg= keyinfo->seg;
543    custom_arg.key_length= hp_rb_make_key(keyinfo, info->recbuf, record, recpos);
544 diff -urN mysql-4.1.23/heap/hp_rfirst.c mysql-4.1/heap/hp_rfirst.c
545 --- mysql-4.1.23/heap/hp_rfirst.c       2007-12-02 20:38:51.000000000 +0100
546 +++ mysql-4.1/heap/hp_rfirst.c  2007-09-13 12:39:15.000000000 +0200
547 @@ -36,6 +36,17 @@
548              sizeof(byte*));
549        info->current_ptr = pos;
550        memcpy(record, pos, (size_t)share->reclength);
551 +      /*
552 +        If we're performing index_first on a table that was taken from
553 +        table cache, info->lastkey_len is initialized to previous query.
554 +        Thus we set info->lastkey_len to proper value for subsequent
555 +        heap_rnext() calls.
556 +        This is needed for DELETE queries only, otherwise this variable is
557 +        not used.
558 +        Note that the same workaround may be needed for heap_rlast(), but
559 +        for now heap_rlast() is never used for DELETE queries.
560 +      */
561 +      info->lastkey_len= 0;
562        info->update = HA_STATE_AKTIV;
563      }
564      else
565 diff -urN mysql-4.1.23/heap/hp_rnext.c mysql-4.1/heap/hp_rnext.c
566 --- mysql-4.1.23/heap/hp_rnext.c        2007-12-02 20:38:52.000000000 +0100
567 +++ mysql-4.1/heap/hp_rnext.c   2007-09-13 12:39:15.000000000 +0200
568 @@ -34,11 +34,40 @@
569      heap_rb_param custom_arg;
570  
571      if (info->last_pos)
572 +    {
573 +      /*
574 +        We enter this branch for non-DELETE queries after heap_rkey()
575 +        or heap_rfirst(). As last key position (info->last_pos) is available,
576 +        we only need to climb the tree using tree_search_next().
577 +      */
578        pos = tree_search_next(&keyinfo->rb_tree, &info->last_pos,
579                               offsetof(TREE_ELEMENT, left),
580                               offsetof(TREE_ELEMENT, right));
581 +    }
582 +    else if (!info->lastkey_len)
583 +    {
584 +      /*
585 +        We enter this branch only for DELETE queries after heap_rfirst(). E.g.
586 +        DELETE FROM t1 WHERE a<10. As last key position is not available
587 +        (last key is removed by heap_delete()), we must restart search as it
588 +        is done in heap_rfirst().
589 +
590 +        It should be safe to handle this situation without this branch. That is
591 +        branch below should find smallest element in a tree as lastkey_len is
592 +        zero. tree_search_edge() is a kind of optimisation here as it should be
593 +        faster than tree_search_key().
594 +      */
595 +      pos= tree_search_edge(&keyinfo->rb_tree, info->parents,
596 +                            &info->last_pos, offsetof(TREE_ELEMENT, left));
597 +    }
598      else
599      {
600 +      /*
601 +        We enter this branch only for DELETE queries after heap_rkey(). E.g.
602 +        DELETE FROM t1 WHERE a=10. As last key position is not available
603 +        (last key is removed by heap_delete()), we must restart search as it
604 +        is done in heap_rkey().
605 +      */
606        custom_arg.keyseg = keyinfo->seg;
607        custom_arg.key_length = info->lastkey_len;
608        custom_arg.search_flag = SEARCH_SAME | SEARCH_FIND;
609 diff -urN mysql-4.1.23/include/my_global.h mysql-4.1/include/my_global.h
610 --- mysql-4.1.23/include/my_global.h    2007-12-02 20:38:51.000000000 +0100
611 +++ mysql-4.1/include/my_global.h       2007-06-22 14:12:39.000000000 +0200
612 @@ -828,7 +828,12 @@
613  typedef unsigned long  ulong;            /* Short for unsigned long */
614  #endif
615  #ifndef longlong_defined
616 -#if defined(HAVE_LONG_LONG) && SIZEOF_LONG != 8
617 +/* 
618 +  Using [unsigned] long long is preferable as [u]longlong because we use 
619 +  [unsigned] long long unconditionally in many places, 
620 +  for example in constants with [U]LL suffix.
621 +*/
622 +#if defined(HAVE_LONG_LONG) && SIZEOF_LONG_LONG == 8
623  typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
624  typedef long long int  longlong;
625  #else
626 diff -urN mysql-4.1.23/include/mysql_com.h mysql-4.1/include/mysql_com.h
627 --- mysql-4.1.23/include/mysql_com.h    2007-12-02 20:38:25.000000000 +0100
628 +++ mysql-4.1/include/mysql_com.h       2007-11-09 13:05:01.000000000 +0100
629 @@ -291,6 +291,11 @@
630  int    net_real_write(NET *net,const char *packet,unsigned long len);
631  unsigned long my_net_read(NET *net);
632  
633 +#ifdef _global_h
634 +void net_set_write_timeout(NET *net, uint timeout);
635 +void net_set_read_timeout(NET *net, uint timeout);
636 +#endif
637 +
638  /*
639    The following function is not meant for normal usage
640    Currently it's used internally by manager.c
641 diff -urN mysql-4.1.23/include/my_sys.h mysql-4.1/include/my_sys.h
642 --- mysql-4.1.23/include/my_sys.h       2007-12-02 20:38:51.000000000 +0100
643 +++ mysql-4.1/include/my_sys.h  2007-10-24 13:09:29.000000000 +0200
644 @@ -784,6 +784,8 @@
645  extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
646  extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
647                                            uint cs_flags, myf my_flags);
648 +extern CHARSET_INFO *get_compatible_charset_with_ctype(CHARSET_INFO
649 +                                                       *original_cs);
650  extern void free_charsets(void);
651  extern char *get_charsets_dir(char *buf);
652  extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2);
653 diff -urN mysql-4.1.23/INSTALL-SOURCE mysql-4.1/INSTALL-SOURCE
654 --- mysql-4.1.23/INSTALL-SOURCE 1970-01-01 01:00:00.000000000 +0100
655 +++ mysql-4.1/INSTALL-SOURCE    2007-11-02 01:29:32.000000000 +0100
656 @@ -0,0 +1,8 @@
657 +
658 +You can find information about how to install from a source distributions at
659 +
660 +  http://dev.mysql.com/doc/refman/4.1/en/installing-source.html
661 +
662 +The MySQL Reference Manual is also available in various formats on
663 +http://dev.mysql.com/doc; if you're interested in the DocBook XML
664 +sources go to http://svn.mysql.com.
665 diff -urN mysql-4.1.23/INSTALL-WIN-SOURCE mysql-4.1/INSTALL-WIN-SOURCE
666 --- mysql-4.1.23/INSTALL-WIN-SOURCE     1970-01-01 01:00:00.000000000 +0100
667 +++ mysql-4.1/INSTALL-WIN-SOURCE        2007-11-02 12:36:29.000000000 +0100
668 @@ -0,0 +1,9 @@
669 +
670 +You can find information about how to install from a Windows source
671 +distributions at
672 +
673 +  http://dev.mysql.com/doc/refman/4.1/en/windows-source-build.html
674 +
675 +The MySQL Reference Manual is also available in various formats on
676 +http://dev.mysql.com/doc; if you're interested in the DocBook XML
677 +sources go to http://svn.mysql.com.
678 diff -urN mysql-4.1.23/libmysqld/ha_blackhole.cc mysql-4.1/libmysqld/ha_blackhole.cc
679 --- mysql-4.1.23/libmysqld/ha_blackhole.cc      2007-12-02 20:38:51.000000000 +0100
680 +++ mysql-4.1/libmysqld/ha_blackhole.cc 1970-01-01 01:00:00.000000000 +0100
681 @@ -1,192 +0,0 @@
682 -/* Copyright (C) 2005 MySQL AB
683 -
684 -  This program is free software; you can redistribute it and/or modify
685 -  it under the terms of the GNU General Public License as published by
686 -  the Free Software Foundation; either version 2 of the License, or
687 -  (at your option) any later version.
688 -
689 -  This program is distributed in the hope that it will be useful,
690 -  but WITHOUT ANY WARRANTY; without even the implied warranty of
691 -  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
692 -  GNU General Public License for more details.
693 -
694 -  You should have received a copy of the GNU General Public License
695 -  along with this program; if not, write to the Free Software
696 -  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
697 -
698 -
699 -#ifdef USE_PRAGMA_IMPLEMENTATION
700 -#pragma implementation                         // gcc: Class implementation
701 -#endif
702 -
703 -#include "mysql_priv.h"
704 -#ifdef HAVE_BLACKHOLE_DB
705 -#include "ha_blackhole.h"
706 -
707 -
708 -const char **ha_blackhole::bas_ext() const
709 -{ 
710 -  static const char *ext[]= { NullS }; 
711 -  return ext; 
712 -}
713 -
714 -int ha_blackhole::open(const char *name, int mode, uint test_if_locked)
715 -{
716 -  DBUG_ENTER("ha_blackhole::open");
717 -  thr_lock_init(&thr_lock);
718 -  thr_lock_data_init(&thr_lock,&lock,NULL);
719 -  DBUG_RETURN(0);
720 -}
721 -
722 -int ha_blackhole::close(void)
723 -{
724 -  DBUG_ENTER("ha_blackhole::close");
725 -  thr_lock_delete(&thr_lock);
726 -  DBUG_RETURN(0);
727 -}
728 -
729 -int ha_blackhole::create(const char *name, TABLE *table_arg,
730 -                         HA_CREATE_INFO *create_info)
731 -{
732 -  DBUG_ENTER("ha_blackhole::create");
733 -  DBUG_RETURN(0);
734 -}
735 -
736 -const char *ha_blackhole::index_type(uint key_number)
737 -{
738 -  DBUG_ENTER("ha_blackhole::index_type");
739 -  DBUG_RETURN((table->key_info[key_number].flags & HA_FULLTEXT) ? 
740 -              "FULLTEXT" :
741 -              (table->key_info[key_number].flags & HA_SPATIAL) ?
742 -              "SPATIAL" :
743 -              (table->key_info[key_number].algorithm == HA_KEY_ALG_RTREE) ?
744 -              "RTREE" :
745 -              "BTREE");
746 -}
747 -
748 -int ha_blackhole::write_row(byte * buf)
749 -{
750 -  DBUG_ENTER("ha_blackhole::write_row");
751 -  DBUG_RETURN(0);
752 -}
753 -
754 -int ha_blackhole::rnd_init(bool scan)
755 -{
756 -  DBUG_ENTER("ha_blackhole::rnd_init");
757 -  DBUG_RETURN(0);
758 -}
759 -
760 -
761 -int ha_blackhole::rnd_next(byte *buf)
762 -{
763 -  DBUG_ENTER("ha_blackhole::rnd_next");
764 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
765 -}
766 -
767 -
768 -int ha_blackhole::rnd_pos(byte * buf, byte *pos)
769 -{
770 -  DBUG_ENTER("ha_blackhole::rnd_pos");
771 -  DBUG_ASSERT(0);
772 -  DBUG_RETURN(0);
773 -}
774 -
775 -
776 -void ha_blackhole::position(const byte *record)
777 -{
778 -  DBUG_ENTER("ha_blackhole::position");
779 -  DBUG_ASSERT(0);
780 -  DBUG_VOID_RETURN;
781 -}
782 -
783 -
784 -int ha_blackhole::info(uint flag)
785 -{
786 -  DBUG_ENTER("ha_blackhole::info");
787 -
788 -  records= 0;
789 -  deleted= 0;
790 -  errkey= 0;
791 -  mean_rec_length= 0;
792 -  data_file_length= 0;
793 -  index_file_length= 0;
794 -  max_data_file_length= 0;
795 -  delete_length= 0;
796 -  if (flag & HA_STATUS_AUTO)
797 -    auto_increment_value= 1;
798 -  DBUG_RETURN(0);
799 -}
800 -
801 -int ha_blackhole::external_lock(THD *thd, int lock_type)
802 -{
803 -  DBUG_ENTER("ha_blackhole::external_lock");
804 -  DBUG_RETURN(0);
805 -}
806 -
807 -
808 -uint ha_blackhole::lock_count(void) const
809 -{
810 -  DBUG_ENTER("ha_blackhole::lock_count");
811 -  DBUG_RETURN(0);
812 -}
813 -
814 -THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd,
815 -                                         THR_LOCK_DATA **to,
816 -                                         enum thr_lock_type lock_type)
817 -{
818 -  DBUG_ENTER("ha_blackhole::store_lock");
819 -  DBUG_RETURN(to);
820 -}
821 -
822 -
823 -int ha_blackhole::index_read(byte * buf, const byte * key,
824 -                             uint key_len, enum ha_rkey_function find_flag)
825 -{
826 -  DBUG_ENTER("ha_blackhole::index_read");
827 -  DBUG_RETURN(0);
828 -}
829 -
830 -
831 -int ha_blackhole::index_read_idx(byte * buf, uint idx, const byte * key,
832 -                                 uint key_len, enum ha_rkey_function find_flag)
833 -{
834 -  DBUG_ENTER("ha_blackhole::index_read_idx");
835 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
836 -}
837 -
838 -
839 -int ha_blackhole::index_read_last(byte * buf, const byte * key, uint key_len)
840 -{
841 -  DBUG_ENTER("ha_blackhole::index_read_last");
842 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
843 -}
844 -
845 -
846 -int ha_blackhole::index_next(byte * buf)
847 -{
848 -  DBUG_ENTER("ha_blackhole::index_next");
849 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
850 -}
851 -
852 -
853 -int ha_blackhole::index_prev(byte * buf)
854 -{
855 -  DBUG_ENTER("ha_blackhole::index_prev");
856 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
857 -}
858 -
859 -
860 -int ha_blackhole::index_first(byte * buf)
861 -{
862 -  DBUG_ENTER("ha_blackhole::index_first");
863 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
864 -}
865 -
866 -
867 -int ha_blackhole::index_last(byte * buf)
868 -{
869 -  DBUG_ENTER("ha_blackhole::index_last");
870 -  DBUG_RETURN(HA_ERR_END_OF_FILE);
871 -}
872 -
873 -#endif /* HAVE_BLACKHOLE_DB */
874 diff -urN mysql-4.1.23/libmysql_r/client_settings.h mysql-4.1/libmysql_r/client_settings.h
875 --- mysql-4.1.23/libmysql_r/client_settings.h   2007-12-02 20:38:26.000000000 +0100
876 +++ mysql-4.1/libmysql_r/client_settings.h      1970-01-01 01:00:00.000000000 +0100
877 @@ -1,66 +0,0 @@
878 -/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
879 -   
880 -   This program is free software; you can redistribute it and/or modify
881 -   it under the terms of the GNU General Public License as published by
882 -   the Free Software Foundation; either version 2 of the License, or
883 -   (at your option) any later version.
884 -   
885 -   This program is distributed in the hope that it will be useful,
886 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
887 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
888 -   GNU General Public License for more details.
889 -   
890 -   You should have received a copy of the GNU General Public License
891 -   along with this program; if not, write to the Free Software
892 -   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
893 -
894 -extern uint            mysql_port;
895 -extern my_string       mysql_unix_port;
896 -
897 -#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG |   \
898 -                             CLIENT_TRANSACTIONS | \
899 -                            CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION)
900 -
901 -sig_handler pipe_sig_handler(int sig);
902 -void read_user_name(char *name);
903 -my_bool handle_local_infile(MYSQL *mysql, const char *net_filename);
904 -
905 -/*
906 -  Let the user specify that we don't want SIGPIPE;  This doesn't however work
907 -  with threaded applications as we can have multiple read in progress.
908 -*/
909 -
910 -#if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
911 -#define init_sigpipe_variables  sig_return old_signal_handler=(sig_return) 0;
912 -#define set_sigpipe(mysql)     if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
913 -#define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
914 -#else
915 -#define init_sigpipe_variables
916 -#define set_sigpipe(mysql)
917 -#define reset_sigpipe(mysql)
918 -#endif
919 -
920 -void mysql_read_default_options(struct st_mysql_options *options,
921 -                               const char *filename,const char *group);
922 -void mysql_detach_stmt_list(LIST **stmt_list);
923 -MYSQL * STDCALL
924 -cli_mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
925 -                      const char *passwd, const char *db,
926 -                      uint port, const char *unix_socket,ulong client_flag);
927 -
928 -void cli_mysql_close(MYSQL *mysql);
929 -
930 -MYSQL_FIELD * cli_list_fields(MYSQL *mysql);
931 -my_bool cli_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt);
932 -MYSQL_DATA * cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
933 -                                  uint fields);
934 -int cli_stmt_execute(MYSQL_STMT *stmt);
935 -int cli_read_binary_rows(MYSQL_STMT *stmt);
936 -int cli_unbuffered_fetch(MYSQL *mysql, char **row);
937 -const char * cli_read_statistics(MYSQL *mysql);
938 -int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd);
939 -
940 -#ifdef EMBEDDED_LIBRARY
941 -int init_embedded_server(int argc, char **argv, char **groups);
942 -void end_embedded_server();
943 -#endif /*EMBEDDED_LIBRARY*/
944 diff -urN mysql-4.1.23/myisam/ft_boolean_search.c mysql-4.1/myisam/ft_boolean_search.c
945 --- mysql-4.1.23/myisam/ft_boolean_search.c     2007-12-02 20:38:25.000000000 +0100
946 +++ mysql-4.1/myisam/ft_boolean_search.c        2007-10-30 11:46:42.000000000 +0100
947 @@ -446,7 +446,8 @@
948    {
949      if (cs->coll->instr(cs, p0, e0 - p0, s1, e1 - s1, m, 2) != 2)
950        return(0);
951 -    if ((!s_after || p0 + m[1].beg == s0 || !true_word_char(cs, p0[m[1].beg-1])) &&
952 +    if ((!s_after || p0 + m[1].beg == s0 ||
953 +         !true_word_char(cs, p0[(int) m[1].beg - 1])) &&
954          (!e_before || p0 + m[1].end == e0 || !true_word_char(cs, p0[m[1].end])))
955        return(1);
956      p0+= m[1].beg;
957 diff -urN mysql-4.1.23/myisam/mi_check.c mysql-4.1/myisam/mi_check.c
958 --- mysql-4.1.23/myisam/mi_check.c      2007-12-02 20:38:51.000000000 +0100
959 +++ mysql-4.1/myisam/mi_check.c 2007-11-07 09:55:27.000000000 +0100
960 @@ -940,7 +940,7 @@
961    ha_rows records,del_blocks;
962    my_off_t used,empty,pos,splits,start_recpos,
963            del_length,link_used,start_block;
964 -  byte *record,*to;
965 +  byte *record= 0, *to;
966    char llbuff[22],llbuff2[22],llbuff3[22];
967    ha_checksum intern_record_checksum;
968    ha_checksum key_checksum[MI_MAX_POSSIBLE_KEY];
969 @@ -957,7 +957,7 @@
970        puts("- check record links");
971    }
972  
973 -  if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0))))
974 +  if (!mi_alloc_rec_buff(info, -1, &record))
975    {
976      mi_check_print_error(param,"Not enough memory for record");
977      DBUG_RETURN(-1);
978 @@ -1364,12 +1364,12 @@
979      printf("Lost space:   %12s    Linkdata:     %10s\n",
980            llstr(empty,llbuff),llstr(link_used,llbuff2));
981    }
982 -  my_free((gptr) record,MYF(0));
983 +  my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
984    DBUG_RETURN (error);
985   err:
986    mi_check_print_error(param,"got error: %d when reading datafile at record: %s",my_errno, llstr(records,llbuff));
987   err2:
988 -  my_free((gptr) record,MYF(0));
989 +  my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
990    param->testflag|=T_RETRY_WITHOUT_QUICK;
991    DBUG_RETURN(1);
992  } /* chk_data_link */
993 @@ -1428,8 +1428,7 @@
994                       MYF(MY_WME | MY_WAIT_IF_FULL)))
995        goto err;
996    info->opt_flag|=WRITE_CACHE_USED;
997 -  if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
998 -                                          MYF(0))) ||
999 +  if (!mi_alloc_rec_buff(info, -1, &sort_param.record) ||
1000        !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff))
1001    {
1002      mi_check_print_error(param, "Not enough memory for extra record");
1003 @@ -1631,7 +1630,8 @@
1004    }
1005    my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff),
1006                              MYF(MY_ALLOW_ZERO_PTR));
1007 -  my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR));
1008 +  my_free(mi_get_rec_buff_ptr(info, sort_param.record),
1009 +          MYF(MY_ALLOW_ZERO_PTR));
1010    my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
1011    VOID(end_io_cache(&param->read_cache));
1012    info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
1013 @@ -2129,8 +2129,7 @@
1014    info->opt_flag|=WRITE_CACHE_USED;
1015    info->rec_cache.file=info->dfile;            /* for sort_delete_record */
1016  
1017 -  if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
1018 -                                          MYF(0))) ||
1019 +  if (!mi_alloc_rec_buff(info, -1, &sort_param.record) ||
1020        !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff))
1021    {
1022      mi_check_print_error(param, "Not enough memory for extra record");
1023 @@ -2415,7 +2414,8 @@
1024  
1025    my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff),
1026                              MYF(MY_ALLOW_ZERO_PTR));
1027 -  my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR));
1028 +  my_free(mi_get_rec_buff_ptr(info, sort_param.record),
1029 +          MYF(MY_ALLOW_ZERO_PTR));
1030    my_free((gptr) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR));
1031    my_free((gptr) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR));
1032    my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
1033 @@ -2493,6 +2493,7 @@
1034    SORT_INFO sort_info;
1035    ulonglong key_map=share->state.key_map;
1036    pthread_attr_t thr_attr;
1037 +  ulong max_pack_reclength;
1038    DBUG_ENTER("mi_repair_parallel");
1039  
1040    start_records=info->state->records;
1041 @@ -2649,10 +2650,13 @@
1042  
1043    del=info->state->del;
1044    param->glob_crc=0;
1045 -
1046 +  /* for compressed tables */
1047 +  max_pack_reclength= share->base.pack_reclength;
1048 +  if (share->options & HA_OPTION_COMPRESS_RECORD)
1049 +    set_if_bigger(max_pack_reclength, share->max_pack_length);
1050    if (!(sort_param=(MI_SORT_PARAM *)
1051          my_malloc((uint) share->base.keys *
1052 -                 (sizeof(MI_SORT_PARAM) + share->base.pack_reclength),
1053 +                 (sizeof(MI_SORT_PARAM) + max_pack_reclength),
1054                   MYF(MY_ZEROFILL))))
1055    {
1056      mi_check_print_error(param,"Not enough memory for key!");
1057 @@ -2704,7 +2708,7 @@
1058      sort_param[i].max_pos=sort_param[i].pos=share->pack.header_length;
1059  
1060      sort_param[i].record= (((char *)(sort_param+share->base.keys))+
1061 -                          (share->base.pack_reclength * i));
1062 +                          (max_pack_reclength * i));
1063      if (!mi_alloc_rec_buff(info, -1, &sort_param[i].rec_buff))
1064      {
1065        mi_check_print_error(param,"Not enough memory!");
1066 @@ -4320,7 +4324,7 @@
1067  void update_auto_increment_key(MI_CHECK *param, MI_INFO *info,
1068                                my_bool repair_only)
1069  {
1070 -  byte *record;
1071 +  byte *record= 0;
1072    DBUG_ENTER("update_auto_increment_key");
1073  
1074    if (!info->s->base.auto_key ||
1075 @@ -4340,8 +4344,7 @@
1076      We have to use an allocated buffer instead of info->rec_buff as 
1077      _mi_put_key_in_record() may use info->rec_buff
1078    */
1079 -  if (!(record= (byte*) my_malloc((uint) info->s->base.pack_reclength,
1080 -                                 MYF(0))))
1081 +  if (!mi_alloc_rec_buff(info, -1, &record))
1082    {
1083      mi_check_print_error(param,"Not enough memory for extra record");
1084      DBUG_VOID_RETURN;
1085 @@ -4353,7 +4356,7 @@
1086      if (my_errno != HA_ERR_END_OF_FILE)
1087      {
1088        mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
1089 -      my_free((char*) record, MYF(0));
1090 +      my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
1091        mi_check_print_error(param,"%d when reading last record",my_errno);
1092        DBUG_VOID_RETURN;
1093      }
1094 @@ -4369,7 +4372,7 @@
1095      set_if_bigger(info->s->state.auto_increment,auto_increment);
1096    }
1097    mi_extra(info,HA_EXTRA_NO_KEYREAD,0);
1098 -  my_free((char*) record, MYF(0));
1099 +  my_free(mi_get_rec_buff_ptr(info, record), MYF(0));
1100    update_state_info(param, info, UPDATE_AUTO_INC);
1101    DBUG_VOID_RETURN;
1102  }
1103 diff -urN mysql-4.1.23/myisam/mi_dynrec.c mysql-4.1/myisam/mi_dynrec.c
1104 --- mysql-4.1.23/myisam/mi_dynrec.c     2007-12-02 20:38:26.000000000 +0100
1105 +++ mysql-4.1/myisam/mi_dynrec.c        2007-11-12 10:00:21.000000000 +0100
1106 @@ -145,6 +145,29 @@
1107    DBUG_ENTER("write_dynamic_record");
1108  
1109    flag=0;
1110 +
1111 +  /*
1112 +    Check if we have enough room for the new record.
1113 +    First we do simplified check to make usual case faster.
1114 +    Then we do more precise check for the space left.
1115 +    Though it still is not absolutely precise, as
1116 +    we always use MI_MAX_DYN_BLOCK_HEADER while it can be
1117 +    less in the most of the cases.
1118 +  */
1119 +
1120 +  if (unlikely(info->s->base.max_data_file_length -
1121 +               info->state->data_file_length <
1122 +               reclength + MI_MAX_DYN_BLOCK_HEADER))
1123 +  {
1124 +    if (info->s->base.max_data_file_length - info->state->data_file_length +
1125 +        info->state->empty - info->state->del * MI_MAX_DYN_BLOCK_HEADER <
1126 +        reclength + MI_MAX_DYN_BLOCK_HEADER)
1127 +    {
1128 +      my_errno=HA_ERR_RECORD_FILE_FULL;
1129 +      DBUG_RETURN(1);
1130 +    }
1131 +  }
1132 +
1133    do
1134    {
1135      if (_mi_find_writepos(info,reclength,&filepos,&length))
1136 @@ -577,6 +600,51 @@
1137    DBUG_ENTER("update_dynamic_record");
1138  
1139    flag=block_info.second_read=0;
1140 +  /*
1141 +     Check if we have enough room for the record.
1142 +     First we do simplified check to make usual case faster.
1143 +     Then we do more precise check for the space left.
1144 +     Though it still is not absolutely precise, as
1145 +     we always use MI_MAX_DYN_BLOCK_HEADER while it can be
1146 +     less in the most of the cases.
1147 +  */
1148 +
1149 +  /*
1150 +    compare with just the reclength as we're going
1151 +    to get some space from the old replaced record
1152 +  */
1153 +  if (unlikely(info->s->base.max_data_file_length -
1154 +        info->state->data_file_length < reclength))
1155 +  {
1156 +    /*
1157 +       let's read the old record's block to find out the length of the
1158 +       old record
1159 +    */
1160 +    if ((error=_mi_get_block_info(&block_info,info->dfile,filepos))
1161 +        & (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR | BLOCK_FATAL_ERROR))
1162 +    {
1163 +      DBUG_PRINT("error",("Got wrong block info"));
1164 +      if (!(error & BLOCK_FATAL_ERROR))
1165 +        my_errno=HA_ERR_WRONG_IN_RECORD;
1166 +      goto err;
1167 +    }
1168 +
1169 +    /*
1170 +      if new record isn't longer, we can go on safely
1171 +    */
1172 +    if (block_info.rec_len < reclength)
1173 +    {
1174 +      if (info->s->base.max_data_file_length - info->state->data_file_length +
1175 +          info->state->empty - info->state->del * MI_MAX_DYN_BLOCK_HEADER <
1176 +          reclength - block_info.rec_len + MI_MAX_DYN_BLOCK_HEADER)
1177 +      {
1178 +        my_errno=HA_ERR_RECORD_FILE_FULL;
1179 +        goto err;
1180 +      }
1181 +    }
1182 +    block_info.second_read=0;
1183 +  }
1184 +
1185    while (reclength > 0)
1186    {
1187      if (filepos != info->s->state.dellink)
1188 diff -urN mysql-4.1.23/myisam/mi_open.c mysql-4.1/myisam/mi_open.c
1189 --- mysql-4.1.23/myisam/mi_open.c       2007-12-02 20:38:26.000000000 +0100
1190 +++ mysql-4.1/myisam/mi_open.c  2007-11-07 09:55:27.000000000 +0100
1191 @@ -659,8 +659,11 @@
1192      /* to simplify initial init of info->rec_buf in mi_open and mi_extra */
1193      if (length == (ulong) -1)
1194      {
1195 -      length= max(info->s->base.pack_reclength,
1196 -                  info->s->base.max_key_length);
1197 +      if (info->s->options & HA_OPTION_COMPRESS_RECORD)
1198 +        length= max(info->s->base.pack_reclength, info->s->max_pack_length);
1199 +      else
1200 +        length= info->s->base.pack_reclength;
1201 +      length= max(length, info->s->base.max_key_length);
1202        /* Avoid unnecessary realloc */
1203        if (newptr && length == old_length)
1204         return newptr;
1205 diff -urN mysql-4.1.23/myisam/mi_packrec.c mysql-4.1/myisam/mi_packrec.c
1206 --- mysql-4.1.23/myisam/mi_packrec.c    2007-12-02 20:38:27.000000000 +0100
1207 +++ mysql-4.1/myisam/mi_packrec.c       2007-11-07 09:55:27.000000000 +0100
1208 @@ -164,7 +164,6 @@
1209    share->pack.header_length=   uint4korr(header+4);
1210    share->min_pack_length=(uint) uint4korr(header+8);
1211    share->max_pack_length=(uint) uint4korr(header+12);
1212 -  set_if_bigger(share->base.pack_reclength,share->max_pack_length);
1213    elements=uint4korr(header+16);
1214    intervall_length=uint4korr(header+20);
1215    trees=uint2korr(header+24);
1216 diff -urN mysql-4.1.23/myisam/mi_rkey.c mysql-4.1/myisam/mi_rkey.c
1217 --- mysql-4.1.23/myisam/mi_rkey.c       2007-12-02 20:38:26.000000000 +0100
1218 +++ mysql-4.1/myisam/mi_rkey.c  2007-08-01 11:54:13.000000000 +0200
1219 @@ -95,42 +95,63 @@
1220                      myisam_read_vec[search_flag], info->s->state.key_root[inx]))
1221      {
1222        /*
1223 -        If we searching for a partial key (or using >, >=, < or <=) and
1224 -        the data is outside of the data file, we need to continue searching
1225 -        for the first key inside the data file
1226 +        Found a key, but it might not be usable. We cannot use rows that
1227 +        are inserted by other threads after we got our table lock
1228 +        ("concurrent inserts"). The record may not even be present yet.
1229 +        Keys are inserted into the index(es) before the record is
1230 +        inserted into the data file. When we got our table lock, we
1231 +        saved the current data_file_length. Concurrent inserts always go
1232 +        to the end of the file. So we can test if the found key
1233 +        references a new record.
1234        */
1235 -      if (info->lastpos >= info->state->data_file_length &&
1236 -          (search_flag != HA_READ_KEY_EXACT ||
1237 -           last_used_keyseg != keyinfo->seg + keyinfo->keysegs))
1238 +      if (info->lastpos >= info->state->data_file_length)
1239        {
1240 -        do
1241 +        /* The key references a concurrently inserted record. */
1242 +        if (search_flag == HA_READ_KEY_EXACT &&
1243 +            last_used_keyseg == keyinfo->seg + keyinfo->keysegs)
1244 +        {
1245 +          /* Simply ignore the key if it matches exactly. (Bug #29838) */
1246 +          my_errno= HA_ERR_KEY_NOT_FOUND;
1247 +          info->lastpos= HA_OFFSET_ERROR;
1248 +        }
1249 +        else
1250          {
1251 -          uint not_used[2];
1252 -          /*
1253 -            Skip rows that are inserted by other threads since we got a lock
1254 -            Note that this can only happen if we are not searching after an
1255 -            full length exact key, because the keys are sorted
1256 -            according to position
1257 -          */
1258 -          if  (_mi_search_next(info, keyinfo, info->lastkey,
1259 -                               info->lastkey_length,
1260 -                               myisam_readnext_vec[search_flag],
1261 -                               info->s->state.key_root[inx]))
1262 -            break;
1263            /*
1264 -            Check that the found key does still match the search.
1265 -            _mi_search_next() delivers the next key regardless of its
1266 -            value.
1267 +            If searching for a partial key (or using >, >=, < or <=) and
1268 +            the data is outside of the data file, we need to continue
1269 +            searching for the first key inside the data file.
1270            */
1271 -          if (search_flag == HA_READ_KEY_EXACT &&
1272 -              ha_key_cmp(keyinfo->seg, key_buff, info->lastkey, use_key_length,
1273 -                         SEARCH_FIND, not_used))
1274 +          do
1275            {
1276 -            my_errno= HA_ERR_KEY_NOT_FOUND;
1277 -            info->lastpos= HA_OFFSET_ERROR;
1278 -            break;
1279 -          }
1280 -        } while (info->lastpos >= info->state->data_file_length);
1281 +            uint not_used[2];
1282 +            /*
1283 +              Skip rows that are inserted by other threads since we got
1284 +              a lock. Note that this can only happen if we are not
1285 +              searching after a full length exact key, because the keys
1286 +              are sorted according to position.
1287 +            */
1288 +            if  (_mi_search_next(info, keyinfo, info->lastkey,
1289 +                                 info->lastkey_length,
1290 +                                 myisam_readnext_vec[search_flag],
1291 +                                 info->s->state.key_root[inx]))
1292 +              break; /* purecov: inspected */
1293 +            /*
1294 +              Check that the found key does still match the search.
1295 +              _mi_search_next() delivers the next key regardless of its
1296 +              value.
1297 +            */
1298 +            if (search_flag == HA_READ_KEY_EXACT &&
1299 +                ha_key_cmp(keyinfo->seg, key_buff, info->lastkey,
1300 +                           use_key_length, SEARCH_FIND, not_used))
1301 +            {
1302 +              /* purecov: begin inspected */
1303 +              my_errno= HA_ERR_KEY_NOT_FOUND;
1304 +              info->lastpos= HA_OFFSET_ERROR;
1305 +              break;
1306 +              /* purecov: end */
1307 +            }
1308 +          } while (info->lastpos >= info->state->data_file_length);
1309 +        }
1310        }
1311      }
1312    }
1313 diff -urN mysql-4.1.23/myisam/myisamchk.c mysql-4.1/myisam/myisamchk.c
1314 --- mysql-4.1.23/myisam/myisamchk.c     2007-12-02 20:38:51.000000000 +0100
1315 +++ mysql-4.1/myisam/myisamchk.c        2007-11-07 09:55:27.000000000 +0100
1316 @@ -338,7 +338,7 @@
1317      (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR,
1318      REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1319    {"stats_method", OPT_STATS_METHOD,
1320 -   "Specifies how index statistics collection code should threat NULLs. "
1321 +   "Specifies how index statistics collection code should treat NULLs. "
1322     "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), "
1323     "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".",
1324     (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0,
1325 @@ -453,7 +453,7 @@
1326                       MySQL faster.  You can check the calculated distribution\n\
1327                       by using '--description --verbose table_name'.\n\
1328    --stats_method=name Specifies how index statistics collection code should\n\
1329 -                      threat NULLs. Possible values of name are \"nulls_unequal\"\n\
1330 +                      treat NULLs. Possible values of name are \"nulls_unequal\"\n\
1331                        (default for 4.1/5.0), \"nulls_equal\" (emulate 4.0), and \n\
1332                        \"nulls_ignored\".\n\
1333    -d, --description   Prints some information about table.\n\
1334 @@ -1543,8 +1543,8 @@
1335      mi_check_print_error(param,"Not enough memory for key block");
1336      goto err;
1337    }
1338 -  if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength,
1339 -                                          MYF(0))))
1340 +
1341 +  if (!mi_alloc_rec_buff(info, -1, &sort_param.record))
1342    {
1343      mi_check_print_error(param,"Not enough memory for record");
1344      goto err;
1345 @@ -1639,7 +1639,8 @@
1346    {
1347      my_afree((gptr) temp_buff);
1348    }
1349 -  my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR));
1350 +  my_free(mi_get_rec_buff_ptr(info, sort_param.record),
1351 +          MYF(MY_ALLOW_ZERO_PTR));
1352    info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
1353    VOID(end_io_cache(&info->rec_cache));
1354    my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR));
1355 diff -urN mysql-4.1.23/myisam/rt_index.c mysql-4.1/myisam/rt_index.c
1356 --- mysql-4.1.23/myisam/rt_index.c      2007-12-02 20:38:51.000000000 +0100
1357 +++ mysql-4.1/myisam/rt_index.c 2007-10-05 12:40:31.000000000 +0200
1358 @@ -485,15 +485,16 @@
1359                              uint key_length, uchar *page_buf, uint nod_flag)
1360  {
1361    double increase;
1362 -  double best_incr = DBL_MAX;
1363 +  double best_incr;
1364    double area;
1365    double best_area;
1366 -  uchar *best_key;
1367 +  uchar *best_key= NULL;
1368    uchar *k = rt_PAGE_FIRST_KEY(page_buf, nod_flag);
1369    uchar *last = rt_PAGE_END(page_buf);
1370  
1371    LINT_INIT(best_area);
1372    LINT_INIT(best_key);
1373 +  LINT_INIT(best_incr);
1374  
1375    for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
1376    {
1377 @@ -502,22 +503,13 @@
1378                                          &area)) == -1.0)
1379        return NULL;
1380      /* The following should be safe, even if we compare doubles */
1381 -    if (increase < best_incr)
1382 +    if (!best_key || increase < best_incr ||
1383 +        ((increase == best_incr) && (area < best_area)))
1384      {
1385        best_key = k;
1386        best_area = area;
1387        best_incr = increase;
1388      }
1389 -    else
1390 -    {
1391 -      /* The following should be safe, even if we compare doubles */
1392 -      if ((increase == best_incr) && (area < best_area))
1393 -      {
1394 -        best_key = k;
1395 -        best_area = area;
1396 -        best_incr = increase;
1397 -      }
1398 -    }
1399    }
1400    return best_key;
1401  }
1402 diff -urN mysql-4.1.23/myisam/rt_mbr.c mysql-4.1/myisam/rt_mbr.c
1403 --- mysql-4.1.23/myisam/rt_mbr.c        2007-12-02 20:38:25.000000000 +0100
1404 +++ mysql-4.1/myisam/rt_mbr.c   2007-10-05 12:40:31.000000000 +0200
1405 @@ -525,7 +525,10 @@
1406  }
1407  
1408  /*
1409 -Calculates MBR_AREA(a+b) - MBR_AREA(a)
1410 +  Calculates MBR_AREA(a+b) - MBR_AREA(a)
1411 +  Note: when 'a' and 'b' objects are far from each other,
1412 +  the area increase can be really big, so this function
1413 +  can return 'inf' as a result.
1414  */
1415  double rtree_area_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b, 
1416                            uint key_length, double *ab_area)
1417 diff -urN mysql-4.1.23/myisam/sort.c mysql-4.1/myisam/sort.c
1418 --- mysql-4.1.23/myisam/sort.c  2007-12-02 20:38:26.000000000 +0100
1419 +++ mysql-4.1/myisam/sort.c     2007-10-11 12:28:08.000000000 +0200
1420 @@ -559,9 +559,10 @@
1421        if (!mergebuf)
1422        {
1423          length=param->sort_buffer_length;
1424 -        while (length >= MIN_SORT_MEMORY && !mergebuf)
1425 +        while (length >= MIN_SORT_MEMORY)
1426          {
1427 -          mergebuf=my_malloc(length, MYF(0));
1428 +          if ((mergebuf= my_malloc(length, MYF(0))))
1429 +              break;
1430            length=length*3/4;
1431          }
1432          if (!mergebuf)
1433 @@ -897,6 +898,7 @@
1434  
1435    count=error=0;
1436    maxcount=keys/((uint) (Tb-Fb) +1);
1437 +  DBUG_ASSERT(maxcount > 0);
1438    LINT_INIT(to_start_filepos);
1439    if (to_file)
1440      to_start_filepos=my_b_tell(to_file);
1441 diff -urN mysql-4.1.23/mysql-test/include/ctype_common.inc mysql-4.1/mysql-test/include/ctype_common.inc
1442 --- mysql-4.1.23/mysql-test/include/ctype_common.inc    2007-12-02 20:38:26.000000000 +0100
1443 +++ mysql-4.1/mysql-test/include/ctype_common.inc       2007-10-04 07:19:59.000000000 +0200
1444 @@ -51,6 +51,15 @@
1445  SELECT c1 as want1result  from t1 where c1 like 'location%';
1446  DROP TABLE t1;
1447  
1448 +#
1449 +# Bug #31070: crash during conversion of charsets
1450 +#
1451 +create table t1 (a set('a') not null);
1452 +insert into t1 values (),();
1453 +select cast(a as char(1)) from t1;
1454 +select a sounds like a from t1;
1455 +drop table t1;
1456 +
1457  DROP DATABASE d1;
1458  # Restore settings
1459  USE test;
1460 diff -urN mysql-4.1.23/mysql-test/lib/mtr_misc.pl mysql-4.1/mysql-test/lib/mtr_misc.pl
1461 --- mysql-4.1.23/mysql-test/lib/mtr_misc.pl     2007-12-02 20:38:50.000000000 +0100
1462 +++ mysql-4.1/mysql-test/lib/mtr_misc.pl        2007-08-29 14:39:39.000000000 +0200
1463 @@ -5,6 +5,7 @@
1464  # same name.
1465  
1466  use strict;
1467 +use File::Find;
1468  
1469  sub mtr_full_hostname ();
1470  sub mtr_short_hostname ();
1471 @@ -17,6 +18,7 @@
1472  sub mtr_exe_exists(@);
1473  sub mtr_exe_maybe_exists(@);
1474  sub mtr_copy_dir($$);
1475 +sub mtr_rmtree($);
1476  sub mtr_same_opts($$);
1477  sub mtr_cmp_opts($$);
1478  
1479 @@ -202,6 +204,64 @@
1480  }
1481  
1482  
1483 +sub mtr_rmtree($) {
1484 +  my ($dir)= @_;
1485 +  my $need_file_find= 0;
1486 +  mtr_verbose("mtr_rmtree: $dir");
1487 +
1488 +  {
1489 +    # Try to use File::Path::rmtree. Recent versions
1490 +    # handles removal of directories and files that don't
1491 +    # have full permissions, while older versions
1492 +    # may have a problem with that and we use our own version
1493 +
1494 +    local $SIG{__WARN__}= sub {
1495 +      $need_file_find= 1;
1496 +      mtr_warning($_[0]);
1497 +    };
1498 +    rmtree($dir);
1499 +  }
1500 +  if ( $need_file_find ) {
1501 +    mtr_warning("rmtree($dir) failed, trying with File::Find...");
1502 +
1503 +    my $errors= 0;
1504 +
1505 +    # chmod
1506 +    find( {
1507 +          no_chdir => 1,
1508 +          wanted => sub {
1509 +            chmod(0777, $_)
1510 +              or mtr_warning("couldn't chmod(0777, $_): $!") and $errors++;
1511 +          }
1512 +         },
1513 +         $dir
1514 +       );
1515 +
1516 +    # rm
1517 +    finddepth( {
1518 +          no_chdir => 1,
1519 +          wanted => sub {
1520 +            my $file= $_;
1521 +            # Use special underscore (_) filehandle, caches stat info
1522 +            if (!-l $file and -d _ ) {
1523 +              rmdir($file) or
1524 +                mtr_warning("couldn't rmdir($file): $!") and $errors++;
1525 +            } else {
1526 +              unlink($file)
1527 +                or mtr_warning("couldn't unlink($file): $!") and $errors++;
1528 +            }
1529 +          }
1530 +         },
1531 +         $dir
1532 +       );
1533 +
1534 +    mtr_error("Failed to remove '$dir'") if $errors;
1535 +
1536 +    mtr_report("OK, that worked!");
1537 +  }
1538 +}
1539 +
1540 +
1541  sub mtr_same_opts ($$) {
1542    my $l1= shift;
1543    my $l2= shift;
1544 diff -urN mysql-4.1.23/mysql-test/mysql-test-run.pl mysql-4.1/mysql-test/mysql-test-run.pl
1545 --- mysql-4.1.23/mysql-test/mysql-test-run.pl   2007-12-02 20:38:25.000000000 +0100
1546 +++ mysql-4.1/mysql-test/mysql-test-run.pl      2007-11-07 09:55:27.000000000 +0100
1547 @@ -1880,6 +1880,21 @@
1548      ($lib_udf_example ?  dirname($lib_udf_example) : "") .
1549        ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : "");
1550  
1551 +  # ----------------------------------------------------
1552 +  # Setup env so childs can execute myisampack and myisamchk
1553 +  # ----------------------------------------------------
1554 +  $ENV{'MYISAMCHK'}= mtr_native_path(mtr_exe_exists(
1555 +                       vs_config_dirs('storage/myisam', 'myisamchk'),
1556 +                       vs_config_dirs('myisam', 'myisamchk'),
1557 +                       "$path_client_bindir/myisamchk",
1558 +                       "$glob_basedir/storage/myisam/myisamchk",
1559 +                       "$glob_basedir/myisam/myisamchk"));
1560 +  $ENV{'MYISAMPACK'}= mtr_native_path(mtr_exe_exists(
1561 +                        vs_config_dirs('storage/myisam', 'myisampack'),
1562 +                        vs_config_dirs('myisam', 'myisampack'),
1563 +                        "$path_client_bindir/myisampack",
1564 +                        "$glob_basedir/storage/myisam/myisampack",
1565 +                        "$glob_basedir/myisam/myisampack"));
1566  
1567    # ----------------------------------------------------
1568    # We are nice and report a bit about our settings
1569 @@ -1988,7 +2003,7 @@
1570        {
1571         # Remove the directory which the link points at
1572         mtr_verbose("Removing " . readlink($opt_vardir));
1573 -       rmtree(readlink($opt_vardir));
1574 +       mtr_rmtree(readlink($opt_vardir));
1575  
1576         # Remove the "var" symlink
1577         mtr_verbose("unlink($opt_vardir)");
1578 @@ -2016,7 +2031,7 @@
1579         foreach my $bin ( glob("$opt_vardir/*") )
1580         {
1581           mtr_verbose("Removing bin $bin");
1582 -         rmtree($bin);
1583 +         mtr_rmtree($bin);
1584         }
1585        }
1586      }
1587 @@ -2024,7 +2039,7 @@
1588      {
1589        # Remove the entire "var" dir
1590        mtr_verbose("Removing $opt_vardir/");
1591 -      rmtree("$opt_vardir/");
1592 +      mtr_rmtree("$opt_vardir/");
1593      }
1594  
1595      if ( $opt_mem )
1596 @@ -2033,7 +2048,7 @@
1597        # remove the $opt_mem dir to assure the symlink
1598        # won't point at an old directory
1599        mtr_verbose("Removing $opt_mem");
1600 -      rmtree($opt_mem);
1601 +      mtr_rmtree($opt_mem);
1602      }
1603  
1604    }
1605 @@ -2046,11 +2061,11 @@
1606      # Remove the var/ dir in mysql-test dir if any
1607      # this could be an old symlink that shouldn't be there
1608      mtr_verbose("Removing $default_vardir");
1609 -    rmtree($default_vardir);
1610 +    mtr_rmtree($default_vardir);
1611  
1612      # Remove the "var" dir
1613      mtr_verbose("Removing $opt_vardir/");
1614 -    rmtree("$opt_vardir/");
1615 +    mtr_rmtree("$opt_vardir/");
1616    }
1617  }
1618  
1619 @@ -2143,16 +2158,23 @@
1620      close FILE;
1621    }
1622  
1623 -  chmod(oct("0755"), $test_file);
1624 -  unlink($test_file);
1625 +  # Some filesystems( for example CIFS) allows reading a file
1626 +  # although mode was set to 0000, but in that case a stat on
1627 +  # the file will not return 0000
1628 +  my $file_mode= (stat($test_file))[2] & 07777;
1629  
1630    $ENV{'MYSQL_TEST_ROOT'}= "NO";
1631 -  if ($result eq "MySQL")
1632 +  mtr_verbose("result: $result, file_mode: $file_mode");
1633 +  if ($result eq "MySQL" && $file_mode == 0)
1634    {
1635      mtr_warning("running this script as _root_ will cause some " .
1636                  "tests to be skipped");
1637      $ENV{'MYSQL_TEST_ROOT'}= "YES";
1638    }
1639 +
1640 +  chmod(oct("0755"), $test_file);
1641 +  unlink($test_file);
1642 +
1643  }
1644  
1645  
1646 @@ -2956,7 +2978,7 @@
1647      {
1648        my $data_dir= $slave->[$idx]->{'path_myddir'};
1649        my $name= basename($data_dir);
1650 -      rmtree($data_dir);
1651 +      mtr_rmtree($data_dir);
1652        mtr_copy_dir("$path_snapshot/$name", $data_dir);
1653      }
1654    }
1655 @@ -3099,9 +3121,12 @@
1656  {
1657    my ($tinfo)= @_;
1658  
1659 +  # Set default message
1660 +  $tinfo->{'comment'}= "Detected by testcase(no log file)";
1661 +
1662    # Open mysqltest.log
1663 -  my $F= IO::File->new($path_timefile) or
1664 -    mtr_error("can't open file \"$path_timefile\": $!");
1665 +  my $F= IO::File->new($path_timefile)
1666 +    or return;
1667    my $reason;
1668  
1669    while ( my $line= <$F> )
1670 @@ -3154,8 +3179,8 @@
1671    my ($tinfo)= @_;
1672  
1673    # Open mysqltest.log
1674 -  my $F= IO::File->new($path_timefile) or
1675 -    mtr_error("can't open file \"$path_timefile\": $!");
1676 +  my $F= IO::File->new($path_timefile)
1677 +    or return;
1678  
1679    while ( my $line= <$F> )
1680    {
1681 @@ -3300,7 +3325,7 @@
1682  sub save_installed_db () {
1683  
1684    mtr_report("Saving snapshot of installed databases");
1685 -  rmtree($path_snapshot);
1686 +  mtr_rmtree($path_snapshot);
1687  
1688    foreach my $data_dir (@data_dir_lst)
1689    {
1690 @@ -3347,7 +3372,7 @@
1691      {
1692        my $name= basename($data_dir);
1693        save_files_before_restore($test_name, $data_dir);
1694 -      rmtree("$data_dir");
1695 +      mtr_rmtree("$data_dir");
1696        mtr_copy_dir("$path_snapshot/$name", "$data_dir");
1697      }
1698  
1699 @@ -3357,7 +3382,7 @@
1700      {
1701        foreach my $ndbd (@{$cluster->{'ndbds'}})
1702        {
1703 -       rmtree("$ndbd->{'path_fs'}" );
1704 +       mtr_rmtree("$ndbd->{'path_fs'}" );
1705        }
1706      }
1707    }
1708 @@ -3815,6 +3840,9 @@
1709      $wait_for_pid_file= 0;
1710    }
1711  
1712 +  # Remove the pidfile
1713 +  unlink($mysqld->{'path_pid'});
1714 +
1715    if ( defined $exe )
1716    {
1717      $pid= mtr_spawn($exe, $args, "",
1718 diff -urN mysql-4.1.23/mysql-test/r/almost_full.result mysql-4.1/mysql-test/r/almost_full.result
1719 --- mysql-4.1.23/mysql-test/r/almost_full.result        1970-01-01 01:00:00.000000000 +0100
1720 +++ mysql-4.1/mysql-test/r/almost_full.result   2007-11-12 10:00:21.000000000 +0100
1721 @@ -0,0 +1,29 @@
1722 +drop table if exists t1;
1723 +set global myisam_data_pointer_size=2;
1724 +CREATE TABLE t1 (a int auto_increment primary key not null, b longtext) ENGINE=MyISAM;
1725 +DELETE FROM t1 WHERE a=1 or a=5;
1726 +INSERT INTO t1 SET b=repeat('a',600);
1727 +ERROR HY000: The table 't1' is full
1728 +CHECK TABLE t1 EXTENDED;
1729 +Table  Op      Msg_type        Msg_text
1730 +test.t1        check   warning Datafile is almost full, 65448 of 65534 used
1731 +test.t1        check   status  OK
1732 +UPDATE t1 SET b=repeat('a', 800) where a=10;
1733 +ERROR HY000: The table 't1' is full
1734 +CHECK TABLE t1 EXTENDED;
1735 +Table  Op      Msg_type        Msg_text
1736 +test.t1        check   warning Datafile is almost full, 65448 of 65534 used
1737 +test.t1        check   status  OK
1738 +INSERT INTO t1 SET b=repeat('a',400);
1739 +CHECK TABLE t1 EXTENDED;
1740 +Table  Op      Msg_type        Msg_text
1741 +test.t1        check   warning Datafile is almost full, 65448 of 65534 used
1742 +test.t1        check   status  OK
1743 +DELETE FROM t1 WHERE a=2 or a=6;
1744 +UPDATE t1 SET b=repeat('a', 600) where a=11;
1745 +CHECK TABLE t1 EXTENDED;
1746 +Table  Op      Msg_type        Msg_text
1747 +test.t1        check   warning Datafile is almost full, 65448 of 65534 used
1748 +test.t1        check   status  OK
1749 +drop table t1;
1750 +set global myisam_data_pointer_size=default;
1751 diff -urN mysql-4.1.23/mysql-test/r/bigint.result mysql-4.1/mysql-test/r/bigint.result
1752 --- mysql-4.1.23/mysql-test/r/bigint.result     2007-12-02 20:38:25.000000000 +0100
1753 +++ mysql-4.1/mysql-test/r/bigint.result        2007-11-12 12:51:40.000000000 +0100
1754 @@ -135,3 +135,9 @@
1755  value64        value32 value64 value32
1756  9223372036854775807    2       9223372036854775807     4
1757  drop table t1, t2;
1758 +create table t1 (sint64 bigint not null);
1759 +insert into t1 values (-9223372036854775808);
1760 +select * from t1;
1761 +sint64
1762 +-9223372036854775808
1763 +drop table t1;
1764 diff -urN mysql-4.1.23/mysql-test/r/ctype_big5.result mysql-4.1/mysql-test/r/ctype_big5.result
1765 --- mysql-4.1.23/mysql-test/r/ctype_big5.result 2007-12-02 20:38:51.000000000 +0100
1766 +++ mysql-4.1/mysql-test/r/ctype_big5.result    2007-10-04 07:19:59.000000000 +0200
1767 @@ -52,6 +52,17 @@
1768  want1result
1769  location
1770  DROP TABLE t1;
1771 +create table t1 (a set('a') not null);
1772 +insert into t1 values (),();
1773 +select cast(a as char(1)) from t1;
1774 +cast(a as char(1))
1775 +
1776 +
1777 +select a sounds like a from t1;
1778 +a sounds like a
1779 +1
1780 +1
1781 +drop table t1;
1782  DROP DATABASE d1;
1783  USE test;
1784  SET character_set_server= @safe_character_set_server;
1785 diff -urN mysql-4.1.23/mysql-test/r/ctype_euckr.result mysql-4.1/mysql-test/r/ctype_euckr.result
1786 --- mysql-4.1.23/mysql-test/r/ctype_euckr.result        2007-12-02 20:38:26.000000000 +0100
1787 +++ mysql-4.1/mysql-test/r/ctype_euckr.result   2007-10-04 07:19:59.000000000 +0200
1788 @@ -52,6 +52,17 @@
1789  want1result
1790  location
1791  DROP TABLE t1;
1792 +create table t1 (a set('a') not null);
1793 +insert into t1 values (),();
1794 +select cast(a as char(1)) from t1;
1795 +cast(a as char(1))
1796 +
1797 +
1798 +select a sounds like a from t1;
1799 +a sounds like a
1800 +1
1801 +1
1802 +drop table t1;
1803  DROP DATABASE d1;
1804  USE test;
1805  SET character_set_server= @safe_character_set_server;
1806 diff -urN mysql-4.1.23/mysql-test/r/ctype_gb2312.result mysql-4.1/mysql-test/r/ctype_gb2312.result
1807 --- mysql-4.1.23/mysql-test/r/ctype_gb2312.result       2007-12-02 20:38:26.000000000 +0100
1808 +++ mysql-4.1/mysql-test/r/ctype_gb2312.result  2007-10-04 07:19:59.000000000 +0200
1809 @@ -52,6 +52,17 @@
1810  want1result
1811  location
1812  DROP TABLE t1;
1813 +create table t1 (a set('a') not null);
1814 +insert into t1 values (),();
1815 +select cast(a as char(1)) from t1;
1816 +cast(a as char(1))
1817 +
1818 +
1819 +select a sounds like a from t1;
1820 +a sounds like a
1821 +1
1822 +1
1823 +drop table t1;
1824  DROP DATABASE d1;
1825  USE test;
1826  SET character_set_server= @safe_character_set_server;
1827 diff -urN mysql-4.1.23/mysql-test/r/ctype_gbk.result mysql-4.1/mysql-test/r/ctype_gbk.result
1828 --- mysql-4.1.23/mysql-test/r/ctype_gbk.result  2007-12-02 20:38:51.000000000 +0100
1829 +++ mysql-4.1/mysql-test/r/ctype_gbk.result     2007-10-04 07:19:59.000000000 +0200
1830 @@ -52,6 +52,17 @@
1831  want1result
1832  location
1833  DROP TABLE t1;
1834 +create table t1 (a set('a') not null);
1835 +insert into t1 values (),();
1836 +select cast(a as char(1)) from t1;
1837 +cast(a as char(1))
1838 +
1839 +
1840 +select a sounds like a from t1;
1841 +a sounds like a
1842 +1
1843 +1
1844 +drop table t1;
1845  DROP DATABASE d1;
1846  USE test;
1847  SET character_set_server= @safe_character_set_server;
1848 diff -urN mysql-4.1.23/mysql-test/r/ctype_uca.result mysql-4.1/mysql-test/r/ctype_uca.result
1849 --- mysql-4.1.23/mysql-test/r/ctype_uca.result  2007-12-02 20:38:51.000000000 +0100
1850 +++ mysql-4.1/mysql-test/r/ctype_uca.result     2007-10-04 07:19:59.000000000 +0200
1851 @@ -2371,6 +2371,17 @@
1852  want1result
1853  location
1854  DROP TABLE t1;
1855 +create table t1 (a set('a') not null);
1856 +insert into t1 values (),();
1857 +select cast(a as char(1)) from t1;
1858 +cast(a as char(1))
1859 +
1860 +
1861 +select a sounds like a from t1;
1862 +a sounds like a
1863 +1
1864 +1
1865 +drop table t1;
1866  DROP DATABASE d1;
1867  USE test;
1868  SET character_set_server= @safe_character_set_server;
1869 diff -urN mysql-4.1.23/mysql-test/r/ctype_ucs.result mysql-4.1/mysql-test/r/ctype_ucs.result
1870 --- mysql-4.1.23/mysql-test/r/ctype_ucs.result  2007-12-02 20:38:27.000000000 +0100
1871 +++ mysql-4.1/mysql-test/r/ctype_ucs.result     2007-10-24 13:09:29.000000000 +0200
1872 @@ -803,4 +803,10 @@
1873  ????????
1874  ????????????????
1875  drop table bug20536;
1876 +CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci);
1877 +INSERT INTO t1 VALUES('abcd');
1878 +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE);
1879 +a
1880 +abcd
1881 +DROP TABLE t1;
1882  End of 4.1 tests
1883 diff -urN mysql-4.1.23/mysql-test/r/delete.result mysql-4.1/mysql-test/r/delete.result
1884 --- mysql-4.1.23/mysql-test/r/delete.result     2007-12-02 20:38:52.000000000 +0100
1885 +++ mysql-4.1/mysql-test/r/delete.result        2007-09-10 14:26:49.000000000 +0200
1886 @@ -193,4 +193,15 @@
1887  @a
1888  1
1889  drop table t1;
1890 +CREATE TABLE t1 (
1891 +`date` date ,
1892 +`time` time ,
1893 +`seq` int(10) unsigned NOT NULL auto_increment,
1894 +PRIMARY KEY  (`seq`),
1895 +KEY `seq` (`seq`),
1896 +KEY `time` (`time`),
1897 +KEY `date` (`date`)
1898 +);
1899 +DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
1900 +drop table t1;
1901  End of 4.1 tests
1902 diff -urN mysql-4.1.23/mysql-test/r/fulltext.result mysql-4.1/mysql-test/r/fulltext.result
1903 --- mysql-4.1.23/mysql-test/r/fulltext.result   2007-12-02 20:38:25.000000000 +0100
1904 +++ mysql-4.1/mysql-test/r/fulltext.result      2007-10-30 11:46:42.000000000 +0100
1905 @@ -454,3 +454,9 @@
1906  SELECT * FROM t1 WHERE MATCH(a) AGAINST('test');
1907  ERROR HY000: Can't find FULLTEXT index matching the column list
1908  DROP TABLE t1;
1909 +CREATE TABLE t1(a TEXT);
1910 +INSERT INTO t1 VALUES(' aaaaa aaaa');
1911 +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE);
1912 +a
1913 + aaaaa aaaa
1914 +DROP TABLE t1;
1915 diff -urN mysql-4.1.23/mysql-test/r/func_str.result mysql-4.1/mysql-test/r/func_str.result
1916 --- mysql-4.1.23/mysql-test/r/func_str.result   2007-12-02 20:38:26.000000000 +0100
1917 +++ mysql-4.1/mysql-test/r/func_str.result      2007-10-30 09:35:02.000000000 +0100
1918 @@ -711,9 +711,9 @@
1919  show create table t1;
1920  Table  Create Table
1921  t1     CREATE TABLE `t1` (
1922 -  `bin(130)` char(64) NOT NULL default '',
1923 -  `oct(130)` char(64) NOT NULL default '',
1924 -  `conv(130,16,10)` char(64) NOT NULL default '',
1925 +  `bin(130)` char(64) default NULL,
1926 +  `oct(130)` char(64) default NULL,
1927 +  `conv(130,16,10)` char(64) default NULL,
1928    `hex(130)` char(6) NOT NULL default '',
1929    `char(130)` char(1) NOT NULL default '',
1930    `format(130,10)` char(4) NOT NULL default '',
1931 @@ -1076,4 +1076,16 @@
1932  Warnings:
1933  Note   1003    select decode(test.t1.f1,'zxcv') AS `enc` from test.t1
1934  drop table t1;
1935 +create table t1 (a bigint not null)engine=myisam;
1936 +insert into t1 set a = 1024*1024*1024*4;
1937 +delete from t1 order by (inet_ntoa(a)) desc limit 10;
1938 +drop table t1;
1939 +create table t1 (a char(36) not null)engine=myisam;
1940 +insert ignore into t1 set a = ' ';
1941 +insert ignore into t1 set a = ' ';
1942 +select * from t1 order by (oct(a));
1943 +a
1944 +
1945 +
1946 +drop table t1;
1947  End of 4.1 tests
1948 diff -urN mysql-4.1.23/mysql-test/r/gis.result mysql-4.1/mysql-test/r/gis.result
1949 --- mysql-4.1.23/mysql-test/r/gis.result        2007-12-02 20:38:26.000000000 +0100
1950 +++ mysql-4.1/mysql-test/r/gis.result   2007-10-03 10:35:33.000000000 +0200
1951 @@ -724,4 +724,10 @@
1952  a
1953  NULL
1954  DROP TABLE t1;
1955 +CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
1956 +INSERT INTO `t1` VALUES ('','0000-00-00');
1957 +select geomfromtext(col9,col89) as a from t1;
1958 +a
1959 +NULL
1960 +DROP TABLE t1;
1961  End of 4.1 tests
1962 diff -urN mysql-4.1.23/mysql-test/r/gis-rtree.result mysql-4.1/mysql-test/r/gis-rtree.result
1963 --- mysql-4.1.23/mysql-test/r/gis-rtree.result  2007-12-02 20:38:27.000000000 +0100
1964 +++ mysql-4.1/mysql-test/r/gis-rtree.result     2007-10-05 12:40:31.000000000 +0200
1965 @@ -1420,3 +1420,34 @@
1966  Table  Op      Msg_type        Msg_text
1967  test.t1        check   status  OK
1968  DROP TABLE t1;
1969 +create table t1 (a geometry not null, spatial index(a));
1970 +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
1971 +insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
1972 +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
1973 +insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
1974 +insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
1975 +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
1976 +insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
1977 +insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
1978 +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
1979 +insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
1980 +insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
1981 +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
1982 +insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
1983 +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
1984 +insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
1985 +insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
1986 +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
1987 +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
1988 +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
1989 +insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
1990 +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
1991 +insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
1992 +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
1993 +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
1994 +insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
1995 +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
1996 +insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
1997 +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
1998 +insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
1999 +drop table t1;
2000 diff -urN mysql-4.1.23/mysql-test/r/group_by.result mysql-4.1/mysql-test/r/group_by.result
2001 --- mysql-4.1.23/mysql-test/r/group_by.result   2007-12-02 20:38:25.000000000 +0100
2002 +++ mysql-4.1/mysql-test/r/group_by.result      2007-07-31 07:45:59.000000000 +0200
2003 @@ -818,3 +818,20 @@
2004  2
2005  1
2006  DROP TABLE t1;
2007 +CREATE TABLE t1 (
2008 +f1 int(10) unsigned NOT NULL auto_increment primary key,
2009 +f2 varchar(100) NOT NULL default ''
2010 +);
2011 +CREATE TABLE t2 (
2012 +f1 varchar(10) NOT NULL default '',
2013 +f2 char(3) NOT NULL default '',
2014 +PRIMARY KEY  (`f1`),
2015 +KEY `k1` (`f2`,`f1`)
2016 +);
2017 +INSERT INTO t1 values(NULL, '');
2018 +INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
2019 +SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2020 +avg(t2.f1)
2021 +SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2022 +avg(t2.f1)
2023 +DROP TABLE t1, t2;
2024 diff -urN mysql-4.1.23/mysql-test/r/having.result mysql-4.1/mysql-test/r/having.result
2025 --- mysql-4.1.23/mysql-test/r/having.result     2007-12-02 20:38:27.000000000 +0100
2026 +++ mysql-4.1/mysql-test/r/having.result        2007-07-21 07:55:59.000000000 +0200
2027 @@ -158,3 +158,22 @@
2028  id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2029  1      SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible HAVING
2030  DROP table t1;
2031 +CREATE TABLE t1 (a int PRIMARY KEY);
2032 +CREATE TABLE t2 (b int PRIMARY KEY, a int);
2033 +CREATE TABLE t3 (b int, flag int);
2034 +INSERT INTO t1 VALUES (1);
2035 +INSERT INTO t2 VALUES (1,1), (2,1), (3,1);
2036 +INSERT INTO t3(b,flag) VALUES (2, 1);
2037 +SELECT t1.a
2038 +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
2039 +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
2040 +a
2041 +SELECT DISTINCT t1.a, MAX(t3.flag)
2042 +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
2043 +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
2044 +a      MAX(t3.flag)
2045 +SELECT DISTINCT t1.a
2046 +FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
2047 +GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
2048 +a
2049 +DROP TABLE t1,t2,t3;
2050 diff -urN mysql-4.1.23/mysql-test/r/heap_btree.result mysql-4.1/mysql-test/r/heap_btree.result
2051 --- mysql-4.1.23/mysql-test/r/heap_btree.result 2007-12-02 20:38:25.000000000 +0100
2052 +++ mysql-4.1/mysql-test/r/heap_btree.result    2007-09-13 12:39:15.000000000 +0200
2053 @@ -307,4 +307,11 @@
2054  ) ENGINE= MEMORY DEFAULT CHARSET= utf8;
2055  INSERT INTO t1 VALUES('1'), ('2');
2056  DROP TABLE t1;
2057 +CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
2058 +INSERT INTO t1 VALUES(1),(2),(2);
2059 +DELETE FROM t1 WHERE a=2;
2060 +SELECT * FROM t1;
2061 +a
2062 +1
2063 +DROP TABLE t1;
2064  End of 4.1 tests
2065 diff -urN mysql-4.1.23/mysql-test/r/innodb_mysql.result mysql-4.1/mysql-test/r/innodb_mysql.result
2066 --- mysql-4.1.23/mysql-test/r/innodb_mysql.result       2007-12-02 20:38:27.000000000 +0100
2067 +++ mysql-4.1/mysql-test/r/innodb_mysql.result  2007-10-04 12:22:30.000000000 +0200
2068 @@ -182,4 +182,40 @@
2069  id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
2070  1      SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
2071  DROP TABLE t1;
2072 +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
2073 +INSERT INTO t1 VALUES ('uk'),('bg');
2074 +SELECT * FROM t1 WHERE a = 'uk';
2075 +a
2076 +uk
2077 +DELETE FROM t1 WHERE a = 'uk';
2078 +SELECT * FROM t1 WHERE a = 'uk';
2079 +a
2080 +UPDATE t1 SET a = 'us' WHERE a = 'uk';
2081 +SELECT * FROM t1 WHERE a = 'uk';
2082 +a
2083 +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
2084 +INSERT INTO t2 VALUES ('uk'),('bg');
2085 +SELECT * FROM t2 WHERE a = 'uk';
2086 +a
2087 +uk
2088 +DELETE FROM t2 WHERE a = 'uk';
2089 +SELECT * FROM t2 WHERE a = 'uk';
2090 +a
2091 +INSERT INTO t2 VALUES ('uk');
2092 +UPDATE t2 SET a = 'us' WHERE a = 'uk';
2093 +SELECT * FROM t2 WHERE a = 'uk';
2094 +a
2095 +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
2096 +INSERT INTO t3 VALUES ('uk'),('bg');
2097 +SELECT * FROM t3 WHERE a = 'uk';
2098 +a
2099 +uk
2100 +DELETE FROM t3 WHERE a = 'uk';
2101 +SELECT * FROM t3 WHERE a = 'uk';
2102 +a
2103 +INSERT INTO t3 VALUES ('uk');
2104 +UPDATE t3 SET a = 'us' WHERE a = 'uk';
2105 +SELECT * FROM t3 WHERE a = 'uk';
2106 +a
2107 +DROP TABLE t1,t2,t3;
2108  End of 4.1 tests
2109 diff -urN mysql-4.1.23/mysql-test/r/insert_select.result mysql-4.1/mysql-test/r/insert_select.result
2110 --- mysql-4.1.23/mysql-test/r/insert_select.result      2007-12-02 20:38:27.000000000 +0100
2111 +++ mysql-4.1/mysql-test/r/insert_select.result 2007-07-31 07:45:59.000000000 +0200
2112 @@ -690,3 +690,29 @@
2113  INSERT INTO t1 values (1), (2);
2114  INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
2115  DROP TABLE t1;
2116 +CREATE TABLE t1 (
2117 +f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
2118 +f2 varchar(100) NOT NULL default ''
2119 +);
2120 +CREATE TABLE t2 (
2121 +f1 varchar(10) NOT NULL default '',
2122 +f2 char(3) NOT NULL default '',
2123 +PRIMARY KEY  (`f1`),
2124 +KEY `k1` (`f2`, `f1`)
2125 +);
2126 +INSERT INTO t1 values(NULL, '');
2127 +INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
2128 +SELECT COUNT(*) FROM t1;
2129 +COUNT(*)
2130 +1
2131 +SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2132 +min(t2.f1)
2133 +INSERT INTO t1 (f2)
2134 +SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2135 +SELECT COUNT(*) FROM t1;
2136 +COUNT(*)
2137 +1
2138 +SELECT * FROM t1;
2139 +f1     f2
2140 +1      
2141 +DROP TABLE t1, t2;
2142 diff -urN mysql-4.1.23/mysql-test/r/loaddata.result mysql-4.1/mysql-test/r/loaddata.result
2143 --- mysql-4.1.23/mysql-test/r/loaddata.result   2007-12-02 20:38:27.000000000 +0100
2144 +++ mysql-4.1/mysql-test/r/loaddata.result      2007-07-03 18:44:26.000000000 +0200
2145 @@ -1,4 +1,4 @@
2146 -drop table if exists t1;
2147 +drop table if exists t1,t2;
2148  create table t1 (a date, b date, c date not null, d date);
2149  load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
2150  Warnings:
2151 @@ -85,3 +85,57 @@
2152  a"b    cd"ef
2153  a"b    c"d"e
2154  drop table t1;
2155 +CREATE TABLE t1 (
2156 +id INT AUTO_INCREMENT PRIMARY KEY,
2157 +c1 VARCHAR(255)
2158 +);
2159 +CREATE TABLE t2 (
2160 +id INT,
2161 +c2 VARCHAR(255)
2162 +);
2163 +INSERT INTO t1 (c1) VALUES
2164 +('r'),   ('rr'),   ('rrr'),   ('rrrr'),
2165 +('.r'),  ('.rr'),  ('.rrr'),  ('.rrrr'),
2166 +('r.'),  ('rr.'),  ('rrr.'),  ('rrrr.'),
2167 +('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
2168 +SELECT * FROM t1;
2169 +id     c1
2170 +1      r
2171 +2      rr
2172 +3      rrr
2173 +4      rrrr
2174 +5      .r
2175 +6      .rr
2176 +7      .rrr
2177 +8      .rrrr
2178 +9      r.
2179 +10     rr.
2180 +11     rrr.
2181 +12     rrrr.
2182 +13     .r.
2183 +14     .rr.
2184 +15     .rrr.
2185 +16     .rrrr.
2186 +SELECT * INTO OUTFILE 'MYSQL_TEST_DIR/var/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
2187 +r1r    rrrr
2188 +r2r    rrrrrr
2189 +r3r    rrrrrrrr
2190 +r4r    rrrrrrrrrr
2191 +r5r    r.rrr
2192 +r6r    r.rrrrr
2193 +r7r    r.rrrrrrr
2194 +r8r    r.rrrrrrrrr
2195 +r9r    rrr.r
2196 +r10r   rrrrr.r
2197 +r11r   rrrrrrr.r
2198 +r12r   rrrrrrrrr.r
2199 +r13r   r.rr.r
2200 +r14r   r.rrrr.r
2201 +r15r   r.rrrrrr.r
2202 +r16r   r.rrrrrrrr.r
2203 +LOAD DATA INFILE 'MYSQL_TEST_DIR/var/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
2204 +SELECT t1.id, c1, c2 FROM t1 LEFT  JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
2205 +id     c1      c2
2206 +SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
2207 +id     c1      c2
2208 +DROP TABLE t1,t2;
2209 diff -urN mysql-4.1.23/mysql-test/r/myisampack.result mysql-4.1/mysql-test/r/myisampack.result
2210 --- mysql-4.1.23/mysql-test/r/myisampack.result 1970-01-01 01:00:00.000000000 +0100
2211 +++ mysql-4.1/mysql-test/r/myisampack.result    2007-11-07 09:55:27.000000000 +0100
2212 @@ -0,0 +1,29 @@
2213 +CREATE TABLE t1(c1 DOUBLE, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 DOUBLE,
2214 +c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY);
2215 +INSERT INTO t1 VALUES
2216 +(-3.31168791059336e-06,-3.19054655887874e-06,-1.06528081684847e-05,-1.227278240089e-06,-1.66718069164799e-06,-2.59038972510885e-06,-2.83145227805303e-06,-4.09678491270648e-07,-2.22610091291797e-06,6),
2217 +(0.0030743000272545,2.53222044316438e-05,2.78674650061845e-05,1.95914465544536e-05,1.7347572525984e-05,1.87513810069614e-05,1.69882826885005e-05,2.44449336987598e-05,1.89914629921774e-05,9),
2218 +(2.85229319423495e-05,3.05970988282259e-05,3.77161100113133e-05,2.3055238978766e-05,2.08241267364615e-05,2.28009504270553e-05,2.12070165658947e-05,2.84350091565409e-05,2.3366822910704e-05,3),
2219 +(0,0,0,0,0,0,0,0,0,12),
2220 +(3.24544577570754e-05,3.44619021870993e-05,4.37561613201124e-05,2.57556808726748e-05,2.3195354640561e-05,2.58532400758869e-05,2.34934241667179e-05,3.1621640063232e-05,2.58229982746189e-05,19),
2221 +(2.53222044316438e-05,0.00445071933455582,2.97447268116016e-05,2.12379514059868e-05,1.86777776502663e-05,2.0170058676712e-05,1.8946030385445e-05,2.66040037173511e-05,2.09161899668946e-05,20),
2222 +(3.03462382611645e-05,3.26517930083994e-05,3.5242025468662e-05,2.53219745106391e-05,2.24384532945004e-05,2.4052346047657e-05,2.23865572957053e-05,3.1634313969082e-05,2.48285463481801e-05,21),
2223 +(1.95914465544536e-05,2.12379514059868e-05,2.27808649037128e-05,0.000341724375366877,1.4512761275113e-05,1.56475828693953e-05,1.44372366441415e-05,2.07952121981765e-05,1.61488256935919e-05,28),
2224 +(1.7347572525984e-05,1.86777776502663e-05,2.04116907052727e-05,1.4512761275113e-05,0.000432162526082388,1.38116514014465e-05,1.2712914948904e-05,1.82503165178506e-05,1.43043075345922e-05,30),
2225 +(1.68339762136661e-05,1.77836497166611e-05,2.36328309295222e-05,1.30183423732016e-05,1.18674654241553e-05,1.32467273128652e-05,1.24581739117775e-05,1.55624190959406e-05,1.33010638508213e-05,31),
2226 +(1.89643062824415e-05,2.06997140070717e-05,2.29045490159364e-05,1.57918175731019e-05,1.39864987449492e-05,1.50580274578455e-05,1.45908734129609e-05,1.95329296993327e-05,1.5814709481221e-05,32),
2227 +(1.69882826885005e-05,1.8946030385445e-05,2.00820439721439e-05,1.44372366441415e-05,1.2712914948904e-05,1.35209686474184e-05,0.00261563314789896,1.78285095864627e-05,1.46699314500019e-05,34),
2228 +(2.0278186540684e-05,2.18923409729654e-05,2.39981539939738e-05,1.71774589459438e-05,1.54654355357383e-05,1.62731485707636e-05,1.49253140625051e-05,2.18229800160297e-05,1.71923561673718e-05,35),
2229 +(2.44449336987598e-05,2.66040037173511e-05,2.84860148925308e-05,2.07952121981765e-05,1.82503165178506e-05,1.97667730441441e-05,1.78285095864627e-05,0.00166478601822712,2.0299952103232e-05,36),
2230 +(1.89914629921774e-05,2.09161899668946e-05,2.26026841007872e-05,1.61488256935919e-05,1.43043075345922e-05,1.52609063290127e-05,1.46699314500019e-05,2.0299952103232e-05,0.00306670170971682,39),
2231 +(0,0,0,0,0,0,0,0,0,41),
2232 +(0,0,0,0,0,0,0,0,0,17),
2233 +(0,0,0,0,0,0,0,0,0,18),
2234 +(2.51880677333017e-05,2.63051795435778e-05,2.79874748974906e-05,2.02888886670845e-05,1.8178636318197e-05,1.91308527003585e-05,1.83260023644133e-05,2.4422300558171e-05,1.96411467520551e-05,44),
2235 +(2.22402118719591e-05,2.37546284320705e-05,2.58463051055541e-05,1.83391609130854e-05,1.6300720519646e-05,1.74559091886791e-05,1.63733785575587e-05,2.26616253279828e-05,1.79541237435621e-05,45),
2236 +(3.01092775359837e-05,3.23865212934412e-05,4.09444584045994e-05,0,2.15470966302776e-05,2.39082636344032e-05,2.28296706429177e-05,2.9007671511595e-05,2.44201138973326e-05,46);
2237 +FLUSH TABLES;
2238 +CHECK TABLE t1 EXTENDED;
2239 +Table  Op      Msg_type        Msg_text
2240 +test.t1        check   status  OK
2241 +DROP TABLE t1;
2242 diff -urN mysql-4.1.23/mysql-test/r/mysqltest.result mysql-4.1/mysql-test/r/mysqltest.result
2243 --- mysql-4.1.23/mysql-test/r/mysqltest.result  2007-12-02 20:38:26.000000000 +0100
2244 +++ mysql-4.1/mysql-test/r/mysqltest.result     2007-06-19 11:06:02.000000000 +0200
2245 @@ -330,6 +330,7 @@
2246  
2247  In loop
2248  here is the sourced script
2249 +here is the sourced script
2250  mysqltest: At line 1: Missing argument to sleep
2251  mysqltest: At line 1: Missing argument to real_sleep
2252  mysqltest: At line 1: Invalid argument to sleep "abc"
2253 @@ -655,4 +656,43 @@
2254  INSERT INTO t1 SELECT f1 - 512 FROM t1;
2255  SELECT * FROM t1;
2256  DROP TABLE t1;
2257 +CREATE TABLE t1(
2258 +a int, b varchar(255), c datetime
2259 +);
2260 +SHOW COLUMNS FROM t1;
2261 +Field  Type    Null    Key     Default Extra
2262 +a      int(11) YES             NULL    
2263 +b      varchar(255)    YES             NULL    
2264 +c      datetime        YES             NULL    
2265 +statement=SHOW COLUMNS FROM t1 row_number=1, column_name="Type", Value=int(11)
2266 +statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=int(11)
2267 +statement=SHOW COLUMNS FROM t1 row_number=1, column_name=Default, Value=NULL
2268 +value= ->A B<-
2269 +value= 1
2270 +mysqltest: At line 1: query_get_value - argument list started with '(' must be ended with ')'
2271 +mysqltest: At line 1: Missing required argument 'query' to command 'query_get_value'
2272 +mysqltest: At line 1: Missing required argument 'column name' to command 'query_get_value'
2273 +mysqltest: At line 1: Missing required argument 'row number' to command 'query_get_value'
2274 +value= No such row
2275 +value= No such row
2276 +mysqltest: At line 1: Invalid row number: 'notnumber'
2277 +mysqltest: At line 1: Could not find column 'column_not_exists' in the result of 'SHOW COLUMNS FROM t1'
2278 +mysqltest: At line 1: Query 'SET @A = 1' didn't return a result set
2279 +mysqltest: At line 1: Could not find column '1 AS B' in the result of 'SELECT 1 AS A'
2280 +value= No such row
2281 +mysqltest: At line 1: Error running query 'SHOW COLNS FROM t1': 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLNS FROM t1' at line 1
2282 +
2283 +Field Type Null Key Default Extra
2284 +a int(11) YES -><- NULL 
2285 +b varchar(255) YES -><- NULL 
2286 +c datetime YES -><- NULL 
2287 +
2288 +Number of columns with Default NULL: 3
2289 +
2290 +SHOW COLUMNS FROM t1;
2291 +Field  Type    Null    Key     Default Extra
2292 +a      int(11) YES             NULL    
2293 +b      varchar(255)    YES             NULL    
2294 +c      datetime        YES             NULL    
2295 +drop table t1;
2296  End of tests
2297 diff -urN mysql-4.1.23/mysql-test/r/repair.result mysql-4.1/mysql-test/r/repair.result
2298 --- mysql-4.1.23/mysql-test/r/repair.result     2007-12-02 20:38:25.000000000 +0100
2299 +++ mysql-4.1/mysql-test/r/repair.result        2007-10-17 08:29:45.000000000 +0200
2300 @@ -83,3 +83,30 @@
2301  SET myisam_repair_threads=@@global.myisam_repair_threads;
2302  SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
2303  DROP TABLE t1;
2304 +CREATE TABLE t1(a CHAR(255), KEY(a));
2305 +SET myisam_sort_buffer_size=4496;
2306 +INSERT INTO t1 VALUES
2307 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2308 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2309 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2310 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2311 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2312 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2313 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2314 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2315 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2316 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2317 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2318 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2319 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2320 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2321 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
2322 +('0'),('0'),('0'),('0'),('0'),('0'),('0');
2323 +SET myisam_repair_threads=2;
2324 +REPAIR TABLE t1;
2325 +Table  Op      Msg_type        Msg_text
2326 +test.t1        repair  status  OK
2327 +SET myisam_repair_threads=@@global.myisam_repair_threads;
2328 +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
2329 +DROP TABLE t1;
2330 +End of 4.1 tests
2331 diff -urN mysql-4.1.23/mysql-test/r/rpl_change_master.result mysql-4.1/mysql-test/r/rpl_change_master.result
2332 --- mysql-4.1.23/mysql-test/r/rpl_change_master.result  2007-12-02 20:38:25.000000000 +0100
2333 +++ mysql-4.1/mysql-test/r/rpl_change_master.result     2007-06-19 12:19:19.000000000 +0200
2334 @@ -15,12 +15,74 @@
2335  n
2336  1
2337  show slave status;
2338 -Slave_IO_State Master_Host     Master_User     Master_Port     Connect_Retry   Master_Log_File Read_Master_Log_Pos     Relay_Log_File  Relay_Log_Pos   Relay_Master_Log_File   Slave_IO_Running        Slave_SQL_Running       Replicate_Do_DB Replicate_Ignore_DB     Replicate_Do_Table      Replicate_Ignore_Table  Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table     Last_Errno      Last_Error      Skip_Counter    Exec_Master_Log_Pos     Relay_Log_Space Until_Condition Until_Log_File  Until_Log_Pos   Master_SSL_Allowed      Master_SSL_CA_File      Master_SSL_CA_Path      Master_SSL_Cert Master_SSL_Cipher       Master_SSL_Key  Seconds_Behind_Master
2339 -#      127.0.0.1       root    MASTER_MYPORT   1       master-bin.000001       273     slave-relay-bin.000002  258     master-bin.000001       No      No                                                      0               0       214     317     None            0       No                                              #
2340 +Slave_IO_State #
2341 +Master_Host    127.0.0.1
2342 +Master_User    root
2343 +Master_Port    MASTER_MYPORT
2344 +Connect_Retry  1
2345 +Master_Log_File        master-bin.000001
2346 +Read_Master_Log_Pos    273
2347 +Relay_Log_File slave-relay-bin.000002
2348 +Relay_Log_Pos  258
2349 +Relay_Master_Log_File  master-bin.000001
2350 +Slave_IO_Running       No
2351 +Slave_SQL_Running      No
2352 +Replicate_Do_DB        
2353 +Replicate_Ignore_DB    
2354 +Replicate_Do_Table     
2355 +Replicate_Ignore_Table 
2356 +Replicate_Wild_Do_Table        
2357 +Replicate_Wild_Ignore_Table    
2358 +Last_Errno     0
2359 +Last_Error     
2360 +Skip_Counter   0
2361 +Exec_Master_Log_Pos    214
2362 +Relay_Log_Space        317
2363 +Until_Condition        None
2364 +Until_Log_File 
2365 +Until_Log_Pos  0
2366 +Master_SSL_Allowed     No
2367 +Master_SSL_CA_File     
2368 +Master_SSL_CA_Path     
2369 +Master_SSL_Cert        
2370 +Master_SSL_Cipher      
2371 +Master_SSL_Key 
2372 +Seconds_Behind_Master  #
2373  change master to master_user='root';
2374  show slave status;
2375 -Slave_IO_State Master_Host     Master_User     Master_Port     Connect_Retry   Master_Log_File Read_Master_Log_Pos     Relay_Log_File  Relay_Log_Pos   Relay_Master_Log_File   Slave_IO_Running        Slave_SQL_Running       Replicate_Do_DB Replicate_Ignore_DB     Replicate_Do_Table      Replicate_Ignore_Table  Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table     Last_Errno      Last_Error      Skip_Counter    Exec_Master_Log_Pos     Relay_Log_Space Until_Condition Until_Log_File  Until_Log_Pos   Master_SSL_Allowed      Master_SSL_CA_File      Master_SSL_CA_Path      Master_SSL_Cert Master_SSL_Cipher       Master_SSL_Key  Seconds_Behind_Master
2376 -#      127.0.0.1       root    MASTER_MYPORT   1       master-bin.000001       214     #       #       master-bin.000001       No      No                                                      0               0       214     #       None            0       No                                              #
2377 +Slave_IO_State #
2378 +Master_Host    127.0.0.1
2379 +Master_User    root
2380 +Master_Port    MASTER_MYPORT
2381 +Connect_Retry  1
2382 +Master_Log_File        master-bin.000001
2383 +Read_Master_Log_Pos    214
2384 +Relay_Log_File #
2385 +Relay_Log_Pos  #
2386 +Relay_Master_Log_File  master-bin.000001
2387 +Slave_IO_Running       No
2388 +Slave_SQL_Running      No
2389 +Replicate_Do_DB        
2390 +Replicate_Ignore_DB    
2391 +Replicate_Do_Table     
2392 +Replicate_Ignore_Table 
2393 +Replicate_Wild_Do_Table        
2394 +Replicate_Wild_Ignore_Table    
2395 +Last_Errno     0
2396 +Last_Error     
2397 +Skip_Counter   0
2398 +Exec_Master_Log_Pos    214
2399 +Relay_Log_Space        #
2400 +Until_Condition        None
2401 +Until_Log_File 
2402 +Until_Log_Pos  0
2403 +Master_SSL_Allowed     No
2404 +Master_SSL_CA_File     
2405 +Master_SSL_CA_Path     
2406 +Master_SSL_Cert        
2407 +Master_SSL_Cipher      
2408 +Master_SSL_Key 
2409 +Seconds_Behind_Master  #
2410  select release_lock("a");
2411  release_lock("a")
2412  1
2413 diff -urN mysql-4.1.23/mysql-test/r/select.result mysql-4.1/mysql-test/r/select.result
2414 --- mysql-4.1.23/mysql-test/r/select.result     2007-12-02 20:38:26.000000000 +0100
2415 +++ mysql-4.1/mysql-test/r/select.result        2007-11-07 16:45:01.000000000 +0100
2416 @@ -2835,4 +2835,12 @@
2417  FFFFFFFFFFFFFFFF       7FFFFFFFFFFFFFFF
2418  8FFFFFFFFFFFFFFF       7FFFFFFFFFFFFFFF
2419  drop table t1;
2420 +CREATE TABLE t1 (c0 int);
2421 +CREATE TABLE t2 (c0 int);
2422 +INSERT INTO t1 VALUES(@@connect_timeout);
2423 +INSERT INTO t2 VALUES(@@connect_timeout);
2424 +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout);
2425 +c0     c0
2426 +X      X
2427 +DROP TABLE t1, t2;
2428  End of 4.1 tests
2429 diff -urN mysql-4.1.23/mysql-test/r/subselect.result mysql-4.1/mysql-test/r/subselect.result
2430 --- mysql-4.1.23/mysql-test/r/subselect.result  2007-12-02 20:38:27.000000000 +0100
2431 +++ mysql-4.1/mysql-test/r/subselect.result     2007-06-06 15:29:14.000000000 +0200
2432 @@ -2834,6 +2834,8 @@
2433  4
2434  DROP TABLE t1,t2,t3;
2435  purge master logs before (select adddate(current_timestamp(), interval -4 day));
2436 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select adddate(current_timestamp(), interval -4 day))' at line 1
2437 +purge master logs before adddate(current_timestamp(), interval -4 day);
2438  CREATE TABLE t1 (f1 INT);
2439  CREATE TABLE t2 (f2 INT);
2440  INSERT INTO t1 VALUES (1);
2441 diff -urN mysql-4.1.23/mysql-test/r/symlink.result mysql-4.1/mysql-test/r/symlink.result
2442 --- mysql-4.1.23/mysql-test/r/symlink.result    2007-12-02 20:38:26.000000000 +0100
2443 +++ mysql-4.1/mysql-test/r/symlink.result       2007-11-12 18:51:47.000000000 +0100
2444 @@ -90,6 +90,12 @@
2445    `b` int(11) default NULL
2446  ) ENGINE=MyISAM DEFAULT CHARSET=latin1
2447  drop table t1;
2448 +CREATE TABLE t1(a INT)
2449 +DATA DIRECTORY='TEST_DIR/master-data/mysql'
2450 +INDEX DIRECTORY='TEST_DIR/master-data/mysql';
2451 +RENAME TABLE t1 TO user;
2452 +ERROR HY000: Can't create/write to file 'TEST_DIR/master-data/mysql/user.MYI' (Errcode: 17)
2453 +DROP TABLE t1;
2454  show create table t1;
2455  Table  Create Table
2456  t1     CREATE TABLE `t1` (
2457 diff -urN mysql-4.1.23/mysql-test/r/type_enum.result mysql-4.1/mysql-test/r/type_enum.result
2458 --- mysql-4.1.23/mysql-test/r/type_enum.result  2007-12-02 20:38:26.000000000 +0100
2459 +++ mysql-4.1/mysql-test/r/type_enum.result     2007-06-27 00:41:47.000000000 +0200
2460 @@ -1778,4 +1778,27 @@
2461  create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','\ 1\ 2\ 3\ 4\ 5\ 6\a\b 
2462  \v\f\r\ e\ f\10\11\12\13\14\15\16\17\18\19\1a\e\1c\1d\1e\1f !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\\7f','yy\\80','zz\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f\90\91\92\93\94\95\96\97\98\99\9a\9b\9c\9d\9e\9f ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'));
2463  ERROR 42000: Field separator argument is not what is expected; check the manual
2464 +CREATE TABLE t1 (
2465 +id INT AUTO_INCREMENT PRIMARY KEY,
2466 +c1 ENUM('a', '', 'b')
2467 +);
2468 +INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b');
2469 +Warnings:
2470 +Warning        1265    Data truncated for column 'c1' at row 1
2471 +SELECT id, c1 + 0, c1 FROM t1;
2472 +id     c1 + 0  c1
2473 +1      0       
2474 +2      1       a
2475 +3      2       
2476 +4      3       b
2477 +ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL;
2478 +Warnings:
2479 +Warning        1265    Data truncated for column 'c1' at row 4
2480 +SELECT id, c1 + 0, c1 FROM t1;
2481 +id     c1 + 0  c1
2482 +1      0       
2483 +2      1       a
2484 +3      2       
2485 +4      0       
2486 +DROP TABLE t1;
2487  End of 4.1 tests
2488 diff -urN mysql-4.1.23/mysql-test/r/variables.result mysql-4.1/mysql-test/r/variables.result
2489 --- mysql-4.1.23/mysql-test/r/variables.result  2007-12-02 20:38:25.000000000 +0100
2490 +++ mysql-4.1/mysql-test/r/variables.result     2007-10-18 10:47:51.000000000 +0200
2491 @@ -561,3 +561,6 @@
2492  select @@query_prealloc_size = @test;
2493  @@query_prealloc_size = @test
2494  1
2495 +set global sql_mode=repeat('a',80);
2496 +ERROR 42000: Variable 'sql_mode' can't be set to the value of 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
2497 +End of 4.1 tests
2498 diff -urN mysql-4.1.23/mysql-test/t/almost_full.test mysql-4.1/mysql-test/t/almost_full.test
2499 --- mysql-4.1.23/mysql-test/t/almost_full.test  1970-01-01 01:00:00.000000000 +0100
2500 +++ mysql-4.1/mysql-test/t/almost_full.test     2007-11-12 10:00:21.000000000 +0100
2501 @@ -0,0 +1,41 @@
2502 +#
2503 +# Some special cases with empty tables
2504 +#
2505 +
2506 +--disable_warnings
2507 +drop table if exists t1;
2508 +--enable_warnings
2509 +
2510 +set global myisam_data_pointer_size=2;
2511 +CREATE TABLE t1 (a int auto_increment primary key not null, b longtext) ENGINE=MyISAM;
2512 +
2513 +--disable_query_log
2514 +let $1= 303;
2515 +while ($1)
2516 +{
2517 +  INSERT INTO t1 SET b=repeat('a',200);
2518 +  dec $1;
2519 +}
2520 +--enable_query_log
2521 +
2522 +DELETE FROM t1 WHERE a=1 or a=5;
2523 +
2524 +--error 1114
2525 +INSERT INTO t1 SET b=repeat('a',600);
2526 +CHECK TABLE t1 EXTENDED;
2527 +
2528 +--error 1114
2529 +UPDATE t1 SET b=repeat('a', 800) where a=10;
2530 +CHECK TABLE t1 EXTENDED;
2531 +
2532 +INSERT INTO t1 SET b=repeat('a',400);
2533 +CHECK TABLE t1 EXTENDED;
2534 +
2535 +DELETE FROM t1 WHERE a=2 or a=6;
2536 +UPDATE t1 SET b=repeat('a', 600) where a=11;
2537 +CHECK TABLE t1 EXTENDED;
2538 +drop table t1;
2539 +
2540 +set global myisam_data_pointer_size=default;
2541 +
2542 +# End of 4.1 tests
2543 diff -urN mysql-4.1.23/mysql-test/t/bigint.test mysql-4.1/mysql-test/t/bigint.test
2544 --- mysql-4.1.23/mysql-test/t/bigint.test       2007-12-02 20:38:51.000000000 +0100
2545 +++ mysql-4.1/mysql-test/t/bigint.test  2007-11-12 12:51:40.000000000 +0100
2546 @@ -107,4 +107,13 @@
2547  
2548  drop table t1, t2;
2549  
2550 +# Test for BUG#30069, can't handle bigint -9223372036854775808 on
2551 +# x86_64, with some GCC versions and optimizations.
2552 +
2553 +create table t1 (sint64 bigint not null);
2554 +insert into t1 values (-9223372036854775808);
2555 +select * from t1;
2556 +
2557 +drop table t1;
2558 +
2559  # End of 4.1 tests
2560 diff -urN mysql-4.1.23/mysql-test/t/ctype_ucs.test mysql-4.1/mysql-test/t/ctype_ucs.test
2561 --- mysql-4.1.23/mysql-test/t/ctype_ucs.test    2007-12-02 20:38:51.000000000 +0100
2562 +++ mysql-4.1/mysql-test/t/ctype_ucs.test       2007-10-24 13:09:29.000000000 +0200
2563 @@ -535,4 +535,12 @@
2564  
2565  drop table bug20536;
2566  
2567 +#
2568 +# BUG#31159 - fulltext search on ucs2 column crashes server
2569 +#
2570 +CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci);
2571 +INSERT INTO t1 VALUES('abcd');
2572 +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE);
2573 +DROP TABLE t1;
2574 +
2575  --echo End of 4.1 tests
2576 diff -urN mysql-4.1.23/mysql-test/t/delete.test mysql-4.1/mysql-test/t/delete.test
2577 --- mysql-4.1.23/mysql-test/t/delete.test       2007-12-02 20:38:52.000000000 +0100
2578 +++ mysql-4.1/mysql-test/t/delete.test  2007-09-10 14:26:49.000000000 +0200
2579 @@ -184,4 +184,17 @@
2580  select @a;
2581  drop table t1;
2582  
2583 +# BUG#30385 "Server crash when deleting with order by and limit"
2584 +CREATE TABLE t1 (
2585 +  `date` date ,
2586 +  `time` time ,
2587 +  `seq` int(10) unsigned NOT NULL auto_increment,
2588 +  PRIMARY KEY  (`seq`),
2589 +  KEY `seq` (`seq`),
2590 +  KEY `time` (`time`),
2591 +  KEY `date` (`date`)
2592 +);
2593 +DELETE FROM t1 ORDER BY date ASC, time ASC LIMIT 1;
2594 +drop table t1;
2595 +
2596  --echo End of 4.1 tests
2597 diff -urN mysql-4.1.23/mysql-test/t/disabled.def mysql-4.1/mysql-test/t/disabled.def
2598 --- mysql-4.1.23/mysql-test/t/disabled.def      2007-12-02 20:38:51.000000000 +0100
2599 +++ mysql-4.1/mysql-test/t/disabled.def 2007-11-02 10:11:26.000000000 +0100
2600 @@ -10,3 +10,4 @@
2601  #
2602  ##############################################################################
2603  
2604 +rpl000015       :  Bug#31030 - rpl000015.test fails if $MYSQL_TCP_PORT != 3306
2605 diff -urN mysql-4.1.23/mysql-test/t/fulltext.test mysql-4.1/mysql-test/t/fulltext.test
2606 --- mysql-4.1.23/mysql-test/t/fulltext.test     2007-12-02 20:38:26.000000000 +0100
2607 +++ mysql-4.1/mysql-test/t/fulltext.test        2007-10-30 11:46:42.000000000 +0100
2608 @@ -379,4 +379,12 @@
2609  SELECT * FROM t1 WHERE MATCH(a) AGAINST('test');
2610  DROP TABLE t1;
2611  
2612 +#
2613 +# BUG#11392 - fulltext search bug
2614 +#
2615 +CREATE TABLE t1(a TEXT);
2616 +INSERT INTO t1 VALUES(' aaaaa aaaa');
2617 +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE);
2618 +DROP TABLE t1;
2619 +
2620  # End of 4.1 tests
2621 diff -urN mysql-4.1.23/mysql-test/t/func_str.test mysql-4.1/mysql-test/t/func_str.test
2622 --- mysql-4.1.23/mysql-test/t/func_str.test     2007-12-02 20:38:26.000000000 +0100
2623 +++ mysql-4.1/mysql-test/t/func_str.test        2007-10-30 09:35:02.000000000 +0100
2624 @@ -721,4 +721,17 @@
2625  explain extended select decode(f1,'zxcv') as 'enc' from t1;
2626  drop table t1;
2627  
2628 +#
2629 +# Bug #31758 inet_ntoa, oct, crashes server with null + filesort 
2630 +#
2631 +create table t1 (a bigint not null)engine=myisam;
2632 +insert into t1 set a = 1024*1024*1024*4;
2633 +delete from t1 order by (inet_ntoa(a)) desc limit 10;
2634 +drop table t1;
2635 +create table t1 (a char(36) not null)engine=myisam;
2636 +insert ignore into t1 set a = ' ';
2637 +insert ignore into t1 set a = ' ';
2638 +select * from t1 order by (oct(a));
2639 +drop table t1;
2640 +
2641  --echo End of 4.1 tests
2642 diff -urN mysql-4.1.23/mysql-test/t/gis-rtree.test mysql-4.1/mysql-test/t/gis-rtree.test
2643 --- mysql-4.1.23/mysql-test/t/gis-rtree.test    2007-12-02 20:38:26.000000000 +0100
2644 +++ mysql-4.1/mysql-test/t/gis-rtree.test       2007-10-05 12:40:31.000000000 +0200
2645 @@ -798,4 +798,40 @@
2646  CHECK TABLE t1 EXTENDED;
2647  DROP TABLE t1;
2648  
2649 +#
2650 +# Bug #30286 spatial index cause corruption and server crash!
2651 +#
2652 +
2653 +create table t1 (a geometry not null, spatial index(a));
2654 +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
2655 +insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
2656 +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
2657 +insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
2658 +insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
2659 +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
2660 +insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
2661 +insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
2662 +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
2663 +insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
2664 +insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
2665 +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
2666 +insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
2667 +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
2668 +insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
2669 +insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
2670 +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
2671 +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
2672 +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
2673 +insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
2674 +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
2675 +insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
2676 +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
2677 +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
2678 +insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
2679 +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
2680 +insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
2681 +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
2682 +insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
2683 +drop table t1;
2684 +
2685  # End of 4.1 tests
2686 diff -urN mysql-4.1.23/mysql-test/t/gis.test mysql-4.1/mysql-test/t/gis.test
2687 --- mysql-4.1.23/mysql-test/t/gis.test  2007-12-02 20:38:27.000000000 +0100
2688 +++ mysql-4.1/mysql-test/t/gis.test     2007-10-03 10:35:33.000000000 +0200
2689 @@ -419,4 +419,12 @@
2690  SELECT * FROM t1;
2691  DROP TABLE t1;
2692  
2693 +#
2694 +# Bug #30955 geomfromtext() crasher
2695 +#
2696 +CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
2697 +INSERT INTO `t1` VALUES ('','0000-00-00');
2698 +select geomfromtext(col9,col89) as a from t1;
2699 +DROP TABLE t1;
2700 +
2701  --echo End of 4.1 tests
2702 diff -urN mysql-4.1.23/mysql-test/t/group_by.test mysql-4.1/mysql-test/t/group_by.test
2703 --- mysql-4.1.23/mysql-test/t/group_by.test     2007-12-02 20:38:27.000000000 +0100
2704 +++ mysql-4.1/mysql-test/t/group_by.test        2007-07-31 07:45:59.000000000 +0200
2705 @@ -633,4 +633,27 @@
2706  SELECT a FROM t1 ORDER BY "a" DESC;
2707  SELECT a FROM t1 ORDER BY `a` DESC;
2708  DROP TABLE t1;
2709 +
2710 +
2711 +#
2712 +# Bug #29717 INSERT INTO SELECT inserts values even if SELECT statement itself
2713 +# returns empty
2714 +# 
2715 +CREATE TABLE t1 (
2716 +    f1 int(10) unsigned NOT NULL auto_increment primary key,
2717 +    f2 varchar(100) NOT NULL default ''
2718 +);
2719 +CREATE TABLE t2 (
2720 +    f1 varchar(10) NOT NULL default '',
2721 +    f2 char(3) NOT NULL default '',
2722 +    PRIMARY KEY  (`f1`),
2723 +    KEY `k1` (`f2`,`f1`)
2724 +);
2725 +
2726 +INSERT INTO t1 values(NULL, '');
2727 +INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
2728 +SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2729 +SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2730 +DROP TABLE t1, t2;
2731 +
2732  # End of 4.1 tests
2733 diff -urN mysql-4.1.23/mysql-test/t/having.test mysql-4.1/mysql-test/t/having.test
2734 --- mysql-4.1.23/mysql-test/t/having.test       2007-12-02 20:38:26.000000000 +0100
2735 +++ mysql-4.1/mysql-test/t/having.test  2007-07-21 07:55:59.000000000 +0200
2736 @@ -151,4 +151,30 @@
2737  
2738  DROP table t1;  
2739  
2740 +#
2741 +# Bug #29911: HAVING clause depending on constant table and evaluated to false
2742 +#
2743 +
2744 +CREATE TABLE t1 (a int PRIMARY KEY);
2745 +CREATE TABLE t2 (b int PRIMARY KEY, a int);
2746 +CREATE TABLE t3 (b int, flag int);
2747 +
2748 +INSERT INTO t1 VALUES (1);
2749 +INSERT INTO t2 VALUES (1,1), (2,1), (3,1);
2750 +INSERT INTO t3(b,flag) VALUES (2, 1);
2751 +
2752 +SELECT t1.a
2753 +  FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
2754 +    GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
2755 +
2756 +SELECT DISTINCT t1.a, MAX(t3.flag)
2757 +  FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
2758 +    GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
2759 +
2760 +SELECT DISTINCT t1.a
2761 +  FROM t1 INNER JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b
2762 +    GROUP BY t1.a, t2.b HAVING MAX(t3.flag)=0;
2763 +
2764 +DROP TABLE t1,t2,t3;
2765 +
2766  # End of 4.1 tests
2767 diff -urN mysql-4.1.23/mysql-test/t/heap_btree.test mysql-4.1/mysql-test/t/heap_btree.test
2768 --- mysql-4.1.23/mysql-test/t/heap_btree.test   2007-12-02 20:38:51.000000000 +0100
2769 +++ mysql-4.1/mysql-test/t/heap_btree.test      2007-09-13 12:39:15.000000000 +0200
2770 @@ -213,4 +213,13 @@
2771  INSERT INTO t1 VALUES('1'), ('2');
2772  DROP TABLE t1;
2773  
2774 +#
2775 +# BUG#30590 - delete from memory table with composite btree primary key
2776 +#
2777 +CREATE TABLE t1 (a INT, KEY USING BTREE(a)) ENGINE=MEMORY;
2778 +INSERT INTO t1 VALUES(1),(2),(2);
2779 +DELETE FROM t1 WHERE a=2;
2780 +SELECT * FROM t1;
2781 +DROP TABLE t1;
2782 +
2783  --echo End of 4.1 tests
2784 diff -urN mysql-4.1.23/mysql-test/t/innodb_mysql.test mysql-4.1/mysql-test/t/innodb_mysql.test
2785 --- mysql-4.1.23/mysql-test/t/innodb_mysql.test 2007-12-02 20:38:26.000000000 +0100
2786 +++ mysql-4.1/mysql-test/t/innodb_mysql.test    2007-10-04 12:22:30.000000000 +0200
2787 @@ -216,4 +216,36 @@
2788  
2789  DROP TABLE t1;
2790  
2791 +#
2792 +# Bug #28878: InnoDB tables with UTF8 character set and indexes cause wrong result for DML
2793 +#
2794 +
2795 +CREATE TABLE t1 (a CHAR(2), KEY (a)) ENGINE = InnoDB DEFAULT CHARSET=UTF8;
2796 +INSERT INTO t1 VALUES ('uk'),('bg');
2797 +SELECT * FROM t1 WHERE a = 'uk';
2798 +DELETE FROM t1 WHERE a = 'uk';
2799 +SELECT * FROM t1 WHERE a = 'uk';
2800 +UPDATE t1 SET a = 'us' WHERE a = 'uk';
2801 +SELECT * FROM t1 WHERE a = 'uk';
2802 +
2803 +CREATE TABLE t2 (a CHAR(2), KEY (a)) ENGINE = InnoDB;
2804 +INSERT INTO t2 VALUES ('uk'),('bg');
2805 +SELECT * FROM t2 WHERE a = 'uk';
2806 +DELETE FROM t2 WHERE a = 'uk';
2807 +SELECT * FROM t2 WHERE a = 'uk';
2808 +INSERT INTO t2 VALUES ('uk');
2809 +UPDATE t2 SET a = 'us' WHERE a = 'uk';
2810 +SELECT * FROM t2 WHERE a = 'uk';
2811 +
2812 +CREATE TABLE t3 (a CHAR(2), KEY (a)) ENGINE = MyISAM;
2813 +INSERT INTO t3 VALUES ('uk'),('bg');
2814 +SELECT * FROM t3 WHERE a = 'uk';
2815 +DELETE FROM t3 WHERE a = 'uk';
2816 +SELECT * FROM t3 WHERE a = 'uk';
2817 +INSERT INTO t3 VALUES ('uk');
2818 +UPDATE t3 SET a = 'us' WHERE a = 'uk';
2819 +SELECT * FROM t3 WHERE a = 'uk';
2820 +
2821 +DROP TABLE t1,t2,t3;
2822 +
2823  --echo End of 4.1 tests
2824 diff -urN mysql-4.1.23/mysql-test/t/insert_select.test mysql-4.1/mysql-test/t/insert_select.test
2825 --- mysql-4.1.23/mysql-test/t/insert_select.test        2007-12-02 20:38:51.000000000 +0100
2826 +++ mysql-4.1/mysql-test/t/insert_select.test   2007-07-31 07:45:59.000000000 +0200
2827 @@ -239,4 +239,32 @@
2828  
2829  DROP TABLE t1;
2830  
2831 +#
2832 +# Bug #29717 INSERT INTO SELECT inserts values even if SELECT statement itself returns empty
2833 +#
2834 +
2835 +CREATE TABLE t1 (
2836 +    f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
2837 +    f2 varchar(100) NOT NULL default ''
2838 +);
2839 +CREATE TABLE t2 (
2840 +    f1 varchar(10) NOT NULL default '',
2841 +    f2 char(3) NOT NULL default '',
2842 +    PRIMARY KEY  (`f1`),
2843 +    KEY `k1` (`f2`, `f1`)
2844 +);
2845 +
2846 +INSERT INTO t1 values(NULL, '');
2847 +INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
2848 +SELECT COUNT(*) FROM t1;
2849 +
2850 +SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2851 +
2852 +INSERT INTO t1 (f2)
2853 +  SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
2854 +
2855 +SELECT COUNT(*) FROM t1;
2856 +SELECT * FROM t1;
2857 +DROP TABLE t1, t2;
2858 +
2859  # End of 4.1 tests
2860 diff -urN mysql-4.1.23/mysql-test/t/loaddata.test mysql-4.1/mysql-test/t/loaddata.test
2861 --- mysql-4.1.23/mysql-test/t/loaddata.test     2007-12-02 20:38:52.000000000 +0100
2862 +++ mysql-4.1/mysql-test/t/loaddata.test        2007-07-03 18:38:21.000000000 +0200
2863 @@ -3,7 +3,7 @@
2864  #
2865  
2866  --disable_warnings
2867 -drop table if exists t1;
2868 +drop table if exists t1,t2;
2869  --enable_warnings
2870  
2871  create table t1 (a date, b date, c date not null, d date);
2872 @@ -67,4 +67,39 @@
2873  select * from t1;
2874  drop table t1;
2875  
2876 +#
2877 +# Bug #29294 SELECT INTO OUTFILE/LOAD DATA INFILE with special
2878 +# characters in the FIELDS ENCLOSED BY clause
2879 +#
2880 +
2881 +CREATE TABLE t1 (
2882 +  id INT AUTO_INCREMENT PRIMARY KEY,
2883 +  c1 VARCHAR(255)
2884 +);
2885 +
2886 +CREATE TABLE t2 (
2887 +  id INT,
2888 +  c2 VARCHAR(255)
2889 +);
2890 +
2891 +INSERT INTO t1 (c1) VALUES
2892 +  ('r'),   ('rr'),   ('rrr'),   ('rrrr'),
2893 +  ('.r'),  ('.rr'),  ('.rrr'),  ('.rrrr'),
2894 +  ('r.'),  ('rr.'),  ('rrr.'),  ('rrrr.'),
2895 +  ('.r.'), ('.rr.'), ('.rrr.'), ('.rrrr.');
2896 +SELECT * FROM t1;
2897 +
2898 +--exec rm -f $MYSQL_TEST_DIR/var/tmp/t1
2899 +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
2900 +eval SELECT * INTO OUTFILE '$MYSQL_TEST_DIR/var/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1;
2901 +--exec cat $MYSQL_TEST_DIR/var/tmp/t1
2902 +
2903 +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
2904 +eval LOAD DATA INFILE '$MYSQL_TEST_DIR/var/tmp/t1' INTO TABLE t2 FIELDS ENCLOSED BY 'r';
2905 +SELECT t1.id, c1, c2 FROM t1 LEFT  JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
2906 +SELECT t1.id, c1, c2 FROM t1 RIGHT JOIN t2 ON t1.id=t2.id WHERE c1 != c2;
2907 +
2908 +--exec rm $MYSQL_TEST_DIR/var/tmp/t1
2909 +DROP TABLE t1,t2;
2910 +
2911  # End of 4.1 tests
2912 diff -urN mysql-4.1.23/mysql-test/t/myisampack.test mysql-4.1/mysql-test/t/myisampack.test
2913 --- mysql-4.1.23/mysql-test/t/myisampack.test   1970-01-01 01:00:00.000000000 +0100
2914 +++ mysql-4.1/mysql-test/t/myisampack.test      2007-11-07 09:55:27.000000000 +0100
2915 @@ -0,0 +1,33 @@
2916 +#
2917 +# BUG#31277 - myisamchk --unpack corrupts a table
2918 +#
2919 +CREATE TABLE t1(c1 DOUBLE, c2 DOUBLE, c3 DOUBLE, c4 DOUBLE, c5 DOUBLE,
2920 +  c6 DOUBLE, c7 DOUBLE, c8 DOUBLE, c9 DOUBLE, a INT PRIMARY KEY);
2921 +INSERT INTO t1 VALUES
2922 +(-3.31168791059336e-06,-3.19054655887874e-06,-1.06528081684847e-05,-1.227278240089e-06,-1.66718069164799e-06,-2.59038972510885e-06,-2.83145227805303e-06,-4.09678491270648e-07,-2.22610091291797e-06,6),
2923 +(0.0030743000272545,2.53222044316438e-05,2.78674650061845e-05,1.95914465544536e-05,1.7347572525984e-05,1.87513810069614e-05,1.69882826885005e-05,2.44449336987598e-05,1.89914629921774e-05,9),
2924 +(2.85229319423495e-05,3.05970988282259e-05,3.77161100113133e-05,2.3055238978766e-05,2.08241267364615e-05,2.28009504270553e-05,2.12070165658947e-05,2.84350091565409e-05,2.3366822910704e-05,3),
2925 +(0,0,0,0,0,0,0,0,0,12),
2926 +(3.24544577570754e-05,3.44619021870993e-05,4.37561613201124e-05,2.57556808726748e-05,2.3195354640561e-05,2.58532400758869e-05,2.34934241667179e-05,3.1621640063232e-05,2.58229982746189e-05,19),
2927 +(2.53222044316438e-05,0.00445071933455582,2.97447268116016e-05,2.12379514059868e-05,1.86777776502663e-05,2.0170058676712e-05,1.8946030385445e-05,2.66040037173511e-05,2.09161899668946e-05,20),
2928 +(3.03462382611645e-05,3.26517930083994e-05,3.5242025468662e-05,2.53219745106391e-05,2.24384532945004e-05,2.4052346047657e-05,2.23865572957053e-05,3.1634313969082e-05,2.48285463481801e-05,21),
2929 +(1.95914465544536e-05,2.12379514059868e-05,2.27808649037128e-05,0.000341724375366877,1.4512761275113e-05,1.56475828693953e-05,1.44372366441415e-05,2.07952121981765e-05,1.61488256935919e-05,28),
2930 +(1.7347572525984e-05,1.86777776502663e-05,2.04116907052727e-05,1.4512761275113e-05,0.000432162526082388,1.38116514014465e-05,1.2712914948904e-05,1.82503165178506e-05,1.43043075345922e-05,30),
2931 +(1.68339762136661e-05,1.77836497166611e-05,2.36328309295222e-05,1.30183423732016e-05,1.18674654241553e-05,1.32467273128652e-05,1.24581739117775e-05,1.55624190959406e-05,1.33010638508213e-05,31),
2932 +(1.89643062824415e-05,2.06997140070717e-05,2.29045490159364e-05,1.57918175731019e-05,1.39864987449492e-05,1.50580274578455e-05,1.45908734129609e-05,1.95329296993327e-05,1.5814709481221e-05,32),
2933 +(1.69882826885005e-05,1.8946030385445e-05,2.00820439721439e-05,1.44372366441415e-05,1.2712914948904e-05,1.35209686474184e-05,0.00261563314789896,1.78285095864627e-05,1.46699314500019e-05,34),
2934 +(2.0278186540684e-05,2.18923409729654e-05,2.39981539939738e-05,1.71774589459438e-05,1.54654355357383e-05,1.62731485707636e-05,1.49253140625051e-05,2.18229800160297e-05,1.71923561673718e-05,35),
2935 +(2.44449336987598e-05,2.66040037173511e-05,2.84860148925308e-05,2.07952121981765e-05,1.82503165178506e-05,1.97667730441441e-05,1.78285095864627e-05,0.00166478601822712,2.0299952103232e-05,36),
2936 +(1.89914629921774e-05,2.09161899668946e-05,2.26026841007872e-05,1.61488256935919e-05,1.43043075345922e-05,1.52609063290127e-05,1.46699314500019e-05,2.0299952103232e-05,0.00306670170971682,39),
2937 +(0,0,0,0,0,0,0,0,0,41),
2938 +(0,0,0,0,0,0,0,0,0,17),
2939 +(0,0,0,0,0,0,0,0,0,18),
2940 +(2.51880677333017e-05,2.63051795435778e-05,2.79874748974906e-05,2.02888886670845e-05,1.8178636318197e-05,1.91308527003585e-05,1.83260023644133e-05,2.4422300558171e-05,1.96411467520551e-05,44),
2941 +(2.22402118719591e-05,2.37546284320705e-05,2.58463051055541e-05,1.83391609130854e-05,1.6300720519646e-05,1.74559091886791e-05,1.63733785575587e-05,2.26616253279828e-05,1.79541237435621e-05,45),
2942 +(3.01092775359837e-05,3.23865212934412e-05,4.09444584045994e-05,0,2.15470966302776e-05,2.39082636344032e-05,2.28296706429177e-05,2.9007671511595e-05,2.44201138973326e-05,46);
2943 +FLUSH TABLES;
2944 +--exec $MYISAMPACK -s $MYSQLTEST_VARDIR/master-data/test/t1
2945 +--exec $MYISAMCHK -srq $MYSQLTEST_VARDIR/master-data/test/t1
2946 +--exec $MYISAMCHK -s --unpack $MYSQLTEST_VARDIR/master-data/test/t1
2947 +CHECK TABLE t1 EXTENDED;
2948 +DROP TABLE t1;
2949 diff -urN mysql-4.1.23/mysql-test/t/mysqltest.test mysql-4.1/mysql-test/t/mysqltest.test
2950 --- mysql-4.1.23/mysql-test/t/mysqltest.test    2007-12-02 20:38:27.000000000 +0100
2951 +++ mysql-4.1/mysql-test/t/mysqltest.test       2007-06-19 11:06:02.000000000 +0200
2952 @@ -807,6 +807,10 @@
2953  }
2954  --enable_abort_on_error
2955  --enable_query_log
2956 +
2957 +# Test source $variable/<filename>
2958 +--source $MYSQLTEST_VARDIR/tmp/sourced.inc
2959 +
2960  --remove_file $MYSQLTEST_VARDIR/tmp/sourced.inc
2961  
2962  # ----------------------------------------------------------------------------
2963 @@ -1811,4 +1815,125 @@
2964  --enable_result_log
2965  DROP TABLE t1;
2966  
2967 +# ----------------------------------------------------------------------------
2968 +# test for query_get_value
2969 +# ----------------------------------------------------------------------------
2970 +
2971 +CREATE TABLE t1(
2972 + a int, b varchar(255), c datetime
2973 +);
2974 +SHOW COLUMNS FROM t1;
2975 +
2976 +#------------ Positive tests ------------
2977 +# 1. constant parameters
2978 +#    value is simple string without spaces
2979 +let $value= query_get_value(SHOW COLUMNS FROM t1, Type, 1);
2980 +--echo statement=SHOW COLUMNS FROM t1 row_number=1, column_name="Type", Value=$value
2981 +let $value= query_get_value("SHOW COLUMNS FROM t1", Type, 1);
2982 +--echo statement="SHOW COLUMNS FROM t1" row_number=1, column_name="Type", Value=$value
2983 +#
2984 +# 2. $variables as parameters
2985 +#    value IS NULL
2986 +let $my_show= SHOW COLUMNS FROM t1;
2987 +let $column_name= Default;
2988 +let $row_number= 1;
2989 +let $value= query_get_value($my_show, $column_name, $row_number);
2990 +--echo statement=$my_show row_number=$row_number, column_name=$column_name, Value=$value
2991 +#
2992 +# 3. result set of a SELECT (not recommended, because projection and
2993 +#         selection could be done much better by pure SELECT functionality)
2994 +#    value is string with space in the middle
2995 +let $value= query_get_value(SELECT 'A B' AS "MyColumn", MyColumn, 1);
2996 +--echo value= ->$value<-
2997 +#
2998 +# 4. column name with space
2999 +let $value= query_get_value(SELECT 1 AS "My Column", My Column, 1);
3000 +--echo value= $value
3001 +#
3002 +#------------ Negative tests ------------
3003 +# 5. Incomplete statement including missing parameters
3004 +# 5.1 incomplete statement
3005 +--error 1
3006 +--exec echo "let \$value= query_get_value(SHOW;" | $MYSQL_TEST 2>&1
3007 +# 5.2 missing query
3008 +--error 1
3009 +--exec echo "let \$value= query_get_value;" | $MYSQL_TEST 2>&1
3010 +# 5.3 missing column name
3011 +--error 1
3012 +--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1);" | $MYSQL_TEST 2>&1
3013 +# 5.4 missing row number
3014 +--error 1
3015 +--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field);" | $MYSQL_TEST 2>&1
3016 +#
3017 +# 6. Somehow "wrong" value of parameters
3018 +# 6.1 row parameter
3019 +# 6.1.1 non sense number 0
3020 +let $value= initialized;
3021 +let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 0);
3022 +--echo value= $value
3023 +# 6.1.2 after the last row
3024 +let $value= initialized;
3025 +let $value= query_get_value(SHOW COLUMNS FROM t1, Field, 10);
3026 +--echo value= $value
3027 +# 6.1.3 invalid row number
3028 +--error 1
3029 +--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, Field, notnumber);" | $MYSQL_TEST 2>&1
3030 +# 6.2 column name parameter, name of not existing column
3031 +--error 1
3032 +--exec echo "let \$value= query_get_value(SHOW COLUMNS FROM t1, column_not_exists, 1);" | $MYSQL_TEST 2>&1
3033 +# 6.3. statement which never gives a result set
3034 +--error 1
3035 +--exec echo "let \$value= query_get_value(SET @A = 1, Field, 1);" | $MYSQL_TEST 2>&1
3036 +# 6.4. statement contains a ","
3037 +#      Note: There is no need to improve this, because we need query_get_value
3038 +#            for SHOW commands only.
3039 +--error 1
3040 +--exec echo "let \$value= query_get_value(SELECT 1 AS "A", 1 AS "B", 1);" | $MYSQL_TEST 2>&1
3041 +#
3042 +# 7. empty result set
3043 +let $value= initialized;
3044 +let $value= query_get_value(SELECT a FROM t1, a, 1);
3045 +--echo value= $value
3046 +#
3047 +# 9. failing statement
3048 +--error 1
3049 +--exec echo "let \$value= query_get_value(SHOW COLNS FROM t1, Field, 1);" | $MYSQL_TEST 2>&1
3050 +#
3051 +# 10. Artificial example how to process a complete SHOW result set:
3052 +let $show_statement= SHOW COLUMNS FROM t1;
3053 +let $rowno= 1;
3054 +let $run=1;
3055 +let $count= 0;
3056 +--echo
3057 +--echo Field Type Null Key Default Extra
3058 +while ($run)
3059 +{
3060 +   let $Field=   query_get_value($show_statement, Field,   $rowno);
3061 +   if (`SELECT '$Field' = 'No such row'`)
3062 +   {
3063 +      let $run= 0;
3064 +   }
3065 +   if (`SELECT '$Field' <> 'No such row'`)
3066 +   {
3067 +      let $Type=    query_get_value($show_statement, Type,    $rowno);
3068 +      let $Null=    query_get_value($show_statement, Null,    $rowno);
3069 +      if (`SELECT '$Null' = 'YES'`)
3070 +      {
3071 +         inc $count;
3072 +      }
3073 +      let $Key=     query_get_value($show_statement, Key,     $rowno);
3074 +      let $Default= query_get_value($show_statement, Default, $rowno);
3075 +      let $Extra=   query_get_value($show_statement, Extra,   $rowno);
3076 +      --echo $Field $Type $Null ->$Key<- $Default $Extra
3077 +      inc $rowno;
3078 +   }
3079 +}
3080 +--echo
3081 +--echo Number of columns with Default NULL: $count
3082 +--echo
3083 +eval $show_statement;
3084 +
3085 +drop table t1;
3086 +
3087  --echo End of tests
3088 +
3089 diff -urN mysql-4.1.23/mysql-test/t/repair.test mysql-4.1/mysql-test/t/repair.test
3090 --- mysql-4.1.23/mysql-test/t/repair.test       2007-12-02 20:38:25.000000000 +0100
3091 +++ mysql-4.1/mysql-test/t/repair.test  2007-10-17 08:29:45.000000000 +0200
3092 @@ -83,4 +83,33 @@
3093  SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
3094  DROP TABLE t1;
3095  
3096 -# End of 4.1 tests
3097 +#
3098 +# BUG#31174 - "Repair" command on MyISAM crashes with small 
3099 +#              myisam_sort_buffer_size
3100 +#
3101 +CREATE TABLE t1(a CHAR(255), KEY(a));
3102 +SET myisam_sort_buffer_size=4496;
3103 +INSERT INTO t1 VALUES
3104 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3105 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3106 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3107 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3108 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3109 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3110 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3111 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3112 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3113 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3114 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3115 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3116 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3117 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3118 +('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),('0'),
3119 +('0'),('0'),('0'),('0'),('0'),('0'),('0');
3120 +SET myisam_repair_threads=2;
3121 +REPAIR TABLE t1;
3122 +SET myisam_repair_threads=@@global.myisam_repair_threads;
3123 +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
3124 +DROP TABLE t1;
3125 +
3126 +--echo End of 4.1 tests
3127 diff -urN mysql-4.1.23/mysql-test/t/rpl_change_master.test mysql-4.1/mysql-test/t/rpl_change_master.test
3128 --- mysql-4.1.23/mysql-test/t/rpl_change_master.test    2007-12-02 20:38:51.000000000 +0100
3129 +++ mysql-4.1/mysql-test/t/rpl_change_master.test       2007-06-19 12:19:19.000000000 +0200
3130 @@ -14,11 +14,11 @@
3131  --replace_result $MASTER_MYPORT MASTER_MYPORT
3132  --replace_column 1 # 8 # 9 # 23 # 33 #
3133  --replace_column 1 # 33 #
3134 -show slave status;
3135 +query_vertical show slave status;
3136  change master to master_user='root';
3137  --replace_result $MASTER_MYPORT MASTER_MYPORT
3138  --replace_column 1 # 8 # 9 # 23 # 33 #
3139 -show slave status;
3140 +query_vertical show slave status;
3141  # Will restart from after the values(2), which is bug
3142  select release_lock("a");
3143  start slave;
3144 diff -urN mysql-4.1.23/mysql-test/t/select.test mysql-4.1/mysql-test/t/select.test
3145 --- mysql-4.1.23/mysql-test/t/select.test       2007-12-02 20:38:51.000000000 +0100
3146 +++ mysql-4.1/mysql-test/t/select.test  2007-11-07 16:45:01.000000000 +0100
3147 @@ -2353,4 +2353,25 @@
3148  select hex(a), hex(b) from t1;
3149  drop table t1;
3150  
3151 +#
3152 +# Bug #32103: optimizer crash when join on int and mediumint with variable in 
3153 +#             where clause
3154 +#
3155 +
3156 +CREATE TABLE t1 (c0 int);
3157 +CREATE TABLE t2 (c0 int);
3158 +
3159 +# We need any variable that:
3160 +# 1. has integer type, 
3161 +# 2. can be used with the "@@name" syntax
3162 +# 3. available in every server build
3163 +INSERT INTO t1 VALUES(@@connect_timeout);
3164 +INSERT INTO t2 VALUES(@@connect_timeout);
3165 +
3166 +# We only need to ensure 1 row is returned to validate the results
3167 +--replace_column 1 X 2 X
3168 +SELECT * FROM t1 JOIN t2 ON t1.c0 = t2.c0 WHERE (t1.c0 <=> @@connect_timeout);
3169 +
3170 +DROP TABLE t1, t2;
3171 +
3172  --echo End of 4.1 tests
3173 diff -urN mysql-4.1.23/mysql-test/t/subselect.test mysql-4.1/mysql-test/t/subselect.test
3174 --- mysql-4.1.23/mysql-test/t/subselect.test    2007-12-02 20:38:27.000000000 +0100
3175 +++ mysql-4.1/mysql-test/t/subselect.test       2007-06-06 15:29:14.000000000 +0200
3176 @@ -1815,11 +1815,12 @@
3177  DROP TABLE t1,t2,t3;
3178  
3179  #
3180 -# BUG #10308: purge log with subselect
3181 +# BUG#10308: purge log with subselect
3182 +# Bug#28553: mysqld crash in "purge master log before(select time from information_schema)"
3183  #
3184 -
3185 +--error 1064
3186  purge master logs before (select adddate(current_timestamp(), interval -4 day));
3187 -
3188 +purge master logs before adddate(current_timestamp(), interval -4 day);
3189  
3190  #
3191  # Bug#18503: Queries with a quantified subquery returning empty set may
3192 diff -urN mysql-4.1.23/mysql-test/t/symlink.test mysql-4.1/mysql-test/t/symlink.test
3193 --- mysql-4.1.23/mysql-test/t/symlink.test      2007-12-02 20:38:51.000000000 +0100
3194 +++ mysql-4.1/mysql-test/t/symlink.test 2007-11-12 18:51:28.000000000 +0100
3195 @@ -119,6 +119,18 @@
3196  drop table t1;
3197  
3198  #
3199 +# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE
3200 +#
3201 +--replace_result $MYSQLTEST_VARDIR TEST_DIR
3202 +eval CREATE TABLE t1(a INT)
3203 +DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql'
3204 +INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql';
3205 +--replace_result $MYSQLTEST_VARDIR TEST_DIR
3206 +--error 1
3207 +RENAME TABLE t1 TO user;
3208 +DROP TABLE t1;
3209 +
3210 +#
3211  # Test specifying DATA DIRECTORY that is the same as what would normally
3212  # have been chosen. (Bug #8707)
3213  #
3214 diff -urN mysql-4.1.23/mysql-test/t/type_enum.test mysql-4.1/mysql-test/t/type_enum.test
3215 --- mysql-4.1.23/mysql-test/t/type_enum.test    2007-12-02 20:38:25.000000000 +0100
3216 +++ mysql-4.1/mysql-test/t/type_enum.test       2007-06-27 00:41:46.000000000 +0200
3217 @@ -156,4 +156,21 @@
3218  create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ','\ 1\ 2\ 3\ 4\ 5\ 6\a\b 
3219  \v\f\r\ e\ f\10\11\12\13\14\15\16\17\18\19\1a\e\1c\1d\1e\1f !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\\7f','yy\\80','zz\81\82\83\84\85\86\87\88\89\8a\8b\8c\8d\8e\8f\90\91\92\93\94\95\96\97\98\99\9a\9b\9c\9d\9e\9f ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'));
3220  
3221 +#
3222 +# Bug #29251: MySQL coerces special 0 enum values to normal '' value
3223 +# when ALTERing the column
3224 +#
3225 +
3226 +CREATE TABLE t1 (
3227 +  id INT AUTO_INCREMENT PRIMARY KEY,
3228 +  c1 ENUM('a', '', 'b')
3229 +);
3230 +INSERT INTO t1 (c1) VALUES (0), ('a'), (''), ('b');
3231 +SELECT id, c1 + 0, c1 FROM t1;
3232 +
3233 +ALTER TABLE t1 CHANGE c1 c1 ENUM('a', '') NOT NULL;
3234 +SELECT id, c1 + 0, c1 FROM t1;
3235 +
3236 +DROP TABLE t1;
3237 +
3238  --echo End of 4.1 tests
3239 diff -urN mysql-4.1.23/mysql-test/t/variables.test mysql-4.1/mysql-test/t/variables.test
3240 --- mysql-4.1.23/mysql-test/t/variables.test    2007-12-02 20:38:25.000000000 +0100
3241 +++ mysql-4.1/mysql-test/t/variables.test       2007-10-18 10:47:52.000000000 +0200
3242 @@ -447,4 +447,11 @@
3243  set @@query_prealloc_size = @test;
3244  select @@query_prealloc_size = @test;
3245  
3246 -# End of 4.1 tests
3247 +#
3248 +# Bug#31588 buffer overrun when setting variables
3249 +#
3250 +# Buffer-size Off By One. Should throw valgrind-warning without fix #31588.
3251 +--error 1231
3252 +set global sql_mode=repeat('a',80);
3253 +
3254 +--echo End of 4.1 tests
3255 diff -urN mysql-4.1.23/mysys/charset.c mysql-4.1/mysys/charset.c
3256 --- mysql-4.1.23/mysys/charset.c        2007-12-02 20:38:25.000000000 +0100
3257 +++ mysql-4.1/mysys/charset.c   2007-10-24 13:09:29.000000000 +0200
3258 @@ -673,3 +673,43 @@
3259    return fs_cset_cache;
3260  }
3261  #endif
3262 +
3263 +
3264 +/**
3265 +  @brief Find compatible character set with ctype.
3266 +
3267 +  @param[in] original_cs Original character set
3268 +
3269 +  @note
3270 +    128 my_charset_ucs2_general_uca      ->192 my_charset_utf8_general_uca_ci
3271 +    129 my_charset_ucs2_icelandic_uca_ci ->193 my_charset_utf8_icelandic_uca_ci
3272 +    130 my_charset_ucs2_latvian_uca_ci   ->194 my_charset_utf8_latvian_uca_ci
3273 +    131 my_charset_ucs2_romanian_uca_ci  ->195 my_charset_utf8_romanian_uca_ci
3274 +    132 my_charset_ucs2_slovenian_uca_ci ->196 my_charset_utf8_slovenian_uca_ci
3275 +    133 my_charset_ucs2_polish_uca_ci    ->197 my_charset_utf8_polish_uca_ci
3276 +    134 my_charset_ucs2_estonian_uca_ci  ->198 my_charset_utf8_estonian_uca_ci
3277 +    135 my_charset_ucs2_spanish_uca_ci   ->199 my_charset_utf8_spanish_uca_ci
3278 +    136 my_charset_ucs2_swedish_uca_ci   ->200 my_charset_utf8_swedish_uca_ci
3279 +    137 my_charset_ucs2_turkish_uca_ci   ->201 my_charset_utf8_turkish_uca_ci
3280 +    138 my_charset_ucs2_czech_uca_ci     ->202 my_charset_utf8_czech_uca_ci
3281 +    139 my_charset_ucs2_danish_uca_ci    ->203 my_charset_utf8_danish_uca_ci
3282 +    140 my_charset_ucs2_lithuanian_uca_ci->204 my_charset_utf8_lithuanian_uca_ci
3283 +    141 my_charset_ucs2_slovak_uca_ci    ->205 my_charset_utf8_slovak_uca_ci
3284 +    142 my_charset_ucs2_spanish2_uca_ci  ->206 my_charset_utf8_spanish2_uca_ci
3285 +    143 my_charset_ucs2_roman_uca_ci     ->207 my_charset_utf8_roman_uca_ci
3286 +    144 my_charset_ucs2_persian_uca_ci   ->208 my_charset_utf8_persian_uca_ci
3287 +
3288 +  @return Compatible character set or NULL.
3289 +*/
3290 +
3291 +CHARSET_INFO *get_compatible_charset_with_ctype(CHARSET_INFO *original_cs)
3292 +{
3293 +  CHARSET_INFO *compatible_cs= 0;
3294 +  DBUG_ENTER("get_compatible_charset_with_ctype");
3295 +  if (!strcmp(original_cs->csname, "ucs2") &&
3296 +      (compatible_cs= get_charset(original_cs->number + 64, MYF(0))) &&
3297 +      (!compatible_cs->ctype ||
3298 +       strcmp(original_cs->name + 4, compatible_cs->name + 4)))
3299 +    compatible_cs= 0;
3300 +  DBUG_RETURN(compatible_cs);
3301 +}
3302 diff -urN mysql-4.1.23/mysys/hash.c mysql-4.1/mysys/hash.c
3303 --- mysql-4.1.23/mysys/hash.c   2007-12-02 20:38:25.000000000 +0100
3304 +++ mysql-4.1/mysys/hash.c      2007-07-05 08:45:13.000000000 +0200
3305 @@ -572,6 +572,25 @@
3306      previous->next=pos->next;          /* unlink pos */
3307  
3308    /* Move data to correct position */
3309 +  if (new_index == empty)
3310 +  {
3311 +    /*
3312 +      At this point record is unlinked from the old chain, thus it holds
3313 +      random position. By the chance this position is equal to position
3314 +      for the first element in the new chain. That means updated record
3315 +      is the only record in the new chain.
3316 +    */
3317 +    if (empty != idx)
3318 +    {
3319 +      /*
3320 +        Record was moved while unlinking it from the old chain.
3321 +        Copy data to a new position.
3322 +      */
3323 +      data[empty]= org_link;
3324 +    }
3325 +    data[empty].next= NO_RECORD;
3326 +    DBUG_RETURN(0);
3327 +  }
3328    pos=data+new_index;
3329    new_pos_index=hash_rec_mask(hash,pos,blength,records);
3330    if (new_index != new_pos_index)
3331 diff -urN mysql-4.1.23/mysys/my_pthread.c mysql-4.1/mysys/my_pthread.c
3332 --- mysql-4.1.23/mysys/my_pthread.c     2007-12-02 20:38:50.000000000 +0100
3333 +++ mysql-4.1/mysys/my_pthread.c        2007-07-30 20:38:48.000000000 +0200
3334 @@ -30,7 +30,7 @@
3335  #define SCHED_POLICY SCHED_OTHER
3336  #endif
3337  
3338 -uint thd_lib_detected;
3339 +uint thd_lib_detected= 0;
3340  
3341  #ifndef my_pthread_setprio
3342  void my_pthread_setprio(pthread_t thread_id,int prior)
3343 diff -urN mysql-4.1.23/mysys/my_symlink2.c mysql-4.1/mysys/my_symlink2.c
3344 --- mysql-4.1.23/mysys/my_symlink2.c    2007-12-02 20:38:27.000000000 +0100
3345 +++ mysql-4.1/mysys/my_symlink2.c       2007-11-12 11:55:20.000000000 +0100
3346 @@ -125,6 +125,7 @@
3347    int was_symlink= (!my_disable_symlinks &&
3348                     !my_readlink(link_name, from, MYF(0)));
3349    int result=0;
3350 +  int name_is_different;
3351    DBUG_ENTER("my_rename_with_symlink");
3352  
3353    if (!was_symlink)
3354 @@ -133,6 +134,14 @@
3355    /* Change filename that symlink pointed to */
3356    strmov(tmp_name, to);
3357    fn_same(tmp_name,link_name,1);               /* Copy dir */
3358 +  name_is_different= strcmp(link_name, tmp_name);
3359 +  if (name_is_different && !access(tmp_name, F_OK))
3360 +  {
3361 +    my_errno= EEXIST;
3362 +    if (MyFlags & MY_WME)
3363 +      my_error(EE_CANTCREATEFILE, MYF(0), tmp_name, EEXIST);
3364 +    DBUG_RETURN(1);
3365 +  }
3366  
3367    /* Create new symlink */
3368    if (my_symlink(tmp_name, to, MyFlags))
3369 @@ -144,7 +153,7 @@
3370      the same basename and different directories.
3371     */
3372  
3373 -  if (strcmp(link_name, tmp_name) && my_rename(link_name, tmp_name, MyFlags))
3374 +  if (name_is_different && my_rename(link_name, tmp_name, MyFlags))
3375    {
3376      int save_errno=my_errno;
3377      my_delete(to, MyFlags);                    /* Remove created symlink */
3378 diff -urN mysql-4.1.23/scripts/mysql_config.sh mysql-4.1/scripts/mysql_config.sh
3379 --- mysql-4.1.23/scripts/mysql_config.sh        2007-12-02 20:38:27.000000000 +0100
3380 +++ mysql-4.1/scripts/mysql_config.sh   2007-08-29 22:24:05.000000000 +0200
3381 @@ -122,7 +122,7 @@
3382  cflags=`echo "$cflags"|sed -e 's/ *\$//'` 
3383  
3384  # Same for --libs(_r)
3385 -for remove in lmtmalloc static-libcxa i-static
3386 +for remove in lmtmalloc static-libcxa i-static static-intel
3387  do
3388    # We know the strings starts with a space
3389    libs=`echo "$libs"|sed -e "s/ -$remove  */ /g"` 
3390 diff -urN mysql-4.1.23/scripts/mysql_setpermission.sh mysql-4.1/scripts/mysql_setpermission.sh
3391 --- mysql-4.1.23/scripts/mysql_setpermission.sh 2007-12-02 20:38:52.000000000 +0100
3392 +++ mysql-4.1/scripts/mysql_setpermission.sh    2007-08-01 11:48:53.000000000 +0200
3393 @@ -19,13 +19,14 @@
3394  ## 1.3 Applied patch provided by Martin Mokrejs <mmokrejs@natur.cuni.cz>
3395  ##     (General code cleanup, use the GRANT statement instead of updating
3396  ##     the privilege tables directly, added option to revoke privileges)
3397 +## 1.4 Remove option 6 which attempted to erroneously grant global privileges
3398  
3399  #### TODO
3400  #
3401  # empty ... suggestions ... mail them to me ...
3402  
3403  
3404 -$version="1.3";
3405 +$version="1.4";
3406  
3407  use DBI;
3408  use Getopt::Long;
3409 @@ -103,13 +104,9 @@
3410                 print "     existing database and host combination (user can do\n";
3411                 print "     SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,\n";
3412                 print "     LOCK TABLES,CREATE TEMPORARY TABLES)\n";
3413 -    print "  6. Create/append database administrative privileges for an\n";
3414 -               print "     existing database and host combination (user can do\n";
3415 -               print "     SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,\n";
3416 -               print "     CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS)\n";
3417 -    print "  7. Create/append full privileges for an existing database\n";
3418 +    print "  6. Create/append full privileges for an existing database\n";
3419                 print "     and host combination (user has FULL privilege)\n";
3420 -    print "  8. Remove all privileges for for an existing database and\n";
3421 +    print "  7. Remove all privileges for for an existing database and\n";
3422                 print "     host combination.\n";
3423      print "     (user will have all permission fields set to N)\n";
3424      print "  0. exit this program\n";
3425 @@ -117,10 +114,10 @@
3426      while (<STDIN>) {
3427        $answer = $_;
3428        chomp($answer);
3429 -      if ($answer =~ /^[12345678]$/) {
3430 +      if ($answer =~ /^[1234567]$/) {
3431          if ($answer == 1) {
3432            setpwd();
3433 -        } elsif ($answer =~ /^[2345678]$/) {
3434 +        } elsif ($answer =~ /^[234567]$/) {
3435            addall($answer);
3436         } else {
3437            print "Sorry, something went wrong. With such option number you should not get here.\n\n";
3438 @@ -233,7 +230,7 @@
3439    }
3440    }
3441  
3442 -  if ( ( !$todo ) or not ( $todo =~ m/^[2-8]$/ ) ) {
3443 +  if ( ( !$todo ) or not ( $todo =~ m/^[2-7]$/ ) ) {
3444      print STDERR "Sorry, select option $todo isn't known inside the program .. See ya\n";
3445      quit();
3446    }
3447 @@ -256,12 +253,9 @@
3448        # user privileges: SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES
3449        $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
3450      } elsif ($todo == 6) {
3451 -       # admin privileges: GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS
3452 -       $sth = $dbh->do("GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,LOCK TABLES,CREATE TEMPORARY TABLES,SHOW DATABASES,PROCESS ON $db.* TO $user@\"$host\" IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
3453 -    } elsif ($todo == 7) {
3454         # all privileges
3455         $sth = $dbh->do("GRANT ALL ON $db.* TO \'$user\'\@\'$host\' IDENTIFIED BY \'$pass\'") || die $dbh->errstr;
3456 -    } elsif ($todo == 8) {
3457 +    } elsif ($todo == 7) {
3458         # all privileges set to N
3459         $sth = $dbh->do("REVOKE ALL ON *.* FROM \'$user\'\@\'$host\'") || die $dbh->errstr;
3460      }
3461 diff -urN mysql-4.1.23/sql/field.cc mysql-4.1/sql/field.cc
3462 --- mysql-4.1.23/sql/field.cc   2007-12-02 20:38:25.000000000 +0100
3463 +++ mysql-4.1/sql/field.cc      2007-10-04 12:22:30.000000000 +0200
3464 @@ -5211,7 +5211,8 @@
3465                            length / field_charset->mbmaxlen);
3466    memcpy(buff, ptr, bytes);
3467    if (bytes < length)
3468 -    bzero(buff + bytes, length - bytes);
3469 +    field_charset->cset->fill(field_charset, buff + bytes, length - bytes,
3470 +                              ' ');
3471    return bytes;
3472  }
3473  
3474 diff -urN mysql-4.1.23/sql/field_conv.cc mysql-4.1/sql/field_conv.cc
3475 --- mysql-4.1.23/sql/field_conv.cc      2007-12-02 20:38:51.000000000 +0100
3476 +++ mysql-4.1/sql/field_conv.cc 2007-06-27 00:41:45.000000000 +0200
3477 @@ -311,6 +311,15 @@
3478  }
3479  
3480  
3481 +static void do_field_enum(Copy_field *copy)
3482 +{
3483 +  if (copy->from_field->val_int() == 0)
3484 +    ((Field_enum *) copy->to_field)->store_type((ulonglong) 0);
3485 +  else
3486 +    do_field_string(copy);
3487 +}
3488 +
3489 +
3490  static void do_field_int(Copy_field *copy)
3491  {
3492    longlong value=copy->from_field->val_int();
3493 @@ -538,7 +547,13 @@
3494           to->real_type() == FIELD_TYPE_SET)
3495        {
3496         if (!to->eq_def(from))
3497 -         return do_field_string;
3498 +        {
3499 +          if (from->real_type() == MYSQL_TYPE_ENUM &&
3500 +              to->real_type() == MYSQL_TYPE_ENUM)
3501 +            return do_field_enum;
3502 +          else
3503 +            return do_field_string;
3504 +        }
3505        }
3506        else if (to->charset() != from->charset())
3507         return do_field_string;
3508 diff -urN mysql-4.1.23/sql/gstream.cc mysql-4.1/sql/gstream.cc
3509 --- mysql-4.1.23/sql/gstream.cc 2007-12-02 20:38:51.000000000 +0100
3510 +++ mysql-4.1/sql/gstream.cc    2007-10-03 10:30:31.000000000 +0200
3511 @@ -45,7 +45,7 @@
3512    skip_space();
3513    res->str= (char*) m_cur;
3514    /* The following will also test for \0 */
3515 -  if (!my_isvar_start(&my_charset_bin, *m_cur))
3516 +  if ((m_cur >= m_limit) || !my_isvar_start(&my_charset_bin, *m_cur))
3517      return 1;
3518  
3519    /*
3520 diff -urN mysql-4.1.23/sql/item_func.cc mysql-4.1/sql/item_func.cc
3521 --- mysql-4.1.23/sql/item_func.cc       2007-12-02 20:38:52.000000000 +0100
3522 +++ mysql-4.1/sql/item_func.cc  2007-10-24 13:09:29.000000000 +0200
3523 @@ -2243,7 +2243,7 @@
3524    else
3525    {
3526  #ifdef EMBEDDED_LIBRARY
3527 -    if (ull->locked && pthread_equal(current_thd->real_id,ull->thread))
3528 +    if (ull->locked && (current_thd->real_id == ull->thread))
3529  #else
3530      if (ull->locked && pthread_equal(pthread_self(),ull->thread))
3531  #endif
3532 @@ -3135,13 +3135,44 @@
3533      my_error(ER_WRONG_ARGUMENTS,MYF(0),"MATCH");
3534      return 1;
3535    }
3536 -  table=((Item_field *)item)->field->table;
3537 +  /*
3538 +    With prepared statements Item_func_match::fix_fields is called twice.
3539 +    When it is called first time we have original item tree here and add
3540 +    conversion layer for character sets that do not have ctype array a few
3541 +    lines below. When it is called second time, we already have conversion
3542 +    layer in item tree.
3543 +  */
3544 +  table= (item->type() == Item::FIELD_ITEM) ?
3545 +         ((Item_field *)item)->field->table :
3546 +         ((Item_field *)((Item_func_conv *)item)->key_item())->field->table;
3547    if (!(table->file->table_flags() & HA_CAN_FULLTEXT))
3548    {
3549      my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0));
3550      return 1;
3551    }
3552    table->fulltext_searched=1;
3553 +  /* A workaround for ucs2 character set */
3554 +  if (!args[1]->collation.collation->ctype)
3555 +  {
3556 +    CHARSET_INFO *compatible_cs=
3557 +      get_compatible_charset_with_ctype(args[1]->collation.collation);
3558 +    bool rc= 1;
3559 +    if (compatible_cs)
3560 +    {
3561 +      Item_string *conv_item= new Item_string("", 0, compatible_cs,
3562 +                                              DERIVATION_EXPLICIT);
3563 +      item= args[0];
3564 +      args[0]= conv_item;
3565 +      rc= agg_item_charsets(cmp_collation, func_name(), args, arg_count,
3566 +                            MY_COLL_ALLOW_SUPERSET_CONV |
3567 +                            MY_COLL_ALLOW_COERCIBLE_CONV |
3568 +                            MY_COLL_DISALLOW_NONE);
3569 +      args[0]= item;
3570 +    }
3571 +    else
3572 +      my_error(ER_WRONG_ARGUMENTS, MYF(0), "MATCH");
3573 +    return rc;
3574 +  }
3575    return agg_arg_collations_for_comparison(cmp_collation, args+1, arg_count-1);
3576  }
3577  
3578 diff -urN mysql-4.1.23/sql/item.h mysql-4.1/sql/item.h
3579 --- mysql-4.1.23/sql/item.h     2007-12-02 20:38:51.000000000 +0100
3580 +++ mysql-4.1/sql/item.h        2007-11-07 16:45:01.000000000 +0100
3581 @@ -690,7 +690,7 @@
3582    double val()
3583      { DBUG_ASSERT(fixed == 1); return ulonglong2double((ulonglong)value); }
3584    String *val_str(String*);
3585 -  Item *new_item() { return new Item_uint(name,max_length); }
3586 +  Item *new_item() { return new Item_uint(name, value, max_length); }
3587    int save_in_field(Field *field, bool no_conversions);
3588    void print(String *str);
3589    Item_num *neg ();
3590 diff -urN mysql-4.1.23/sql/item_strfunc.h mysql-4.1/sql/item_strfunc.h
3591 --- mysql-4.1.23/sql/item_strfunc.h     2007-12-02 20:38:26.000000000 +0100
3592 +++ mysql-4.1/sql/item_strfunc.h        2007-10-30 09:35:02.000000000 +0100
3593 @@ -531,6 +531,7 @@
3594    {
3595      collation.set(default_charset());
3596      decimals=0; max_length=64;
3597 +    maybe_null= 1;
3598    }
3599  };
3600  
3601 @@ -623,7 +624,7 @@
3602      }
3603    String* val_str(String* str);
3604    const char *func_name() const { return "inet_ntoa"; }
3605 -  void fix_length_and_dec() { decimals = 0; max_length=3*8+7; }
3606 +  void fix_length_and_dec() { decimals = 0; max_length=3*8+7; maybe_null=1;}
3607  };
3608  
3609  class Item_func_quote :public Item_str_func
3610 diff -urN mysql-4.1.23/sql/lock.cc mysql-4.1/sql/lock.cc
3611 --- mysql-4.1.23/sql/lock.cc    2007-12-02 20:38:51.000000000 +0100
3612 +++ mysql-4.1/sql/lock.cc       2007-06-01 10:50:12.000000000 +0200
3613 @@ -155,6 +155,13 @@
3614      if (thr_multi_lock(sql_lock->locks + sql_lock->lock_count,
3615                         sql_lock->lock_count))
3616      {
3617 +      /*
3618 +        reset_lock_data is required here. If thr_multi_lock fails it
3619 +        resets lock type for tables, which were locked before (and
3620 +        including) one that caused error. Lock type for other tables
3621 +        preserved.
3622 +      */
3623 +      reset_lock_data(sql_lock);
3624        thd->some_tables_deleted=1;              // Try again
3625        sql_lock->lock_count=0;                  // Locks are alread freed
3626      }
3627 diff -urN mysql-4.1.23/sql/mysql_priv.h mysql-4.1/sql/mysql_priv.h
3628 --- mysql-4.1.23/sql/mysql_priv.h       2007-12-02 20:38:51.000000000 +0100
3629 +++ mysql-4.1/sql/mysql_priv.h  2007-11-09 13:05:01.000000000 +0100
3630 @@ -59,9 +59,6 @@
3631  bool net_request_file(NET* net, const char* fname);
3632  char* query_table_status(THD *thd,const char *db,const char *table_name);
3633  
3634 -void net_set_write_timeout(NET *net, uint timeout);
3635 -void net_set_read_timeout(NET *net, uint timeout);
3636 -
3637  #define x_free(A)      { my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); }
3638  #define safeFree(x)    { if(x) { my_free((gptr) x,MYF(0)); x = NULL; } }
3639  #define PREV_BITS(type,A)      ((type) (((type) 1 << (A)) -1))
3640 @@ -408,6 +405,16 @@
3641  int create_table_precheck(THD *thd, TABLE_LIST *tables,
3642                           TABLE_LIST *create_table);
3643  Item *negate_expression(THD *thd, Item *expr);
3644 +
3645 +/* log.cc */
3646 +void sql_perror(const char *message);
3647 +
3648 +void vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
3649 +void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
3650 +void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
3651 +void sql_print_information(const char *format, ...)
3652 +  ATTRIBUTE_FORMAT(printf, 1, 2);
3653 +
3654  #include "sql_class.h"
3655  #include "sql_acl.h"
3656  #include "tztime.h"
3657 @@ -842,14 +849,6 @@
3658  int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length);
3659  
3660  bool init_errmessage(void);
3661 -void sql_perror(const char *message);
3662 -
3663 -void vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
3664 -void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
3665 -void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
3666 -void sql_print_information(const char *format, ...)
3667 -  ATTRIBUTE_FORMAT(printf, 1, 2);
3668 -
3669  
3670  bool fn_format_relative_to_data_home(my_string to, const char *name,
3671                                      const char *dir, const char *extension);
3672 diff -urN mysql-4.1.23/sql/net_serv.cc mysql-4.1/sql/net_serv.cc
3673 --- mysql-4.1.23/sql/net_serv.cc        2007-12-02 20:38:27.000000000 +0100
3674 +++ mysql-4.1/sql/net_serv.cc   2007-06-19 08:13:10.000000000 +0200
3675 @@ -111,13 +111,13 @@
3676  my_bool my_net_init(NET *net, Vio* vio)
3677  {
3678    DBUG_ENTER("my_net_init");
3679 +  net->vio = vio;
3680    my_net_local_init(net);                      /* Set some limits */
3681    if (!(net->buff=(uchar*) my_malloc((uint32) net->max_packet+
3682                                      NET_HEADER_SIZE + COMP_HEADER_SIZE,
3683                                      MYF(MY_WME))))
3684      DBUG_RETURN(1);
3685    net->buff_end=net->buff+net->max_packet;
3686 -  net->vio = vio;
3687    net->no_send_ok = 0;
3688    net->error=0; net->return_errno=0; net->return_status=0;
3689    net->pkt_nr=net->compress_pkt_nr=0;
3690 diff -urN mysql-4.1.23/sql/opt_range.cc mysql-4.1/sql/opt_range.cc
3691 --- mysql-4.1.23/sql/opt_range.cc       2007-12-02 20:38:25.000000000 +0100
3692 +++ mysql-4.1/sql/opt_range.cc  2007-09-10 14:26:49.000000000 +0200
3693 @@ -825,6 +825,7 @@
3694      if (!(table->keys_in_use_for_query.is_set(idx)))
3695        continue;
3696      KEY_PART_INFO *keyinfo= table->key_info[idx].key_part;
3697 +    uint n_parts=  table->key_info[idx].key_parts;
3698      uint partno= 0;
3699      
3700      /* 
3701 @@ -834,7 +835,7 @@
3702      */
3703      if (!(table->file->index_flags(idx, 0, 1) & HA_READ_ORDER))
3704        continue;
3705 -    for (ord= order; ord; ord= ord->next, partno++)
3706 +    for (ord= order; ord && partno < n_parts; ord= ord->next, partno++)
3707      {
3708        Item *item= order->item[0];
3709        if (!(item->type() == Item::FIELD_ITEM &&
3710 diff -urN mysql-4.1.23/sql/set_var.cc mysql-4.1/sql/set_var.cc
3711 --- mysql-4.1.23/sql/set_var.cc 2007-12-02 20:38:27.000000000 +0100
3712 +++ mysql-4.1/sql/set_var.cc    2007-10-18 10:47:52.000000000 +0200
3713 @@ -1573,7 +1573,7 @@
3714                                             &not_used));
3715      if (error_len)
3716      {
3717 -      strmake(buff, error, min(sizeof(buff), error_len));
3718 +      strmake(buff, error, min(sizeof(buff) - 1, error_len));
3719        goto err;
3720      }
3721    }
3722 diff -urN mysql-4.1.23/sql/share/english/errmsg.txt mysql-4.1/sql/share/english/errmsg.txt
3723 --- mysql-4.1.23/sql/share/english/errmsg.txt   2007-12-02 20:38:52.000000000 +0100
3724 +++ mysql-4.1/sql/share/english/errmsg.txt      2007-07-26 12:49:50.000000000 +0200
3725 @@ -21,7 +21,7 @@
3726  "NO",
3727  "YES",
3728  "Can't create file '%-.64s' (errno: %d)",
3729 -"Can't create table '%-.64s' (errno: %d)",
3730 +"Can't create table '%-.150s' (errno: %d)",
3731  "Can't create database '%-.64s' (errno: %d)",
3732  "Can't create database '%-.64s'; database exists",
3733  "Can't drop database '%-.64s'; database doesn't exist",
3734 @@ -33,7 +33,7 @@
3735  "Can't get working directory (errno: %d)",
3736  "Can't lock file (errno: %d)",
3737  "Can't open file: '%-.64s' (errno: %d)",
3738 -"Can't find file: '%-.64s' (errno: %d)",
3739 +"Can't find file: '%-.150s' (errno: %d)",
3740  "Can't read dir of '%-.64s' (errno: %d)",
3741  "Can't change dir to '%-.64s' (errno: %d)",
3742  "Record has changed since last read in table '%-.64s'",
3743 @@ -41,7 +41,7 @@
3744  "Can't write; duplicate key in table '%-.64s'",
3745  "Error on close of '%-.64s' (errno: %d)",
3746  "Error reading file '%-.64s' (errno: %d)",
3747 -"Error on rename of '%-.64s' to '%-.64s' (errno: %d)",
3748 +"Error on rename of '%-.107s' to '%-.107s' (errno: %d)",
3749  "Error writing file '%-.64s' (errno: %d)",
3750  "'%-.64s' is locked against change",
3751  "Sort aborted",
3752 diff -urN mysql-4.1.23/sql/sql_class.cc mysql-4.1/sql/sql_class.cc
3753 --- mysql-4.1.23/sql/sql_class.cc       2007-12-02 20:38:51.000000000 +0100
3754 +++ mysql-4.1/sql/sql_class.cc  2007-07-03 18:04:24.000000000 +0200
3755 @@ -1020,6 +1020,7 @@
3756    field_sep_char= (exchange->enclosed->length() ? (*exchange->enclosed)[0] :
3757                    field_term_length ? (*exchange->field_term)[0] : INT_MAX);
3758    escape_char= (exchange->escaped->length() ? (*exchange->escaped)[0] : -1);
3759 +  is_ambiguous_field_sep= test(strchr(ESCAPE_CHARS, field_sep_char));
3760    line_sep_char= (exchange->line_term->length() ?
3761                   (*exchange->line_term)[0] : INT_MAX);
3762    if (!field_term_length)
3763 @@ -1113,7 +1114,9 @@
3764               (int) *pos == line_sep_char || !*pos)
3765           {
3766             char tmp_buff[2];
3767 -           tmp_buff[0]= escape_char;
3768 +            tmp_buff[0]= ((int) *pos == field_sep_char &&
3769 +                          is_ambiguous_field_sep) ?
3770 +                          field_sep_char : escape_char;
3771             tmp_buff[1]= *pos ? *pos : '0';
3772             if (my_b_write(&cache,(byte*) start,(uint) (pos-start)) ||
3773                 my_b_write(&cache,(byte*) tmp_buff,2))
3774 diff -urN mysql-4.1.23/sql/sql_class.h mysql-4.1/sql/sql_class.h
3775 --- mysql-4.1.23/sql/sql_class.h        2007-12-02 20:38:51.000000000 +0100
3776 +++ mysql-4.1/sql/sql_class.h   2007-07-16 22:38:49.000000000 +0200
3777 @@ -1018,11 +1018,27 @@
3778      proc_info = old_msg;
3779      pthread_mutex_unlock(&mysys_var->mutex);
3780    }
3781 +
3782 +  static inline void safe_time(time_t *t)
3783 +  {
3784 +    /**
3785 +       Wrapper around time() which retries on error (-1)
3786 +
3787 +       @details
3788 +       This is needed because, despite the documentation, time() may fail
3789 +       in some circumstances.  Here we retry time() until it succeeds, and
3790 +       log the failure so that performance problems related to this can be
3791 +       identified.
3792 +    */
3793 +    while(unlikely(time(t) == ((time_t) -1)))
3794 +      sql_print_information("time() failed with %d", errno);
3795 +  }
3796 +
3797    inline time_t query_start() { query_start_used=1; return start_time; }
3798 -  inline void  set_time()    { if (user_time) start_time=time_after_lock=user_time; else time_after_lock=time(&start_time); }
3799 -  inline void  end_time()    { time(&start_time); }
3800 +  inline void  set_time()    { if (user_time) start_time=time_after_lock=user_time; else { safe_time(&start_time); time_after_lock= start_time; }}
3801 +  inline void  end_time()    { safe_time(&start_time); }
3802    inline void  set_time(time_t t) { time_after_lock=start_time=user_time=t; }
3803 -  inline void  lock_time()   { time(&time_after_lock); }
3804 +  inline void  lock_time()   { safe_time(&time_after_lock); }
3805    inline void  insert_id(ulonglong id_arg)
3806    {
3807      last_insert_id= id_arg;
3808 @@ -1224,9 +1240,18 @@
3809  };
3810  
3811  
3812 +#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
3813 +
3814 +
3815  class select_export :public select_to_file {
3816    uint field_term_length;
3817    int field_sep_char,escape_char,line_sep_char;
3818 +  /*
3819 +    The is_ambiguous_field_sep field is true if a value of the field_sep_char
3820 +    field is one of the 'n', 't', 'r' etc characters
3821 +    (see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
3822 +  */
3823 +  bool is_ambiguous_field_sep;
3824    bool fixed_row_size;
3825  public:
3826    select_export(sql_exchange *ex) :select_to_file(ex) {}
3827 diff -urN mysql-4.1.23/sql/sql_load.cc mysql-4.1/sql/sql_load.cc
3828 --- mysql-4.1.23/sql/sql_load.cc        2007-12-02 20:38:51.000000000 +0100
3829 +++ mysql-4.1/sql/sql_load.cc   2007-07-03 16:05:06.000000000 +0200
3830 @@ -611,6 +611,7 @@
3831  char
3832  READ_INFO::unescape(char chr)
3833  {
3834 +  /* keep this switch synchornous with the ESCAPE_CHARS macro */
3835    switch(chr) {
3836    case 'n': return '\n';
3837    case 't': return '\t';
3838 diff -urN mysql-4.1.23/sql/sql_parse.cc mysql-4.1/sql/sql_parse.cc
3839 --- mysql-4.1.23/sql/sql_parse.cc       2007-12-02 20:38:51.000000000 +0100
3840 +++ mysql-4.1/sql/sql_parse.cc  2007-06-12 14:47:34.000000000 +0200
3841 @@ -1445,11 +1445,14 @@
3842        Old clients send null-terminated string ('\0' for empty string) for
3843        password.  New clients send the size (1 byte) + string (not null
3844        terminated, so also '\0' for empty string).
3845 +
3846 +      Cast *passwd to an unsigned char, so that it doesn't extend the sign
3847 +      for *passwd > 127 and become 2**32-127 after casting to uint.
3848      */
3849      char db_buff[NAME_LEN+1];                 // buffer to store db in utf8 
3850      char *db= passwd;
3851      uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? 
3852 -      *passwd++ : strlen(passwd);
3853 +      (uchar)(*passwd++) : strlen(passwd);
3854      db+= passwd_len + 1;
3855  #ifndef EMBEDDED_LIBRARY
3856      /* Small check for incomming packet */
3857 diff -urN mysql-4.1.23/sql/sql_select.cc mysql-4.1/sql/sql_select.cc
3858 --- mysql-4.1.23/sql/sql_select.cc      2007-12-02 20:38:25.000000000 +0100
3859 +++ mysql-4.1/sql/sql_select.cc 2007-07-31 08:00:17.000000000 +0200
3860 @@ -777,6 +777,7 @@
3861      order=0;                                   // The output has only one row
3862      simple_order=1;
3863      select_distinct= 0;                       // No need in distinct for 1 row
3864 +    group_optimized_away= 1;
3865    }
3866  
3867    calc_group_buffer(this, group_list);
3868 @@ -6896,7 +6897,8 @@
3869    if (!join->first_record || end_of_records ||
3870        (idx=test_if_group_changed(join->group_fields)) >= 0)
3871    {
3872 -    if (join->first_record || (end_of_records && !join->group))
3873 +    if (join->first_record || 
3874 +        (end_of_records && !join->group && !join->group_optimized_away))
3875      {
3876        if (join->procedure)
3877         join->procedure->end_group();
3878 @@ -8118,7 +8120,7 @@
3879        field_count++;
3880    }
3881  
3882 -  if (!field_count && !(join->select_options & OPTION_FOUND_ROWS)) 
3883 +  if (!field_count && !(join->select_options & OPTION_FOUND_ROWS) && !having) 
3884    {                    // only const items with no OPTION_FOUND_ROWS
3885      join->unit->select_limit_cnt= 1;           // Only send first row
3886      DBUG_RETURN(0);
3887 diff -urN mysql-4.1.23/sql/sql_select.h mysql-4.1/sql/sql_select.h
3888 --- mysql-4.1.23/sql/sql_select.h       2007-12-02 20:38:25.000000000 +0100
3889 +++ mysql-4.1/sql/sql_select.h  2007-07-31 07:45:59.000000000 +0200
3890 @@ -180,6 +180,14 @@
3891    ROLLUP rollup;                               // Used with rollup
3892  
3893    bool select_distinct;                                // Set if SELECT DISTINCT
3894 +  /*
3895 +    If we have the GROUP BY statement in the query,
3896 +    but the group_list was emptied by optimizer, this
3897 +    flag is TRUE.
3898 +    It happens when fields in the GROUP BY are from
3899 +    constant table
3900 +  */
3901 +  bool group_optimized_away;
3902  
3903    /*
3904      simple_xxxxx is set if ORDER/GROUP BY doesn't include any references
3905 @@ -276,6 +284,7 @@
3906      ref_pointer_array_size= 0;
3907      zero_result_cause= 0;
3908      optimized= 0;
3909 +    group_optimized_away= 0;
3910  
3911      fields_list= fields_arg;
3912      bzero((char*) &keyuse,sizeof(keyuse));
3913 diff -urN mysql-4.1.23/sql/sql_yacc.yy mysql-4.1/sql/sql_yacc.yy
3914 --- mysql-4.1.23/sql/sql_yacc.yy        2007-12-02 20:38:27.000000000 +0100
3915 +++ mysql-4.1/sql/sql_yacc.yy   2007-06-06 15:29:14.000000000 +0200
3916 @@ -3567,7 +3567,8 @@
3917           LEX *lex= Lex;
3918           lex->derived_tables= 1;
3919            if (lex->sql_command == (int)SQLCOM_HA_READ ||
3920 -              lex->sql_command == (int)SQLCOM_KILL)
3921 +              lex->sql_command == (int)SQLCOM_KILL ||
3922 +              lex->sql_command == (int)SQLCOM_PURGE)
3923           {
3924             yyerror(ER(ER_SYNTAX_ERROR));
3925             YYABORT;
3926 @@ -4748,6 +4749,7 @@
3927         {
3928           LEX *lex=Lex;
3929           lex->type=0;
3930 +          lex->sql_command = SQLCOM_PURGE;
3931         } purge_options
3932         {}
3933         ;
3934 @@ -4759,7 +4761,6 @@
3935  purge_option:
3936          TO_SYM TEXT_STRING_sys
3937          {
3938 -          Lex->sql_command = SQLCOM_PURGE;
3939            Lex->to_log = $2.str;
3940          }
3941         | BEFORE_SYM expr
3942 @@ -6212,7 +6213,8 @@
3943         {
3944           LEX *lex=Lex;
3945            if (lex->sql_command == (int)SQLCOM_HA_READ ||
3946 -              lex->sql_command == (int)SQLCOM_KILL)
3947 +              lex->sql_command == (int)SQLCOM_KILL ||
3948 +              lex->sql_command == (int)SQLCOM_PURGE)
3949           {
3950              yyerror(ER(ER_SYNTAX_ERROR));
3951             YYABORT;
3952 diff -urN mysql-4.1.23/sql-common/client.c mysql-4.1/sql-common/client.c
3953 --- mysql-4.1.23/sql-common/client.c    2007-12-02 20:38:25.000000000 +0100
3954 +++ mysql-4.1/sql-common/client.c       2007-11-09 13:05:01.000000000 +0100
3955 @@ -1176,12 +1176,12 @@
3956        /* fields count may be wrong */
3957        DBUG_ASSERT ((field - result) < fields);
3958        cli_fetch_lengths(&lengths[0], row->data, default_value ? 8 : 7);
3959 -      field->catalog  = strdup_root(alloc,(char*) row->data[0]);
3960 -      field->db       = strdup_root(alloc,(char*) row->data[1]);
3961 -      field->table    = strdup_root(alloc,(char*) row->data[2]);
3962 -      field->org_table= strdup_root(alloc,(char*) row->data[3]);
3963 -      field->name     = strdup_root(alloc,(char*) row->data[4]);
3964 -      field->org_name = strdup_root(alloc,(char*) row->data[5]);
3965 +      field->catalog=   strmake_root(alloc,(char*) row->data[0], lengths[0]);
3966 +      field->db=        strmake_root(alloc,(char*) row->data[1], lengths[1]);
3967 +      field->table=     strmake_root(alloc,(char*) row->data[2], lengths[2]);
3968 +      field->org_table= strmake_root(alloc,(char*) row->data[3], lengths[3]);
3969 +      field->name=      strmake_root(alloc,(char*) row->data[4], lengths[4]);
3970 +      field->org_name=  strmake_root(alloc,(char*) row->data[5], lengths[5]);
3971  
3972        field->catalog_length=   lengths[0];
3973        field->db_length=                lengths[1];
3974 @@ -1202,7 +1202,7 @@
3975          field->flags|= NUM_FLAG;
3976        if (default_value && row->data[7])
3977        {
3978 -        field->def=strdup_root(alloc,(char*) row->data[7]);
3979 +        field->def=strmake_root(alloc,(char*) row->data[7], lengths[7]);
3980         field->def_length= lengths[7];
3981        }
3982        else
3983 @@ -1884,13 +1884,11 @@
3984  
3985    /* If user set read_timeout, let it override the default */
3986    if (mysql->options.read_timeout)
3987 -    net->read_timeout= mysql->options.read_timeout;
3988 -  vio_timeout(net->vio, 0, net->read_timeout);
3989 +    net_set_read_timeout(net, mysql->options.read_timeout);
3990  
3991    /* If user set write_timeout, let it override the default */
3992    if (mysql->options.write_timeout)
3993 -    net->write_timeout= mysql->options.write_timeout;
3994 -  vio_timeout(net->vio, 1, net->write_timeout);
3995 +    net_set_write_timeout(net, mysql->options.write_timeout);
3996  
3997    if (mysql->options.max_allowed_packet)
3998      net->max_packet_size= mysql->options.max_allowed_packet;
3999 diff -urN mysql-4.1.23/strings/ctype-big5.c mysql-4.1/strings/ctype-big5.c
4000 --- mysql-4.1.23/strings/ctype-big5.c   2007-12-02 20:38:25.000000000 +0100
4001 +++ mysql-4.1/strings/ctype-big5.c      2007-10-04 07:19:59.000000000 +0200
4002 @@ -6256,12 +6256,12 @@
4003               my_wc_t *pwc,const uchar *s,const uchar *e)
4004  {
4005  
4006 -  int hi=s[0];
4007 +  int hi;
4008    
4009    if (s >= e)
4010      return MY_CS_TOOSMALL;
4011    
4012 -  if (hi<0x80)
4013 +  if ((hi= s[0]) < 0x80)
4014    {
4015      pwc[0]=hi;
4016      return 1;
4017 diff -urN mysql-4.1.23/strings/ctype-cp932.c mysql-4.1/strings/ctype-cp932.c
4018 --- mysql-4.1.23/strings/ctype-cp932.c  2007-12-02 20:38:25.000000000 +0100
4019 +++ mysql-4.1/strings/ctype-cp932.c     2007-10-04 07:19:59.000000000 +0200
4020 @@ -5352,12 +5352,12 @@
4021  static int 
4022  my_mb_wc_cp932(CHARSET_INFO *cs  __attribute__((unused)),
4023               my_wc_t *pwc, const uchar *s, const uchar *e){
4024 -  int hi=s[0];
4025 +  int hi;
4026    
4027    if (s >= e)
4028      return MY_CS_TOOSMALL;
4029    
4030 -  if (hi < 0x80)
4031 +  if ((hi= s[0]) < 0x80)
4032    {
4033      pwc[0]=hi;
4034      return 1;
4035 diff -urN mysql-4.1.23/strings/ctype-euc_kr.c mysql-4.1/strings/ctype-euc_kr.c
4036 --- mysql-4.1.23/strings/ctype-euc_kr.c 2007-12-02 20:38:26.000000000 +0100
4037 +++ mysql-4.1/strings/ctype-euc_kr.c    2007-10-04 07:19:59.000000000 +0200
4038 @@ -8614,12 +8614,12 @@
4039                  my_wc_t *pwc, const uchar *s, const uchar *e)
4040  {
4041    
4042 -  int hi=s[0];
4043 +  int hi;
4044    
4045    if (s >= e)
4046      return MY_CS_TOOSMALL;
4047    
4048 -  if (hi<0x80)
4049 +  if ((hi= s[0]) < 0x80)
4050    {
4051      pwc[0]=hi;
4052      return 1;
4053 diff -urN mysql-4.1.23/strings/ctype-gb2312.c mysql-4.1/strings/ctype-gb2312.c
4054 --- mysql-4.1.23/strings/ctype-gb2312.c 2007-12-02 20:38:26.000000000 +0100
4055 +++ mysql-4.1/strings/ctype-gb2312.c    2007-10-04 07:19:59.000000000 +0200
4056 @@ -5665,12 +5665,10 @@
4057                 my_wc_t *pwc, const uchar *s, const uchar *e){
4058    int hi;
4059    
4060 -  hi=(int) s[0];
4061 -  
4062    if (s >= e)
4063      return MY_CS_TOOSMALL;
4064    
4065 -  if (hi<0x80)
4066 +  if ((hi= s[0]) < 0x80)
4067    {
4068      pwc[0]=hi;
4069      return 1;
4070 diff -urN mysql-4.1.23/strings/ctype-simple.c mysql-4.1/strings/ctype-simple.c
4071 --- mysql-4.1.23/strings/ctype-simple.c 2007-12-02 20:38:25.000000000 +0100
4072 +++ mysql-4.1/strings/ctype-simple.c    2007-09-28 22:33:23.000000000 +0200
4073 @@ -802,7 +802,7 @@
4074    {
4075      if (val < 0)
4076      {
4077 -      val= -val;
4078 +      val= -(unsigned long int)val;
4079        *dst++= '-';
4080        len--;
4081        sign= 1;
4082 @@ -838,7 +838,7 @@
4083    {
4084      if (val < 0)
4085      {
4086 -      val = -val;
4087 +      val = -(ulonglong)val;
4088        *dst++= '-';
4089        len--;
4090        sign= 1;
4091 diff -urN mysql-4.1.23/strings/ctype-sjis.c mysql-4.1/strings/ctype-sjis.c
4092 --- mysql-4.1.23/strings/ctype-sjis.c   2007-12-02 20:38:52.000000000 +0100
4093 +++ mysql-4.1/strings/ctype-sjis.c      2007-10-04 07:19:59.000000000 +0200
4094 @@ -4512,12 +4512,12 @@
4095  static int 
4096  my_mb_wc_sjis(CHARSET_INFO *cs  __attribute__((unused)),
4097               my_wc_t *pwc, const uchar *s, const uchar *e){
4098 -  int hi=s[0];
4099 +  int hi;
4100    
4101    if (s >= e)
4102      return MY_CS_TOOSMALL;
4103    
4104 -  if (hi < 0x80)
4105 +  if ((hi= s[0]) < 0x80)
4106    {
4107      pwc[0]=hi;
4108      return 1;
4109 diff -urN mysql-4.1.23/support-files/MacOSX/ReadMe.txt mysql-4.1/support-files/MacOSX/ReadMe.txt
4110 --- mysql-4.1.23/support-files/MacOSX/ReadMe.txt        1970-01-01 01:00:00.000000000 +0100
4111 +++ mysql-4.1/support-files/MacOSX/ReadMe.txt   2007-11-02 01:29:32.000000000 +0100
4112 @@ -0,0 +1,8 @@
4113 +
4114 +You can find information about how to install on Mac OS X at
4115 +
4116 +  http://dev.mysql.com/doc/refman/4.1/en/mac-os-x-installation.html
4117 +
4118 +The MySQL Reference Manual is also available in various formats on
4119 +http://dev.mysql.com/doc; if you're interested in the DocBook XML
4120 +sources go to http://svn.mysql.com.
4121 diff -urN mysql-4.1.23/VC++Files/sql/mysqld.dsp mysql-4.1/VC++Files/sql/mysqld.dsp
4122 --- mysql-4.1.23/VC++Files/sql/mysqld.dsp       2007-12-02 20:38:51.000000000 +0100
4123 +++ mysql-4.1/VC++Files/sql/mysqld.dsp  2007-05-16 23:09:48.000000000 +0200
4124 @@ -1610,7 +1610,7 @@
4125  # End Source File
4126  # Begin Source File
4127  
4128 -SOURCE=.\sql\sql_locale.cpp
4129 +SOURCE=.\sql_locale.cpp
4130  # End Source File
4131  # Begin Source File
4132  
This page took 0.3921 seconds and 3 git commands to generate.