List:Commits« Previous MessageNext Message »
From:Mats Kindahl Date:May 11 2009 1:30pm
Subject:bzr commit into mysql-5.1-bugteam branch (mats:2873)
View as plain text  
#At file:///home/bzr/bugs/b44442-5.1-bugteam/ based on revid:mats@stripped0uddz6ktm

 2873 Mats Kindahl	2009-05-11 [merge]
      Merging with 5.1-bugteam tree.

    removed:
      mysql-test/suite/rpl/t/rpl_000015-slave.sh
    added:
      mysql-test/r/myisam_debug.result
      mysql-test/std_data/bug37631.MYD
      mysql-test/std_data/bug37631.MYI
      mysql-test/std_data/bug37631.frm
      mysql-test/suite/rpl/r/rpl_bug38694.result
      mysql-test/suite/rpl/t/rpl_bug38694-slave.opt
      mysql-test/suite/rpl/t/rpl_bug38694.test
      mysql-test/t/myisam_debug.test
    modified:
      client/mysql.cc
      client/mysql_upgrade.c
      client/mysqlbinlog.cc
      client/mysqldump.c
      client/mysqltest.cc
      extra/perror.c
      mysql-test/r/ctype_cp932_binlog_stm.result
      mysql-test/r/ctype_sjis.result
      mysql-test/r/distinct.result
      mysql-test/r/fulltext.result
      mysql-test/r/func_encrypt.result
      mysql-test/r/gis-rtree.result
      mysql-test/r/gis.result
      mysql-test/r/heap_btree.result
      mysql-test/r/insert_select.result
      mysql-test/r/myisam.result
      mysql-test/r/mysql.result
      mysql-test/r/mysqlbinlog.result
      mysql-test/r/select.result
      mysql-test/r/sp.result
      mysql-test/r/subselect3.result
      mysql-test/r/upgrade.result
      mysql-test/r/user_var.result
      mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
      mysql-test/suite/rpl/t/rpl_incident.test
      mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
      mysql-test/t/ctype_cp932_binlog_stm.test
      mysql-test/t/ctype_sjis.test
      mysql-test/t/fulltext.test
      mysql-test/t/func_encrypt.test
      mysql-test/t/gis-rtree.test
      mysql-test/t/gis.test
      mysql-test/t/heap_btree.test
      mysql-test/t/insert_select.test
      mysql-test/t/myisam.test
      mysql-test/t/mysql.test
      mysql-test/t/mysqlbinlog.test
      mysql-test/t/select.test
      mysql-test/t/sp.test
      mysql-test/t/sp_trans_log.test
      mysql-test/t/subselect3.test
      mysql-test/t/upgrade.test
      mysql-test/t/user_var.test
      mysys/mf_keycache.c
      mysys/safemalloc.c
      scripts/mysql_convert_table_format.sh
      scripts/mysqld_multi.sh
      scripts/mysqldumpslow.sh
      scripts/mysqlhotcopy.sh
      sql/handler.h
      sql/item.cc
      sql/item_func.cc
      sql/item_func.h
      sql/item_geofunc.cc
      sql/rpl_filter.cc
      sql/slave.cc
      sql/sp_head.cc
      sql/sp_head.h
      sql/sp_pcontext.cc
      sql/sp_pcontext.h
      sql/sql_class.cc
      sql/sql_delete.cc
      sql/sql_repl.cc
      sql/sql_select.cc
      sql/sql_table.cc
      sql/sql_update.cc
      sql/sql_yacc.yy
      sql/unireg.cc
      storage/ibmdb2i/Makefile.am
      storage/ibmdb2i/db2i_charsetSupport.cc
      storage/ibmdb2i/db2i_conversion.cc
      storage/ibmdb2i/db2i_errors.cc
      storage/ibmdb2i/db2i_errors.h
      storage/ibmdb2i/ha_ibmdb2i.cc
      storage/myisam/ft_boolean_search.c
      storage/myisam/ha_myisam.cc
      storage/myisam/mi_delete.c
      storage/myisam/mi_open.c
      storage/myisam/mi_write.c
      storage/ndb/src/kernel/blocks/backup/read.cpp
      strings/ctype-cp932.c
      strings/ctype-sjis.c
      tests/mysql_client_test.c
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc	2009-04-14 14:17:44 +0000
+++ b/client/mysql.cc	2009-04-28 18:30:21 +0000
@@ -1345,7 +1345,7 @@ static struct my_option my_long_options[
   {"debug", '#', "Output debug log", (uchar**) &default_dbug_option,
    (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
 #endif
-  {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit .",
+  {"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
    (uchar**) &debug_check_flag, (uchar**) &debug_check_flag, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &debug_info_flag,
@@ -3381,9 +3381,12 @@ print_table_data_html(MYSQL_RES *result)
   {
     while((field = mysql_fetch_field(result)))
     {
-      tee_fprintf(PAGER, "<TH>%s</TH>", (field->name ? 
-					 (field->name[0] ? field->name : 
-					  " &nbsp; ") : "NULL"));
+      tee_fputs("<TH>", PAGER);
+      if (field->name && field->name[0])
+        xmlencode_print(field->name, field->name_length);
+      else
+        tee_fputs(field->name ? " &nbsp; " : "NULL", PAGER);
+      tee_fputs("</TH>", PAGER);
     }
     (void) tee_fputs("</TR>", PAGER);
   }
@@ -3396,7 +3399,7 @@ print_table_data_html(MYSQL_RES *result)
     for (uint i=0; i < mysql_num_fields(result); i++)
     {
       (void) tee_fputs("<TD>", PAGER);
-      safe_put_field(cur[i],lengths[i]);
+      xmlencode_print(cur[i], lengths[i]);
       (void) tee_fputs("</TD>", PAGER);
     }
     (void) tee_fputs("</TR>", PAGER);

=== modified file 'client/mysql_upgrade.c'
--- a/client/mysql_upgrade.c	2009-03-20 14:27:53 +0000
+++ b/client/mysql_upgrade.c	2009-04-28 18:26:31 +0000
@@ -115,11 +115,11 @@ static struct my_option my_long_options[
 #endif
   {"socket", 'S', "Socket file to use for connection.",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+#include <sslopt-longopts.h>
   {"tmpdir", 't', "Directory for temporary files",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"user", 'u', "User for login if not current user.", (uchar**) &opt_user,
    (uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#include <sslopt-longopts.h>
   {"verbose", 'v', "Display more output about the process",
    (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0,
    GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},

=== modified file 'client/mysqlbinlog.cc'
--- a/client/mysqlbinlog.cc	2009-02-13 16:41:47 +0000
+++ b/client/mysqlbinlog.cc	2009-05-08 17:24:15 +0000
@@ -1529,8 +1529,7 @@ static Exit_status dump_remote_log_entri
       If reading from a remote host, ensure the temp_buf for the
       Log_event class is pointing to the incoming stream.
     */
-    if (remote_opt)
-      ev->register_temp_buf((char*) net->read_pos + 1); 
+    ev->register_temp_buf((char *) net->read_pos + 1);
 
     Log_event_type type= ev->get_type_code();
     if (glob_description_event->binlog_version >= 3 ||

=== modified file 'client/mysqldump.c'
--- a/client/mysqldump.c	2009-03-24 13:58:52 +0000
+++ b/client/mysqldump.c	2009-04-28 18:23:21 +0000
@@ -221,7 +221,7 @@ static struct my_option my_long_options[
    (uchar**) &opt_compatible_mode_str, (uchar**) &opt_compatible_mode_str, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"compact", OPT_COMPACT,
-   "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs.  Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-add-locks",
+   "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs.  Enables options --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset",
    (uchar**) &opt_compact, (uchar**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
    0, 0},
   {"complete-insert", 'c', "Use complete insert statements.",

=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc	2009-04-09 09:24:36 +0000
+++ b/client/mysqltest.cc	2009-04-28 18:26:31 +0000
@@ -5665,11 +5665,11 @@ static struct my_option my_long_options[
   {"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select",
    (uchar**) &sp_protocol, (uchar**) &sp_protocol, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+#include "sslopt-longopts.h"
   {"tail-lines", OPT_TAIL_LINES,
    "Number of lines of the resul to include in a failure report",
    (uchar**) &opt_tail_lines, (uchar**) &opt_tail_lines, 0,
    GET_INT, REQUIRED_ARG, 0, 0, 10000, 0, 0, 0},
-#include "sslopt-longopts.h"
   {"test-file", 'x', "Read test from/in this file (default stdin).",
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
   {"timer-file", 'm', "File where the timing in micro seconds is stored.",

=== modified file 'extra/perror.c'
--- a/extra/perror.c	2009-02-24 10:33:51 +0000
+++ b/extra/perror.c	2009-04-28 18:16:44 +0000
@@ -115,7 +115,7 @@ static void usage(void)
 {
   print_version();
   puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
-  printf("Print a description for a system error code or an error code from\na MyISAM/ISAM/BDB table handler.\n");
+  printf("Print a description for a system error code or a MySQL error code.\n");
   printf("If you want to get the error for a negative error code, you should use\n-- before the first error code to tell perror that there was no more options.\n\n");
   printf("Usage: %s [OPTIONS] [ERRORCODE [ERRORCODE...]]\n",my_progname);
   my_print_help(my_long_options);

=== modified file 'mysql-test/r/ctype_cp932_binlog_stm.result'
--- a/mysql-test/r/ctype_cp932_binlog_stm.result	2008-10-02 05:56:07 +0000
+++ b/mysql-test/r/ctype_cp932_binlog_stm.result	2009-05-05 06:55:22 +0000
@@ -46,4 +46,12 @@ master-bin.000001	1137	Query	1	1216	use 
 End of 5.0 tests
 SHOW BINLOG EVENTS FROM 364;
 ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error
+Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
+CREATE TABLE t1 (a varchar(16)) character set cp932;
+INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
+SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
+hex(a)	hex(lower(a))	hex(upper(a))
+8352835E	8352835E	8352835E
+8372835E	8372835E	8372835E
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/r/ctype_sjis.result'
--- a/mysql-test/r/ctype_sjis.result	2008-02-20 18:49:26 +0000
+++ b/mysql-test/r/ctype_sjis.result	2009-05-05 06:55:22 +0000
@@ -209,3 +209,13 @@ SET NAMES sjis;
 SELECT HEX('�����@�\') FROM DUAL;
 HEX('��� tests
+Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
+CREATE TABLE t1 (a varchar(16)) character set sjis;
+INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
+SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
+hex(a)	hex(lower(a))	hex(upper(a))
+8352835E	8352835E	8352835E
+8372835E	8372835E	8372835E
+DROP TABLE t1;
+# End of 5.1 tests

=== modified file 'mysql-test/r/distinct.result'
--- a/mysql-test/r/distinct.result	2008-10-29 17:38:18 +0000
+++ b/mysql-test/r/distinct.result	2009-05-10 16:20:35 +0000
@@ -629,21 +629,21 @@ SELECT DISTINCT @v5:= fruit_id, @v6:= fr
 fruit_name = 'APPLE';
 SELECT @v5, @v6, @v7, @v8;
 @v5	@v6	@v7	@v8
-3	PEAR	3	PEAR
+2	APPLE	2	APPLE
 SELECT DISTINCT @v5 + fruit_id, CONCAT(@v6, fruit_name) INTO @v9, @v10 FROM t1 
 WHERE fruit_name = 'APPLE';
 SELECT @v5, @v6, @v7, @v8, @v9, @v10;
 @v5	@v6	@v7	@v8	@v9	@v10
-3	PEAR	3	PEAR	5	PEARAPPLE
+2	APPLE	2	APPLE	4	APPLEAPPLE
 SELECT DISTINCT @v11:= @v5 + fruit_id, @v12:= CONCAT(@v6, fruit_name) INTO 
 @v13, @v14 FROM t1 WHERE fruit_name = 'APPLE';
 SELECT @v11, @v12, @v13, @v14;
 @v11	@v12	@v13	@v14
-6	PEARPEAR	6	PEARPEAR
+4	APPLEAPPLE	4	APPLEAPPLE
 SELECT DISTINCT @v13, @v14 INTO @v15, @v16 FROM t1 WHERE fruit_name = 'APPLE';
 SELECT @v15, @v16;
 @v15	@v16
-6	PEARPEAR
+4	APPLEAPPLE
 SELECT DISTINCT 2 + 2, 'Bob' INTO @v17, @v18 FROM t1 WHERE fruit_name = 
 'APPLE';
 SELECT @v17, @v18;

=== modified file 'mysql-test/r/fulltext.result'
--- a/mysql-test/r/fulltext.result	2009-02-12 10:10:07 +0000
+++ b/mysql-test/r/fulltext.result	2009-04-23 11:24:08 +0000
@@ -535,3 +535,11 @@ CREATE TABLE t1(a TEXT);
 SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE);
 ERROR HY000: Incorrect arguments to AGAINST
 DROP TABLE t1;
+CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a));
+INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd');
+SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE);
+a
+awrd bwrd cwrd
+awrd bwrd cwrd
+awrd bwrd cwrd
+DROP TABLE t1;

=== modified file 'mysql-test/r/func_encrypt.result'
--- a/mysql-test/r/func_encrypt.result	2009-04-23 07:47:54 +0000
+++ b/mysql-test/r/func_encrypt.result	2009-04-27 10:05:01 +0000
@@ -189,9 +189,4 @@ engine=myisam default charset=latin1;
 insert into t1 values (null,'contraction\'s');
 insert into t1 values (-15818,'requirement\'s');
 select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;
-a
-NULL
-re3VF.eOzS/lg
-NULL
-re3VF.eOzS/lg
 drop table t1;

=== modified file 'mysql-test/r/gis-rtree.result'
--- a/mysql-test/r/gis-rtree.result	2007-10-23 08:44:14 +0000
+++ b/mysql-test/r/gis-rtree.result	2009-04-29 02:59:10 +0000
@@ -186,106 +186,106 @@ CREATE TABLE t2 (
 fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
 g GEOMETRY NOT NULL
 ) ENGINE=MyISAM;
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))));
-INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)));
+INSERT INTO t2 (g) VALUES (LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)));
 ALTER TABLE t2 ADD SPATIAL KEY(g);
 SHOW CREATE TABLE t2;
 Table	Create Table
@@ -309,406 +309,406 @@ fid	AsText(g)
 56	LINESTRING(41 41,50 50)
 45	LINESTRING(51 51,60 60)
 55	LINESTRING(41 51,50 60)
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-99
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-98
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-97
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-96
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-95
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-94
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-93
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-92
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-91
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-90
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-89
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-88
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-87
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-86
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-85
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-84
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-83
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-82
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-81
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-80
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-79
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-78
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-77
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-76
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-75
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-74
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-73
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-72
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-71
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-70
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-69
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-68
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-67
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-66
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-65
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-64
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-63
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-62
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-61
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-60
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-59
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-58
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-57
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-56
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-55
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-54
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-53
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-52
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-51
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-50
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-49
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-48
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-47
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-46
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-45
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-44
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-43
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-42
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-41
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-40
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-39
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-38
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-37
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-36
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-35
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-34
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-33
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-32
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-31
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-30
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-29
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-28
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-27
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-26
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-25
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-24
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-23
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-22
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-21
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-20
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-19
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-18
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-17
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-16
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-15
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-14
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-13
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-12
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-11
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-10
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-9
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-8
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-7
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-6
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-5
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-4
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-3
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-2
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-1
-DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
+100
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))));
 SELECT count(*) FROM t2;
 count(*)
-0
+100
 DROP TABLE t2;
 drop table if exists t1;
 Warnings:
@@ -863,11 +863,11 @@ Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 DROP TABLE t1;
 CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,0)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,0)));
-SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
+INSERT INTO t1 (foo) VALUES (POINT(1,1));
+INSERT INTO t1 (foo) VALUES (POINT(1,0));
+INSERT INTO t1 (foo) VALUES (POINT(0,1));
+INSERT INTO t1 (foo) VALUES (POINT(0,0));
+SELECT 1 FROM t1 WHERE foo != POINT(0,0);
 1
 1
 1
@@ -1426,35 +1426,35 @@ Table	Op	Msg_type	Msg_text
 test.t1	check	status	OK
 DROP TABLE t1;
 create table t1 (a geometry not null, spatial index(a));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
-insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
-insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
-insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
-insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
-insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
-insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
-insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
-insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
-insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
-insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
-insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
+insert into t1 values (POINT(1.1517219314031e+164, 131072));
+insert into t1 values (POINT(9.1248812352444e+192, 2.9740338169556e+284));
+insert into t1 values (POINT(4.7783097267365e-299, -0));
+insert into t1 values (POINT(1.49166814624e-154, 2.0880974297595e-53));
+insert into t1 values (POINT(4.0917382598702e+149, 1.2024538023802e+111));
+insert into t1 values (POINT(2.0349165139404e+236, 2.9993936277913e-241));
+insert into t1 values (POINT(2.5243548967072e-29, 1.2024538023802e+111));
+insert into t1 values (POINT(0, 6.9835074892995e-251));
+insert into t1 values (POINT(2.0880974297595e-53, 3.1050361846014e+231));
+insert into t1 values (POINT(2.8728483499323e-188, 2.4600631144627e+260));
+insert into t1 values (POINT(3.0517578125e-05, 2.0349165139404e+236));
+insert into t1 values (POINT(1.1517219314031e+164, 1.1818212630766e-125));
+insert into t1 values (POINT(2.481040258324e-265, 5.7766220027675e-275));
+insert into t1 values (POINT(2.0880974297595e-53, 2.5243548967072e-29));
+insert into t1 values (POINT(5.7766220027675e-275, 9.9464647281957e+86));
+insert into t1 values (POINT(2.2181357552967e+130, 3.7857669957337e-270));
+insert into t1 values (POINT(4.5767114681874e-246, 3.6893488147419e+19));
+insert into t1 values (POINT(4.5767114681874e-246, 3.7537584144024e+255));
+insert into t1 values (POINT(3.7857669957337e-270, 1.8033161362863e-130));
+insert into t1 values (POINT(0, 5.8774717541114e-39));
+insert into t1 values (POINT(1.1517219314031e+164, 2.2761049594727e-159));
+insert into t1 values (POINT(6.243497100632e+144, 3.7857669957337e-270));
+insert into t1 values (POINT(3.7857669957337e-270, 2.6355494858076e-82));
+insert into t1 values (POINT(2.0349165139404e+236, 3.8518598887745e-34));
+insert into t1 values (POINT(4.6566128730774e-10, 2.0880974297595e-53));
+insert into t1 values (POINT(2.0880974297595e-53, 1.8827498946116e-183));
+insert into t1 values (POINT(1.8033161362863e-130, 9.1248812352444e+192));
+insert into t1 values (POINT(4.7783097267365e-299, 2.2761049594727e-159));
+insert into t1 values (POINT(1.94906280228e+289, 1.2338789709327e-178));
 drop table t1;
 CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
 INSERT INTO t1(foo) VALUES (NULL);

