mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-19819 ALTER from POINT to LINESTRING erroneously preserves POINT values
This commit is contained 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)));
|
||||
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
|
||||
#
|
||||
|
@ -3094,6 +3094,25 @@ SELECT (1,0) IN ((POINT(1,1),0),(0,0));
|
||||
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
|
||||
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 # End of 10.4 tests
|
||||
--echo #
|
||||
|
@ -485,8 +485,7 @@ ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
|
||||
affected rows: 10
|
||||
info: Records: 10 Duplicates: 0 Warnings: 0
|
||||
ERROR 22007: Incorrect POLYGON value: 'LINESTRING' for column `test`.`tab`.`c3` at row 1
|
||||
ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
|
||||
affected rows: 0
|
||||
info: Records: 0 Duplicates: 0 Warnings: 0
|
||||
@ -528,7 +527,7 @@ Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` geometry NOT NULL,
|
||||
`c3` polygon NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` polygon NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
`c7` point NOT NULL,
|
||||
@ -565,7 +564,7 @@ Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` geometry NOT NULL,
|
||||
`c3` polygon NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
`c7` point NOT NULL,
|
||||
@ -614,9 +613,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
||||
ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL;
|
||||
affected rows: 8
|
||||
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;
|
||||
affected rows: 8
|
||||
info: Records: 8 Duplicates: 0 Warnings: 0
|
||||
|
@ -476,6 +476,7 @@ ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
||||
|
||||
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 add COLUMN c7 POINT NOT NULL;
|
||||
@ -552,8 +553,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
||||
--enable_info
|
||||
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;
|
||||
--disable_info
|
||||
|
||||
|
19
sql/field.h
19
sql/field.h
@ -1528,7 +1528,7 @@ public:
|
||||
{
|
||||
return field_length / charset()->mbmaxlen;
|
||||
}
|
||||
virtual geometry_type get_geometry_type()
|
||||
virtual geometry_type get_geometry_type() const
|
||||
{
|
||||
/* shouldn't get here. */
|
||||
DBUG_ASSERT(0);
|
||||
@ -4138,6 +4138,21 @@ public:
|
||||
const Item *item,
|
||||
bool is_eq_func) 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);
|
||||
int store(const char *to, size_t length, CHARSET_INFO *charset);
|
||||
int store(double nr);
|
||||
@ -4161,7 +4176,7 @@ public:
|
||||
bool load_data_set_null(THD *thd);
|
||||
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);
|
||||
uint get_srid() { return srid; }
|
||||
void print_key_value(String *out, uint32 length)
|
||||
|
Reference in New Issue
Block a user