List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:April 30 2009 12:41pm
Subject:bzr commit into mysql-5.0-bugteam branch (aelkin:2731)
View as plain text  
#At file:///home/andrei/MySQL/BZR/FIXES/5.0-bt-bug38694-race_condition_at_shutdown/ based on revid:aelkin@stripped

 2731 Andrei Elkin	2009-04-30 [merge]
      merging from 5.0-bt rep to a local branch
modified:
  innobase/btr/btr0sea.c
  innobase/include/srv0srv.h
  innobase/page/page0cur.c
  innobase/srv/srv0srv.c
  myisam/mi_delete.c
  myisam/mi_write.c
  mysql-test/r/gis-rtree.result
  mysql-test/r/gis.result
  mysql-test/r/innodb.result
  mysql-test/r/insert_update.result
  mysql-test/r/not_embedded_server.result
  mysql-test/r/select.result
  mysql-test/r/sp_trans_log.result
  mysql-test/r/varbinary.result
  mysql-test/suite/funcs_2/charset/charset_master.test
  mysql-test/t/gis-rtree.test
  mysql-test/t/gis.test
  mysql-test/t/innodb.test
  mysql-test/t/insert_update.test
  mysql-test/t/not_embedded_server.test
  mysql-test/t/select.test
  mysql-test/t/sp_trans_log.test
  mysql-test/t/varbinary.test
  scripts/mysqlhotcopy.sh
  server-tools/instance-manager/instance_options.cc
  sql/ha_innodb.h
  sql/item.cc
  sql/item_geofunc.cc
  sql/mysqld.cc
  sql/set_var.cc
  sql/slave.cc
  sql/sp_head.cc
  sql/sp_head.h
  sql/sp_pcontext.cc
  sql/sp_pcontext.h
  sql/sql_select.cc
  sql/sql_table.cc
  sql/sql_yacc.yy
  tests/mysql_client_test.c

=== modified file 'innobase/btr/btr0sea.c'
--- a/innobase/btr/btr0sea.c	2008-12-13 00:40:31 +0000
+++ b/innobase/btr/btr0sea.c	2009-04-24 11:48:20 +0000
@@ -1101,12 +1101,20 @@ btr_search_drop_page_hash_when_freed(
 	page = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL,
 				BUF_GET_IF_IN_POOL, __FILE__, __LINE__,
 				&mtr);
+	/* Because the buffer pool mutex was released by
+	buf_page_peek_if_search_hashed(), it is possible that the
+	block was removed from the buffer pool by another thread
+	before buf_page_get_gen() got a chance to acquire the buffer
+	pool mutex again.  Thus, we must check for a NULL return. */
+
+	if (UNIV_LIKELY(page != NULL)) {
 
 #ifdef UNIV_SYNC_DEBUG
-	buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH);
+		buf_page_dbg_add_level(page, SYNC_TREE_NODE_FROM_HASH);
 #endif /* UNIV_SYNC_DEBUG */
 
-	btr_search_drop_page_hash_index(page);
+		btr_search_drop_page_hash_index(page);
+	}
 
 	mtr_commit(&mtr);
 }

=== modified file 'innobase/include/srv0srv.h'
--- a/innobase/include/srv0srv.h	2008-07-31 21:47:57 +0000
+++ b/innobase/include/srv0srv.h	2009-04-24 11:03:50 +0000
@@ -253,6 +253,12 @@ extern ulint srv_read_ahead_seq;
 /* variable to count the number of random read-aheads were done */
 extern ulint srv_read_ahead_rnd;
 
+/* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
+NOT update cardinality for indexes of InnoDB table". By default we are
+running with the fix disabled because MySQL 5.1 is frozen for such
+behavioral changes. */
+extern char srv_use_legacy_cardinality_algorithm;
+
 /* In this structure we store status variables to be passed to MySQL */
 typedef struct export_var_struct export_struc;
 

=== modified file 'innobase/page/page0cur.c'
--- a/innobase/page/page0cur.c	2005-07-05 09:10:20 +0000
+++ b/innobase/page/page0cur.c	2009-04-24 11:03:50 +0000
@@ -15,6 +15,8 @@ Created 10/4/1994 Heikki Tuuri
 #include "mtr0log.h"
 #include "log0recv.h"
 #include "rem0cmp.h"
+#include "srv0srv.h"
+#include "ut0ut.h"
 
 static ulint	page_rnd	= 976722341;
 
@@ -23,6 +25,44 @@ static ulint	page_rnd	= 976722341;
 ulint	page_cur_short_succ	= 0;
 # endif /* UNIV_SEARCH_PERF_STAT */
 
