mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Merge MySQL 5.1.46 into MariaDB.
Still two test failures to be solved: main.myisam and main.subselect.
This commit is contained in:
87
sql/field.cc
87
sql/field.cc
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
|
||||
/* Copyright (c) 2000, 2010 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
|
||||
@@ -1374,12 +1374,14 @@ bool Field::send_binary(Protocol *protocol)
|
||||
to the size of this field (the slave or destination).
|
||||
|
||||
@param field_metadata Encoded size in field metadata
|
||||
@param mflags Flags from the table map event for the table.
|
||||
|
||||
@retval 0 if this field's size is < the source field's size
|
||||
@retval 1 if this field's size is >= the source field's size
|
||||
*/
|
||||
int Field::compatible_field_size(uint field_metadata,
|
||||
const Relay_log_info *rli_arg __attribute__((unused)))
|
||||
const Relay_log_info *rli_arg __attribute__((unused)),
|
||||
uint16 mflags __attribute__((unused)))
|
||||
{
|
||||
uint const source_size= pack_length_from_metadata(field_metadata);
|
||||
uint const destination_size= row_pack_length();
|
||||
@@ -1706,11 +1708,10 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
|
||||
uint store_length;
|
||||
copy->str=ptr;
|
||||
copy->length=pack_length();
|
||||
copy->blob_field=0;
|
||||
copy->field= this;
|
||||
if (flags & BLOB_FLAG)
|
||||
{
|
||||
copy->blob_field=(Field_blob*) this;
|
||||
copy->strip=0;
|
||||
copy->type= CACHE_BLOB;
|
||||
copy->length-= table->s->blob_ptr_size;
|
||||
return copy->length;
|
||||
}
|
||||
@@ -1718,15 +1719,15 @@ uint Field::fill_cache_field(CACHE_FIELD *copy)
|
||||
(type() == MYSQL_TYPE_STRING && copy->length >= 4 &&
|
||||
copy->length < 256))
|
||||
{
|
||||
copy->strip=1; /* Remove end space */
|
||||
copy->type= CACHE_STRIPPED;
|
||||
store_length= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
copy->strip=0;
|
||||
copy->type= 0;
|
||||
store_length= 0;
|
||||
}
|
||||
return copy->length+ store_length;
|
||||
return copy->length + store_length;
|
||||
}
|
||||
|
||||
|
||||
@@ -2881,7 +2882,8 @@ uint Field_new_decimal::pack_length_from_metadata(uint field_metadata)
|
||||
@retval 1 if this field's size is >= the source field's size
|
||||
*/
|
||||
int Field_new_decimal::compatible_field_size(uint field_metadata,
|
||||
const Relay_log_info * __attribute__((unused)))
|
||||
const Relay_log_info * __attribute__((unused)),
|
||||
uint16 mflags __attribute__((unused)))
|
||||
{
|
||||
int compatible= 0;
|
||||
uint const source_precision= (field_metadata >> 8U) & 0x00ff;
|
||||
@@ -2946,16 +2948,16 @@ Field_new_decimal::unpack(uchar* to,
|
||||
a decimal and write that to the raw data buffer.
|
||||
*/
|
||||
decimal_digit_t dec_buf[DECIMAL_MAX_PRECISION];
|
||||
decimal_t dec;
|
||||
dec.len= from_precision;
|
||||
dec.buf= dec_buf;
|
||||
decimal_t dec_val;
|
||||
dec_val.len= from_precision;
|
||||
dec_val.buf= dec_buf;
|
||||
/*
|
||||
Note: bin2decimal does not change the length of the field. So it is
|
||||
just the first step the resizing operation. The second step does the
|
||||
resizing using the precision and decimals from the slave.
|
||||
*/
|
||||
bin2decimal((uchar *)from, &dec, from_precision, from_decimal);
|
||||
decimal2bin(&dec, to, precision, decimals());
|
||||
bin2decimal((uchar *)from, &dec_val, from_precision, from_decimal);
|
||||
decimal2bin(&dec_val, to, precision, decimals());
|
||||
}
|
||||
else
|
||||
memcpy(to, from, len); // Sizes are the same, just copy the data.
|
||||
@@ -6334,7 +6336,7 @@ check_string_copy_error(Field_str *field,
|
||||
|
||||
SYNOPSIS
|
||||
Field_longstr::report_if_important_data()
|
||||
ptr - Truncated rest of string
|
||||
pstr - Truncated rest of string
|
||||
end - End of truncated string
|
||||
count_spaces - Treat traling spaces as important data
|
||||
|
||||
@@ -6350,12 +6352,12 @@ check_string_copy_error(Field_str *field,
|
||||
*/
|
||||
|
||||
int
|
||||
Field_longstr::report_if_important_data(const char *ptr, const char *end,
|
||||
Field_longstr::report_if_important_data(const char *pstr, const char *end,
|
||||
bool count_spaces)
|
||||
{
|
||||
if ((ptr < end) && table->in_use->count_cuted_fields)
|
||||
if ((pstr < end) && table->in_use->count_cuted_fields)
|
||||
{
|
||||
if (test_if_important_data(field_charset, ptr, end))
|
||||
if (test_if_important_data(field_charset, pstr, end))
|
||||
{
|
||||
if (table->in_use->abort_on_warning)
|
||||
set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
|
||||
@@ -6661,7 +6663,8 @@ check_field_for_37426(const void *param_arg)
|
||||
#endif
|
||||
|
||||
int Field_string::compatible_field_size(uint field_metadata,
|
||||
const Relay_log_info *rli_arg)
|
||||
const Relay_log_info *rli_arg,
|
||||
uint16 mflags __attribute__((unused)))
|
||||
{
|
||||
#ifdef HAVE_REPLICATION
|
||||
const Check_field_param check_param = { this };
|
||||
@@ -6669,7 +6672,7 @@ int Field_string::compatible_field_size(uint field_metadata,
|
||||
check_field_for_37426, &check_param))
|
||||
return FALSE; // Not compatible field sizes
|
||||
#endif
|
||||
return Field::compatible_field_size(field_metadata, rli_arg);
|
||||
return Field::compatible_field_size(field_metadata, rli_arg, mflags);
|
||||
}
|
||||
|
||||
|
||||
@@ -7014,9 +7017,8 @@ const uint Field_varstring::MAX_SIZE= UINT_MAX16;
|
||||
*/
|
||||
int Field_varstring::do_save_field_metadata(uchar *metadata_ptr)
|
||||
{
|
||||
char *ptr= (char *)metadata_ptr;
|
||||
DBUG_ASSERT(field_length <= 65535);
|
||||
int2store(ptr, field_length);
|
||||
int2store((char*)metadata_ptr, field_length);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -9221,8 +9223,13 @@ uint Field_bit::get_key_image(uchar *buff, uint length, imagetype type_arg)
|
||||
*/
|
||||
int Field_bit::do_save_field_metadata(uchar *metadata_ptr)
|
||||
{
|
||||
*metadata_ptr= bit_len;
|
||||
*(metadata_ptr + 1)= bytes_in_rec;
|
||||
/*
|
||||
Since this class and Field_bit_as_char have different ideas of
|
||||
what should be stored here, we compute the values of the metadata
|
||||
explicitly using the field_length.
|
||||
*/
|
||||
metadata_ptr[0]= field_length % 8;
|
||||
metadata_ptr[1]= field_length / 8;
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -9262,20 +9269,26 @@ uint Field_bit::pack_length_from_metadata(uint field_metadata)
|
||||
@retval 1 if this field's size is >= the source field's size
|
||||
*/
|
||||
int Field_bit::compatible_field_size(uint field_metadata,
|
||||
const Relay_log_info * __attribute__((unused)))
|
||||
const Relay_log_info * __attribute__((unused)),
|
||||
uint16 mflags)
|
||||
{
|
||||
int compatible= 0;
|
||||
uint const source_size= pack_length_from_metadata(field_metadata);
|
||||
uint const destination_size= row_pack_length();
|
||||
uint const from_bit_len= field_metadata & 0x00ff;
|
||||
uint const from_len= (field_metadata >> 8U) & 0x00ff;
|
||||
if ((bit_len == 0) || (from_bit_len == 0))
|
||||
compatible= (source_size <= destination_size);
|
||||
else if (from_bit_len > bit_len)
|
||||
compatible= (from_len < bytes_in_rec);
|
||||
else
|
||||
compatible= ((from_bit_len <= bit_len) && (from_len <= bytes_in_rec));
|
||||
return (compatible);
|
||||
uint from_bit_len= 8 * (field_metadata >> 8) + (field_metadata & 0xff);
|
||||
uint to_bit_len= max_display_length();
|
||||
|
||||
/*
|
||||
If the bit length exact flag is clear, we are dealing with an old
|
||||
master, so we allow some less strict behaviour if replicating by
|
||||
moving both bit lengths to an even multiple of 8.
|
||||
|
||||
We do this by computing the number of bytes to store the field
|
||||
instead, and then compare the result.
|
||||
*/
|
||||
if (!(mflags & Table_map_log_event::TM_BIT_LEN_EXACT_F)) {
|
||||
from_bit_len= (from_bit_len + 7) / 8;
|
||||
to_bit_len= (to_bit_len + 7) / 8;
|
||||
}
|
||||
|
||||
return from_bit_len <= to_bit_len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user