=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2009-02-14 09:11:32 +0000
+++ b/mysql-test/r/gis.result	2009-04-29 02:59:10 +0000
@@ -47,26 +47,26 @@ INSERT INTO gis_point VALUES 
 INSERT INTO gis_line VALUES
 (105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
 (106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
-(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
 INSERT INTO gis_polygon VALUES
 (108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
 (109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
-(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
 INSERT INTO gis_multi_point VALUES
 (111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
 (112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
-(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
 INSERT INTO gis_multi_line VALUES
 (114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
 (115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
-(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
 INSERT INTO gis_multi_polygon VALUES
 (117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
 (118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
-(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
 INSERT INTO gis_geometrycollection VALUES
 (120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
-(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
 INSERT into gis_geometry SELECT * FROM gis_point;
 INSERT into gis_geometry SELECT * FROM gis_line;
 INSERT into gis_geometry SELECT * FROM gis_polygon;

=== modified file 'mysql-test/r/heap_btree.result'
--- a/mysql-test/r/heap_btree.result	2007-10-19 20:12:14 +0000
+++ b/mysql-test/r/heap_btree.result	2009-05-06 09:30:14 +0000
@@ -336,4 +336,11 @@ a	b
 NULL	NULL
 NULL	1
 drop table t1;
+#
+# bug#39918 - memory (heap) engine crashing while executing self join with delete
+#
+CREATE TABLE t1(a INT, KEY USING BTREE (a)) ENGINE=MEMORY;
+INSERT INTO t1 VALUES(1),(1);
+DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a;
+DROP TABLE t1;
 End of 5.0 tests

=== modified file 'mysql-test/r/insert_select.result'
--- a/mysql-test/r/insert_select.result	2007-09-24 13:23:40 +0000
+++ b/mysql-test/r/insert_select.result	2009-05-04 12:45:36 +0000
@@ -765,6 +765,11 @@ f1	f2
 2	2
 10	10
 DROP TABLE t1, t2;
+CREATE TABLE t1 ( a INT KEY, b INT );
+INSERT INTO t1 VALUES ( 0, 1 );
+INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2;
+ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
+DROP TABLE t1;
 SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
 CREATE TABLE t1 (c VARCHAR(30), INDEX ix_c (c(10)));
 CREATE TABLE t2 (d VARCHAR(10));

=== modified file 'mysql-test/r/myisam.result'
--- a/mysql-test/r/myisam.result	2008-09-06 00:51:17 +0000
+++ b/mysql-test/r/myisam.result	2009-04-30 11:03:44 +0000
@@ -2226,4 +2226,30 @@ Key Start Len Index   Type
 1   2     30  multip. varchar              
 2   33    30  multip. char NULL            
 DROP TABLE t1;
+CREATE TABLE t1 (
+c INT,
+d bit(1),
+e INT,
+f VARCHAR(1),
+g BIT(1),
+h BIT(1),
+KEY (h, d, e, g)
+);
+INSERT INTO t1 VALUES
+(  3, 1, 1, 'a', 0, 0 ),
+(  3, 1, 5, 'a', 0, 0 ),
+( 10, 1, 2, 'a', 0, 1 ),
+( 10, 1, 3, 'a', 0, 1 ),
+( 10, 1, 4, 'a', 0, 1 );
+SELECT f FROM t1 WHERE d = 1 AND e = 2 AND g = 0 AND h = 1;
+f
+a
+SELECT h+0, d + 0, e, g + 0 FROM t1;
+h+0	d + 0	e	g + 0
+0	1	1	0
+0	1	5	0
+1	1	2	0
+1	1	3	0
+1	1	4	0
+DROP TABLE t1;
 End of 5.1 tests

=== added file 'mysql-test/r/myisam_debug.result'
--- a/mysql-test/r/myisam_debug.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/myisam_debug.result	2009-04-30 11:03:44 +0000
@@ -0,0 +1,39 @@
+#
+# BUG#40827 - Killing insert-select to MyISAM can cause table corruption
+#
+CREATE TABLE `t1` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+KEY(id1), KEY(id)
+) ENGINE=MyISAM;
+CREATE TABLE `t2` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+KEY (id1), KEY(id)
+) ENGINE=MyISAM;
+INSERT INTO t2 (id) VALUES (123);
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+INSERT INTO t2 (id) SELECT id  FROM t2;
+# Switch to insert Connection
+SET SESSION debug='+d,wait_in_enable_indexes';
+# Send insert data
+INSERT INTO t1(id) SELECT id  FROM t2;
+# Switch to default Connection
+# Wait for insert data to reach the debug point
+SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE STATE = 'wait_in_enable_indexes' AND 
+INFO = "INSERT INTO t1(id) SELECT id  FROM t2" 
+INTO @thread_id;
+KILL QUERY @thread_id;
+CHECK TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	status	OK
+DROP TABLE t1,t2;

=== modified file 'mysql-test/r/mysql.result'
--- a/mysql-test/r/mysql.result	2009-03-24 20:48:31 +0000
+++ b/mysql-test/r/mysql.result	2009-04-28 17:54:26 +0000
@@ -200,4 +200,5 @@ Warning (Code 1286): Unknown table engin
 Warning (Code 1266): Using storage engine MyISAM for table 't2'
 Error (Code 1050): Table 't2' already exists
 drop tables t1, t2;
+<TABLE BORDER=1><TR><TH>&lt;</TH></TR><TR><TD>&lt; &amp;
> &gt;</TD></TR></TABLE>
 End of tests

=== modified file 'mysql-test/r/mysqlbinlog.result'
--- a/mysql-test/r/mysqlbinlog.result	2009-03-20 14:49:43 +0000
+++ b/mysql-test/r/mysqlbinlog.result	2009-05-08 17:24:15 +0000
@@ -471,4 +471,7 @@ IS NOT NULL
 1
 *** Unsigned server_id 4294967295 is found: 1 ***
 SET @@global.server_id= 1;
+RESET MASTER;
+FLUSH LOGS;
+End of 5.0 tests
 End of 5.1 tests

=== modified file 'mysql-test/r/select.result'
--- a/mysql-test/r/select.result	2009-03-16 05:02:10 +0000
+++ b/mysql-test/r/select.result	2009-04-28 00:27:38 +0000
@@ -4373,6 +4373,19 @@ f3	f4	count
 1	abc	1
 1	def	2
 drop table t1, t2, t3;
+CREATE TABLE t1 (a INT KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	3	100.00	Using where
+Warnings:
+Note	1003	select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t1`.`a`) and (`test`.`t1`.`a` > 1)) limit 2
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	3	100.00	Using where
+Warnings:
+Note	1003	select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = `test`.`t1`.`b`) and (`test`.`t1`.`a` > 1)) limit 2
+DROP TABLE t1;
 End of 5.0 tests
 create table t1(a INT, KEY (a));
 INSERT INTO t1 VALUES (1),(2),(3),(4),(5);

=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result	2009-04-01 08:58:55 +0000
+++ b/mysql-test/r/sp.result	2009-04-30 09:37:29 +0000
@@ -6994,6 +6994,21 @@ select name from mysql.proc where name =
 name
 p
 drop procedure p;
+CREATE DEFINER = 'root'@'localhost' PROCEDURE p1()
+NOT DETERMINISTIC
+CONTAINS SQL
+SQL SECURITY DEFINER
+COMMENT ''
+BEGIN
+SHOW TABLE STATUS like 't1';
+END;//
+CREATE TABLE t1 (f1 INT);
+CALL p1();
+CALL p1();
+CALL p1();
+CALL p1();
+DROP PROCEDURE p1;
+DROP TABLE t1;
 # ------------------------------------------------------------------
 # -- End of 5.1 tests
 # ------------------------------------------------------------------

=== modified file 'mysql-test/r/subselect3.result'
--- a/mysql-test/r/subselect3.result	2009-01-28 18:48:41 +0000
+++ b/mysql-test/r/subselect3.result	2009-04-30 19:27:10 +0000
@@ -849,6 +849,25 @@ ROW(1,2) = (SELECT    1,    1)	ROW(1,2) 
 SELECT ROW(1,2) = (SELECT    1,    2), ROW(1,2) IN (SELECT    1,    2);
 ROW(1,2) = (SELECT    1,    2)	ROW(1,2) IN (SELECT    1,    2)
 1	1
+CREATE TABLE t1 (a INT, b INT, c INT);
+INSERT INTO t1 VALUES (1,1,1), (1,1,1);
+EXPLAIN EXTENDED 
+SELECT c FROM 
+( SELECT 
+(SELECT COUNT(a) FROM 
+(SELECT COUNT(b) FROM t1) AS x GROUP BY c
+) FROM t1 GROUP BY b
+) AS y;
+ERROR 42S22: Unknown column 'c' in 'field list'
+SHOW WARNINGS;
+Level	Code	Message
+Note	1276	Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2
+Note	1276	Field or reference 'test.t1.c' of SELECT #3 was resolved in SELECT #2
+Error	1054	Unknown column 'c' in 'field list'
+Note	1003	select `c` AS `c` from (select (select count(`test`.`t1`.`a`) AS `COUNT(a)` from (select count(`test`.`t1`.`b`) AS `COUNT(b)` from `test`.`t1`) `x` group by `c`) AS `(SELECT COUNT(a) FROM 
+(SELECT COUNT(b) FROM t1) AS x GROUP BY c
+)` from `test`.`t1` group by `test`.`t1`.`b`) `y`
+DROP TABLE t1;
 End of 5.0 tests
 create table t0 (a int);
 insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

=== modified file 'mysql-test/r/upgrade.result'
--- a/mysql-test/r/upgrade.result	2009-04-10 09:25:48 +0000
+++ b/mysql-test/r/upgrade.result	2009-04-30 12:46:49 +0000
@@ -57,6 +57,18 @@ s1
 1
 drop table `txu@0023p@0023p1`;
 drop table `txu#p#p1`;
+#
+# Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
+#
+# copy table created using mysql4.0 into the data dir
+# check the table created using mysql 4.0
+CHECK TABLE t1;
+Table	Op	Msg_type	Msg_text
+test.t1	check	error	Table upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+# query the table created using mysql 4.0
+SELECT * FROM t1;
+c1	c2	c3
+DROP TABLE t1;
 truncate t1;
 drop table t1;
 drop database if exists `tabc`;

=== modified file 'mysql-test/r/user_var.result'
--- a/mysql-test/r/user_var.result	2009-01-23 18:18:02 +0000
+++ b/mysql-test/r/user_var.result	2009-05-10 16:20:35 +0000
@@ -399,6 +399,17 @@ select @lastid != id, @lastid, @lastid :
 0	3	3
 1	3	4
 drop table t1;
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20);
+SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b;
+SELECT @a, @b;
+@a	@b
+2	3
+SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b;
+a	b
+2	3
+DROP TABLE t1;
+End of 5.0 tests
 CREATE TABLE t1 (i INT);
 CREATE TRIGGER t_after_insert AFTER INSERT ON t1 FOR EACH ROW SET @bug42188 = 10;
 INSERT INTO t1 VALUES (1);

=== added file 'mysql-test/std_data/bug37631.MYD'

=== added file 'mysql-test/std_data/bug37631.MYI'
Binary files a/mysql-test/std_data/bug37631.MYI	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/bug37631.MYI	2009-04-30 12:46:49 +0000 differ

=== added file 'mysql-test/std_data/bug37631.frm'
Binary files a/mysql-test/std_data/bug37631.frm	1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/bug37631.frm	2009-04-30 12:46:49 +0000 differ

=== modified file 'mysql-test/suite/rpl/include/rpl_mixed_ddl.inc'
--- a/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc	2007-08-28 00:41:29 +0000
+++ b/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc	2009-04-26 21:21:01 +0000
@@ -83,4 +83,4 @@ sync_slave_with_master;
 # will be created. You will need to go to the mysql-test dir and diff
 # the files your self to see what is not matching
 
---exec diff $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql
+--diff_files $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_slave.sql

=== added file 'mysql-test/suite/rpl/r/rpl_bug38694.result'
--- a/mysql-test/suite/rpl/r/rpl_bug38694.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_bug38694.result	2009-04-30 13:20:38 +0000
@@ -0,0 +1,6 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;

=== removed file 'mysql-test/suite/rpl/t/rpl_000015-slave.sh'
--- a/mysql-test/suite/rpl/t/rpl_000015-slave.sh	2007-06-27 12:28:02 +0000
+++ b/mysql-test/suite/rpl/t/rpl_000015-slave.sh	1970-01-01 00:00:00 +0000
@@ -1 +0,0 @@
-rm -f $MYSQLTEST_VARDIR/slave-data/master.info

=== added file 'mysql-test/suite/rpl/t/rpl_bug38694-slave.opt'
--- a/mysql-test/suite/rpl/t/rpl_bug38694-slave.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug38694-slave.opt	2009-04-30 13:20:38 +0000
@@ -0,0 +1 @@
+--loose-debug=d,simulate_slave_delay_at_terminate_bug38694

=== added file 'mysql-test/suite/rpl/t/rpl_bug38694.test'
--- a/mysql-test/suite/rpl/t/rpl_bug38694.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug38694.test	2009-04-30 13:20:38 +0000
@@ -0,0 +1,10 @@
+# Testing replication threads stopping concurrency issue
+# at the server shutdown
+# Related bugs: bug#38694, bug#29968, bug#25306
+# The test checks if a delay at the termination phase of slave threads
+# DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
+# could cause any issue.
+
+source include/master-slave.inc;
+
+# End of tests

=== modified file 'mysql-test/suite/rpl/t/rpl_incident.test'
--- a/mysql-test/suite/rpl/t/rpl_incident.test	2008-08-14 09:38:22 +0000
+++ b/mysql-test/suite/rpl/t/rpl_incident.test	2009-05-02 19:28:54 +0000
@@ -14,42 +14,13 @@ REPLACE INTO t1 VALUES (4);
 SELECT * FROM t1;
 
 connection slave;
-source include/wait_for_slave_sql_to_stop.inc;
+# Wait until SQL thread stops with error LOST_EVENT on master
+let $slave_sql_errno= 1590;
+source include/wait_for_slave_sql_error.inc;
 
 # The 4 should not be inserted into the table, since the incident log
 # event should have stop the slave.
 --echo **** On Slave ****
-#### BEGIN DEBUG INFO ADDED BY SVEN 2008-07-18 -- SEE BUG#38077 ####
-let $tables= query_get_value(SHOW TABLES, Tables_in_test, 1);
-if (`SELECT '$tables' != 't1'`)
-{
-  --echo **** TEST CASE BUG! PRINTING DEBUG INFO! ****
-  --echo **** Dear developer, if you see this in the output of a test
-  --echo **** case run, please add all the information below as a
-  --echo **** comment to BUG#38077. If it's a pushbuild failure, please
-  --echo **** include a link to the push page.
-  --echo **** Thank you! /Sven
-  SHOW BINLOG EVENTS;
-  --echo **** master binlog ****
-  --error 0,1
-  --exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/master-bin.000001
-  --echo **** slave binlog ****
-  --error 0,1
-  --exec $MYSQL_BINLOG --hexdump $MYSQLTEST_VARDIR/log/slave-bin.000001

-  --echo **** slave status ****
-  query_vertical SHOW SLAVE STATUS;
-  --echo **** slave's master status ****
-  SHOW MASTER STATUS;
-  --echo **** slave binlog events ****
-  --echo [on master]
-  connection master;
-  --echo **** master status ****
-  SHOW MASTER STATUS;
-  --echo **** master binlog events ****
-  SHOW BINLOG EVENTS;
-  exit;
-}
-#### END DEBUG INFO ####
 SELECT * FROM t1;
 
 --replace_result $MASTER_MYPORT MASTER_PORT

=== modified file 'mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test'
--- a/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	2008-04-03 19:40:10 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test	2009-04-24 01:02:07 +0000
@@ -244,7 +244,7 @@ connection master;
 
 # We should be gold by the time, so I will get rid of our file.
 
---exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
 ################### End Bug 17654 ######################
 
 # What is the point of this test? It seems entirely pointless. It
@@ -349,9 +349,9 @@ FLUSH LOGS;
 
 --diff_files $MYSQLTEST_VARDIR/tmp/local.sql $MYSQLTEST_VARDIR/tmp/remote.sql
 
---exec rm $MYSQLTEST_VARDIR/tmp/remote.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/remote.sql
 
---exec rm $MYSQLTEST_VARDIR/tmp/local.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/local.sql
 
 DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5; 
 sync_slave_with_master;

=== modified file 'mysql-test/t/ctype_cp932_binlog_stm.test'
--- a/mysql-test/t/ctype_cp932_binlog_stm.test	2007-05-30 10:23:47 +0000
+++ b/mysql-test/t/ctype_cp932_binlog_stm.test	2009-05-05 06:55:22 +0000
@@ -34,4 +34,10 @@ delimiter ;|
 --error 1220
 SHOW BINLOG EVENTS FROM 364;
 
+--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
+CREATE TABLE t1 (a varchar(16)) character set cp932;
+INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
+SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/ctype_sjis.test'
--- a/mysql-test/t/ctype_sjis.test	2008-02-20 18:49:26 +0000
+++ b/mysql-test/t/ctype_sjis.test	2009-05-05 06:55:22 +0000
@@ -83,3 +83,13 @@ SET NAMES sjis;
 SELECT HEX('�����@�\') FROM DUAL;
 
 # End of 4.1 tests
+
+--echo # Start of 5.1 tests
+
+--echo Bug#44352 UPPER/LOWER function doesn't work correctly on cp932 and sjis environment.
+CREATE TABLE t1 (a varchar(16)) character set sjis;
+INSERT INTO t1 VALUES (0x8372835E),(0x8352835E);
+SELECT hex(a), hex(lower(a)), hex(upper(a)) FROM t1 ORDER BY binary(a);
+DROP TABLE t1;
+
+--echo # End of 5.1 tests

=== modified file 'mysql-test/t/fulltext.test'
--- a/mysql-test/t/fulltext.test	2009-02-12 10:10:07 +0000
+++ b/mysql-test/t/fulltext.test	2009-04-23 11:24:08 +0000
@@ -462,3 +462,12 @@ CREATE TABLE t1(a TEXT);
 --error ER_WRONG_ARGUMENTS
 SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE);
 DROP TABLE t1;
+
+#
+# BUG#42907 - Multi-term boolean fulltext query containing a single
+#             quote fails in 5.1.x
+#
+CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a));
+INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd');
+SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE);
+DROP TABLE t1;

=== modified file 'mysql-test/t/func_encrypt.test'
--- a/mysql-test/t/func_encrypt.test	2009-04-23 07:47:54 +0000
+++ b/mysql-test/t/func_encrypt.test	2009-04-27 10:05:01 +0000
@@ -99,5 +99,7 @@ create table t1 (f1 smallint(6) default 
 engine=myisam default charset=latin1;
 insert into t1 values (null,'contraction\'s');
 insert into t1 values (-15818,'requirement\'s');
+--disable_result_log
 select encrypt(f1,f2) as a from t1,(select encrypt(f1,f2) as b from t1) a;
+--enable_result_log
 drop table t1;

=== modified file 'mysql-test/t/gis-rtree.test'
--- a/mysql-test/t/gis-rtree.test	2007-10-05 10:43:15 +0000
+++ b/mysql-test/t/gis-rtree.test	2009-04-29 02:59:10 +0000
@@ -41,7 +41,7 @@ while ($1)
   let $2=10;
   while ($2)
   {
-    eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
+    eval INSERT INTO t2 (g) VALUES (LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)));
     dec $2;
   }
   dec $1;
@@ -61,7 +61,7 @@ while ($1)
   let $2=10;
   while ($2)
   {
-    eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))));
+    eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
     SELECT count(*) FROM t2;
     dec $2;
   }
@@ -235,11 +235,11 @@ DROP TABLE t1;
 # Bug #21888: Query on GEOMETRY field using PointFromWKB() results in lost connection
 #
 CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,0)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,1)));
-INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,0)));
-SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
+INSERT INTO t1 (foo) VALUES (POINT(1,1));
+INSERT INTO t1 (foo) VALUES (POINT(1,0));
+INSERT INTO t1 (foo) VALUES (POINT(0,1));
+INSERT INTO t1 (foo) VALUES (POINT(0,0));
+SELECT 1 FROM t1 WHERE foo != POINT(0,0);
 DROP TABLE t1;
 
 #
@@ -802,35 +802,35 @@ DROP TABLE t1;
 #
 
 create table t1 (a geometry not null, spatial index(a));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
-insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
-insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
-insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
-insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
-insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
-insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
-insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
-insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
-insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
-insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
-insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
-insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
-insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
-insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
-insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
-insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
-insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
-insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
-insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
+insert into t1 values (POINT(1.1517219314031e+164, 131072));
+insert into t1 values (POINT(9.1248812352444e+192, 2.9740338169556e+284));
+insert into t1 values (POINT(4.7783097267365e-299, -0));
+insert into t1 values (POINT(1.49166814624e-154, 2.0880974297595e-53));
+insert into t1 values (POINT(4.0917382598702e+149, 1.2024538023802e+111));
+insert into t1 values (POINT(2.0349165139404e+236, 2.9993936277913e-241));
+insert into t1 values (POINT(2.5243548967072e-29, 1.2024538023802e+111));
+insert into t1 values (POINT(0, 6.9835074892995e-251));
+insert into t1 values (POINT(2.0880974297595e-53, 3.1050361846014e+231));
+insert into t1 values (POINT(2.8728483499323e-188, 2.4600631144627e+260));
+insert into t1 values (POINT(3.0517578125e-05, 2.0349165139404e+236));
+insert into t1 values (POINT(1.1517219314031e+164, 1.1818212630766e-125));
+insert into t1 values (POINT(2.481040258324e-265, 5.7766220027675e-275));
+insert into t1 values (POINT(2.0880974297595e-53, 2.5243548967072e-29));
+insert into t1 values (POINT(5.7766220027675e-275, 9.9464647281957e+86));
+insert into t1 values (POINT(2.2181357552967e+130, 3.7857669957337e-270));
+insert into t1 values (POINT(4.5767114681874e-246, 3.6893488147419e+19));
+insert into t1 values (POINT(4.5767114681874e-246, 3.7537584144024e+255));
+insert into t1 values (POINT(3.7857669957337e-270, 1.8033161362863e-130));
+insert into t1 values (POINT(0, 5.8774717541114e-39));
+insert into t1 values (POINT(1.1517219314031e+164, 2.2761049594727e-159));
+insert into t1 values (POINT(6.243497100632e+144, 3.7857669957337e-270));
+insert into t1 values (POINT(3.7857669957337e-270, 2.6355494858076e-82));
+insert into t1 values (POINT(2.0349165139404e+236, 3.8518598887745e-34));
+insert into t1 values (POINT(4.6566128730774e-10, 2.0880974297595e-53));
+insert into t1 values (POINT(2.0880974297595e-53, 1.8827498946116e-183));
+insert into t1 values (POINT(1.8033161362863e-130, 9.1248812352444e+192));
+insert into t1 values (POINT(4.7783097267365e-299, 2.2761049594727e-159));
+insert into t1 values (POINT(1.94906280228e+289, 1.2338789709327e-178));
 drop table t1;
 
 # End of 4.1 tests

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2009-02-15 09:47:04 +0000
+++ b/mysql-test/t/gis.test	2009-04-29 02:59:10 +0000
@@ -37,32 +37,32 @@ INSERT INTO gis_point VALUES 
 INSERT INTO gis_line VALUES
 (105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
 (106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
-(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
 
 INSERT INTO gis_polygon VALUES
 (108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
 (109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
-(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
 
 INSERT INTO gis_multi_point VALUES
 (111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
 (112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
-(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
 
 INSERT INTO gis_multi_line VALUES
 (114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
 (115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
-(116, MLineFromWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
 
 
 INSERT INTO gis_multi_polygon VALUES
 (117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
 (118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
-(119, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
 
 INSERT INTO gis_geometrycollection VALUES
 (120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
-(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
 
 INSERT into gis_geometry SELECT * FROM gis_point;
 INSERT into gis_geometry SELECT * FROM gis_line;

=== modified file 'mysql-test/t/heap_btree.test'
--- a/mysql-test/t/heap_btree.test	2007-10-19 20:12:14 +0000
+++ b/mysql-test/t/heap_btree.test	2009-05-06 09:30:14 +0000
@@ -253,5 +253,13 @@ insert into t1 values (1, 1), (3, 3), (2
 select * from t1 where a is null;
 drop table t1;
 
+-- echo #
+-- echo # bug#39918 - memory (heap) engine crashing while executing self join with delete
+-- echo #
+
+CREATE TABLE t1(a INT, KEY USING BTREE (a)) ENGINE=MEMORY;
+INSERT INTO t1 VALUES(1),(1);
+DELETE a1 FROM t1 AS a1, t1 AS a2 WHERE a1.a=a2.a;
+DROP TABLE t1;
 --echo End of 5.0 tests
 

=== modified file 'mysql-test/t/insert_select.test'
--- a/mysql-test/t/insert_select.test	2007-09-24 13:23:40 +0000
+++ b/mysql-test/t/insert_select.test	2009-05-04 12:45:36 +0000
@@ -324,6 +324,16 @@ SELECT * FROM t2;
 DROP TABLE t1, t2;
 
 #
+# Bug#44306: Assertion fail on duplicate key error in 'INSERT ... SELECT' 
+# statements
+#
+CREATE TABLE t1 ( a INT KEY, b INT );
+INSERT INTO t1 VALUES ( 0, 1 );
+--error ER_DUP_ENTRY
+INSERT INTO t1 ( b ) SELECT MAX( b ) FROM t1 WHERE b = 2;
+DROP TABLE t1;
+
+#
 # Bug #26207: inserts don't work with shortened index
 #
 SET SQL_MODE='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

=== modified file 'mysql-test/t/myisam.test'
--- a/mysql-test/t/myisam.test	2008-09-06 00:51:17 +0000
+++ b/mysql-test/t/myisam.test	2009-04-30 11:03:44 +0000
@@ -1478,5 +1478,30 @@ let $MYSQLD_DATADIR= `select @@datadir`;
 --exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1
 DROP TABLE t1;
 
+#
+# Bug#43737: Select query return bad result
+#
+CREATE TABLE t1 (
+  c INT,
+  d bit(1),
+  e INT,
+  f VARCHAR(1),
+  g BIT(1),
+  h BIT(1),
+  KEY (h, d, e, g)
+);
+INSERT INTO t1 VALUES
+  (  3, 1, 1, 'a', 0, 0 ),
+  (  3, 1, 5, 'a', 0, 0 ),
+  ( 10, 1, 2, 'a', 0, 1 ),
+  ( 10, 1, 3, 'a', 0, 1 ),
+  ( 10, 1, 4, 'a', 0, 1 );
+
+SELECT f FROM t1 WHERE d = 1 AND e = 2 AND g = 0 AND h = 1;
+
+SELECT h+0, d + 0, e, g + 0 FROM t1;
+
+DROP TABLE t1;
+
 --echo End of 5.1 tests
 

=== added file 'mysql-test/t/myisam_debug.test'
--- a/mysql-test/t/myisam_debug.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/myisam_debug.test	2009-05-04 09:05:16 +0000
@@ -0,0 +1,57 @@
+--source include/have_debug.inc
+
+# We disable this test in embedded mode because of BUG#43733
+--source include/not_embedded.inc
+
+--echo #
+--echo # BUG#40827 - Killing insert-select to MyISAM can cause table corruption
+--echo #
+
+CONNECT (insertConn, localhost, root,,);
+
+CREATE TABLE `t1` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+ KEY(id1), KEY(id)
+) ENGINE=MyISAM;
+
+CREATE TABLE `t2` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+ KEY (id1), KEY(id)
+) ENGINE=MyISAM;
+
+INSERT INTO t2 (id) VALUES (123);
+
+let $i = 10; 
+while ($i)
+{
+  INSERT INTO t2 (id) SELECT id  FROM t2; 
+  dec $i; 
+}
+
+--echo # Switch to insert Connection
+CONNECTION insertConn;
+SET SESSION debug='+d,wait_in_enable_indexes';
+--echo # Send insert data
+SEND INSERT INTO t1(id) SELECT id  FROM t2; 
+
+--echo # Switch to default Connection
+CONNECTION default;
+--echo # Wait for insert data to reach the debug point
+
+let $wait_condition=
+  SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+  WHERE STATE = "wait_in_enable_indexes" AND 
+  INFO = "INSERT INTO t1(id) SELECT id  FROM t2";
+--source include/wait_condition.inc
+
+SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE STATE = 'wait_in_enable_indexes' AND 
+INFO = "INSERT INTO t1(id) SELECT id  FROM t2" 
+INTO @thread_id;
+
+KILL QUERY @thread_id;
+CHECK TABLE t1; 
+DROP TABLE t1,t2;
+DISCONNECT insertConn;

=== modified file 'mysql-test/t/mysql.test'
--- a/mysql-test/t/mysql.test	2009-03-24 20:53:25 +0000
+++ b/mysql-test/t/mysql.test	2009-04-28 17:54:26 +0000
@@ -367,4 +367,10 @@ remove_file $MYSQLTEST_VARDIR/tmp/bug310
 
 drop tables t1, t2;
 
+#
+# Bug #27884: mysql --html does not quote HTML special characters in output
+# 
+--exec $MYSQL --html test -e "select '< & >' as \`<\`"
+
+--echo
 --echo End of tests

=== modified file 'mysql-test/t/mysqlbinlog.test'
--- a/mysql-test/t/mysqlbinlog.test	2009-03-06 14:56:17 +0000
+++ b/mysql-test/t/mysqlbinlog.test	2009-05-08 17:24:15 +0000
@@ -367,4 +367,16 @@ echo *** Unsigned server_id $s_id_max is
 eval SET @@global.server_id= $save_server_id;
 --remove_file $binlog_file
 
+#
+# Bug #41943: mysqlbinlog.exe crashes if --hexdump option is used
+#
+
+RESET MASTER;
+FLUSH LOGS;
+
+# We do not need the results, just make sure that mysqlbinlog does not crash
+--exec $MYSQL_BINLOG --hexdump --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT  master-bin.000001 >/dev/null
+
+--echo End of 5.0 tests
+
 --echo End of 5.1 tests

=== modified file 'mysql-test/t/select.test'
--- a/mysql-test/t/select.test	2009-03-16 05:02:10 +0000
+++ b/mysql-test/t/select.test	2009-04-28 00:27:38 +0000
@@ -3726,6 +3726,20 @@ cr.f4 = cr2.f4
 GROUP BY a.f3, cr.f4;
 
 drop table t1, t2, t3;
+
+
+#
+# Bug #40925: Equality propagation takes non indexed attribute
+#
+
+CREATE TABLE t1 (a INT KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
+
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND a = b LIMIT 2;
+EXPLAIN EXTENDED SELECT a, b FROM t1 WHERE a > 1 AND b = a LIMIT 2;
+
+DROP TABLE t1;
+ 
 --echo End of 5.0 tests
 
 #

=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test	2009-04-01 08:58:55 +0000
+++ b/mysql-test/t/sp.test	2009-04-30 09:37:29 +0000
@@ -8270,6 +8270,33 @@ select replace(@full_mode, 'ALLOW_INVALI
 select name from mysql.proc where name = 'p' and sql_mode = @full_mode;
 drop procedure p;
 
+#
+# Bug#43962 "Packets out of order" calling a SHOW TABLE STATUS
+#
+DELIMITER //;
+CREATE DEFINER = 'root'@'localhost' PROCEDURE p1()
+NOT DETERMINISTIC
+CONTAINS SQL
+SQL SECURITY DEFINER
+COMMENT ''
+BEGIN
+ SHOW TABLE STATUS like 't1';
+END;//
+DELIMITER ;//
+
+
+CREATE TABLE t1 (f1 INT);
+--disable_result_log
+let $tab_count= 4;
+while ($tab_count)
+{
+ EVAL CALL p1();
+ dec $tab_count ;
+}
+--enable_result_log
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
 --echo # ------------------------------------------------------------------
 --echo # -- End of 5.1 tests
 --echo # ------------------------------------------------------------------

=== modified file 'mysql-test/t/sp_trans_log.test'
--- a/mysql-test/t/sp_trans_log.test	2007-06-06 17:57:07 +0000
+++ b/mysql-test/t/sp_trans_log.test	2009-04-28 18:42:17 +0000
@@ -8,17 +8,17 @@
 delimiter |;
 
 #
-# Bug #13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
-# Bug #23333 stored function + non-transac table + transac table =
-#            breaks stmt-based binlog
-# Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
+# Bug#13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog
+# Bug#23333 stored function + non-transac table + transac table =
+#           breaks stmt-based binlog
+# Bug#27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF()
 #
 --disable_warnings
 drop function if exists bug23333|
 drop table if exists t1,t2|
 --enable_warnings
- CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM|
- CREATE TABLE t2 (a int  NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
+CREATE TABLE t1 (a int  NOT NULL auto_increment primary key) ENGINE=MyISAM|
+CREATE TABLE t2 (a int  NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB|
 
 insert into t2 values (1,1)|
 

=== modified file 'mysql-test/t/subselect3.test'
--- a/mysql-test/t/subselect3.test	2009-01-28 18:48:41 +0000
+++ b/mysql-test/t/subselect3.test	2009-04-30 19:27:10 +0000
@@ -669,6 +669,25 @@ SELECT ROW(1,2) = (SELECT NULL,    1), R
 SELECT ROW(1,2) = (SELECT    1,    1), ROW(1,2) IN (SELECT    1,    1);
 SELECT ROW(1,2) = (SELECT    1,    2), ROW(1,2) IN (SELECT    1,    2);
 
+#
+# Bug #37362      Crash in do_field_eq
+#
+CREATE TABLE t1 (a INT, b INT, c INT);
+INSERT INTO t1 VALUES (1,1,1), (1,1,1);
+
+--error 1054
+EXPLAIN EXTENDED 
+  SELECT c FROM 
+    ( SELECT 
+      (SELECT COUNT(a) FROM 
+        (SELECT COUNT(b) FROM t1) AS x GROUP BY c
+      ) FROM t1 GROUP BY b
+    ) AS y;
+SHOW WARNINGS;
+
+DROP TABLE t1;
+
+
 --echo End of 5.0 tests
 
 #

=== modified file 'mysql-test/t/upgrade.test'
--- a/mysql-test/t/upgrade.test	2009-04-13 13:09:10 +0000
+++ b/mysql-test/t/upgrade.test	2009-04-30 12:46:49 +0000
@@ -48,6 +48,20 @@ select * from `txu#p#p1`;
 drop table `txu@0023p@0023p1`;
 drop table `txu#p#p1`;
 
+--echo #
+--echo # Bug#37631 Incorrect key file for table after upgrading from 5.0 to 5.1
+--echo #
+--echo # copy table created using mysql4.0 into the data dir
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+copy_file std_data/bug37631.frm $MYSQLD_DATADIR/test/t1.frm;
+copy_file std_data/bug37631.MYD $MYSQLD_DATADIR/test/t1.MYD;
+copy_file std_data/bug37631.MYI $MYSQLD_DATADIR/test/t1.MYI;
+--echo # check the table created using mysql 4.0
+CHECK TABLE t1;
+--echo # query the table created using mysql 4.0
+SELECT * FROM t1;
+DROP TABLE t1;
+
 #
 # Check if old tables work
 #

=== modified file 'mysql-test/t/user_var.test'
--- a/mysql-test/t/user_var.test	2009-01-24 14:07:10 +0000
+++ b/mysql-test/t/user_var.test	2009-05-10 16:20:35 +0000
@@ -286,6 +286,18 @@ select @lastid != id, @lastid, @lastid :
 drop table t1;
 
 #
+# Bug#42009: SELECT into variable gives different results to direct SELECT
+#
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20);
+SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b;
+SELECT @a, @b;
+SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b;
+DROP TABLE t1;
+
+--echo End of 5.0 tests
+
+#
 # Bug#42188: crash and/or memory corruption with user variables in trigger
 #
 

=== modified file 'mysys/mf_keycache.c'
--- a/mysys/mf_keycache.c	2009-02-13 16:41:47 +0000
+++ b/mysys/mf_keycache.c	2009-04-29 11:51:10 +0000
@@ -2044,13 +2044,15 @@ restart:
         }
         else
         {
+          size_t block_mem_offset;
           /* There are some never used blocks, take first of them */
           DBUG_ASSERT(keycache->blocks_used <
                       (ulong) keycache->disk_blocks);
           block= &keycache->block_root[keycache->blocks_used];
+          block_mem_offset= 
+           ((size_t) keycache->blocks_used) * keycache->key_cache_block_size;
           block->buffer= ADD_TO_PTR(keycache->block_mem,
-                                    ((ulong) keycache->blocks_used*
-                                     keycache->key_cache_block_size),
+                                    block_mem_offset,
                                     uchar*);
           keycache->blocks_used++;
           DBUG_ASSERT(!block->next_used);

=== modified file 'mysys/safemalloc.c'
--- a/mysys/safemalloc.c	2009-02-13 16:41:47 +0000
+++ b/mysys/safemalloc.c	2009-04-30 13:42:38 +0000
@@ -174,7 +174,7 @@ void *_mymalloc(size_t size, const char 
   data[size + 3]= MAGICEND3;
   irem->filename= (char *) filename;
   irem->linenum= lineno;
-  irem->datasize= (uint32) size;
+  irem->datasize= size;
   irem->prev=	  NULL;
 
   /* Add this remember structure to the linked list */

=== modified file 'scripts/mysql_convert_table_format.sh'
--- a/scripts/mysql_convert_table_format.sh	2007-12-28 00:07:42 +0000
+++ b/scripts/mysql_convert_table_format.sh	2009-04-28 18:47:34 +0000
@@ -23,18 +23,30 @@ $opt_help=$opt_version=$opt_verbose=$opt
 $opt_user=$opt_database=$opt_password=undef;
 $opt_host="localhost";
 $opt_socket="";
-$opt_type="MYISAM";
+$opt_engine="MYISAM";
 $opt_port=0;
 $exit_status=0;
 
-GetOptions("force","help","host=s","password=s","user=s","type=s","verbose","version","socket=s", "port=i") || 
-  usage(0);
+GetOptions(
+  "e|engine|type=s"       => \$opt_type,
+  "f|force"               => \$opt_force,
+  "help|?"               => \$opt_help,
+  "h|host=s"              => \$opt_host,
+  "p|password=s"          => \$opt_password,
+  "u|user=s"              => \$opt_user,
+  "v|verbose"             => \$opt_verbose,
+  "V|version"             => \$opt_version,
+  "S|socket=s"            => \$opt_socket, 
+  "P|port=i"              => \$opt_port
+) || usage(0);
+
 usage($opt_version) if ($#ARGV < 0 || $opt_help || $opt_version);
+
 $opt_database=shift(@ARGV);
 
-if (uc($opt_type) eq "HEAP")
+if (grep { /^$opt_engine$/i } qw(HEAP MEMORY BLACKHOLE))
 {
-  print "Converting to type HEAP would delete your tables; aborting\n";
+  print "Converting to '$opt_engine' would delete your data; aborting\n";
   exit(1);
 }
 
@@ -54,21 +66,29 @@ $dbh = DBI->connect("DBI:mysql:$opt_data
 		    { PrintError => 0})
   || die "Can't connect to database $opt_database: $DBI::errstr\n";
 
-if ($#ARGV < 0)
+my @tables;
+
+push(@ARGV, "%") if(!@ARGV);
+
+foreach $pattern (@ARGV)
 {
-  # Fetch all table names from the database
   my ($sth,$row);
-  $sth=$dbh->prepare("show tables");
-  $sth->execute || die "Can't get tables from $opt_database; $DBI::errstr\n";
+  $sth=$dbh->prepare("SHOW TABLES LIKE ?");
+  $rv= $sth->execute($pattern);
+  if(!int($rv))
+  {
+    warn "Can't get tables matching '$pattern' from $opt_database; $DBI::errstr\n"; 
+    exit(1) unless $opt_force;
+  }
   while (($row = $sth->fetchrow_arrayref))
   {
-    push(@ARGV,$row->[0]);
+    push(@tables, $row->[0]);
   }
   $sth->finish;
 }
 
 print "Converting tables:\n" if ($opt_verbose);
-foreach $table (@ARGV)
+foreach $table (@tables)
 {
   my ($sth,$row);
 
@@ -76,14 +96,15 @@ foreach $table (@ARGV)
   $sth=$dbh->prepare("show table status like '$table'");  
   if ($sth->execute && ($row = $sth->fetchrow_arrayref))
   {
-    if (uc($row->[1]) eq uc($opt_type))
+    if (uc($row->[1]) eq uc($opt_engine))
     {
-      print "$table is already of type $opt_type;  Ignored\n";
+      print "$table already uses the '$opt_engine' engine;  Ignored\n";
       next;
     }
   }
   print "converting $table\n" if ($opt_verbose);
-  if (!$dbh->do("ALTER TABLE $table ENGINE=$opt_type"))
+  $table=~ s/`/``/g;
+  if (!$dbh->do("ALTER TABLE `$table` ENGINE=$opt_engine"))
   {
     print STDERR "Can't convert $table: Error $DBI::errstr\n";
     exit(1) if (!$opt_force);
@@ -103,43 +124,43 @@ sub usage
 
   print <<EOF;
 
-Conversion of a MySQL tables to other table types.
+Conversion of a MySQL tables to other storage engines
 
- Usage: $0 database [tables]
+ Usage: $0 database [table[ table ...]]
  If no tables has been specifed, all tables in the database will be converted.
+ You can also use wildcards, ie "my%"
 
  The following options are available:
 
---force
+-f, --force
   Continue even if there is some error.
 
---help or --Information
+-?, --help
   Shows this help
 
---host='host name' (Default $opt_host)
-  Host name where the database server is located.
+-e, --engine=ENGINE
+  Converts tables to the given storage engine (Default: $opt_engine)
 
---password='password'
+-h, --host=HOST
+  Host name where the database server is located. (Default: $opt_host)
+
+-p, --password=PASSWORD
   Password for the current user.
 
---port=port
+-P, --port=PORT
   TCP/IP port to connect to if host is not "localhost".
 
---socket='/path/to/socket'
+-S, --socket=SOCKET
   Socket to connect with.
 
---ENGINE='table-type'
-  Converts tables to the given table type (Default: $opt_type)
-  MySQL 3.23 supports at least the BDB, ISAM and MYISAM types.
-
---user='user_name'
+-u, --user=USER
   User name to log into the SQL server.
 
---verbose
+-v, --verbose
   This is a test specific option that is only used when debugging a test.
   Print more information about what is going on.
 
---version
+-V, --version
   Shows the version of this program.
 EOF
   exit(1);

=== modified file 'scripts/mysqld_multi.sh'
--- a/scripts/mysqld_multi.sh	2009-04-02 19:42:29 +0000
+++ b/scripts/mysqld_multi.sh	2009-04-28 18:28:03 +0000
@@ -316,11 +316,11 @@ sub start_mysqlds()
 	$tmp.= " $options[$j]";
       }
     }
-    if ($opt_verbose && $com =~ m/\/safe_mysqld$/ && !$info_sent)
+    if ($opt_verbose && $com =~ m/\/(safe_mysqld|mysqld_safe)$/ && !$info_sent)
     {
-      print "WARNING: safe_mysqld is being used to start mysqld. In this case you ";
+      print "WARNING: $1 is being used to start mysqld. In this case you ";
       print "may need to pass\n\"ledir=...\" under groups [mysqldN] to ";
-      print "safe_mysqld in order to find the actual mysqld binary.\n";
+      print "$1 in order to find the actual mysqld binary.\n";
       print "ledir (library executable directory) should be the path to the ";
       print "wanted mysqld binary.\n\n";
       $info_sent= 1;
@@ -670,9 +670,9 @@ language   = @datadir@/mysql/english
 user       = unix_user1
 
 [mysqld3]
-mysqld     = /path/to/safe_mysqld/safe_mysqld
+mysqld     = /path/to/mysqld_safe
 ledir      = /path/to/mysqld-binary/
-mysqladmin = /path/to/mysqladmin/mysqladmin
+mysqladmin = /path/to/mysqladmin
 socket     = /tmp/mysql.sock3
 port       = 3308
 pid-file   = @localstatedir@3/hostname.pid3

=== modified file 'scripts/mysqldumpslow.sh'
--- a/scripts/mysqldumpslow.sh	2009-02-24 08:07:40 +0000
+++ b/scripts/mysqldumpslow.sh	2009-04-28 18:19:58 +0000
@@ -20,7 +20,7 @@ GetOptions(\%opt,
     'v|verbose+',# verbose
     'help+',	# write usage info
     'd|debug+',	# debug
-    's=s',	# what to sort by (t, at, l, al, r, ar etc)
+    's=s',	# what to sort by (al, at, ar, c, t, l, r)
     'r!',	# reverse the sort order (largest last instead of first)
     't=i',	# just show the top n queries
     'a!',	# don't abstract all numbers to N and strings to 'S'
@@ -163,7 +163,7 @@ Parse and summarize the MySQL slow query
 
   -v           verbose
   -d           debug
-  -s ORDER     what to sort by (t, at, l, al, r, ar etc), 'at' is default
+  -s ORDER     what to sort by (al, at, ar, c, t, l, r), 'at' is default
   -r           reverse the sort order (largest last instead of first)
   -t NUM       just show the top n queries
   -a           don't abstract all numbers to N and strings to 'S'

=== modified file 'scripts/mysqlhotcopy.sh'
--- a/scripts/mysqlhotcopy.sh	2008-03-07 20:45:40 +0000
+++ b/scripts/mysqlhotcopy.sh	2009-04-28 16:16:17 +0000
@@ -49,11 +49,11 @@ $0 Ver $VERSION
 
 Usage: $0 db_name[./table_regex/] [new_db_name | directory]
 
-  -?, --help           display this helpscreen and exit
+  -?, --help           display this help-screen and exit
   -u, --user=#         user for database login if not current user
   -p, --password=#     password to use when connecting to server (if not set
                        in my.cnf, which is recommended)
-  -h, --host=#         Hostname for local server when connecting over TCP/IP
+  -h, --host=#         hostname for local server when connecting over TCP/IP
   -P, --port=#         port to use when connecting to local server with TCP/IP
   -S, --socket=#       socket to use when connecting to local server
 
@@ -86,7 +86,7 @@ sub usage {
 
 # Do not initialize user or password options; that way, any user/password
 # options specified in option files will be used.  If no values are specified
-# all, the defaults will be used (login name, no password).
+# at all, the defaults will be used (login name, no password).
 
 my %opt = (
     noindices	=> 0,
@@ -95,7 +95,7 @@ my %opt = (
     method	=> "cp",
     flushlog    => 0,
 );
-Getopt::Long::Configure(qw(no_ignore_case)); # disambuguate -p and -P
+Getopt::Long::Configure(qw(no_ignore_case)); # disambiguate -p and -P
 GetOptions( \%opt,
     "help",
     "host|h=s",
@@ -453,7 +453,7 @@ else {
     printf "Locked $num_tables tables in %d seconds.\n", time-$start unless $opt{quiet};
     $hc_started = time;	# count from time lock is granted
 
-    # flush tables to make on-disk copy uptodate
+    # flush tables to make on-disk copy up to date
     $start = time;
     $dbh->do("FLUSH TABLES /*!32323 $hc_tables */");
     printf "Flushed tables ($hc_tables) in %d seconds.\n", time-$start unless $opt{quiet};
@@ -895,7 +895,7 @@ tables and you don't want to have all th
 whole duration.
 
 In this situation, I<if> you are happy for groups of tables to be
-backed up separately (and thus possibly not be logically consistant
+backed up separately (and thus possibly not be logically consistent
 with one another) then you can run mysqlhotcopy several times on
 the same database each with different db_name./table_regex/.
 All but the first should use the --addtodest option so the tables
@@ -920,7 +920,7 @@ server in a mutual replication setup.
 
 =item --regexp pattern
 
-Copy all databases with names matching the pattern
+Copy all databases with names matching the pattern.
 
 =item --regexp /pattern1/./pattern2/
 
@@ -933,7 +933,7 @@ names begin with 'bar' from all database
 =item db_name./pattern/
 
 Copy only tables matching pattern. Shell metacharacters ( (, ), |, !,
-etc.) have to be escaped (e.g. \). For example, to select all tables
+etc.) have to be escaped (e.g., \). For example, to select all tables
 in database db1 whose names begin with 'foo' or 'bar':
 
     mysqlhotcopy --indices --method=cp db1./^\(foo\|bar\)/
@@ -947,19 +947,19 @@ that do not begin with foo nor bar:
 
 =item -?, --help
 
-Display helpscreen and exit
+Display help-screen and exit.
 
 =item -u, --user=#         
 
-user for database login if not current user
+User for database login if not current user.
 
 =item -p, --password=#     
 
-password to use when connecting to the server. Note that you are strongly
+Password to use when connecting to the server. Note that you are strongly
 encouraged *not* to use this option as every user would be able to see the
 password in the process list. Instead use the '[mysqlhotcopy]' section in
 one of the config files, normally /etc/my.cnf or your personal ~/.my.cnf.
-(See the chapter 'my.cnf Option Files' in the manual)
+(See the chapter 'my.cnf Option Files' in the manual.)
 
 =item -h, -h, --host=#
 
@@ -968,12 +968,12 @@ different from 'localhost' will trigger 
 
 =item -P, --port=#         
 
-port to use when connecting to MySQL server with TCP/IP.  This is only used
+Port to use when connecting to MySQL server with TCP/IP.  This is only used
 when using the --host option.
 
 =item -S, --socket=#         
 
-UNIX domain socket to use when connecting to local server
+UNIX domain socket to use when connecting to local server.
 
 =item  --noindices          
 
@@ -983,7 +983,7 @@ on the backup.
 
 =item  --method=#           
 
-method for copy (only "cp" currently supported). Alpha support for
+Method for copy (only "cp" currently supported). Alpha support for
 "scp" was added in November 2000. Your experience with the scp method
 will vary with your ability to understand how scp works. 'man scp'
 and 'man ssh' are your friends.
@@ -1000,15 +1000,15 @@ scp or rsync the files at your leisure.
 
 =item -q, --quiet              
 
-be silent except for errors
+Be silent except for errors.
 
 =item  --debug
 
-Debug messages are displayed 
+Debug messages are displayed.
 
 =item -n, --dryrun
 
-Display commands without actually doing them
+Display commands without actually doing them.
 
 =back
 
@@ -1030,18 +1030,18 @@ to be specified on the command line:
   mysqlhotcopy db newdb  t1 t2 /^foo_/ : t3 /^bar_/ : +
 
 where ":" delimits the subsets, the /^foo_/ indicates all tables
-with names begining with "foo_" and the "+" indicates all tables
+with names beginning with "foo_" and the "+" indicates all tables
 not copied by the previous subsets.
 
-newdb is either another not existing database or a full path to a directory
-where we can create a directory 'db'
+'newdb' is either the name of the new database, or the full path name
+of the new database file. The database should not already exist.
 
 Add option to lock each table in turn for people who don\'t need
 cross-table integrity.
 
 Add option to FLUSH STATUS just before UNLOCK TABLES.
 
-Add support for other copy methods (eg tar to single file?).
+Add support for other copy methods (e.g., tar to single file?).
 
 Add support for forthcoming MySQL ``RAID'' table subdirectory layouts.
 
@@ -1049,26 +1049,26 @@ Add support for forthcoming MySQL ``RAID
 
 Tim Bunce
 
-Martin Waite - added checkpoint, flushlog, regexp and dryrun options
+Martin Waite - Added checkpoint, flushlog, regexp and dryrun options.
                Fixed cleanup of targets when hotcopy fails. 
-	       Added --record_log_pos.
+               Added --record_log_pos.
                RAID tables are now copied (don't know if this works over scp).
 
-Ralph Corderoy - added synonyms for commands
+Ralph Corderoy - Added synonyms for commands.
 
-Scott Wiersdorf - added table regex and scp support
+Scott Wiersdorf - Added table regex and scp support.
 
-Monty - working --noindex (copy only first 2048 bytes of index file)
-        Fixes for --method=scp
+Monty - Working --noindex (copy only first 2048 bytes of index file).
+        Fixes for --method=scp.
 
 Ask Bjoern Hansen - Cleanup code to fix a few bugs and enable -w again.
 
 Emil S. Hansen - Added resetslave and resetmaster.
 
-Jeremy D. Zawodny - Removed depricated DBI calls.  Fixed bug which
+Jeremy D. Zawodny - Removed deprecated DBI calls.  Fixed bug which
 resulted in nothing being copied when a regexp was specified but no
 database name(s).
 
 Martin Waite - Fix to handle database name that contains space.
 
-Paul DuBois - Remove end '/' from directory names
+Paul DuBois - Remove end '/' from directory names.

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2008-12-10 20:14:50 +0000
+++ b/sql/handler.h	2009-05-04 10:00:15 +0000
@@ -876,9 +876,9 @@ typedef struct {
   ulonglong delete_length;
   ha_rows records;
   ulong mean_rec_length;
-  time_t create_time;
-  time_t check_time;
-  time_t update_time;
+  ulong create_time;
+  ulong check_time;
+  ulong update_time;
   ulonglong check_sum;
 } PARTITION_INFO;
 
@@ -1037,9 +1037,9 @@ public:
   ha_rows records;
   ha_rows deleted;			/* Deleted records */
   ulong mean_rec_length;		/* physical reclength */
-  time_t create_time;			/* When table was created */
-  time_t check_time;
-  time_t update_time;
+  ulong create_time;			/* When table was created */
+  ulong check_time;
+  ulong update_time;
   uint block_size;			/* index block size */
 
   ha_statistics():

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2009-04-01 11:10:03 +0000
+++ b/sql/item.cc	2009-05-04 20:33:23 +0000
@@ -3390,14 +3390,12 @@ static void mark_as_dependent(THD *thd, 
   current->mark_as_dependent(last);
   if (thd->lex->describe & DESCRIBE_EXTENDED)
   {
-    char warn_buff[MYSQL_ERRMSG_SIZE];
-    sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED),
-            db_name, (db_name[0] ? "." : ""),
-            table_name, (table_name [0] ? "." : ""),
-            resolved_item->field_name,
-	    current->select_number, last->select_number);
-    push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
-		 ER_WARN_FIELD_RESOLVED, warn_buff);
+    push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+		 ER_WARN_FIELD_RESOLVED, ER(ER_WARN_FIELD_RESOLVED),
+                 db_name, (db_name[0] ? "." : ""),
+                 table_name, (table_name [0] ? "." : ""),
+                 resolved_item->field_name,
+                 current->select_number, last->select_number);
   }
 }
 
@@ -4468,7 +4466,7 @@ Item *Item_field::replace_equal_field(uc
       return const_item;
     }
     Item_field *subst= item_equal->get_first();
-    if (subst && !field->eq(subst->field))
+    if (subst && field->table != subst->field->table && !field->eq(subst->field))
       return subst;
   }
   return this;

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2009-04-23 07:50:34 +0000
+++ b/sql/item_func.cc	2009-05-10 16:20:35 +0000
@@ -4178,6 +4178,41 @@ Item_func_set_user_var::check(bool use_r
 
 
 /**
+  @brief Evaluate and store item's result.
+  This function is invoked on "SELECT ... INTO @var ...".
+  
+  @param    item    An item to get value from.
+*/
+
+void Item_func_set_user_var::save_item_result(Item *item)
+{
+  DBUG_ENTER("Item_func_set_user_var::save_item_result");
+
+  switch (cached_result_type) {
+  case REAL_RESULT:
+    save_result.vreal= item->val_result();
+    break;
+  case INT_RESULT:
+    save_result.vint= item->val_int_result();
+    unsigned_flag= item->unsigned_flag;
+    break;
+  case STRING_RESULT:
+    save_result.vstr= item->str_result(&value);
+    break;
+  case DECIMAL_RESULT:
+    save_result.vdec= item->val_decimal_result(&decimal_buff);
+    break;
+  case ROW_RESULT:
+  default:
+    // Should never happen
+    DBUG_ASSERT(0);
+    break;
+  }
+  DBUG_VOID_RETURN;
+}
+
+
+/**
   This functions is invoked on
   SET \@variable or \@variable:= expression.
 

=== modified file 'sql/item_func.h'
--- a/sql/item_func.h	2009-01-23 18:18:02 +0000
+++ b/sql/item_func.h	2009-05-10 16:20:35 +0000
@@ -1341,6 +1341,7 @@ public:
   bool send(Protocol *protocol, String *str_arg);
   void make_field(Send_field *tmp_field);
   bool check(bool use_result_field);
+  void save_item_result(Item *item);
   bool update();
   enum Item_result result_type () const { return cached_result_type; }
   bool fix_fields(THD *thd, Item **ref);

=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc	2007-12-20 21:11:37 +0000
+++ b/sql/item_geofunc.cc	2009-04-29 02:59:10 +0000
@@ -78,10 +78,17 @@ String *Item_func_geometry_from_wkb::val
 {
   DBUG_ASSERT(fixed == 1);
   String arg_val;
-  String *wkb= args[0]->val_str(&arg_val);
+  String *wkb;
   Geometry_buffer buffer;
   uint32 srid= 0;
 
+  if (args[0]->field_type() == MYSQL_TYPE_GEOMETRY)
+  {
+    return args[0]->val_str(str);
+  }
+
+  wkb= args[0]->val_str(&arg_val);
+
   if ((arg_count == 2) && !args[1]->null_value)
     srid= (uint32)args[1]->val_int();
 
@@ -91,8 +98,8 @@ String *Item_func_geometry_from_wkb::val
   str->length(0);
   str->q_append(srid);
   if ((null_value= 
-       (args[0]->null_value ||
-        !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length(), str))))
+        (args[0]->null_value ||
+         !Geometry::create_from_wkb(&buffer, wkb->ptr(), wkb->length(), str))))
     return 0;
   return str;
 }
@@ -345,14 +352,16 @@ String *Item_func_point::val_str(String 
   DBUG_ASSERT(fixed == 1);
   double x= args[0]->val_real();
   double y= args[1]->val_real();
+  uint32 srid= 0;
 
   if ((null_value= (args[0]->null_value ||
 		    args[1]->null_value ||
-		    str->realloc(1 + 4 + SIZEOF_STORED_DOUBLE*2))))
+                    str->realloc(4/*SRID*/ + 1 + 4 + SIZEOF_STORED_DOUBLE*2))))
     return 0;
 
   str->set_charset(&my_charset_bin);
   str->length(0);
+  str->q_append(srid);
   str->q_append((char)Geometry::wkb_ndr);
   str->q_append((uint32)Geometry::wkb_point);
   str->q_append(x);
@@ -376,12 +385,14 @@ String *Item_func_spatial_collection::va
   DBUG_ASSERT(fixed == 1);
   String arg_value;
   uint i;
+  uint32 srid= 0;
 
   str->set_charset(&my_charset_bin);
   str->length(0);
-  if (str->reserve(1 + 4 + 4, 512))
+  if (str->reserve(4/*SRID*/ + 1 + 4 + 4, 512))
     goto err;
 
+  str->q_append(srid);
   str->q_append((char) Geometry::wkb_ndr);
   str->q_append((uint32) coll_type);
   str->q_append((uint32) arg_count);
@@ -399,13 +410,13 @@ String *Item_func_spatial_collection::va
 	In the case of GeometryCollection we don't need any checkings
 	for item types, so just copy them into target collection
       */
-      if (str->append(res->ptr(), len, (uint32) 512))
+      if (str->append(res->ptr() + 4/*SRID*/, len - 4/*SRID*/, (uint32) 512))
         goto err;
     }
     else
     {
       enum Geometry::wkbType wkb_type;
-      const char *data= res->ptr() + 1;
+      const char *data= res->ptr() + 4/*SRID*/ + 1;
 
       /*
 	In the case of named collection we must check that items
@@ -414,7 +425,7 @@ String *Item_func_spatial_collection::va
 
       wkb_type= (Geometry::wkbType) uint4korr(data);
       data+= 4;
-      len-= 5;
+      len-= 5 + 4/*SRID*/;
       if (wkb_type != item_type)
         goto err;
 

=== modified file 'sql/rpl_filter.cc'
--- a/sql/rpl_filter.cc	2007-08-13 13:11:25 +0000
+++ b/sql/rpl_filter.cc	2009-04-29 02:59:10 +0000
@@ -340,8 +340,7 @@ Rpl_filter::add_wild_table_rule(DYNAMIC_
   e->tbl_name= e->db + (dot - table_spec) + 1;
   e->key_len= len;
   memcpy(e->db, table_spec, len);
-  insert_dynamic(a, (uchar*)&e);
-  return 0;
+  return insert_dynamic(a, (uchar*)&e);
 }
 
 

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-04-21 08:30:40 +0000
+++ b/sql/slave.cc	2009-05-08 05:51:00 +0000
@@ -143,8 +143,8 @@ static int get_master_version_and_clock(
 static Log_event* next_event(Relay_log_info* rli);
 static int queue_event(Master_info* mi,const char* buf,ulong event_len);
 static int terminate_slave_thread(THD *thd,
-                                  pthread_mutex_t* term_lock,
-                                  pthread_cond_t* term_cond,
+                                  pthread_mutex_t *term_lock,
+                                  pthread_cond_t *term_cond,
                                   volatile uint *slave_running,
                                   bool skip_lock);
 static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info);
@@ -399,24 +399,24 @@ int terminate_slave_threads(Master_info*
   int error,force_all = (thread_mask & SLAVE_FORCE_ALL);
   pthread_mutex_t *sql_lock = &mi->rli.run_lock, *io_lock = &mi->run_lock;
 
-  if ((thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL)))
+  if (thread_mask & (SLAVE_IO|SLAVE_FORCE_ALL))
   {
     DBUG_PRINT("info",("Terminating IO thread"));
     mi->abort_slave=1;
-    if ((error=terminate_slave_thread(mi->io_thd,io_lock,
-                                      &mi->stop_cond,
-                                      &mi->slave_running,
+    if ((error=terminate_slave_thread(mi->io_thd, io_lock,
+				      &mi->stop_cond,
+				      &mi->slave_running,
                                       skip_lock)) &&
         !force_all)
       DBUG_RETURN(error);
   }
-  if ((thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL)))
+  if (thread_mask & (SLAVE_SQL|SLAVE_FORCE_ALL))
   {
     DBUG_PRINT("info",("Terminating SQL thread"));
     mi->rli.abort_slave=1;
-    if ((error=terminate_slave_thread(mi->rli.sql_thd,sql_lock,
-                                      &mi->rli.stop_cond,
-                                      &mi->rli.slave_running,
+    if ((error=terminate_slave_thread(mi->rli.sql_thd, sql_lock,
+				      &mi->rli.stop_cond,
+				      &mi->rli.slave_running,
                                       skip_lock)) &&
         !force_all)
       DBUG_RETURN(error);
@@ -424,7 +424,6 @@ int terminate_slave_threads(Master_info*
   DBUG_RETURN(0);
 }
 
-
 /**
    Wait for a slave thread to terminate.
 
@@ -452,29 +451,44 @@ int terminate_slave_threads(Master_info*
           the condition. In this case, it is assumed that the calling
           function acquires the lock before calling this function.
 
-   @retval 0 All OK
+   @retval 0 All OK ER_SLAVE_NOT_RUNNING otherwise.
+
+   @note  If the executing thread has to acquire term_lock (skip_lock
+          is false), the negative running status does not represent
+          any issue therefore no error is reported.
+
  */
 static int
 terminate_slave_thread(THD *thd,
-                       pthread_mutex_t* term_lock,
-                       pthread_cond_t* term_cond,
+                       pthread_mutex_t *term_lock,
+                       pthread_cond_t *term_cond,
                        volatile uint *slave_running,
                        bool skip_lock)
 {
-  int error;
-
   DBUG_ENTER("terminate_slave_thread");
-
   if (!skip_lock)
+  {
     pthread_mutex_lock(term_lock);
-
-  safe_mutex_assert_owner(term_lock);
-
+  }
+  else
+  {
+    safe_mutex_assert_owner(term_lock);
+  }
   if (!*slave_running)
   {
     if (!skip_lock)
+    {
+      /*
+        if run_lock (term_lock) is acquired locally then either
+        slave_running status is fine
+      */
       pthread_mutex_unlock(term_lock);
-    DBUG_RETURN(ER_SLAVE_NOT_RUNNING);
+      DBUG_RETURN(0);
+    }
+    else
+    {
+      DBUG_RETURN(ER_SLAVE_NOT_RUNNING);
+    }
   }
   DBUG_ASSERT(thd != 0);
   THD_CHECK_SENTRY(thd);
@@ -486,6 +500,7 @@ terminate_slave_thread(THD *thd,
 
   while (*slave_running)                        // Should always be true
   {
+    int error;
     DBUG_PRINT("loop", ("killing slave thread"));
 
     pthread_mutex_lock(&thd->LOCK_delete);
@@ -627,7 +642,7 @@ int start_slave_threads(bool need_slave_
                              &mi->rli.slave_running, &mi->rli.slave_run_id,
                              mi, 0);
     if (error)
-      terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0);
+      terminate_slave_threads(mi, thread_mask & SLAVE_IO, !need_slave_mutex);
   }
   DBUG_RETURN(error);
 }
@@ -2640,6 +2655,7 @@ err:
     delete the mi structure leading to a crash! (see BUG#25306 for details)
    */ 
   pthread_cond_broadcast(&mi->stop_cond);       // tell the world we are done
+  DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
   pthread_mutex_unlock(&mi->run_lock);
   my_thread_end();
   pthread_exit(0);
@@ -2989,6 +3005,7 @@ the slave SQL thread with \"SLAVE START\
   delete the mi structure leading to a crash! (see BUG#25306 for details)
  */ 
   pthread_cond_broadcast(&rli->stop_cond);
+  DBUG_EXECUTE_IF("simulate_slave_delay_at_terminate_bug38694", sleep(5););
   pthread_mutex_unlock(&rli->run_lock);  // tell the world we are done
   
   my_thread_end();

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2009-04-08 23:58:57 +0000
+++ b/sql/sp_head.cc	2009-04-30 09:37:29 +0000
@@ -207,6 +207,7 @@ sp_get_flags_for_command(LEX *lex)
   case SQLCOM_SHOW_STATUS_PROC:
   case SQLCOM_SHOW_STORAGE_ENGINES:
   case SQLCOM_SHOW_TABLES:
+  case SQLCOM_SHOW_TABLE_STATUS:
   case SQLCOM_SHOW_VARIABLES:
   case SQLCOM_SHOW_WARNS:
   case SQLCOM_REPAIR:
@@ -2132,17 +2133,16 @@ sp_head::restore_lex(THD *thd)
 /**
   Put the instruction on the backpatch list, associated with the label.
 */
-void
+int
 sp_head::push_backpatch(sp_instr *i, sp_label_t *lab)
 {
   bp_t *bp= (bp_t *)sql_alloc(sizeof(bp_t));
 
-  if (bp)
-  {
-    bp->lab= lab;
-    bp->instr= i;
-    (void)m_backpatch.push_front(bp);
-  }
+  if (!bp)
+    return 1;
+  bp->lab= lab;
+  bp->instr= i;
+  return m_backpatch.push_front(bp);
 }
 
 /**
@@ -2217,7 +2217,7 @@ sp_head::fill_field_definition(THD *thd,
 }
 
 
-void
+int
 sp_head::new_cont_backpatch(sp_instr_opt_meta *i)
 {
   m_cont_level+= 1;
@@ -2225,15 +2225,17 @@ sp_head::new_cont_backpatch(sp_instr_opt
   {
     /* Use the cont. destination slot to store the level */
     i->m_cont_dest= m_cont_level;
-    (void)m_cont_backpatch.push_front(i);
+    if (m_cont_backpatch.push_front(i))
+      return 1;
   }
+  return 0;
 }
 
-void
+int
 sp_head::add_cont_backpatch(sp_instr_opt_meta *i)
 {
   i->m_cont_dest= m_cont_level;
-  (void)m_cont_backpatch.push_front(i);
+  return m_cont_backpatch.push_front(i);
 }
 
 void
@@ -2469,7 +2471,7 @@ sp_head::show_create_routine(THD *thd, i
   @param instr   Instruction
 */
 
-void sp_head::add_instr(sp_instr *instr)
+int sp_head::add_instr(sp_instr *instr)
 {
   instr->free_list= m_thd->free_list;
   m_thd->free_list= 0;
@@ -2480,7 +2482,7 @@ void sp_head::add_instr(sp_instr *instr)
     entire stored procedure, as their life span is equal.
   */
   instr->mem_root= &main_mem_root;
-  insert_dynamic(&m_instr, (uchar*)&instr);
+  return insert_dynamic(&m_instr, (uchar*)&instr);
 }
 
 

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2009-02-13 16:41:47 +0000
+++ b/sql/sp_head.h	2009-04-29 02:59:10 +0000
@@ -308,7 +308,7 @@ public:
   bool
   show_create_routine(THD *thd, int type);
 
-  void
+  int
   add_instr(sp_instr *instr);
 
   inline uint
@@ -344,7 +344,7 @@ public:
   restore_lex(THD *thd);
 
   /// Put the instruction on the backpatch list, associated with the label.
-  void
+  int
   push_backpatch(sp_instr *, struct sp_label *);
 
   /// Update all instruction with this label in the backpatch list to
@@ -353,11 +353,11 @@ public:
   backpatch(struct sp_label *);
 
   /// Start a new cont. backpatch level. If 'i' is NULL, the level is just incr.
-  void
+  int
   new_cont_backpatch(sp_instr_opt_meta *i);
 
   /// Add an instruction to the current level
-  void
+  int
   add_cont_backpatch(sp_instr_opt_meta *i);
 
   /// Backpatch (and pop) the current level to the current position.

=== modified file 'sql/sp_pcontext.cc'
--- a/sql/sp_pcontext.cc	2008-03-21 18:08:04 +0000
+++ b/sql/sp_pcontext.cc	2009-04-29 02:59:10 +0000
@@ -265,8 +265,8 @@ sp_pcontext::push_variable(LEX_STRING *n
   p->mode= mode;
   p->offset= current_var_count();
   p->dflt= NULL;
-  insert_dynamic(&m_vars, (uchar*)&p);
-
+  if (insert_dynamic(&m_vars, (uchar*)&p))
+    return NULL;
   return p;
 }
 
@@ -310,18 +310,17 @@ sp_pcontext::find_label(char *name)
   return NULL;
 }
 
-void
+int
 sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val)
 {
   sp_cond_t *p= (sp_cond_t *)sql_alloc(sizeof(sp_cond_t));
 
-  if (p)
-  {
-    p->name.str= name->str;
-    p->name.length= name->length;
-    p->val= val;
-    insert_dynamic(&m_conds, (uchar*)&p);
-  }
+  if (p == NULL)
+    return 1;
+  p->name.str= name->str;
+  p->name.length= name->length;
+  p->val= val;
+  return insert_dynamic(&m_conds, (uchar *)&p);
 }
 
 /*
@@ -384,7 +383,7 @@ sp_pcontext::find_handler(sp_cond_type_t
   return FALSE;
 }
 
-void
+int
 sp_pcontext::push_cursor(LEX_STRING *name)
 {
   LEX_STRING n;
@@ -393,7 +392,7 @@ sp_pcontext::push_cursor(LEX_STRING *nam
     m_max_cursor_index+= 1;
   n.str= name->str;
   n.length= name->length;
-  insert_dynamic(&m_cursors, (uchar*)&n);
+  return insert_dynamic(&m_cursors, (uchar *)&n);
 }
 
 /*

=== modified file 'sql/sp_pcontext.h'
--- a/sql/sp_pcontext.h	2007-06-10 10:43:57 +0000
+++ b/sql/sp_pcontext.h	2009-04-29 02:59:10 +0000
@@ -323,7 +323,7 @@ public:
   // Conditions
   //
 
-  void
+  int
   push_cond(LEX_STRING *name, sp_cond_type_t *val);
 
   inline void
@@ -365,7 +365,7 @@ public:
   // Cursors
   //
 
-  void
+  int
   push_cursor(LEX_STRING *name);
 
   my_bool

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2009-04-03 18:21:57 +0000
+++ b/sql/sql_class.cc	2009-05-10 16:20:35 +0000
@@ -2599,7 +2599,7 @@ bool select_dumpvar::send_data(List<Item
     {
       Item_func_set_user_var *suv= new Item_func_set_user_var(mv->s, item);
       suv->fix_fields(thd, 0);
-      suv->check(0);
+      suv->save_item_result(item);
       suv->update();
     }
   }

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2009-04-08 23:42:51 +0000
+++ b/sql/sql_delete.cc	2009-05-06 09:30:14 +0000
@@ -582,6 +582,11 @@ int mysql_multi_delete_prepare(THD *thd)
       }
     }
   }
+  /*
+    Reset the exclude flag to false so it doesn't interfare
+    with further calls to unique_table
+  */
+  lex->select_lex.exclude_from_table_unique_test= FALSE;
   DBUG_RETURN(FALSE);
 }
 
@@ -617,11 +622,24 @@ multi_delete::initialize_tables(JOIN *jo
     DBUG_RETURN(1);
 
   table_map tables_to_delete_from=0;
+  delete_while_scanning= 1;
   for (walk= delete_tables; walk; walk= walk->next_local)
+  {
     tables_to_delete_from|= walk->table->map;
+    if (delete_while_scanning &&
+        unique_table(thd, walk, join->tables_list, false))
+    {
+      /*
+        If the table we are going to delete from appears
+        in join, we need to defer delete. So the delete
+        doesn't interfers with the scaning of results.
+      */
+      delete_while_scanning= 0;
+    }
+  }
+
 
   walk= delete_tables;
-  delete_while_scanning= 1;
   for (JOIN_TAB *tab=join->join_tab, *end=join->join_tab+join->tables;
        tab < end;
        tab++)

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2009-02-13 16:41:47 +0000
+++ b/sql/sql_repl.cc	2009-04-30 12:28:07 +0000
@@ -1026,7 +1026,10 @@ int reset_slave(THD *thd, Master_info* m
   if ((error= purge_relay_logs(&mi->rli, thd,
 			       1 /* just reset */,
 			       &errmsg)))
+  {
+    sql_errno= ER_RELAY_LOG_FAIL;
     goto err;
+  }
 
   /*
     Clear master's log coordinates and reset host/user/etc to the values

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-04-01 11:10:03 +0000
+++ b/sql/sql_select.cc	2009-05-04 12:57:42 +0000
@@ -2248,6 +2248,14 @@ JOIN::destroy()
   cond_equal= 0;
 
   cleanup(1);
+ /* Cleanup items referencing temporary table columns */
+  if (!tmp_all_fields3.is_empty())
+  {
+    List_iterator_fast<Item> it(tmp_all_fields3);
+    Item *item;
+    while ((item= it++))
+      item->cleanup();
+  }
   if (exec_tmp_table1)
     free_tmp_table(thd, exec_tmp_table1);
   if (exec_tmp_table2)
@@ -3476,14 +3484,6 @@ add_key_fields(JOIN *join, KEY_FIELD **k
   }
 }
 
-/**
-  Add all keys with uses 'field' for some keypart.
-
-  If field->and_level != and_level then only mark key_part as const_part.
-
-  @todo
-    ft-keys in non-ft queries.   SerG
-*/
 
 static uint
 max_part_bit(key_part_map bits)
@@ -3493,7 +3493,16 @@ max_part_bit(key_part_map bits)
   return found;
 }
 
-static void
+/*
+  Add all keys with uses 'field' for some keypart
+  If field->and_level != and_level then only mark key_part as const_part
+
+  RETURN 
+   0 - OK
+   1 - Out of memory.
+*/
+
+static bool
 add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field)
 {
   Field *field=key_field->field;
@@ -3523,24 +3532,26 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array
 	  keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL;
           keyuse.null_rejecting= key_field->null_rejecting;
           keyuse.cond_guard= key_field->cond_guard;
-	  VOID(insert_dynamic(keyuse_array,(uchar*) &keyuse));
+	  if (insert_dynamic(keyuse_array,(uchar*) &keyuse))
+            return TRUE;
 	}
       }
     }
   }
+  return FALSE;
 }
 
 
 #define FT_KEYPART   (MAX_REF_PARTS+10)
 
-static void
+static bool
 add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
             JOIN_TAB *stat,COND *cond,table_map usable_tables)
 {
   Item_func_match *cond_func=NULL;
 
   if (!cond)
-    return;
+    return FALSE;
 
   if (cond->type() == Item::FUNC_ITEM)
   {
@@ -3574,13 +3585,16 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
     {
       Item *item;
       while ((item=li++))
-        add_ft_keys(keyuse_array,stat,item,usable_tables);
+      {
+        if (add_ft_keys(keyuse_array,stat,item,usable_tables))
+          return TRUE;
+      }
     }
   }
 
   if (!cond_func || cond_func->key == NO_SUCH_KEY ||
       !(usable_tables & cond_func->table->map))
-    return;
+    return FALSE;
 
   KEYUSE keyuse;
   keyuse.table= cond_func->table;
@@ -3590,7 +3604,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
   keyuse.used_tables=cond_func->key_item()->used_tables();
   keyuse.optimize= 0;
   keyuse.keypart_map= 0;
-  VOID(insert_dynamic(keyuse_array,(uchar*) &keyuse));
+  return insert_dynamic(keyuse_array,(uchar*) &keyuse);
 }
 
 
@@ -3744,7 +3758,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
                    sargables);
     for (; field != end ; field++)
     {
-      add_key_part(keyuse,field);
+      if (add_key_part(keyuse,field))
+        return TRUE;
       /* Mark that we can optimize LEFT JOIN */
       if (field->val->type() == Item::NULL_ITEM &&
 	  !field->field->real_maybe_null())
@@ -3782,11 +3797,15 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
 
   /* fill keyuse with found key parts */
   for ( ; field != end ; field++)
-    add_key_part(keyuse,field);
+  {
+    if (add_key_part(keyuse,field))
+      return TRUE;
+  }
 
   if (select_lex->ftfunc_list->elements)
   {
-    add_ft_keys(keyuse,join_tab,cond,normal_tables);
+    if (add_ft_keys(keyuse,join_tab,cond,normal_tables))
+      return TRUE;
   }
 
   /*
@@ -3807,7 +3826,8 @@ update_ref_and_keys(THD *thd, DYNAMIC_AR
 	  (qsort_cmp) sort_keyuse);
 
     bzero((char*) &key_end,sizeof(key_end));    /* Add for easy testing */
-    VOID(insert_dynamic(keyuse,(uchar*) &key_end));
+    if (insert_dynamic(keyuse,(uchar*) &key_end))
+      return TRUE;
 
     use=save_pos=dynamic_element(keyuse,0,KEYUSE*);
     prev= &key_end;
@@ -7072,15 +7092,17 @@ return_zero_rows(JOIN *join, select_resu
   if (!(result->send_fields(fields,
                               Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)))
   {
+    bool send_error= FALSE;
     if (send_row)
     {
       List_iterator_fast<Item> it(fields);
       Item *item;
       while ((item= it++))
 	item->no_rows_in_result();
-      result->send_data(fields);
+      send_error= result->send_data(fields);
     }
-    result->send_eof();				// Should be safe
+    if (!send_error)
+      result->send_eof();				// Should be safe
   }
   /* Update results for FOUND_ROWS */
   join->thd->limit_found_rows= join->thd->examined_row_count= 0;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-04-23 17:55:32 +0000
+++ b/sql/sql_table.cc	2009-05-04 20:33:23 +0000

@@ -3126,7 +3126,7 @@ static bool prepare_blob_field(THD *thd,
     }
     sql_field->sql_type= MYSQL_TYPE_BLOB;
     sql_field->flags|= BLOB_FLAG;
-    sprintf(warn_buff, ER(ER_AUTO_CONVERT), sql_field->field_name,
+    my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_AUTO_CONVERT), sql_field->field_name,
             (sql_field->charset == &my_charset_bin) ? "VARBINARY" : "VARCHAR",
             (sql_field->charset == &my_charset_bin) ? "BLOB" : "TEXT");
     push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_AUTO_CONVERT,

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2009-04-08 23:42:51 +0000
+++ b/sql/sql_update.cc	2009-05-04 20:33:23 +0000
@@ -818,7 +818,7 @@ int mysql_update(THD *thd,
   if (error < 0)
   {
     char buff[STRING_BUFFER_USUAL_SIZE];
-    sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated,
+    my_snprintf(buff, sizeof(buff), ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated,
 	    (ulong) thd->cuted_fields);
     thd->row_count_func=
       (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
@@ -2066,8 +2066,8 @@ bool multi_update::send_eof()
 
   id= thd->arg_of_last_insert_id_function ?
     thd->first_successful_insert_id_in_prev_stmt : 0;
-  sprintf(buff, ER(ER_UPDATE_INFO), (ulong) found, (ulong) updated,
-	  (ulong) thd->cuted_fields);
+  my_snprintf(buff, sizeof(buff), ER(ER_UPDATE_INFO),
+              (ulong) found, (ulong) updated, (ulong) thd->cuted_fields);
   thd->row_count_func=
     (thd->client_capabilities & CLIENT_FOUND_ROWS) ? found : updated;
   ::my_ok(thd, (ulong) thd->row_count_func, id, buff);

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-04-03 19:46:00 +0000
+++ b/sql/sql_yacc.yy	2009-04-29 02:59:10 +0000
@@ -280,9 +280,7 @@ int case_stmt_action_expr(LEX *lex, Item
                                 parsing_ctx, case_expr_id, expr, lex);
 
   sp->add_cont_backpatch(i);
-  sp->add_instr(i);
-
-  return 0;
+  return sp->add_instr(i);
 }
 
 /**
@@ -293,7 +291,7 @@ int case_stmt_action_expr(LEX *lex, Item
   @param simple true for simple cases, false for searched cases
 */
 
-void case_stmt_action_when(LEX *lex, Item *when, bool simple)
+int case_stmt_action_when(LEX *lex, Item *when, bool simple)
 {
   sp_head *sp= lex->sphead;
   sp_pcontext *ctx= lex->spcont;
@@ -325,9 +323,10 @@ void case_stmt_action_when(LEX *lex, Ite
     (jump_if_not from instruction 2 to 5, 5 to 8 ... in the example)
   */
 
-  sp->push_backpatch(i, ctx->push_label((char *)"", 0));
-  sp->add_cont_backpatch(i);
-  sp->add_instr(i);
+  return !test(i) ||
+         sp->push_backpatch(i, ctx->push_label((char *)"", 0)) ||
+         sp->add_cont_backpatch(i) ||
+         sp->add_instr(i);
 }
 
 /**
@@ -336,13 +335,14 @@ void case_stmt_action_when(LEX *lex, Ite
   @param lex the parser lex context
 */
 
-void case_stmt_action_then(LEX *lex)
+int case_stmt_action_then(LEX *lex)
 {
   sp_head *sp= lex->sphead;
   sp_pcontext *ctx= lex->spcont;
   uint ip= sp->instructions();
   sp_instr_jump *i = new sp_instr_jump(ip, ctx);
-  sp->add_instr(i);
+  if (!test(i) || sp->add_instr(i))
+    return 1;
 
   /*
     BACKPATCH: Resolving forward jump from
@@ -358,7 +358,7 @@ void case_stmt_action_then(LEX *lex)
     (jump from instruction 4 to 12, 7 to 12 ... in the example)
   */
 
-  sp->push_backpatch(i, ctx->last_label());
+  return sp->push_backpatch(i, ctx->last_label());
 }
 
 /**
@@ -2322,10 +2322,9 @@ sp_decl:
                                                  var_type,
                                                  lex,
                                                  (i == num_vars - 1));
-              if (is == NULL)
+              if (is == NULL ||
+                  lex->sphead->add_instr(is))
                 MYSQL_YYABORT;
-
-              lex->sphead->add_instr(is);
             }
 
             pctx->declare_var_boundary(0);
@@ -2339,12 +2338,13 @@ sp_decl:
             LEX *lex= Lex;
             sp_pcontext *spc= lex->spcont;
 
-            if (spc->find_cond(&$2, TRUE))
-            {
-              my_error(ER_SP_DUP_COND, MYF(0), $2.str);
+	    if (spc->find_cond(&$2, TRUE))
+	    {
+	      my_error(ER_SP_DUP_COND, MYF(0), $2.str);
+	      MYSQL_YYABORT;
+	    }
+	    if(YYTHD->lex->spcont->push_cond(&$2, $5))
               MYSQL_YYABORT;
-            }
-            YYTHD->lex->spcont->push_cond(&$2, $5);
             $$.vars= $$.hndlrs= $$.curs= 0;
             $$.conds= 1;
           }
@@ -2358,11 +2358,11 @@ sp_decl:
             sp_pcontext *ctx= lex->spcont;
             sp_instr_hpush_jump *i=
               new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
-                                      ctx->current_var_count());
-            if (i == NULL)
+	                              ctx->current_var_count());
+            if (i == NULL ||
+	        sp->add_instr(i) ||
+                sp->push_backpatch(i, ctx->push_label((char *)"", 0)))
               MYSQL_YYABORT;
-            sp->add_instr(i);
-            sp->push_backpatch(i, ctx->push_label((char *)"", 0));
           }
           sp_hcond_list sp_proc_stmt
           {
@@ -2376,17 +2376,17 @@ sp_decl:
             {
               i= new sp_instr_hreturn(sp->instructions(), ctx,
                                       ctx->current_var_count());
-              if (i == NULL)
+              if (i == NULL ||
+	          sp->add_instr(i))
                 MYSQL_YYABORT;
-              sp->add_instr(i);
             }
             else
             {  /* EXIT or UNDO handler, just jump to the end of the block */
               i= new sp_instr_hreturn(sp->instructions(), ctx, 0);
-              if (i == NULL)
+              if (i == NULL ||
+	          sp->add_instr(i) ||
+	          sp->push_backpatch(i, lex->spcont->last_label())) /* Block end */
                 MYSQL_YYABORT;
-              sp->add_instr(i);
-              sp->push_backpatch(i, lex->spcont->last_label()); /* Block end */
             }
             lex->sphead->backpatch(hlab);
 
@@ -2412,10 +2412,10 @@ sp_decl:
             }
             i= new sp_instr_cpush(sp->instructions(), ctx, $5,
                                   ctx->current_cursor_count());
-            if (i == NULL)
+	    if (i == NULL ||
+                sp->add_instr(i) ||
+	        ctx->push_cursor(&$2))
               MYSQL_YYABORT;
-            sp->add_instr(i);
-            ctx->push_cursor(&$2);
             $$.vars= $$.conds= $$.hndlrs= 0;
             $$.curs= 1;
           }
@@ -2652,10 +2652,11 @@ sp_proc_stmt_statement:
                 i->m_query.length= lip->get_ptr() - sp->m_tmp_query;
               else
                 i->m_query.length= lip->get_tok_end() - sp->m_tmp_query;
-              i->m_query.str= strmake_root(thd->mem_root,
-                                           sp->m_tmp_query,
-                                           i->m_query.length);
-              sp->add_instr(i);
+              if (!(i->m_query.str= strmake_root(thd->mem_root,
+                                                 sp->m_tmp_query,
+                                                 i->m_query.length)) ||
+                    sp->add_instr(i))
+                MYSQL_YYABORT;
             }
             sp->restore_lex(thd);
           }
@@ -2680,9 +2681,9 @@ sp_proc_stmt_return:
 
               i= new sp_instr_freturn(sp->instructions(), lex->spcont, $3,
                                       sp->m_return_field_def.sql_type, lex);
-              if (i == NULL)
+              if (i == NULL ||
+	          sp->add_instr(i))
                 MYSQL_YYABORT;
-              sp->add_instr(i);
               sp->m_flags|= sp_head::HAS_RETURN;
             }
             sp->restore_lex(YYTHD);
@@ -2779,22 +2780,22 @@ sp_proc_stmt_iterate:
               if (n)
               {
                 sp_instr_hpop *hpop= new sp_instr_hpop(ip++, ctx, n);
-                if (hpop == NULL)
+                if (hpop == NULL ||
+                    sp->add_instr(hpop))
                   MYSQL_YYABORT;
-                sp->add_instr(hpop);
               }
               n= ctx->diff_cursors(lab->ctx, FALSE);  /* Inclusive the dest. */
               if (n)
               {
                 sp_instr_cpop *cpop= new sp_instr_cpop(ip++, ctx, n);
-                if (cpop == NULL)
+                if (cpop == NULL ||
+                    sp->add_instr(cpop))
                   MYSQL_YYABORT;
-                sp->add_instr(cpop);
               }
               i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
-              if (i == NULL)
+              if (i == NULL ||
+                  sp->add_instr(i))
                 MYSQL_YYABORT;
-              sp->add_instr(i);
             }
           }
         ;
@@ -2813,9 +2814,9 @@ sp_proc_stmt_open:
               MYSQL_YYABORT;
             }
             i= new sp_instr_copen(sp->instructions(), lex->spcont, offset);
-            if (i == NULL)
+            if (i == NULL ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-            sp->add_instr(i);
           }
         ;
 
@@ -2833,9 +2834,9 @@ sp_proc_stmt_fetch:
               MYSQL_YYABORT;
             }
             i= new sp_instr_cfetch(sp->instructions(), lex->spcont, offset);
-            if (i == NULL)
+            if (i == NULL ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-            sp->add_instr(i);
           }
           sp_fetch_list
           {}
@@ -2855,9 +2856,9 @@ sp_proc_stmt_close:
               MYSQL_YYABORT;
             }
             i= new sp_instr_cclose(sp->instructions(), lex->spcont,  offset);
-            if (i == NULL)
+            if (i == NULL ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-            sp->add_instr(i);
           }
         ;
 
@@ -2920,12 +2921,11 @@ sp_if:
             uint ip= sp->instructions();
             sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, ctx,
                                                                $2, lex);
-            if (i == NULL)
+            if (i == NULL ||
+	        sp->push_backpatch(i, ctx->push_label((char *)"", 0)) ||
+                sp->add_cont_backpatch(i) ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-
-            sp->push_backpatch(i, ctx->push_label((char *)"", 0));
-            sp->add_cont_backpatch(i);
-            sp->add_instr(i);
             sp->restore_lex(YYTHD);
           }
           sp_proc_stmts1
@@ -2934,10 +2934,9 @@ sp_if:
             sp_pcontext *ctx= Lex->spcont;
             uint ip= sp->instructions();
             sp_instr_jump *i = new sp_instr_jump(ip, ctx);
-            if (i == NULL)
+            if (i == NULL ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-
-            sp->add_instr(i);
             sp->backpatch(ctx->pop_label());
             sp->push_backpatch(i, ctx->push_label((char *)"", 0));
           }
@@ -3021,14 +3020,16 @@ simple_when_clause:
             /* Simple case: <caseval> = <whenval> */
 
             LEX *lex= Lex;
-            case_stmt_action_when(lex, $3, true);
+            if (case_stmt_action_when(lex, $3, true))
+              MYSQL_YYABORT;
             lex->sphead->restore_lex(YYTHD); /* For expr $3 */
           }
           THEN_SYM
           sp_proc_stmts1
           {
             LEX *lex= Lex;
-            case_stmt_action_then(lex);
+            if (case_stmt_action_then(lex))
+              MYSQL_YYABORT;
           }
         ;
 
@@ -3040,14 +3041,16 @@ searched_when_clause:
           expr
           {
             LEX *lex= Lex;
-            case_stmt_action_when(lex, $3, false);
+            if (case_stmt_action_when(lex, $3, false))
+              MYSQL_YYABORT;
             lex->sphead->restore_lex(YYTHD); /* For expr $3 */
           }
           THEN_SYM
           sp_proc_stmts1
           {
             LEX *lex= Lex;
-            case_stmt_action_then(lex);
+            if (case_stmt_action_then(lex))
+              MYSQL_YYABORT;
           }
         ;
 
@@ -3059,9 +3062,9 @@ else_clause_opt:
             uint ip= sp->instructions();
             sp_instr_error *i= new sp_instr_error(ip, lex->spcont,
                                                   ER_SP_CASE_NOT_FOUND);
-            if (i == NULL)
+            if (i == NULL ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-            sp->add_instr(i);
           }
         | ELSE sp_proc_stmts1
         ;
@@ -3175,16 +3178,16 @@ sp_block_content:
             if ($3.hndlrs)
             {
               i= new sp_instr_hpop(sp->instructions(), ctx, $3.hndlrs);
-              if (i == NULL)
+              if (i == NULL ||
+                  sp->add_instr(i))
                 MYSQL_YYABORT;
-              sp->add_instr(i);
             }
             if ($3.curs)
             {
               i= new sp_instr_cpop(sp->instructions(), ctx, $3.curs);
-              if (i == NULL)
+              if (i == NULL ||
+                  sp->add_instr(i))
                 MYSQL_YYABORT;
-              sp->add_instr(i);
             }
             lex->spcont= ctx->pop_context();
           }
@@ -3198,10 +3201,10 @@ sp_unlabeled_control:
             uint ip= lex->sphead->instructions();
             sp_label_t *lab= lex->spcont->last_label();  /* Jumping back */
             sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
-            if (i == NULL)
+            if (i == NULL ||
+                lex->sphead->add_instr(i))
               MYSQL_YYABORT;
-            lex->sphead->add_instr(i);
-          }
+	  }
         | WHILE_SYM 
           { Lex->sphead->reset_lex(YYTHD); }
           expr DO_SYM
@@ -3211,12 +3214,12 @@ sp_unlabeled_control:
             uint ip= sp->instructions();
             sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
                                                                $3, lex);
-            if (i == NULL)
+            if (i == NULL ||
+	    /* Jumping forward */
+                sp->push_backpatch(i, lex->spcont->last_label()) ||
+                sp->new_cont_backpatch(i) ||
+                sp->add_instr(i))
               MYSQL_YYABORT;
-            /* Jumping forward */
-            sp->push_backpatch(i, lex->spcont->last_label());
-            sp->new_cont_backpatch(i);
-            sp->add_instr(i);
             sp->restore_lex(YYTHD);
           }
           sp_proc_stmts1 END WHILE_SYM
@@ -3225,9 +3228,9 @@ sp_unlabeled_control:
             uint ip= lex->sphead->instructions();
             sp_label_t *lab= lex->spcont->last_label();  /* Jumping back */
             sp_instr_jump *i = new sp_instr_jump(ip, lex->spcont, lab->ip);
-            if (i == NULL)
+            if (i == NULL ||
+                lex->sphead->add_instr(i))
               MYSQL_YYABORT;
-            lex->sphead->add_instr(i);
             lex->sphead->do_cont_backpatch();
           }
         | REPEAT_SYM sp_proc_stmts1 UNTIL_SYM 
@@ -3240,9 +3243,9 @@ sp_unlabeled_control:
             sp_instr_jump_if_not *i = new sp_instr_jump_if_not(ip, lex->spcont,
                                                                $5, lab->ip,
                                                                lex);
-            if (i == NULL)
+            if (i == NULL ||
+                lex->sphead->add_instr(i))
               MYSQL_YYABORT;
-            lex->sphead->add_instr(i);
             lex->sphead->restore_lex(YYTHD);
             /* We can shortcut the cont_backpatch here */
             i->m_cont_dest= ip+1;
@@ -11751,7 +11754,8 @@ option_type_value:
                         qbuff.length);
                 qbuff.length+= 4;
                 i->m_query= qbuff;
-                sp->add_instr(i);
+                if (sp->add_instr(i))
+                  MYSQL_YYABORT;
               }
               lex->sphead->restore_lex(thd);
             }
@@ -11843,7 +11847,8 @@ sys_option_value:
                                                  (uchar **) &trg_fld->
                                                    next_trg_field);
 
-              lex->sphead->add_instr(sp_fld);
+              if (lex->sphead->add_instr(sp_fld))
+                MYSQL_YYABORT;
             }
             else if ($2.var)
             { /* System variable */
@@ -11882,9 +11887,9 @@ sys_option_value:
               }
               sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
                                        spv->offset, it, spv->type, lex, TRUE);
-              if (sp_set == NULL)
+              if (sp_set == NULL ||
+                  lex->sphead->add_instr(sp_set))
                 MYSQL_YYABORT;
-              lex->sphead->add_instr(sp_set);
             }
           }
         | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types

=== modified file 'sql/unireg.cc'
--- a/sql/unireg.cc	2009-03-17 20:29:24 +0000
+++ b/sql/unireg.cc	2009-05-04 20:33:23 +0000
@@ -37,8 +37,7 @@ static bool pack_header(uchar *forminfo,
 			List<Create_field> &create_fields,
 			uint info_length, uint screens, uint table_options,
 			ulong data_offset, handler *file);
-static uint get_interval_id(uint *int_count,List<Create_field> &create_fields,
-			    Create_field *last_field);
+static uint get_interval_id(uint *,List<Create_field> &, Create_field *);
 static bool pack_fields(File file, List<Create_field> &create_fields,
                         ulong data_offset);
 static bool make_empty_rec(THD *thd, int file, enum legacy_db_type table_type,

=== modified file 'storage/ibmdb2i/Makefile.am'
--- a/storage/ibmdb2i/Makefile.am	2009-02-15 02:18:30 +0000
+++ b/storage/ibmdb2i/Makefile.am	2009-04-01 20:18:49 +0000
@@ -27,6 +27,7 @@ DEFS =                  @DEFS@
 noinst_HEADERS =	ha_ibmdb2i.h db2i_collationSupport.h db2i_file.h \
 			db2i_ioBuffers.h db2i_blobCollection.h \
 			db2i_global.h db2i_misc.h db2i_charsetSupport.h db2i_errors.h \
+			db2i_iconv.h db2i_myconv.h db2i_safeString.h db2i_sqlStatementStream.h \
 			db2i_ileBridge.h db2i_validatedPointer.h
 
 EXTRA_LTLIBRARIES =	ha_ibmdb2i.la

=== modified file 'storage/ibmdb2i/db2i_charsetSupport.cc'
--- a/storage/ibmdb2i/db2i_charsetSupport.cc	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_charsetSupport.cc	2009-05-05 09:33:52 +0000
@@ -268,8 +268,15 @@ static int32 getNewTextDesc(const int32 
       RESULT_INT32);
   if (unlikely(arguments->base.result.s_int32.r_int32 < 0))
   {
-     getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32);
-     DBUG_RETURN(DB2I_ERR_ILECALL);
+    if (arguments->base.result.s_int32.r_int32 == Qlg_InDescriptorNotFound)
+    {
+      DBUG_RETURN(DB2I_ERR_UNSUPP_CHARSET);
+    }
+    else
+    {
+      getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32);
+      DBUG_RETURN(DB2I_ERR_ILECALL);
+    }
   }
   
   // Store the conversion information into a cache entry
@@ -428,8 +435,13 @@ int32 convertIANAToDb2Ccsid(const char* 
   int aixEncodingScheme;
   int db2EncodingScheme;
   rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAS400CCSID, parmIANADesc, aixCcsidString);
-  if (rc != 0)
+  if (unlikely(rc))
+  {
+    if (rc == DB2I_ERR_UNSUPP_CHARSET)
+      getErrTxt(DB2I_ERR_UNSUPP_CHARSET, parmIANADesc);
+    
     return rc;
+  }
   aixCcsid = atoi(aixCcsidString);
   rc = getEncodingScheme(aixCcsid, aixEncodingScheme);     
   if (rc != 0) 
@@ -646,32 +658,38 @@ static int32 openNewConversion(enum_conv
      there equivalent iconv descriptions.
   */
   rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAix41, mysqlCSName, mysqlAix41Desc);
-  if (rc)
+  if (unlikely(rc))
+  {
+    if (rc == DB2I_ERR_UNSUPP_CHARSET)
+      getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName);
+    
     DBUG_RETURN(rc);
+  }
   CHARSET_INFO *cs= &my_charset_bin;
   (uint)(cs->cset->long10_to_str)(cs,db2CcsidString,sizeof(db2CcsidString), 10, db2CCSID);  
   rc = convertTextDesc(Qlg_TypeAS400CCSID, Qlg_TypeAix41, db2CcsidString, db2Aix41Desc);
-  if (rc)
-      DBUG_RETURN(rc);
+  if (unlikely(rc))
+  {
+    if (rc == DB2I_ERR_UNSUPP_CHARSET)
+      getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName);
+    
+    DBUG_RETURN(rc);
+  }
   
   /* Call iconv to open the conversion. */
   if (direction == toDB2)
   {
     newConversion = iconv_open(db2Aix41Desc, mysqlAix41Desc);
-    if (newConversion == (iconv_t) -1)
-    {
-       getErrTxt(DB2I_ERR_ICONV_OPEN, mysqlAix41Desc, db2Aix41Desc,  errno);
-       DBUG_RETURN(DB2I_ERR_ICONV_OPEN);
-    }
   }
   else
   {
     newConversion = iconv_open(mysqlAix41Desc, db2Aix41Desc);
-    if (newConversion == (iconv_t) -1)
-    {
-       getErrTxt(DB2I_ERR_ICONV_OPEN, db2Aix41Desc, mysqlAix41Desc, errno);
-       DBUG_RETURN(DB2I_ERR_ICONV_OPEN);
-    }
+  }
+
+  if (unlikely(newConversion == (iconv_t) -1))
+  {
+    getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName);
+    DBUG_RETURN(DB2I_ERR_UNSUPP_CHARSET);
   }
  
   /* Insert the new conversion into the cache. */

=== modified file 'storage/ibmdb2i/db2i_conversion.cc'
--- a/storage/ibmdb2i/db2i_conversion.cc	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_conversion.cc	2009-05-05 09:33:52 +0000
@@ -151,7 +151,7 @@ int ha_ibmdb2i::convertFieldChars(enum_c
   
   if (unlikely(conversion == (iconv_t)(-1)))
   {
-    return (DB2I_ERR_ICONV_OPEN);
+    return (DB2I_ERR_UNSUPP_CHARSET);
   }
 
   size_t initOLen= olen;
@@ -670,6 +670,13 @@ int ha_ibmdb2i::getFieldTypeMapping(Fiel
               if (rtnCode)
                 return rtnCode;
             }
+            
+            // Check whether there is a character conversion available.
+            iconv_t temp;
+            int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp);
+            if (unlikely(rc))
+              return rc;
+            
             sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid);
             mapping.append(stringBuildBuffer);
           }

=== modified file 'storage/ibmdb2i/db2i_errors.cc'
--- a/storage/ibmdb2i/db2i_errors.cc	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_errors.cc	2009-05-05 09:33:52 +0000
@@ -52,7 +52,7 @@ static const char* engineErrors[MAX_MSGS
   {"Error opening codeset conversion from %.64s to %.64s (errno = %d)"},      
   {"Invalid %-.10s name '%-.128s'"},                                          
   {"Unsupported move from '%-.128s' to '%-.128s' on RENAME TABLE statement"}, 
-  {"Unsupported schema '%-.128s' specified on RENAME TABLE statement"},       
+  {"The %-.64s character set is not supported."},       
   {"Auto_increment is not allowed for a partitioned table"},                  
   {"Character set conversion error due to unknown encoding scheme %d"},       
   {""}, 

=== modified file 'storage/ibmdb2i/db2i_errors.h'
--- a/storage/ibmdb2i/db2i_errors.h	2009-03-09 21:20:14 +0000
+++ b/storage/ibmdb2i/db2i_errors.h	2009-05-05 09:33:52 +0000
@@ -54,7 +54,7 @@ enum DB2I_errors
   DB2I_ERR_ICONV_OPEN,
   DB2I_ERR_INVALID_NAME,
   DB2I_ERR_RENAME_MOVE,
-  DB2I_ERR_RENAME_QTEMP,
+  DB2I_ERR_UNSUPP_CHARSET,
   DB2I_ERR_PART_AUTOINC,
   DB2I_ERR_UNKNOWN_ENCODING,
   DB2I_ERR_RESERVED,

=== modified file 'storage/ibmdb2i/ha_ibmdb2i.cc'
--- a/storage/ibmdb2i/ha_ibmdb2i.cc	2009-04-13 11:35:40 +0000
+++ b/storage/ibmdb2i/ha_ibmdb2i.cc	2009-04-29 11:21:14 +0000
@@ -898,6 +898,8 @@ int ha_ibmdb2i::index_init(uint idx, boo
       releaseIndexFile(idx);
   }
   
+  rrnAssocHandle= 0;
+
   DBUG_RETURN(rc); 
 }
 
@@ -1154,6 +1156,8 @@ int ha_ibmdb2i::rnd_init(bool scan)
       releaseDataFile();
   }
   
+  rrnAssocHandle= 0;
+
   DBUG_RETURN(0); // MySQL sometimes does not check the return code, causing 
                   // an assert in ha_rnd_end later on if we return a non-zero
                   // value here. 
@@ -1251,7 +1255,8 @@ int ha_ibmdb2i::rnd_pos(uchar * buf, uch
   
   int rc = 0;
 
-  if (activeHandle != rrnAssocHandle) 
+  if (rrnAssocHandle &&
+      (activeHandle != rrnAssocHandle))
   {
     if (activeHandle) releaseActiveHandle();
     rc = useFileByHandle(QMY_UPDATABLE, rrnAssocHandle);    

=== modified file 'storage/myisam/ft_boolean_search.c'
--- a/storage/myisam/ft_boolean_search.c	2008-12-09 09:27:46 +0000
+++ b/storage/myisam/ft_boolean_search.c	2009-04-23 11:24:08 +0000
@@ -335,7 +335,23 @@ static int _ftb_no_dupes_cmp(void* not_u
   return CMP_NUM((*((my_off_t*)a)), (*((my_off_t*)b)));
 }
 
-/* returns 1 if the search was finished (must-word wasn't found) */
+/*
+  When performing prefix search (a word with truncation operator), we
+  must preserve original prefix to ensure that characters which may be
+  expanded/contracted do not break the prefix. This is done by storing
+  newly found key immediatly after the original word in ftbw->word
+  buffer.
+
+  ftbw->word= LENGTH WORD [ LENGTH1 WORD1 ] WEIGHT REFERENCE
+  LENGTH - 1 byte, length of the WORD
+  WORD - LENGTH bytes, the word itself
+  LENGTH1 - 1 byte, length of the WORD1, present in case of prefix search
+  WORD1 - LENGTH bytes, the word itself, present in case of prefix search
+  WEIGHT - 4 bytes (HA_FT_WLEN), either weight or number of subkeys
+  REFERENCE - rec_reflength bytes, pointer to the record
+
+  returns 1 if the search was finished (must-word wasn't found)
+*/
 static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search)
 {
   int r;
@@ -369,7 +385,8 @@ static int _ft2_search(FTB *ftb, FTB_WOR
     if (ftbw->docid[0] < max_docid)
     {
       sflag|= SEARCH_SAME;
-      _mi_dpointer(info, (uchar *)(ftbw->word + ftbw->len + HA_FT_WLEN),
+      _mi_dpointer(info, (uchar*) (lastkey_buf + HA_FT_WLEN +
+                                   (ftbw->off ? 0 : lastkey_buf[0] + 1)),
                    max_docid);
     }
     r=_mi_search(info, ftbw->keyinfo, (uchar*) lastkey_buf,

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2009-04-08 06:55:19 +0000
+++ b/storage/myisam/ha_myisam.cc	2009-04-30 12:52:48 +0000
@@ -43,6 +43,28 @@ TYPELIB myisam_stats_method_typelib= {
   array_elements(myisam_stats_method_names) - 1, "",
   myisam_stats_method_names, NULL};
 
+#ifndef DBUG_OFF
+/**
+  Causes the thread to wait in a spin lock for a query kill signal.
+  This function is used by the test frame work to identify race conditions.
+
+  The signal is caught and ignored and the thread is not killed.
+*/
+
+static void debug_wait_for_kill(const char *info)
+{
+  DBUG_ENTER("debug_wait_for_kill");
+  const char *prev_info;
+  THD *thd;
+  thd= current_thd;
+  prev_info= thd_proc_info(thd, info);
+  while(!thd->killed)
+    my_sleep(1000);
+  DBUG_PRINT("info", ("Exit debug_wait_for_kill"));
+  thd_proc_info(thd, prev_info);
+  DBUG_VOID_RETURN;
+}
+#endif
 
 /*****************************************************************************
 ** MyISAM tables
@@ -392,7 +414,7 @@ int check_definition(MI_KEYDEF *t1_keyin
                             test(t2_keyinfo[i].flag & HA_SPATIAL)));
        DBUG_RETURN(1);
     }
-    if ((mysql_40_compat &&
+    if ((!mysql_40_compat &&
         t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) ||
         t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs)
     {
@@ -424,7 +446,7 @@ int check_definition(MI_KEYDEF *t1_keyin
           t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */
       }
 
-      if ((mysql_40_compat &&
+      if ((!mysql_40_compat &&
           t1_keysegs[j].language != t2_keysegs[j].language) ||
           t1_keysegs_j__type != t2_keysegs[j].type ||
           t1_keysegs[j].null_bit != t2_keysegs[j].null_bit ||
@@ -1395,6 +1417,9 @@ int ha_myisam::enable_indexes(uint mode)
 {
   int error;
 
+  DBUG_EXECUTE_IF("wait_in_enable_indexes",
+                  debug_wait_for_kill("wait_in_enable_indexes"); );
+
   if (mi_is_all_keys_active(file->s->state.key_map, file->s->base.keys))
   {
     /* All indexes are enabled already. */
@@ -1508,8 +1533,9 @@ void ha_myisam::start_bulk_insert(ha_row
     /*
       Only disable old index if the table was empty and we are inserting
       a lot of rows.
-      We should not do this for only a few rows as this is slower and
-      we don't want to update the key statistics based of only a few rows.
+      Note that in end_bulk_insert() we may truncate the table if
+      enable_indexes() failed, thus it's essential that indexes are
+      disabled ONLY for an empty table.
     */
     if (file->state->records == 0 && can_enable_indexes &&
         (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES))
@@ -1541,8 +1567,27 @@ int ha_myisam::end_bulk_insert()
 {
   mi_end_bulk_insert(file);
   int err=mi_extra(file, HA_EXTRA_NO_CACHE, 0);
-  return err ? err : can_enable_indexes ?
-                     enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0;
+  if (!err)
+  {
+    if (can_enable_indexes)
+    {
+      /* 
+        Truncate the table when enable index operation is killed. 
+        After truncating the table we don't need to enable the 
+        indexes, because the last repair operation is aborted after 
+        setting the indexes as active and  trying to recreate them. 
+     */
+   
+      if (((err= enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE)) != 0) && 
+                                                  current_thd->killed)
+      {
+        delete_all_rows();
+        /* not crashed, despite being killed during repair */
+        file->s->state.changed&= ~(STATE_CRASHED|STATE_CRASHED_ON_REPAIR);
+      }
+    } 
+  }
+  return err;
 }
 
 

=== modified file 'storage/myisam/mi_delete.c'
--- a/storage/myisam/mi_delete.c	2008-03-29 08:02:54 +0000
+++ b/storage/myisam/mi_delete.c	2009-04-29 02:59:10 +0000
@@ -250,7 +250,11 @@ static int d_search(register MI_INFO *in
       if (info->ft1_to_ft2)
       {
         /* we're in ft1->ft2 conversion mode. Saving key data */
-        insert_dynamic(info->ft1_to_ft2, (lastkey+off));
+        if (insert_dynamic(info->ft1_to_ft2, (lastkey+off)))
+        {
+          DBUG_PRINT("error",("Out of memory"));
+          DBUG_RETURN(-1);
+        }
       }
       else
       {

=== modified file 'storage/myisam/mi_open.c'
--- a/storage/myisam/mi_open.c	2009-02-13 16:41:47 +0000
+++ b/storage/myisam/mi_open.c	2009-04-29 12:00:34 +0000
@@ -1160,7 +1160,8 @@ uchar *mi_keyseg_read(uchar *ptr, HA_KEY
    keyseg->null_pos	= mi_uint4korr(ptr);  ptr +=4;
    keyseg->charset=0;				/* Will be filled in later */
    if (keyseg->null_bit)
-     keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == 7));
+     /* We adjust bit_pos if null_bit is last in the byte */
+     keyseg->bit_pos= (uint16)(keyseg->null_pos + (keyseg->null_bit == (1 << 7)));
    else
    {
      keyseg->bit_pos= (uint16)keyseg->null_pos;

=== modified file 'storage/myisam/mi_write.c'
--- a/storage/myisam/mi_write.c	2008-03-31 07:40:39 +0000
+++ b/storage/myisam/mi_write.c	2009-04-29 02:59:10 +0000
@@ -562,7 +562,14 @@ int _mi_insert(register MI_INFO *info, r
              we cannot easily dispatch an empty page here */
           b+=blen+ft2len+2;
           for (a=anc_buff+a_length ; b < a ; b+=ft2len+2)
-            insert_dynamic(info->ft1_to_ft2, b);
+          {
+            if (insert_dynamic(info->ft1_to_ft2, b))
+            {
+              mi_print_error(info->s, HA_ERR_OUT_OF_MEM);
+              my_errno= HA_ERR_OUT_OF_MEM;
+              DBUG_RETURN(-1);
+            }
+          }
 
           /* fixing the page's length - it contains only one key now */
           mi_putint(anc_buff,2+blen+ft2len+2,0);

=== modified file 'storage/ndb/src/kernel/blocks/backup/read.cpp'
--- a/storage/ndb/src/kernel/blocks/backup/read.cpp	2006-12-23 19:20:40 +0000
+++ b/storage/ndb/src/kernel/blocks/backup/read.cpp	2009-04-28 18:21:47 +0000
@@ -50,7 +50,7 @@ main(int argc, const char * argv[]){
 
   ndb_init();
   if(argc <= 1){
-    printf("Usage: %s <filename>", argv[0]);
+    printf("Usage: %s <filename>\n", argv[0]);

     exit(1);
   }
   FILE * f = fopen(argv[1], "rb");

=== modified file 'strings/ctype-cp932.c'
--- a/strings/ctype-cp932.c	2007-11-29 10:35:15 +0000
+++ b/strings/ctype-cp932.c	2009-05-05 06:55:22 +0000
@@ -5489,10 +5489,10 @@ static MY_CHARSET_HANDLER my_charset_han
   my_mb_wc_cp932,	/* mb_wc */
   my_wc_mb_cp932,	/* wc_mb */
   my_mb_ctype_mb,
-  my_caseup_str_8bit,
-  my_casedn_str_8bit,
-  my_caseup_8bit,
-  my_casedn_8bit,
+  my_caseup_str_mb,
+  my_casedn_str_mb,
+  my_caseup_mb,
+  my_casedn_mb,
   my_snprintf_8bit,
   my_long10_to_str_8bit,
   my_longlong10_to_str_8bit,

=== modified file 'strings/ctype-sjis.c'
--- a/strings/ctype-sjis.c	2007-10-04 07:10:15 +0000
+++ b/strings/ctype-sjis.c	2009-05-05 06:55:22 +0000
@@ -4650,10 +4650,10 @@ static MY_CHARSET_HANDLER my_charset_han
   my_mb_wc_sjis,	/* mb_wc */
   my_wc_mb_sjis,	/* wc_mb */
   my_mb_ctype_mb,
-  my_caseup_str_8bit,
-  my_casedn_str_8bit,
-  my_caseup_8bit,
-  my_casedn_8bit,
+  my_caseup_str_mb,
+  my_casedn_str_mb,
+  my_caseup_mb,
+  my_casedn_mb,
   my_snprintf_8bit,
   my_long10_to_str_8bit,
   my_longlong10_to_str_8bit,

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2009-03-24 13:58:52 +0000
+++ b/tests/mysql_client_test.c	2009-05-05 10:34:25 +0000
@@ -2464,6 +2464,9 @@ static void test_ps_query_cache()
 
   myheader("test_ps_query_cache");
 
+  rc= mysql_query(mysql, "SET SQL_MODE=''");
+  myquery(rc);
+
   /* prepare the table */
 
   rc= mysql_query(mysql, "drop table if exists t1");
@@ -2506,6 +2509,9 @@ static void test_ps_query_cache()
         mysql_close(lmysql);
         DIE_UNLESS(0);
       }
+      rc= mysql_query(lmysql, "SET SQL_MODE=''");
+      myquery(rc);
+
       if (!opt_silent)
         fprintf(stdout, "OK");
     }
@@ -4240,6 +4246,10 @@ static void test_fetch_date()
 
   myheader("test_fetch_date");
 
+  /* Will not work if sql_mode is NO_ZERO_DATE (implicit if TRADITIONAL) /*/
+  rc= mysql_query(mysql, "SET SQL_MODE=''");
+  myquery(rc);
+
   rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_bind_result");
   myquery(rc);
 
@@ -4954,6 +4964,9 @@ static void test_stmt_close()
   /* set AUTOCOMMIT to ON*/
   mysql_autocommit(lmysql, TRUE);
 
+  rc= mysql_query(lmysql, "SET SQL_MODE = ''");
+  myquery(rc);
+
   rc= mysql_query(lmysql, "DROP TABLE IF EXISTS test_stmt_close");
   myquery(rc);
 
@@ -12088,6 +12101,9 @@ static void test_bug6058()
 
   myheader("test_bug6058");
 
+  rc= mysql_query(mysql, "SET SQL_MODE=''");
+  myquery(rc);
+
   stmt_text= "SELECT CAST('0000-00-00' AS DATE)";
 
   rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
@@ -13303,6 +13319,9 @@ static void test_bug8378()
   if (!opt_silent)
     fprintf(stdout, "OK");
 
+  rc= mysql_query(lmysql, "SET SQL_MODE=''");
+  myquery(rc);
+
   len= mysql_real_escape_string(lmysql, out, TEST_BUG8378_IN, 4);
 
   /* No escaping should have actually happened. */
@@ -16390,12 +16409,27 @@ static void test_change_user()
   myquery(rc);
 
   sprintf(buff,
+          "grant select on %s.* to %s@'localhost' identified by '%s'",
+          db,
+          user_pw,
+          pw);
+  rc= mysql_query(mysql, buff);
+  myquery(rc);
+
+  sprintf(buff,
           "grant select on %s.* to %s@'%%'",
           db,
           user_no_pw);
   rc= mysql_query(mysql, buff);
   myquery(rc);
 
+  sprintf(buff,
+          "grant select on %s.* to %s@'localhost'",
+          db,
+          user_no_pw);
+  rc= mysql_query(mysql, buff);
+  myquery(rc);
+
 
   /* Try some combinations */
   rc= mysql_change_user(mysql, NULL, NULL, NULL);
@@ -16552,63 +16586,16 @@ static void test_change_user()
   rc= mysql_query(mysql, buff);
   myquery(rc);
 
-  DBUG_VOID_RETURN;
-}
-
-#ifdef HAVE_SPATIAL
-/**
-  Bug#37956 memory leak and / or crash with geometry and prepared statements! 
-*/
-
-static void test_bug37956(void)
-{
-  const char *query="select point(?,?)";
-  MYSQL_STMT *stmt=NULL;
-  ulong val=0;
-  MYSQL_BIND bind_param[2];
-  unsigned char buff[2]= { 134, 211 };
-  DBUG_ENTER("test_bug37956");
-  myheader("test_bug37956");
-
-  stmt= mysql_simple_prepare(mysql, query);
-  check_stmt(stmt);
-
-  val=1;
-  mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void *)&val);
-  val=CURSOR_TYPE_READ_ONLY;
-  mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void *)&val);
-  val=0;
-  mysql_stmt_attr_set(stmt, STMT_ATTR_PREFETCH_ROWS, (void *)&val);
-
-  memset(bind_param, 0, sizeof(bind_param));
-  bind_param[0].buffer_type=MYSQL_TYPE_TINY;
-  bind_param[0].buffer= (void *)buff;
-  bind_param[0].is_null=NULL;
-  bind_param[0].error=NULL;
-  bind_param[0].is_unsigned=1;
-  bind_param[1].buffer_type=MYSQL_TYPE_TINY;
-  bind_param[1].buffer= (void *)(buff+1);
-  bind_param[1].is_null=NULL;
-  bind_param[1].error=NULL;
-  bind_param[1].is_unsigned=1;
+  sprintf(buff, "drop user %s@'localhost'", user_pw);
+  rc= mysql_query(mysql, buff);
+  myquery(rc);
 
-  if (mysql_stmt_bind_param(stmt, bind_param))
-  {
-    mysql_stmt_close(stmt);
-    DIE_UNLESS(0);
-  }
+  sprintf(buff, "drop user %s@'localhost'", user_no_pw);
+  rc= mysql_query(mysql, buff);
+  myquery(rc);
 
-  if (mysql_stmt_execute(stmt))
-  {
-    mysql_stmt_close(stmt);
-    DBUG_VOID_RETURN;
-  }
-  /* Should never reach here: execution returns an error. */
-  mysql_stmt_close(stmt);
-  DIE_UNLESS(0);
   DBUG_VOID_RETURN;
 }
-#endif
 
 /*
   Bug#27592 (stack overrun when storing datetime value using prepared statements)
@@ -17275,6 +17262,11 @@ static void test_bug31669()
   rc= mysql_query(mysql, query);
   myquery(rc);
 
+  strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'localhost' IDENTIFIED BY "
+                 "'", buff, "' WITH GRANT OPTION", NullS);
+  rc= mysql_query(mysql, query);
+  myquery(rc);
+
   rc= mysql_query(mysql, "FLUSH PRIVILEGES");
   myquery(rc);
 
@@ -17312,7 +17304,7 @@ static void test_bug31669()
   strxmov(query, "DELETE FROM mysql.user WHERE User='", user, "'", NullS);
   rc= mysql_query(mysql, query);
   myquery(rc);
-  DIE_UNLESS(mysql_affected_rows(mysql) == 1);
+  DIE_UNLESS(mysql_affected_rows(mysql) == 2);
 #endif
 
   DBUG_VOID_RETURN;
@@ -17524,6 +17516,9 @@ static void test_wl4166_2()
 
   myheader("test_wl4166_2");
 
+  rc= mysql_query(mysql, "SET SQL_MODE=''");
+  myquery(rc);
+
   rc= mysql_query(mysql, "drop table if exists t1");
   myquery(rc);
   rc= mysql_query(mysql, "create table t1 (c_int int, d_date date)");
@@ -18145,9 +18140,6 @@ static struct my_tests_st my_tests[]= {
   { "test_wl4166_2", test_wl4166_2 },
   { "test_bug38486", test_bug38486 },
   { "test_bug40365", test_bug40365 },
-#ifdef HAVE_SPATIAL
-  { "test_bug37956", test_bug37956 },
-#endif
 #ifdef HAVE_QUERY_CACHE
   { "test_bug36326", test_bug36326 },
 #endif

Attachment: [text/bzr-bundle] bzr/mats@sun.com-20090511132802-nnkiyb2huih1tklz.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (mats:2873)Mats Kindahl11 May