From eb347921b736c06651189623b1dcd92a6d6d1039 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Nov 2007 10:51:47 +0400 Subject: Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) max_length parameter for BLOB-returning functions must be big enough for any possible content. Otherwise the field created for a table will be too small. mysql-test/r/gis.result: Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) test result mysql-test/t/gis.test: Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) test case sql/field.cc: Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) max_field_size used instead of numeric value sql/field.h: Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) max_field_size constant defined sql/item_geofunc.cc: Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) max_length parameter fixed --- mysql-test/r/gis.result | 26 +++++++++++++++++++++++++- mysql-test/t/gis.test | 31 +++++++++++++++++++++++++++++++ sql/field.cc | 2 +- sql/field.h | 1 + sql/item_geofunc.cc | 2 +- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 55f70e59fcf..ff4673d4c0f 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -668,7 +668,7 @@ def test t1 t1 g g 255 4294967295 0 Y 144 0 63 g select asbinary(g) from t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def asbinary(g) 252 8192 0 Y 128 0 63 +def asbinary(g) 252 4294967295 0 Y 128 0 63 asbinary(g) drop table t1; create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b)); @@ -730,4 +730,28 @@ select geomfromtext(col9,col89) as a from t1; a NULL DROP TABLE t1; +CREATE TABLE t1 ( +geomdata polygon NOT NULL, +SPATIAL KEY index_geom (geomdata) +) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED; +CREATE TABLE t2 ( +geomdata polygon NOT NULL, +SPATIAL KEY index_geom (geomdata) +) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED; +CREATE TABLE t3 +select +aswkb(ws.geomdata) AS geomdatawkb +from +t1 ws +union +select +aswkb(ws.geomdata) AS geomdatawkb +from +t2 ws; +describe t3; +Field Type Null Key Default Extra +geomdatawkb longblob YES NULL +drop table t1; +drop table t2; +drop table t3; End of 4.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index cf5c3b31bc1..3b9514bebbd 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -427,4 +427,35 @@ INSERT INTO `t1` VALUES ('','0000-00-00'); select geomfromtext(col9,col89) as a from t1; DROP TABLE t1; +# +# Bug #31158 Spatial, Union, LONGBLOB vs BLOB bug (crops data) +# + +CREATE TABLE t1 ( + geomdata polygon NOT NULL, + SPATIAL KEY index_geom (geomdata) +) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED; + +CREATE TABLE t2 ( + geomdata polygon NOT NULL, + SPATIAL KEY index_geom (geomdata) +) ENGINE=MyISAM DEFAULT CHARSET=latin2 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED; + +CREATE TABLE t3 +select + aswkb(ws.geomdata) AS geomdatawkb + from + t1 ws +union + select + aswkb(ws.geomdata) AS geomdatawkb + from + t2 ws; + +describe t3; + +drop table t1; +drop table t2; +drop table t3; + --echo End of 4.1 tests diff --git a/sql/field.cc b/sql/field.cc index 5b43b9b1955..ed6523e9299 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -6975,7 +6975,7 @@ uint32 Field_blob::max_length() case 3: return 16777215 * field_charset->mbmaxlen; case 4: - return (uint32) 4294967295U; + return max_field_size; default: DBUG_ASSERT(0); // we should never go here return 0; diff --git a/sql/field.h b/sql/field.h index 20f1209a439..29be9ef38d4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -26,6 +26,7 @@ #define NOT_FIXED_DEC 31 #define DATETIME_DEC 6 +const uint32 max_field_size= (uint32) 4294967295U; class Send_field; class Protocol; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 6cb8c790319..7900396e5d8 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -29,7 +29,7 @@ void Item_geometry_func::fix_length_and_dec() { collation.set(&my_charset_bin); decimals=0; - max_length=MAX_BLOB_WIDTH; + max_length= max_field_size; maybe_null= 1; } -- cgit v1.2.1 From 8a8d634b23f38b1d7eb454036fc734e8e7d27966 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Nov 2007 17:11:05 +0400 Subject: merging --- mysql-test/r/gis.result | 66 ++----------------------------------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 334a285b93f..84b7b449cb5 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -680,7 +680,7 @@ def test t1 t1 g g 255 4294967295 0 Y 144 0 63 g select asbinary(g) from t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def asbinary(g) 252 8192 0 Y 128 0 63 +def asbinary(g) 252 4294967295 0 Y 128 0 63 asbinary(g) drop table t1; create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b)); @@ -730,69 +730,6 @@ point(b, b) IS NULL linestring(b) IS NULL polygon(b) IS NULL multipoint(b) IS NU 1 1 1 1 1 1 1 0 1 1 1 1 1 1 drop table t1; -select (asWKT(geomfromwkb((0x000000000140240000000000004024000000000000)))); -(asWKT(geomfromwkb((0x000000000140240000000000004024000000000000)))) -POINT(10 10) -select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440)))); -(asWKT(geomfromwkb((0x010100000000000000000024400000000000002440)))) -POINT(10 10) -create table t1 (g GEOMETRY); -select * from t1; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def test t1 t1 g g 255 4294967295 0 Y 144 0 63 -g -select asbinary(g) from t1; -Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr -def asbinary(g) 252 4294967295 0 Y 128 0 63 -asbinary(g) -drop table t1; -create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b)); -alter table t1 disable keys; -load data infile '../../std_data/bad_gis_data.dat' into table t1; -ERROR 01000: Data truncated; NULL supplied to NOT NULL column 'b' at row 1 -alter table t1 enable keys; -drop table t1; -create table t1 (a int, b blob); -insert into t1 values (1, ''), (2, NULL), (3, '1'); -select * from t1; -a b -1 -2 NULL -3 1 -select -geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL, -aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL, -envelope(b) IS NULL, startpoint(b) IS NULL, endpoint(b) IS NULL, -exteriorring(b) IS NULL, pointn(b, 1) IS NULL, geometryn(b, 1) IS NULL, -interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, isempty(b) IS NULL, -issimple(b) IS NULL, isclosed(b) IS NULL, dimension(b) IS NULL, -numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL, -area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL, -y(b) IS NULL -from t1; -geometryfromtext(b) IS NULL geometryfromwkb(b) IS NULL astext(b) IS NULL aswkb(b) IS NULL geometrytype(b) IS NULL centroid(b) IS NULL envelope(b) IS NULL startpoint(b) IS NULL endpoint(b) IS NULL exteriorring(b) IS NULL pointn(b, 1) IS NULL geometryn(b, 1) IS NULL interiorringn(b, 1) IS NULL multipoint(b) IS NULL isempty(b) IS NULL issimple(b) IS NULL isclosed(b) IS NULL dimension(b) IS NULL numgeometries(b) IS NULL numinteriorrings(b) IS NULL numpoints(b) IS NULL area(b) IS NULL glength(b) IS NULL srid(b) IS NULL x(b) IS NULL y(b) IS NULL -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -select -within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL, -equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL, -intersects(b, b) IS NULL, crosses(b, b) IS NULL -from t1; -within(b, b) IS NULL contains(b, b) IS NULL overlaps(b, b) IS NULL equals(b, b) IS NULL disjoint(b, b) IS NULL touches(b, b) IS NULL intersects(b, b) IS NULL crosses(b, b) IS NULL -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 -select -point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL, -multilinestring(b) IS NULL, multipolygon(b) IS NULL, -geometrycollection(b) IS NULL -from t1; -point(b, b) IS NULL linestring(b) IS NULL polygon(b) IS NULL multipoint(b) IS NULL multilinestring(b) IS NULL multipolygon(b) IS NULL geometrycollection(b) IS NULL -0 1 1 1 1 1 1 -1 1 1 1 1 1 1 -0 1 1 1 1 1 1 -drop table t1; CREATE TABLE t1(a POINT) ENGINE=MyISAM; INSERT INTO t1 VALUES (NULL); SELECT * FROM t1; @@ -1020,3 +957,4 @@ COUNT(*) 2 DROP TABLE t1, t2; End of 5.0 tests +End of 5.0 tests -- cgit v1.2.1