summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc65
1 files changed, 32 insertions, 33 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 429d914db97..a718a402897 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -118,12 +118,12 @@ set_field_to_null(Field *field)
return 0;
}
field->reset();
- if (current_thd->count_cuted_fields == CHECK_FIELD_WARN)
+ if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN)
{
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
return 0;
}
- if (!current_thd->no_errors)
+ if (!field->table->in_use->no_errors)
my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
return -1;
}
@@ -164,7 +164,7 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
when set to NULL (TIMESTAMP fields which allow setting to NULL
are handled by first check).
*/
- if (field->type() == FIELD_TYPE_TIMESTAMP)
+ if (field->type() == MYSQL_TYPE_TIMESTAMP)
{
((Field_timestamp*) field)->set_time();
return 0; // Ok to set time to NULL
@@ -175,13 +175,12 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
field->table->auto_increment_field_not_null= FALSE;
return 0; // field is set in fill_record()
}
- if (current_thd->count_cuted_fields == CHECK_FIELD_WARN)
+ if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN)
{
- field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_NULL_TO_NOTNULL, 1);
+ field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_NULL_ERROR, 1);
return 0;
}
- if (!current_thd->no_errors)
+ if (!field->table->in_use->no_errors)
my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name);
return -1;
}
@@ -425,7 +424,7 @@ static void do_varstring1(Copy_field *copy)
if (length > copy->to_length- 1)
{
length=copy->to_length - 1;
- if (current_thd->count_cuted_fields)
+ if (copy->from_field->table->in_use->count_cuted_fields)
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1);
}
@@ -440,7 +439,7 @@ static void do_varstring2(Copy_field *copy)
if (length > copy->to_length- HA_KEY_BLOB_LENGTH)
{
length=copy->to_length-HA_KEY_BLOB_LENGTH;
- if (current_thd->count_cuted_fields)
+ if (copy->from_field->table->in_use->count_cuted_fields)
copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN,
WARN_DATA_TRUNCATED, 1);
}
@@ -507,7 +506,7 @@ void Copy_field::set(char *to,Field *from)
void Copy_field::set(Field *to,Field *from,bool save)
{
- if (to->type() == FIELD_TYPE_NULL)
+ if (to->type() == MYSQL_TYPE_NULL)
{
to_null_ptr=0; // For easy debugging
to_ptr=0;
@@ -541,7 +540,7 @@ void Copy_field::set(Field *to,Field *from,bool save)
}
else
{
- if (to_field->type() == FIELD_TYPE_TIMESTAMP)
+ if (to_field->type() == MYSQL_TYPE_TIMESTAMP)
do_copy= do_copy_timestamp; // Automatic timestamp
else if (to_field == to_field->table->next_number_field)
do_copy= do_copy_next_number;
@@ -585,8 +584,8 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
}
else
{
- if (to->real_type() == FIELD_TYPE_BIT ||
- from->real_type() == FIELD_TYPE_BIT)
+ if (to->real_type() == MYSQL_TYPE_BIT ||
+ from->real_type() == MYSQL_TYPE_BIT)
return do_field_int;
if (to->result_type() == DECIMAL_RESULT)
return do_field_decimal;
@@ -610,17 +609,17 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
!compatible_db_low_byte_first ||
((to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) &&
- to->type() == FIELD_TYPE_DATE ||
- to->type() == FIELD_TYPE_DATETIME))
+ to->type() == MYSQL_TYPE_DATE ||
+ to->type() == MYSQL_TYPE_DATETIME))
{
- if (from->real_type() == FIELD_TYPE_ENUM ||
- from->real_type() == FIELD_TYPE_SET)
+ if (from->real_type() == MYSQL_TYPE_ENUM ||
+ from->real_type() == MYSQL_TYPE_SET)
if (to->result_type() != STRING_RESULT)
return do_field_int; // Convert SET to number
return do_field_string;
}
- if (to->real_type() == FIELD_TYPE_ENUM ||
- to->real_type() == FIELD_TYPE_SET)
+ if (to->real_type() == MYSQL_TYPE_ENUM ||
+ to->real_type() == MYSQL_TYPE_SET)
{
if (!to->eq_def(from))
return do_field_string;
@@ -642,7 +641,7 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
do_cut_string : do_cut_string_complex);
else if (to_length > from_length)
{
- if ((to->flags & BINARY_FLAG) != 0)
+ if (to->charset() == &my_charset_bin)
return do_expand_binary;
else
return do_expand_string;
@@ -653,7 +652,7 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
to_length != from_length ||
!compatible_db_low_byte_first)
{
- if (to->real_type() == FIELD_TYPE_DECIMAL ||
+ if (to->real_type() == MYSQL_TYPE_DECIMAL ||
to->result_type() == STRING_RESULT)
return do_field_string;
if (to->result_type() == INT_RESULT)
@@ -664,7 +663,7 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
{
if (!to->eq_def(from) || !compatible_db_low_byte_first)
{
- if (to->real_type() == FIELD_TYPE_DECIMAL)
+ if (to->real_type() == MYSQL_TYPE_DECIMAL)
return do_field_string;
if (to->result_type() == INT_RESULT)
return do_field_int;
@@ -691,22 +690,22 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*)
int field_conv(Field *to,Field *from)
{
if (to->real_type() == from->real_type() &&
- !(to->type() == FIELD_TYPE_BLOB && to->table->copy_blobs))
+ !(to->type() == MYSQL_TYPE_BLOB && to->table->copy_blobs))
{
if (to->pack_length() == from->pack_length() &&
!(to->flags & UNSIGNED_FLAG && !(from->flags & UNSIGNED_FLAG)) &&
- to->real_type() != FIELD_TYPE_ENUM &&
- to->real_type() != FIELD_TYPE_SET &&
- to->real_type() != FIELD_TYPE_BIT &&
- (to->real_type() != FIELD_TYPE_NEWDECIMAL ||
+ to->real_type() != MYSQL_TYPE_ENUM &&
+ to->real_type() != MYSQL_TYPE_SET &&
+ to->real_type() != MYSQL_TYPE_BIT &&
+ (to->real_type() != MYSQL_TYPE_NEWDECIMAL ||
(to->field_length == from->field_length &&
(((Field_num*)to)->dec == ((Field_num*)from)->dec))) &&
from->charset() == to->charset() &&
to->table->s->db_low_byte_first == from->table->s->db_low_byte_first &&
(!(to->table->in_use->variables.sql_mode &
(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE | MODE_INVALID_DATES)) ||
- to->type() != FIELD_TYPE_DATE &&
- to->type() != FIELD_TYPE_DATETIME) &&
+ to->type() != MYSQL_TYPE_DATE &&
+ to->type() != MYSQL_TYPE_DATETIME) &&
(from->real_type() != MYSQL_TYPE_VARCHAR ||
((Field_varstring*)from)->length_bytes ==
((Field_varstring*)to)->length_bytes))
@@ -719,7 +718,7 @@ int field_conv(Field *to,Field *from)
return 0;
}
}
- if (to->type() == FIELD_TYPE_BLOB)
+ if (to->type() == MYSQL_TYPE_BLOB)
{ // Be sure the value is stored
Field_blob *blob=(Field_blob*) to;
from->val_str(&blob->value);
@@ -736,9 +735,9 @@ int field_conv(Field *to,Field *from)
}
if ((from->result_type() == STRING_RESULT &&
(to->result_type() == STRING_RESULT ||
- (from->real_type() != FIELD_TYPE_ENUM &&
- from->real_type() != FIELD_TYPE_SET))) ||
- to->type() == FIELD_TYPE_DECIMAL)
+ (from->real_type() != MYSQL_TYPE_ENUM &&
+ from->real_type() != MYSQL_TYPE_SET))) ||
+ to->type() == MYSQL_TYPE_DECIMAL)
{
char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),from->charset());