mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 23:25:34 +02:00
BUG#27788685: NO WARNING WHEN TRUNCATING A STRING WITH DATA
LOSS ANALYSIS: ========= When converting from a BLOB/TEXT type to a smaller BLOB/TEXT type, no warning/error is reported to the user informing about the truncation/data loss. FIX: ==== We are now reporting a warning in non-strict mode and an appropriate error in strict mode.
This commit is contained in:
parent
8a7db4c320
commit
1501557987
4 changed files with 118 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -287,9 +287,23 @@ static void do_copy_next_number(Copy_field *copy)
|
|||
|
||||
static void do_copy_blob(Copy_field *copy)
|
||||
{
|
||||
ulong length=((Field_blob*) copy->from_field)->get_length();
|
||||
((Field_blob*) copy->to_field)->store_length(length);
|
||||
ulong from_length=((Field_blob*) copy->from_field)->get_length();
|
||||
((Field_blob*) copy->to_field)->store_length(from_length);
|
||||
memcpy(copy->to_ptr, copy->from_ptr, sizeof(char*));
|
||||
ulong to_length=((Field_blob*) copy->to_field)->get_length();
|
||||
if (to_length < from_length)
|
||||
{
|
||||
if (copy->to_field->table->in_use->abort_on_warning)
|
||||
{
|
||||
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
ER_DATA_TOO_LONG, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
|
||||
WARN_DATA_TRUNCATED, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void do_conv_blob(Copy_field *copy)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue