]> git.pld-linux.org Git - packages/mysql.git/blame - mysql-bk-20071202.patch
- convert to utf8
[packages/mysql.git] / mysql-bk-20071202.patch
Content-type: text/html ]> git.pld-linux.org Git - packages/mysql.git/blame - mysql-bk-20071202.patch


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 6) line 1, <$fd> line 4934.
This page took 0.320873 seconds and 4 git commands to generate.
CommitLineData
3f28115d
AM
1diff -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
8diff -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") ||
30diff -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 {
348diff -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);
368diff -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
3f28115d
AM
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"])
391diff -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.
403diff -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.%
449diff -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.
483diff -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;
530diff -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);
544diff -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
565diff -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;
609diff -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
626diff -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
641diff -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);
653diff -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.
665diff -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.
678diff -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 */
874diff -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*/
944diff -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;
957diff -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 }
1103diff -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)
1188diff -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;
1205diff -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);
1216diff -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 }
1313diff -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));
1355diff -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 }
1402diff -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)
1417diff -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);
1441diff -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;
1460diff -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;
1544diff -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, "",
1718diff -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;
1751diff -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;
1764diff -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;
1785diff -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;
1806diff -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;
1827diff -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;
1848diff -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;
1869diff -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
1883diff -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
1902diff -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;
1915diff -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
1948diff -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
1962diff -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;
2000diff -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;
2024diff -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;
2050diff -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
2065diff -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
2109diff -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;
2142diff -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;
2209diff -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;
2242diff -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
2297diff -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
2331diff -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
2413diff -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
2429diff -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);
2441diff -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` (
2457diff -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