summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2004-09-22 22:36:53 +0500
committerunknown <hf@deer.(none)>2004-09-22 22:36:53 +0500
commit126ea49d08dda845740c2f9c93531b69bc707873 (patch)
treeaa41988964c204abc8e7cd531addfd35f09a1f7d
parent871c5c0175cc579f355202464f9f858b473a9357 (diff)
downloadmariadb-git-126ea49d08dda845740c2f9c93531b69bc707873.tar.gz
Additional fix for bug #5136 (Geometry object is corrupted when queried)
CREATE TABLE t1 SELECT POINT(1,2); fixed mysql-test/r/gis.result: Appropriate test result mysql-test/t/gis.test: test case sql/item_geofunc.cc: Item_geometry_func::fix_lengths_and_dec implementation several fix_length_and_dec's not needed now sql/item_geofunc.h: Item_geometry_func class presented
-rw-r--r--mysql-test/r/gis.result7
-rw-r--r--mysql-test/t/gis.test4
-rw-r--r--sql/item_geofunc.cc25
-rw-r--r--sql/item_geofunc.h62
4 files changed, 50 insertions, 48 deletions
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 9f5dd286cf9..fd71cad36a6 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -485,3 +485,10 @@ MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
AsText(a)
POINT(1 1)
drop table t1;
+create table t1 select POINT(1,3);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `POINT(1,3)` longblob NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index e35b9996a44..30da019be3e 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -190,3 +190,7 @@ select AsText(a) from t1 where
and
MBRContains(GeomFromText('Polygon((0 0, 0 7, 7 7, 7 0, 0 0))'), a);
drop table t1;
+
+create table t1 select POINT(1,3);
+show create table t1;
+drop table t1;
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 790fdcd5cd1..935925c1e83 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -27,6 +27,13 @@
#include "sql_acl.h"
#include <m_ctype.h>
+void Item_geometry_func::fix_length_and_dec()
+{
+ collation.set(&my_charset_bin);
+ decimals=0;
+ max_length=MAX_BLOB_WIDTH;
+}
+
String *Item_func_geometry_from_text::val_str(String *str)
{
@@ -55,12 +62,6 @@ String *Item_func_geometry_from_text::val_str(String *str)
}
-void Item_func_geometry_from_text::fix_length_and_dec()
-{
- max_length=MAX_BLOB_WIDTH;
-}
-
-
String *Item_func_geometry_from_wkb::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -86,12 +87,6 @@ String *Item_func_geometry_from_wkb::val_str(String *str)
}
-void Item_func_geometry_from_wkb::fix_length_and_dec()
-{
- max_length=MAX_BLOB_WIDTH;
-}
-
-
String *Item_func_as_wkt::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
@@ -140,12 +135,6 @@ String *Item_func_as_wkb::val_str(String *str)
}
-void Item_func_as_wkb::fix_length_and_dec()
-{
- max_length= MAX_BLOB_WIDTH;
-}
-
-
String *Item_func_geometry_type::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index a1f36130152..79e4f804a04 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -23,24 +23,33 @@
#pragma interface /* gcc class implementation */
#endif
-class Item_func_geometry_from_text: public Item_str_func
+class Item_geometry_func: public Item_str_func
{
public:
- Item_func_geometry_from_text(Item *a) :Item_str_func(a) {}
- Item_func_geometry_from_text(Item *a, Item *srid) :Item_str_func(a, srid) {}
+ Item_geometry_func() :Item_str_func() {}
+ Item_geometry_func(Item *a) :Item_str_func(a) {}
+ Item_geometry_func(Item *a,Item *b) :Item_str_func(a,b) {}
+ Item_geometry_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
+ Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
+ void fix_length_and_dec();
+};
+
+class Item_func_geometry_from_text: public Item_geometry_func
+{
+public:
+ Item_func_geometry_from_text(Item *a) :Item_geometry_func(a) {}
+ Item_func_geometry_from_text(Item *a, Item *srid) :Item_geometry_func(a, srid) {}
const char *func_name() const { return "geometryfromtext"; }
String *val_str(String *);
- void fix_length_and_dec();
};
-class Item_func_geometry_from_wkb: public Item_str_func
+class Item_func_geometry_from_wkb: public Item_geometry_func
{
public:
- Item_func_geometry_from_wkb(Item *a): Item_str_func(a) {}
- Item_func_geometry_from_wkb(Item *a, Item *srid): Item_str_func(a, srid) {}
+ Item_func_geometry_from_wkb(Item *a): Item_geometry_func(a) {}
+ Item_func_geometry_from_wkb(Item *a, Item *srid): Item_geometry_func(a, srid) {}
const char *func_name() const { return "geometryfromwkb"; }
String *val_str(String *);
- void fix_length_and_dec();
};
class Item_func_as_wkt: public Item_str_func
@@ -52,13 +61,12 @@ public:
void fix_length_and_dec();
};
-class Item_func_as_wkb: public Item_str_func
+class Item_func_as_wkb: public Item_geometry_func
{
public:
- Item_func_as_wkb(Item *a): Item_str_func(a) {}
+ Item_func_as_wkb(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "aswkb"; }
String *val_str(String *);
- void fix_length_and_dec();
};
class Item_func_geometry_type: public Item_str_func
@@ -73,40 +81,37 @@ public:
};
};
-class Item_func_centroid: public Item_str_func
+class Item_func_centroid: public Item_geometry_func
{
public:
- Item_func_centroid(Item *a): Item_str_func(a) {}
+ Item_func_centroid(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "centroid"; }
String *val_str(String *);
- void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
-class Item_func_envelope: public Item_str_func
+class Item_func_envelope: public Item_geometry_func
{
public:
- Item_func_envelope(Item *a): Item_str_func(a) {}
+ Item_func_envelope(Item *a): Item_geometry_func(a) {}
const char *func_name() const { return "envelope"; }
String *val_str(String *);
- void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
-class Item_func_point: public Item_str_func
+class Item_func_point: public Item_geometry_func
{
public:
- Item_func_point(Item *a, Item *b): Item_str_func(a, b) {}
- Item_func_point(Item *a, Item *b, Item *srid): Item_str_func(a, b, srid) {}
+ Item_func_point(Item *a, Item *b): Item_geometry_func(a, b) {}
+ Item_func_point(Item *a, Item *b, Item *srid): Item_geometry_func(a, b, srid) {}
const char *func_name() const { return "point"; }
String *val_str(String *);
- void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
-class Item_func_spatial_decomp: public Item_str_func
+class Item_func_spatial_decomp: public Item_geometry_func
{
enum Functype decomp_func;
public:
Item_func_spatial_decomp(Item *a, Item_func::Functype ft) :
- Item_str_func(a) { decomp_func = ft; }
+ Item_geometry_func(a) { decomp_func = ft; }
const char *func_name() const
{
switch (decomp_func)
@@ -123,15 +128,14 @@ public:
}
}
String *val_str(String *);
- void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
-class Item_func_spatial_decomp_n: public Item_str_func
+class Item_func_spatial_decomp_n: public Item_geometry_func
{
enum Functype decomp_func_n;
public:
Item_func_spatial_decomp_n(Item *a, Item *b, Item_func::Functype ft):
- Item_str_func(a, b) { decomp_func_n = ft; }
+ Item_geometry_func(a, b) { decomp_func_n = ft; }
const char *func_name() const
{
switch (decomp_func_n)
@@ -148,10 +152,9 @@ public:
}
}
String *val_str(String *);
- void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
};
-class Item_func_spatial_collection: public Item_str_func
+class Item_func_spatial_collection: public Item_geometry_func
{
String tmp_value;
enum Geometry::wkbType coll_type;
@@ -159,13 +162,12 @@ class Item_func_spatial_collection: public Item_str_func
public:
Item_func_spatial_collection(
List<Item> &list, enum Geometry::wkbType ct, enum Geometry::wkbType it):
- Item_str_func(list)
+ Item_geometry_func(list)
{
coll_type=ct;
item_type=it;
}
String *val_str(String *);
- void fix_length_and_dec(){max_length=MAX_BLOB_WIDTH;}
const char *func_name() const { return "multipoint"; }
};