+/***********************************************************************
+This is a linear congruential generator PRNG. Returns a pseudo random
+number between 0 and 2^64-1 inclusive. The formula and the constants
+being used are:
+X[n+1] = (a * X[n] + c) mod m
+where:
+X[0] = ut_usectime()
+a = 1103515245 (3^5 * 5 * 7 * 129749)
+c = 12345 (3 * 5 * 823)
+m = 18446744073709551616 (2^64)
+*/
+#define LCG_a	1103515245
+#define LCG_c	12345
+static
+unsigned long long
+page_cur_lcg_prng()
+/*===============*/
+			/* out: number between 0 and 2^64-1 */
+{
+	static unsigned long long lcg_current = 0;
+	static ibool		initialized = FALSE;
+	ulint			time_sec;
+	ulint			time_ms;
+
+	if (!initialized) {
+		ut_usectime(&time_sec, &time_ms);
+		lcg_current = (unsigned long long) (time_sec * 1000000
+						    + time_ms);
+		initialized = TRUE;
+	}
+
+	/* no need to "% 2^64" explicitly because lcg_current is
+	64 bit and this will be done anyway */
+	lcg_current = LCG_a * lcg_current + LCG_c;
+
+	return(lcg_current);
+}
+
 /********************************************************************
 Tries a search shortcut based on the last insert. */
 UNIV_INLINE
@@ -489,9 +529,13 @@ page_cur_open_on_rnd_user_rec(
 		return;
 	}	
 
-	page_rnd += 87584577;	
+	if (srv_use_legacy_cardinality_algorithm) {
+		page_rnd += 87584577;
 
-	rnd = page_rnd % page_get_n_recs(page);
+		rnd = page_rnd % page_get_n_recs(page);
+	} else {
+		rnd = (ulint) page_cur_lcg_prng() % page_get_n_recs(page);
+	}
 
 	rec = page_get_infimum_rec(page);
 
@@ -1419,3 +1463,30 @@ page_cur_delete_rec(
 		page_dir_balance_slot(page, cur_slot_no);
 	}
 }
+
+#ifdef UNIV_COMPILE_TEST_FUNCS
+
+/***********************************************************************
+Print the first n numbers, generated by page_cur_lcg_prng() to make sure
+(visually) that it works properly. */
+void
+test_page_cur_lcg_prng(
+/*===================*/
+	int	n)	/* in: print first n numbers */
+{
+	int			i;
+	unsigned long long	rnd;
+
+	for (i = 0; i < n; i++) {
+		rnd = page_cur_lcg_prng();
+		printf("%llu\t%%2=%llu %%3=%llu %%5=%llu %%7=%llu %%11=%llu\n",
+		       rnd,
+		       rnd % 2,
+		       rnd % 3,
+		       rnd % 5,
+		       rnd % 7,
+		       rnd % 11);
+	}
+}
+
+#endif /* UNIV_COMPILE_TEST_FUNCS */

=== modified file 'innobase/srv/srv0srv.c'
--- a/innobase/srv/srv0srv.c	2008-12-12 22:48:26 +0000
+++ b/innobase/srv/srv0srv.c	2009-04-24 11:03:50 +0000
@@ -239,6 +239,12 @@ ulint srv_read_ahead_seq = 0;
 /* variable to count the number of random read-aheads */
 ulint srv_read_ahead_rnd = 0;
 
+/* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
+NOT update cardinality for indexes of InnoDB table". By default we are
+running with the fix disabled because MySQL 5.1 is frozen for such
+behavioral changes. */
+char srv_use_legacy_cardinality_algorithm = TRUE;
+
 /* structure to pass status variables to MySQL */
 export_struc export_vars;
 

