Commit e9a692fe authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19819 ALTER from POINT to LINESTRING erroneously preserves POINT values

parent 8b576616
...@@ -5019,5 +5019,21 @@ ERROR HY000: Illegal parameter data types int and geometry for operation 'in' ...@@ -5019,5 +5019,21 @@ ERROR HY000: Illegal parameter data types int and geometry for operation 'in'
SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0))); SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0)));
ERROR HY000: Illegal parameter data types int and geometry for operation 'in' ERROR HY000: Illegal parameter data types int and geometry for operation 'in'
# #
# MDEV-19819 ALTER from POINT to LINESTRING erroneously preserves POINT values
#
CREATE TABLE t1 (a POINT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (Point(0,0));
ALTER TABLE t1 MODIFY a LINESTRING;
ERROR 22007: Incorrect LINESTRING value: 'POINT' for column `test`.`t1`.`a` at row 1
DROP TABLE t1;
CREATE TABLE t1 (a LINESTRING);
CREATE TABLE t2 (a POINT);
INSERT INTO t2 VALUES (POINT(0,0));
INSERT INTO t1 SELECT * FROM t2;
ERROR 22007: Incorrect LINESTRING value: 'POINT' for column `test`.`t1`.`a` at row 1
SELECT AsText(a) FROM t1;
AsText(a)
DROP TABLE t1, t2;
#
# End of 10.4 tests # End of 10.4 tests
# #
...@@ -3094,6 +3094,25 @@ SELECT (1,0) IN ((POINT(1,1),0),(0,0)); ...@@ -3094,6 +3094,25 @@ SELECT (1,0) IN ((POINT(1,1),0),(0,0));
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION --error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0))); SELECT (1,(0,0)) IN ((1,(POINT(1,1),0)),(0,(0,0)));
--echo #
--echo # MDEV-19819 ALTER from POINT to LINESTRING erroneously preserves POINT values
--echo #
CREATE TABLE t1 (a POINT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (Point(0,0));
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
ALTER TABLE t1 MODIFY a LINESTRING;
DROP TABLE t1;
CREATE TABLE t1 (a LINESTRING);
CREATE TABLE t2 (a POINT);
INSERT INTO t2 VALUES (POINT(0,0));
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
INSERT INTO t1 SELECT * FROM t2;
SELECT AsText(a) FROM t1;
DROP TABLE t1, t2;
--echo # --echo #
--echo # End of 10.4 tests --echo # End of 10.4 tests
--echo # --echo #
...@@ -485,8 +485,7 @@ ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL; ...@@ -485,8 +485,7 @@ ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL; ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
affected rows: 10 ERROR 22007: Incorrect POLYGON value: 'LINESTRING' for column `test`.`tab`.`c3` at row 1
info: Records: 10 Duplicates: 0 Warnings: 0
ALTER TABLE tab add COLUMN c7 POINT NOT NULL; ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
...@@ -528,7 +527,7 @@ Table Create Table ...@@ -528,7 +527,7 @@ Table Create Table
tab CREATE TABLE `tab` ( tab CREATE TABLE `tab` (
`c1` int(11) NOT NULL, `c1` int(11) NOT NULL,
`c2` geometry NOT NULL, `c2` geometry NOT NULL,
`c3` polygon NOT NULL, `c3` linestring NOT NULL,
`c4` polygon NOT NULL, `c4` polygon NOT NULL,
`c5` geometry NOT NULL, `c5` geometry NOT NULL,
`c7` point NOT NULL, `c7` point NOT NULL,
...@@ -565,7 +564,7 @@ Table Create Table ...@@ -565,7 +564,7 @@ Table Create Table
tab CREATE TABLE `tab` ( tab CREATE TABLE `tab` (
`c1` int(11) NOT NULL, `c1` int(11) NOT NULL,
`c2` geometry NOT NULL, `c2` geometry NOT NULL,
`c3` polygon NOT NULL, `c3` linestring NOT NULL,
`c4` geometry NOT NULL, `c4` geometry NOT NULL,
`c5` geometry NOT NULL, `c5` geometry NOT NULL,
`c7` point NOT NULL, `c7` point NOT NULL,
...@@ -614,9 +613,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)'); ...@@ -614,9 +613,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL; ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL;
affected rows: 8 affected rows: 8
info: Records: 8 Duplicates: 0 Warnings: 0 info: Records: 8 Duplicates: 0 Warnings: 0
ALTER TABLE tab MODIFY COLUMN c3 LINESTRING NOT NULL;
affected rows: 8
info: Records: 8 Duplicates: 0 Warnings: 0
ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL; ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL;
affected rows: 8 affected rows: 8
info: Records: 8 Duplicates: 0 Warnings: 0 info: Records: 8 Duplicates: 0 Warnings: 0
......
...@@ -476,6 +476,7 @@ ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; ...@@ -476,6 +476,7 @@ ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL; ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD
ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL; ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
ALTER TABLE tab add COLUMN c7 POINT NOT NULL; ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
...@@ -552,8 +553,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)'); ...@@ -552,8 +553,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
--enable_info --enable_info
ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL; ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL;
ALTER TABLE tab MODIFY COLUMN c3 LINESTRING NOT NULL;
ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL; ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL;
--disable_info --disable_info
......
...@@ -1528,7 +1528,7 @@ class Field: public Value_source ...@@ -1528,7 +1528,7 @@ class Field: public Value_source
{ {
return field_length / charset()->mbmaxlen; return field_length / charset()->mbmaxlen;
} }
virtual geometry_type get_geometry_type() virtual geometry_type get_geometry_type() const
{ {
/* shouldn't get here. */ /* shouldn't get here. */
DBUG_ASSERT(0); DBUG_ASSERT(0);
...@@ -4138,6 +4138,21 @@ class Field_geom :public Field_blob { ...@@ -4138,6 +4138,21 @@ class Field_geom :public Field_blob {
const Item *item, const Item *item,
bool is_eq_func) const; bool is_eq_func) const;
void sql_type(String &str) const; void sql_type(String &str) const;
Copy_func *get_copy_func(const Field *from) const
{
if (type_handler() == from->type_handler() &&
(geom_type == GEOM_GEOMETRY ||
geom_type == static_cast<const Field_geom*>(from)->geom_type))
return get_identical_copy_func();
return do_conv_blob;
}
bool memcpy_field_possible(const Field *from) const
{
return type_handler() == from->type_handler() &&
(geom_type == GEOM_GEOMETRY ||
geom_type == static_cast<const Field_geom*>(from)->geom_type) &&
!table->copy_blobs;
}
uint is_equal(Create_field *new_field); uint is_equal(Create_field *new_field);
int store(const char *to, size_t length, CHARSET_INFO *charset); int store(const char *to, size_t length, CHARSET_INFO *charset);
int store(double nr); int store(double nr);
...@@ -4161,7 +4176,7 @@ class Field_geom :public Field_blob { ...@@ -4161,7 +4176,7 @@ class Field_geom :public Field_blob {
bool load_data_set_null(THD *thd); bool load_data_set_null(THD *thd);
bool load_data_set_no_data(THD *thd, bool fixed_format); bool load_data_set_no_data(THD *thd, bool fixed_format);
geometry_type get_geometry_type() { return geom_type; }; geometry_type get_geometry_type() const { return geom_type; };
static geometry_type geometry_type_merge(geometry_type, geometry_type); static geometry_type geometry_type_merge(geometry_type, geometry_type);
uint get_srid() { return srid; } uint get_srid() { return srid; }
void print_key_value(String *out, uint32 length) void print_key_value(String *out, uint32 length)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment