From aec287fd670e7ee51c4ab7dfcd1b18da96ff3dea Mon Sep 17 00:00:00 2001
From: unknown <gkodinov/kgeorge@magare.gmz>
Date: Wed, 10 Oct 2007 16:26:02 +0300
Subject: Bug #30825: Problems when putting a non-spatial index on a GIS column
  Fixed the usage of spatial data (and Point in specific) with  non-spatial
 indexes.  Several problems :    - The length of the Point class was not
 updated to include the      spatial reference system identifier. Fixed by
 increasing with 4      bytes.    - The storage length of the spatial columns
 was not accounting for      the length that is prepended to it. Fixed by
 treating the      spatial data columns as blobs (and thus increasing the
 storage      length)    - When creating the key image for comparison in index
 read wrong      key image was created (the one needed for and r-tree search, 
     not the one for b-tree/other search). Fixed by treating the      spatial
 data columns as blobs (and creating the correct kind of      image based on
 the index type).

mysql-test/r/bdb_gis.result:
  Bug #30825: bdb tests
mysql-test/r/gis-rtree.result:
  Bug #30825: key length changed
mysql-test/r/gis.result:
  Bug #30825: MyISAM tests
mysql-test/r/innodb_gis.result:
  Bug #30825: InnoDB tests
mysql-test/t/bdb_gis.test:
  Bug #30825: bdb tests
mysql-test/t/gis.test:
  Bug #30825: MyISAM tests
mysql-test/t/innodb_gis.test:
  Bug #30825: InnoDB tests
sql/field.cc:
  Bug #30825: Removed Field_geom::get_key_image as Field_blog::get_key_image
    takes type parameter into consideration and is a superset of
    Field_geom::get_key_image()
sql/field.h:
  Bug #30825: Removed Field_geom::get_key_image as Field_blog::get_key_image
    takes type parameter into consideration and is a superset of
    Field_geom::get_key_image()
sql/sql_select.h:
  Bug #30825: Geometry data are a blob derivate
sql/sql_table.cc:
  Bug #30825: Increased key length to accomodate for
    spatial reference system identifier (srid)
sql/sql_yacc.yy:
  Bug #30825: Increased key length to accomodate for
    spatial reference system identifier (srid)
sql/table.cc:
  Bug #30825: It stores a length for spatial data
   as well, so increase the storage length (as it's
   done for blobs).
mysql-test/include/gis_keys.inc:
  Bug #30825: Test file for spatial data and non-spatial indexes
---
 sql/table.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'sql/table.cc')

diff --git a/sql/table.cc b/sql/table.cc
index a393f1a676b..7fe9aa774f3 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -732,9 +732,11 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat,
 	    keyinfo->key_length+= HA_KEY_NULL_LENGTH;
 	  }
 	  if (field->type() == FIELD_TYPE_BLOB ||
-	      field->real_type() == MYSQL_TYPE_VARCHAR)
+	      field->real_type() == MYSQL_TYPE_VARCHAR ||
+              field->type() == FIELD_TYPE_GEOMETRY)
 	  {
-	    if (field->type() == FIELD_TYPE_BLOB)
+	    if (field->type() == FIELD_TYPE_BLOB ||
+                field->type() == FIELD_TYPE_GEOMETRY)
 	      key_part->key_part_flag|= HA_BLOB_PART;
             else
               key_part->key_part_flag|= HA_VAR_LENGTH_PART;
-- 
cgit v1.2.1