mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
bug #20691 (INSERT (DEFAULT) may insert garbage with NO DEFAULT NOT NULL field)
Some fields (GEOMETRY first of all) can't be handled properly in this case at all. So we return an error in this case
This commit is contained in:
parent
d1185aaeaf
commit
8299b596ae
5 changed files with 39 additions and 3 deletions
|
@ -193,6 +193,16 @@ a b c d e f g h i x
|
|||
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 1
|
||||
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 2
|
||||
two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 3
|
||||
small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4
|
||||
00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4
|
||||
drop table bug20691;
|
||||
create table t1 (id int not null);
|
||||
insert into t1 values(default);
|
||||
Warnings:
|
||||
Warning 1364 Field 'id' doesn't have a default value
|
||||
create view v1 (c) as select id from t1;
|
||||
insert into t1 values(default);
|
||||
Warnings:
|
||||
Warning 1364 Field 'id' doesn't have a default value
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
End of 5.0 tests.
|
||||
|
|
|
@ -717,3 +717,7 @@ desc t1;
|
|||
Field Type Null Key Default Extra
|
||||
GeomFromText('point(1 1)') geometry NO
|
||||
drop table t1;
|
||||
create table t1 (g geometry not null);
|
||||
insert into t1 values(default);
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
drop table t1;
|
||||
|
|
|
@ -137,6 +137,13 @@ insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAUL
|
|||
select * from bug20691 order by x asc;
|
||||
drop table bug20691;
|
||||
|
||||
###
|
||||
create table t1 (id int not null);
|
||||
insert into t1 values(default);
|
||||
|
||||
create view v1 (c) as select id from t1;
|
||||
insert into t1 values(default);
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
||||
|
|
|
@ -428,3 +428,12 @@ drop table t1;
|
|||
create table t1 select GeomFromText('point(1 1)');
|
||||
desc t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #20691 (DEFAULT over NOT NULL field)
|
||||
#
|
||||
create table t1 (g geometry not null);
|
||||
--error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
insert into t1 values(default);
|
||||
drop table t1;
|
||||
|
||||
|
|
|
@ -5505,6 +5505,13 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
|
|||
{
|
||||
if (field_arg->flags & NO_DEFAULT_VALUE_FLAG)
|
||||
{
|
||||
if (field_arg->reset())
|
||||
{
|
||||
my_message(ER_CANT_CREATE_GEOMETRY_OBJECT,
|
||||
ER(ER_CANT_CREATE_GEOMETRY_OBJECT), MYF(0));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (context->error_processor == &view_error_processor)
|
||||
{
|
||||
TABLE_LIST *view= cached_table->top_table();
|
||||
|
@ -5523,7 +5530,6 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions)
|
|||
ER(ER_NO_DEFAULT_FOR_FIELD),
|
||||
field_arg->field_name);
|
||||
}
|
||||
field_arg->set_default();
|
||||
return 1;
|
||||
}
|
||||
field_arg->set_default();
|
||||
|
|
Loading…
Reference in a new issue