mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-19317 TEXT column accepts too long literals as a default value
Adding new virtual methods in Field: - make_empty_rec_store_default_value() - make_empty_rec_reset() This simplifies the logic for every Field type, and makes the code more friendly to pluggable data types.
This commit is contained in:
20
sql/field.cc
20
sql/field.cc
@ -1382,6 +1382,14 @@ error:
|
||||
}
|
||||
|
||||
|
||||
bool Field::make_empty_rec_store_default_value(THD *thd, Item *item)
|
||||
{
|
||||
DBUG_ASSERT(!(flags & BLOB_FLAG));
|
||||
int res= item->save_in_field(this, true);
|
||||
return res != 0 && res != 3;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Numeric fields base class constructor.
|
||||
*/
|
||||
@ -8773,6 +8781,18 @@ void Field_blob::make_send_field(Send_field *field)
|
||||
}
|
||||
|
||||
|
||||
bool Field_blob::make_empty_rec_store_default_value(THD *thd, Item *item)
|
||||
{
|
||||
DBUG_ASSERT(flags & BLOB_FLAG);
|
||||
int res= item->save_in_field(this, true);
|
||||
DBUG_ASSERT(res != 3); // Field_blob never returns 3
|
||||
if (res)
|
||||
return true; // E.g. truncation happened
|
||||
reset(); // Clear the pointer to a String, it should not be written to frm
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int Field_blob_compressed::store(const char *from, size_t length,
|
||||
CHARSET_INFO *cs)
|
||||
{
|
||||
|
Reference in New Issue
Block a user