Commit fe0d2e1a authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-13923 Assertion `!is_set() || (m_status == DA_OK_BULK &&

                    is_bulk_op())' failed upon altering table with geometry field.

        Check for the validity of the DEFAULT value for the
        geometry field.
parent dd85ec6f
......@@ -12,3 +12,27 @@ WHERE ST_Contains(point_data, GeomFromText('Point(38.0248492 23.8512726)'));
id
2
DROP TABLE t1;
create table t1 (p point default "qwer");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
create table t1 (p point default 0);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
create table t1 (p point not null default st_geometryfromtext('point 0)'));
ERROR 42000: Invalid default value for 'p'
create table t1 (p point not null default st_geometryfromtext('point(0 0)'));
insert into t1 values(default);
select st_astext(p) from t1;
st_astext(p)
POINT(0 0)
drop table t1;
create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
set timestamp=10;
insert into t1 values(default);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
SET timestamp=default;
create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
set timestamp=10;
alter table t1 add column i int;
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
SET timestamp=default;
......@@ -15,3 +15,31 @@ SELECT id FROM t1
WHERE ST_Contains(point_data, GeomFromText('Point(38.0248492 23.8512726)'));
DROP TABLE t1;
#
# MDEV-13923 Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon altering table with geometry field
#
--error ER_CANT_CREATE_GEOMETRY_OBJECT
create table t1 (p point default "qwer");
--error ER_CANT_CREATE_GEOMETRY_OBJECT
create table t1 (p point default 0);
--error ER_INVALID_DEFAULT
create table t1 (p point not null default st_geometryfromtext('point 0)'));
create table t1 (p point not null default st_geometryfromtext('point(0 0)'));
insert into t1 values(default);
select st_astext(p) from t1;
drop table t1;
create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
set timestamp=10;
--error ER_CANT_CREATE_GEOMETRY_OBJECT
insert into t1 values(default);
drop table t1;
SET timestamp=default;
create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),0));
set timestamp=10;
--error ER_CANT_CREATE_GEOMETRY_OBJECT
alter table t1 add column i int;
drop table t1;
SET timestamp=default;
......@@ -75,9 +75,9 @@ String *Item_func_geometry_from_text::val_str(String *str)
srid= (uint32)args[1]->val_int();
str->set_charset(&my_charset_bin);
str->length(0);
if (str->reserve(SRID_SIZE, 512))
return 0;
str->length(0);
str->q_append(srid);
if ((null_value= !Geometry::create_from_wkt(&buffer, &trs, str, 0)))
return 0;
......
......@@ -979,13 +979,17 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
null_count+= field->length & 7;
if (field->default_value && !field->default_value->flags &&
!(field->flags & BLOB_FLAG))
(!(field->flags & BLOB_FLAG) || field->sql_type == MYSQL_TYPE_GEOMETRY))
{
Item *expr= field->default_value->expr;
int res= !expr->fixed && // may be already fixed if ALTER TABLE
expr->fix_fields(thd, &expr);
if (!res)
res= expr->save_in_field(regfield, 1);
if (!res && (field->flags & BLOB_FLAG))
regfield->reset();
/* If not ok or warning of level 'note' */
if (res != 0 && res != 3)
{
......@@ -994,6 +998,7 @@ static bool make_empty_rec(THD *thd, uchar *buff, uint table_options,
delete regfield; //To avoid memory leak
goto err;
}
delete regfield; //To avoid memory leak
}
else if (regfield->real_type() == MYSQL_TYPE_ENUM &&
(field->flags & NOT_NULL_FLAG))
......
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