=== modified file 'myisam/mi_delete.c'
--- a/myisam/mi_delete.c	2008-03-29 07:52:16 +0000
+++ b/myisam/mi_delete.c	2008-11-21 13:38:42 +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, (char*) (lastkey+off));
+        if (insert_dynamic(info->ft1_to_ft2, (char*) (lastkey+off)))
+        {
+          DBUG_PRINT("error",("Out of memory"));
+          DBUG_RETURN(-1);
+        }
       }
       else
       {

=== modified file 'myisam/mi_write.c'
--- a/myisam/mi_write.c	2008-03-29 07:52:16 +0000
+++ b/myisam/mi_write.c	2008-11-21 13:38:42 +0000
@@ -550,7 +550,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, (char*) b);
+          {
+            if (insert_dynamic(info->ft1_to_ft2, (char*) 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 'mysql-test/r/gis-rtree.result'
--- a/mysql-test/r/gis-rtree.result	2007-10-10 13:26:02 +0000
+++ b/mysql-test/r/gis-rtree.result	2009-04-28 09:47:26 +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-01-28 17:59:08 +0000
+++ b/mysql-test/r/gis.result	2009-04-28 09:47:26 +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/innodb.result'
--- a/mysql-test/r/innodb.result	2008-05-06 16:43:46 +0000
+++ b/mysql-test/r/innodb.result	2009-04-24 11:57:53 +0000
@@ -1803,15 +1803,12 @@ Innodb_buffer_pool_pages_total	512
 show status like "Innodb_page_size";
 Variable_name	Value
 Innodb_page_size	16384
-show status like "Innodb_rows_deleted";
-Variable_name	Value
-Innodb_rows_deleted	73
-show status like "Innodb_rows_inserted";
-Variable_name	Value
-Innodb_rows_inserted	29734
-show status like "Innodb_rows_updated";
-Variable_name	Value
-Innodb_rows_updated	29532
+innodb_rows_deleted
+73
+innodb_rows_inserted
+29734
+innodb_rows_updated
+29532
 show status like "Innodb_row_lock_waits";
 Variable_name	Value
 Innodb_row_lock_waits	0

=== modified file 'mysql-test/r/insert_update.result'
--- a/mysql-test/r/insert_update.result	2007-06-11 21:41:23 +0000
+++ b/mysql-test/r/insert_update.result	2009-04-28 18:12:18 +0000
@@ -393,6 +393,7 @@ id	c1	cnt
 1	0	3
 2	2	1
 DROP TABLE t1;
+DROP TABLE t2;
 create table t1(f1 int primary key,
 f2 timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP);
 insert into t1(f1) values(1);

=== modified file 'mysql-test/r/not_embedded_server.result'
--- a/mysql-test/r/not_embedded_server.result	2009-01-15 09:36:34 +0000
+++ b/mysql-test/r/not_embedded_server.result	2009-04-30 10:26:11 +0000
@@ -4,9 +4,4 @@ Id	User	Host	db	Command	Time	State	Info
 number	root	localhost	test	Query	time	NULL	show full processlist
 deallocate prepare stmt1;
 FLUSH STATUS;
-SHOW GLOBAL STATUS LIKE 'com_select';
-Variable_name	Value
-Com_select	101
-SHOW GLOBAL STATUS LIKE 'com_select';
-Variable_name	Value
-Com_select	101
+Value of com_select did not change

=== modified file 'mysql-test/r/select.result'
--- a/mysql-test/r/select.result	2009-01-28 17:59:08 +0000
+++ b/mysql-test/r/select.result	2009-04-28 00:19:13 +0000
@@ -4388,4 +4388,17 @@ 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	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	3	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	Extra
+1	SIMPLE	t1	range	PRIMARY	PRIMARY	4	NULL	3	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

=== modified file 'mysql-test/r/sp_trans_log.result'
--- a/mysql-test/r/sp_trans_log.result	2007-12-21 19:30:23 +0000
+++ b/mysql-test/r/sp_trans_log.result	2009-04-28 18:12:18 +0000
@@ -1,3 +1,5 @@
+drop function if exists bug23333|
+drop table if exists t1,t2|
 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)|
@@ -20,4 +22,5 @@ master-bin.000001	#	Query	1	#	#
 select count(*),@a from t1 /* must be 1,1 */|
 count(*)	@a
 1	1
-drop table t1, t2|
+drop table t1,t2;
+drop function if exists bug23333;

=== modified file 'mysql-test/r/varbinary.result'
--- a/mysql-test/r/varbinary.result	2008-06-27 15:56:41 +0000
+++ b/mysql-test/r/varbinary.result	2009-04-28 18:12:18 +0000
@@ -78,6 +78,7 @@ alter table t1 modify a varchar(255);
 select length(a) from t1;
 length(a)
 6
+drop table t1;
 select 0b01000001;
 0b01000001
 A

=== modified file 'mysql-test/suite/funcs_2/charset/charset_master.test'
--- a/mysql-test/suite/funcs_2/charset/charset_master.test	2008-07-09 11:22:07 +0000
+++ b/mysql-test/suite/funcs_2/charset/charset_master.test	2009-04-24 16:58:23 +0000
@@ -86,6 +86,15 @@ let $check_std_csets= 1;
 let $check_ucs2_csets= 1;
 let $check_utf8_csets= 1;
 
+# Bug#32784: Timeout in test "innodb_charset": InnoDB much slower 
+#            than other handlers
+# NOTE:  We turn autocommit off to improve the performance of the innodb variant
+#        of this test.  Per Innobase's recommendation.
+
+--disable_query_log
+SET autocommit=0;
+--enable_query_log
+
 #
 # Check all charsets/collation combinations
 #

=== modified file 'mysql-test/t/gis-rtree.test'
--- a/mysql-test/t/gis-rtree.test	2007-10-05 10:41:56 +0000
+++ b/mysql-test/t/gis-rtree.test	2009-04-28 09:47:26 +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:26:08 +0000
+++ b/mysql-test/t/gis.test	2009-04-28 09:47:26 +0000
@@ -36,32 +36,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/innodb.test'
--- a/mysql-test/t/innodb.test	2007-10-13 12:49:42 +0000
+++ b/mysql-test/t/innodb.test	2009-04-24 11:57:53 +0000
@@ -13,6 +13,18 @@
 
 -- source include/have_innodb.inc
 
+# Save the original values of some variables in order to be able to
+# estimate how much they have changed during the tests. Previously this
+# test assumed that e.g. rows_deleted is 0 here and after deleting 23
+# rows it expected that rows_deleted will be 23. Now we do not make
+# assumptions about the values of the variables at the beginning, e.g.
+# rows_deleted should be 23 + "rows_deleted before the test". This allows
+# the test to be run multiple times without restarting the mysqld server.
+# See Bug#43309 Test main.innodb can't be run twice
+-- let $innodb_rows_deleted_orig = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_deleted', Value, 1)
+-- let $innodb_rows_inserted_orig = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_inserted', Value, 1)
+-- let $innodb_rows_updated_orig = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_updated', Value, 1)
+
 #
 # Small basic test with ignore
 #
@@ -1344,9 +1356,14 @@ drop table t1;
 # uses previous ones(pages_created, rows_deleted, ...).
 show status like "Innodb_buffer_pool_pages_total";
 show status like "Innodb_page_size";
-show status like "Innodb_rows_deleted";
-show status like "Innodb_rows_inserted";
-show status like "Innodb_rows_updated";
+-- let $innodb_rows_deleted = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_deleted', Value, 1)
+-- let $innodb_rows_inserted = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_inserted', Value, 1)
+-- let $innodb_rows_updated = query_get_value(SHOW STATUS WHERE variable_name = 'innodb_rows_updated', Value, 1)
+-- disable_query_log
+-- eval SELECT $innodb_rows_deleted - $innodb_rows_deleted_orig AS innodb_rows_deleted
+-- eval SELECT $innodb_rows_inserted - $innodb_rows_inserted_orig AS innodb_rows_inserted
+-- eval SELECT $innodb_rows_updated - $innodb_rows_updated_orig AS innodb_rows_updated
+-- enable_query_log
 
 # Test for row locks InnoDB status variables.
 show status like "Innodb_row_lock_waits";
@@ -1365,6 +1382,8 @@ set global innodb_sync_spin_loops=20;
 show variables like "innodb_sync_spin_loops";
 
 # Test for innodb_thread_concurrency variable
+# save the original value so we can restore it at the end
+-- let $innodb_thread_concurrency_orig = query_get_value(SHOW VARIABLES WHERE variable_name = 'innodb_thread_concurrency', Value, 1)
 show variables like "innodb_thread_concurrency";
 set global innodb_thread_concurrency=1001;
 show variables like "innodb_thread_concurrency";
@@ -1372,6 +1391,10 @@ set global innodb_thread_concurrency=0;
 show variables like "innodb_thread_concurrency";
 set global innodb_thread_concurrency=16;
 show variables like "innodb_thread_concurrency";
+# restore the orginal value, this way the test can be run multiple times
+-- disable_query_log
+-- eval set global innodb_thread_concurrency = $innodb_thread_concurrency_orig
+-- enable_query_log
 
 # Test for innodb_concurrency_tickets variable
 show variables like "innodb_concurrency_tickets";

=== modified file 'mysql-test/t/insert_update.test'
--- a/mysql-test/t/insert_update.test	2007-06-11 21:41:23 +0000
+++ b/mysql-test/t/insert_update.test	2009-04-28 18:12:18 +0000
@@ -12,7 +12,7 @@ INSERT t1 VALUES (8,4,50) ON DUPLICATE K
 SELECT * FROM t1;
 INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
 SELECT * FROM t1;
--- error 1062
+-- error ER_DUP_ENTRY
 INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
 SELECT * FROM t1;
 TRUNCATE TABLE t1;
@@ -63,7 +63,7 @@ INSERT t1 SELECT 8,4,50 FROM DUAL ON DUP
 SELECT * FROM t1;
 INSERT t1 SELECT 1,4,60 FROM DUAL ON DUPLICATE KEY UPDATE c=c+10000;
 SELECT * FROM t1;
--- error 1062
+-- error ER_DUP_ENTRY
 INSERT t1 SELECT 1,9,70 FROM DUAL ON DUPLICATE KEY UPDATE c=c+100000, b=4;
 SELECT * FROM t1;
 TRUNCATE TABLE t1;
@@ -76,7 +76,7 @@ INSERT t1 SELECT a,b,c FROM t2 WHERE d=1
 SELECT * FROM t1;
 INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
 SELECT * FROM t1;
---error 1052
+--error ER_NON_UNIQ_ERROR
 INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=c+VALUES(a);
 INSERT t1 SELECT a,b,c FROM t2 WHERE d=2 ON DUPLICATE KEY UPDATE c=t1.c+VALUES(t1.a);
 SELECT *, VALUES(a) FROM t1;
@@ -95,9 +95,9 @@ insert ignore into t1 select a from t1 a
 select * from t1;
 insert into t1 select 1 on duplicate key update a=2;
 select * from t1;
---error 1052
+--error ER_NON_UNIQ_ERROR
 insert into t1 select a from t1 on duplicate key update a=a+1 ;
---error 1052
+--error ER_NON_UNIQ_ERROR
 insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ;
 drop table t1;
 
@@ -171,13 +171,13 @@ SET SQL_MODE = 'TRADITIONAL';
 
 CREATE TABLE t1 (a INT PRIMARY KEY, b INT NOT NULL);
 
---error 1364
+--error ER_NO_DEFAULT_FOR_FIELD
 INSERT INTO t1 (a) VALUES (1);
 
---error 1364
+--error ER_NO_DEFAULT_FOR_FIELD
 INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE a = b;
 
---error 1364
+--error ER_NO_DEFAULT_FOR_FIELD
 INSERT INTO t1 (a) VALUES (1) ON DUPLICATE KEY UPDATE b = b;
 
 SELECT * FROM t1;
@@ -278,7 +278,7 @@ INSERT INTO t1 (id,c1) VALUES (1,10);
 SELECT * FROM t1;
 CREATE TABLE t2 (id INT, c1 INT);
 INSERT INTO t2 VALUES (1,NULL), (2,2);
---error 1048
+--error ER_BAD_NULL_ERROR
 INSERT INTO t1 (id,c1) SELECT 1,NULL
   ON DUPLICATE KEY UPDATE c1=NULL;
 SELECT * FROM t1;
@@ -290,6 +290,7 @@ INSERT IGNORE INTO t1 (id,c1) SELECT * F
 SELECT * FROM t1;
 
 DROP TABLE t1;
+DROP TABLE t2;
 
 #
 # Bug#28904: INSERT .. ON DUPLICATE was silently updating rows when it

=== modified file 'mysql-test/t/not_embedded_server.test'
--- a/mysql-test/t/not_embedded_server.test	2009-01-15 09:36:34 +0000
+++ b/mysql-test/t/not_embedded_server.test	2009-04-30 10:26:11 +0000
@@ -39,8 +39,14 @@ while ($i)
 --enable_query_log
 --enable_result_log
 
-SHOW GLOBAL STATUS LIKE 'com_select';
+let $before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1);
 
 --change_user
 
-SHOW GLOBAL STATUS LIKE 'com_select';
+let $after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_select',Value,1);
+
+if (`select $after != $before`){
+  SHOW GLOBAL STATUS LIKE 'com_select';
+  die The value of com_select changed during change_user;
+}
+echo Value of com_select did not change;

=== modified file 'mysql-test/t/select.test'
--- a/mysql-test/t/select.test	2008-12-24 15:24:11 +0000
+++ b/mysql-test/t/select.test	2009-04-28 00:19:13 +0000
@@ -3737,4 +3737,18 @@ 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_trans_log.test'
--- a/mysql-test/t/sp_trans_log.test	2007-08-22 12:43:16 +0000
+++ b/mysql-test/t/sp_trans_log.test	2009-04-28 18:12:18 +0000
@@ -4,11 +4,15 @@
 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|
 
@@ -29,5 +33,10 @@ insert into t2 values (bug23333(),1)| 
 --replace_column 2 # 5 # 6 #
 show binlog events from 98 /* with fixes for #23333 will show there are 2 queries */|
 select count(*),@a from t1 /* must be 1,1 */|
-drop table t1, t2|
 
+delimiter ;|
+
+# clean-up
+
+drop table t1,t2;
+drop function if exists bug23333;

=== modified file 'mysql-test/t/varbinary.test'
--- a/mysql-test/t/varbinary.test	2008-06-27 15:56:41 +0000
+++ b/mysql-test/t/varbinary.test	2009-04-28 18:12:18 +0000
@@ -83,6 +83,7 @@ insert into t1 values("aaa   ");
 select length(a) from t1;
 alter table t1 modify a varchar(255);
 select length(a) from t1;
+drop table t1;
 
 #
 # Bug#35658 (An empty binary value leads to mysqld crash)

=== 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 'server-tools/instance-manager/instance_options.cc'
--- a/server-tools/instance-manager/instance_options.cc	2009-02-10 22:47:54 +0000
+++ b/server-tools/instance-manager/instance_options.cc	2009-04-28 09:48:54 +0000
@@ -522,8 +522,7 @@ int Instance_options::add_option(const c
        switch (selected_options->type) {
        case SAVE_WHOLE_AND_ADD:
          *(selected_options->value)= tmp;
-         insert_dynamic(&options_array,(gptr) &tmp);
-         return 0;
+         return insert_dynamic(&options_array,(gptr) &tmp);
        case SAVE_VALUE:
          *(selected_options->value)= strchr(tmp, '=') + 1;
          return 0;

=== modified file 'sql/ha_innodb.h'
--- a/sql/ha_innodb.h	2007-10-03 05:47:30 +0000
+++ b/sql/ha_innodb.h	2009-04-24 11:03:50 +0000
@@ -234,6 +234,11 @@ extern ulong srv_thread_sleep_delay;
 extern ulong srv_thread_concurrency;
 extern ulong srv_commit_concurrency;
 extern ulong srv_flush_log_at_trx_commit;
+/* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
+NOT update cardinality for indexes of InnoDB table". By default we are
+running with the fix disabled because MySQL 5.1 is frozen for such
+behavioral changes. */
+extern char srv_use_legacy_cardinality_algorithm;
 }
 
 bool innobase_init(void);

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2009-04-01 11:02:26 +0000
+++ b/sql/item.cc	2009-04-28 00:19:13 +0000
@@ -4341,7 +4341,7 @@ Item *Item_field::replace_equal_field(by
       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_geofunc.cc'
--- a/sql/item_geofunc.cc	2007-11-17 12:48:57 +0000
+++ b/sql/item_geofunc.cc	2009-04-28 09:47:26 +0000
@@ -70,10 +70,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();
 
@@ -83,8 +90,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;
 }
@@ -337,14 +344,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);
@@ -368,12 +377,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);
@@ -391,13 +402,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
@@ -406,7 +417,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/mysqld.cc'
--- a/sql/mysqld.cc	2009-03-19 13:44:58 +0000
+++ b/sql/mysqld.cc	2009-04-24 11:03:50 +0000
@@ -5044,7 +5044,8 @@ enum options_mysqld
   OPT_SECURE_FILE_PRIV,
   OPT_KEEP_FILES_ON_CREATE,
   OPT_INNODB_ADAPTIVE_HASH_INDEX,
-  OPT_FEDERATED
+  OPT_FEDERATED,
+  OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM
 };
 
 
@@ -5351,6 +5352,14 @@ Disable with --skip-innodb-doublewrite."
    (gptr*) &global_system_variables.innodb_table_locks,
    (gptr*) &global_system_variables.innodb_table_locks,
    0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
+  {"innodb_use_legacy_cardinality_algorithm", 
+   OPT_INNODB_USE_LEGACY_CARDINALITY_ALGORITHM,
+   "Use legacy algorithm for picking random pages during index cardinality "
+   "estimation. Disable this to use a better algorithm, but note that your "
+   "query plans may change (enabled by default).",
+   (gptr*) &srv_use_legacy_cardinality_algorithm,
+   (gptr*) &srv_use_legacy_cardinality_algorithm,
+   0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
 #endif /* End HAVE_INNOBASE_DB */
   {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.",
    (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0,

=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc	2009-02-10 22:47:54 +0000
+++ b/sql/set_var.cc	2009-04-24 11:03:50 +0000
@@ -450,6 +450,9 @@ sys_var_thd_bool	sys_innodb_table_locks(
                                                &SV::innodb_table_locks);
 sys_var_thd_bool	sys_innodb_support_xa("innodb_support_xa",
                                                &SV::innodb_support_xa);
+sys_var_bool_ptr        sys_innodb_use_legacy_cardinality_algorithm(
+                          "innodb_use_legacy_cardinality_algorithm",
+                          &srv_use_legacy_cardinality_algorithm);
 sys_var_long_ptr	sys_innodb_autoextend_increment("innodb_autoextend_increment",
 							&srv_auto_extend_increment);
 sys_var_long_ptr	sys_innodb_sync_spin_loops("innodb_sync_spin_loops",
@@ -804,6 +807,7 @@ sys_var *sys_variables[]=
   &sys_innodb_max_purge_lag,
   &sys_innodb_table_locks,
   &sys_innodb_support_xa,
+  &sys_innodb_use_legacy_cardinality_algorithm,
   &sys_innodb_autoextend_increment,
   &sys_innodb_sync_spin_loops,
   &sys_innodb_concurrency_tickets,
@@ -946,6 +950,8 @@ struct show_var_st init_vars[]= {
   {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
   {sys_innodb_thread_concurrency.name, (char*) &sys_innodb_thread_concurrency, SHOW_SYS},
   {sys_innodb_thread_sleep_delay.name, (char*) &sys_innodb_thread_sleep_delay, SHOW_SYS},
+  {sys_innodb_use_legacy_cardinality_algorithm.name,
+   (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS},
 #endif
   {sys_interactive_timeout.name,(char*) &sys_interactive_timeout,   SHOW_SYS},
   {sys_join_buffer_size.name,   (char*) &sys_join_buffer_size,	    SHOW_SYS},

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2009-04-28 11:46:07 +0000
+++ b/sql/slave.cc	2009-04-30 12:41:47 +0000
@@ -1104,8 +1104,7 @@ int add_wild_table_rule(DYNAMIC_ARRAY* a
   e->tbl_name = e->db + (dot - table_spec) + 1;
   e->key_len = len;
   memcpy(e->db, table_spec, len);
-  insert_dynamic(a, (gptr)&e);
-  return 0;
+  return insert_dynamic(a, (gptr)&e);
 }
 
 

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2009-04-08 08:17:26 +0000
+++ b/sql/sp_head.cc	2009-04-28 09:48:54 +0000
@@ -1929,17 +1929,16 @@ sp_head::restore_lex(THD *thd)
   DBUG_VOID_RETURN;
 }
 
-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);
 }
 
 void
@@ -2014,7 +2013,7 @@ sp_head::fill_field_definition(THD *thd,
 }
 
 
-void
+int
 sp_head::new_cont_backpatch(sp_instr_opt_meta *i)
 {
   m_cont_level+= 1;
@@ -2022,15 +2021,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
@@ -2212,7 +2213,7 @@ sp_head::show_create_procedure(THD *thd)
     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;
@@ -2223,7 +2224,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, (gptr)&instr);
+  return insert_dynamic(&m_instr, (gptr)&instr);
 }
 
 

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2008-07-07 16:00:08 +0000
+++ b/sql/sp_head.h	2008-11-21 13:38:42 +0000
@@ -226,7 +226,7 @@ public:
   int
   show_create_function(THD *thd);
 
-  void
+  int
   add_instr(sp_instr *instr);
 
   inline uint
@@ -254,7 +254,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
@@ -263,11 +263,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	2007-03-14 18:02:32 +0000
+++ b/sql/sp_pcontext.cc	2008-11-21 13:38:42 +0000
@@ -263,7 +263,8 @@ sp_pcontext::push_variable(LEX_STRING *n
   p->mode= mode;
   p->offset= current_var_count();
   p->dflt= NULL;
-  insert_dynamic(&m_vars, (gptr)&p);
+  if (insert_dynamic(&m_vars, (gptr)&p))
+    return NULL;
 
   return p;
 }
@@ -308,18 +309,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, (gptr)&p);
-  }
+  if (p == NULL)
+    return 1;
+  p->name.str= name->str;
+  p->name.length= name->length;
+  p->val= val;
+  return insert_dynamic(&m_conds, (gptr)&p);
 }
 
 /*
@@ -382,7 +382,7 @@ sp_pcontext::find_handler(sp_cond_type_t
   return FALSE;
 }
 
-void
+int
 sp_pcontext::push_cursor(LEX_STRING *name)
 {
   LEX_STRING n;
@@ -391,7 +391,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, (gptr)&n);
+  return insert_dynamic(&m_cursors, (gptr)&n);
 }
 
 /*

=== modified file 'sql/sp_pcontext.h'
--- a/sql/sp_pcontext.h	2007-03-14 18:02:32 +0000
+++ b/sql/sp_pcontext.h	2008-11-21 13:38:42 +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_select.cc'
--- a/sql/sql_select.cc	2009-04-01 11:02:26 +0000
+++ b/sql/sql_select.cc	2009-04-28 09:48:54 +0000
@@ -3371,10 +3371,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
-*/
 
 static uint
 max_part_bit(key_part_map bits)
@@ -3384,7 +3380,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;
@@ -3414,24 +3419,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,(gptr) &keyuse));
+	  if (insert_dynamic(keyuse_array,(gptr) &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)
   {
@@ -3465,13 +3472,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;
@@ -3481,7 +3491,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,(gptr) &keyuse));
+  return insert_dynamic(keyuse_array,(gptr) &keyuse);
 }
 
 
@@ -3631,7 +3641,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())
@@ -3669,11 +3680,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;
   }
 
   /*
@@ -3694,7 +3709,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,(gptr) &key_end));
+    if (insert_dynamic(keyuse,(gptr) &key_end))
+      return TRUE;
 
     use=save_pos=dynamic_element(keyuse,0,KEYUSE*);
     prev= &key_end;

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-03-27 05:19:50 +0000
+++ b/sql/sql_table.cc	2009-04-23 17:52:39 +0000
@@ -4376,6 +4376,16 @@ bool mysql_checksum_table(THD *thd, TABL
 	{
 	  for (;;)
 	  {
+            if (thd->killed)
+            {
+              /* 
+                 we've been killed; let handler clean up, and remove the 
+                 partial current row from the recordset (embedded lib) 
+              */
+              t->file->ha_rnd_end();
+              thd->protocol->remove_last_row();
+              goto err;
+            }
 	    ha_checksum row_crc= 0;
             int error= t->file->rnd_next(t->record[0]);
             if (unlikely(error))

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-04-03 19:11:54 +0000
+++ b/sql/sql_yacc.yy	2009-04-28 09:48:54 +0000
@@ -234,9 +234,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);
 }
 
 /**
@@ -247,7 +245,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;
@@ -279,9 +277,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);
 }
 
 /**
@@ -290,13 +289,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
@@ -312,7 +312,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());
 }
 
 /**
@@ -1905,10 +1905,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);
@@ -1927,7 +1926,8 @@ sp_decl:
 	      my_error(ER_SP_DUP_COND, MYF(0), $2.str);
 	      MYSQL_YYABORT;
 	    }
-	    YYTHD->lex->spcont->push_cond(&$2, $5);
+	    if(YYTHD->lex->spcont->push_cond(&$2, $5))
+              MYSQL_YYABORT;
 	    $$.vars= $$.hndlrs= $$.curs= 0;
 	    $$.conds= 1;
 	  }
@@ -1942,10 +1942,10 @@ sp_decl:
 	    sp_instr_hpush_jump *i=
               new sp_instr_hpush_jump(sp->instructions(), ctx, $2,
 	                              ctx->current_var_count());
-            if (i == NULL)
+            if (i == NULL ||
+	        sp->add_instr(i))
               MYSQL_YYABORT;
 
-	    sp->add_instr(i);
 	    sp->push_backpatch(i, ctx->push_label((char *)"", 0));
 	  }
 	  sp_hcond_list sp_proc_stmt
@@ -1960,17 +1960,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);
 
@@ -1996,10 +1996,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;
 	  }
@@ -2223,10 +2223,11 @@ sp_proc_stmt:
                 i->m_query.length= lip->ptr - sp->m_tmp_query;
               else
                 i->m_query.length= lip->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);
           }
@@ -2251,9 +2252,9 @@ sp_proc_stmt:
 
 	      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);
@@ -2311,23 +2312,23 @@ sp_proc_stmt:
 	      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, exclusive);
 	      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);
-              if (i == NULL)
+              if (i == NULL ||
+	          sp->push_backpatch(i, lab) ||  /* Jumping forward */
+                  sp->add_instr(i))
                 MYSQL_YYABORT;
-	      sp->push_backpatch(i, lab);  /* Jumping forward */
-              sp->add_instr(i);
 	    }
 	  }
 	| ITERATE_SYM label_ident
@@ -2352,22 +2353,22 @@ sp_proc_stmt:
 	      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);
 	    }
 	  }
 	| OPEN_SYM ident
@@ -2383,9 +2384,9 @@ sp_proc_stmt:
 	      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);
 	  }
 	| FETCH_SYM sp_opt_fetch_noise ident INTO
 	  {
@@ -2400,9 +2401,9 @@ sp_proc_stmt:
 	      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
 	  { }
@@ -2419,9 +2420,9 @@ sp_proc_stmt:
 	      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);
 	  }
 	;
 
@@ -2488,11 +2489,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
@@ -2501,9 +2502,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));
 	  }
@@ -2589,14 +2590,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;
           }
         ;
 
@@ -2609,14 +2612,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;
           }
         ;
 
@@ -2628,9 +2633,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
         ;
@@ -2744,17 +2749,17 @@ sp_block_content:
             {
               sp_instr_hpop *hpop= new sp_instr_hpop(sp->instructions(), ctx,
                                                      $3.hndlrs);
-              if (hpop == NULL)
+              if (hpop == NULL ||
+	          sp->add_instr(hpop))
                 MYSQL_YYABORT;
-	      sp->add_instr(hpop);
             }
 	    if ($3.curs)
             {
               sp_instr_cpop *cpop= new sp_instr_cpop(sp->instructions(), ctx,
                                                      $3.curs);
-              if (cpop == NULL)
+              if (cpop == NULL ||
+	          sp->add_instr(cpop))
                 MYSQL_YYABORT;
-	      sp->add_instr(cpop);
             }
 	    lex->spcont= ctx->pop_context();
 	  }
@@ -2768,9 +2773,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);
 	  }
         | WHILE_SYM 
           {
@@ -2784,12 +2789,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)
-              MYSQL_YYABORT;
+            if (i == NULL ||
 	    /* Jumping forward */
-	    sp->push_backpatch(i, lex->spcont->last_label());
-            sp->new_cont_backpatch(i);
-            sp->add_instr(i);
+                sp->push_backpatch(i, lex->spcont->last_label()) ||
+                sp->new_cont_backpatch(i) ||
+                sp->add_instr(i))
+              MYSQL_YYABORT;
             sp->restore_lex(YYTHD);
 	  }
 	  sp_proc_stmts1 END WHILE_SYM
@@ -2798,9 +2803,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 
@@ -2816,9 +2821,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;
@@ -9649,7 +9654,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);
           }
@@ -9731,7 +9737,8 @@ sys_option_value:
             lex->trg_table_fields.link_in_list((byte *)trg_fld,
                                     (byte **)&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 */
@@ -9761,11 +9768,12 @@ sys_option_value:
               it= spv->dflt;
             else
               it= new Item_null();
-            if (it == NULL)
+            if (it == NULL ||
+                (sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
+                                          spv->offset, it, spv->type, lex,
+                                          TRUE)) == NULL ||
+                lex->sphead->add_instr(sp_set))
               MYSQL_YYABORT;
-            sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
-                                     spv->offset, it, spv->type, lex, TRUE);
-            lex->sphead->add_instr(sp_set);
           }
         }
         | option_type TRANSACTION_SYM ISOLATION LEVEL_SYM isolation_types

=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c	2009-03-19 13:44:58 +0000
+++ b/tests/mysql_client_test.c	2009-04-30 07:52:27 +0000
@@ -15904,61 +15904,6 @@ static void test_bug28934()
 }
 
 
-#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;
-
-  if (mysql_stmt_bind_param(stmt, bind_param))
-  {
-    mysql_stmt_close(stmt);
-    DIE_UNLESS(0);
-  }
-
-  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)
 */
@@ -16945,9 +16890,6 @@ static struct my_tests_st my_tests[]= {
   { "test_bug32265", test_bug32265 },
   { "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

Thread
bzr commit into mysql-5.0-bugteam branch (aelkin:2731)Andrei Elkin30 Apr