1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge branch '10.1' into 10.2

This commit is contained in:
Sergei Golubchik
2016-02-25 18:19:55 +01:00
372 changed files with 10986 additions and 4523 deletions

View File

@ -15,6 +15,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#include <my_global.h>
#include <my_bit.h>
#include "rpl_utility.h"
#include "log_event.h"
@ -22,30 +23,6 @@
#include "rpl_rli.h"
#include "sql_select.h"
/**
Function to compare two size_t integers for their relative
order. Used below.
*/
int compare(size_t a, size_t b)
{
if (a < b)
return -1;
if (b < a)
return 1;
return 0;
}
/**
Max value for an unsigned integer of 'bits' bits.
The somewhat contorted expression is to avoid overflow.
*/
uint32 uint_max(int bits) {
return (((1UL << (bits - 1)) - 1) << 1) | 1;
}
/**
Calculate display length for MySQL56 temporal data types from their metadata.
It contains fractional precision in the low 16-bit word.
@ -121,20 +98,22 @@ max_display_length_for_field(enum_field_types sql_type, unsigned int metadata)
return 3;
case MYSQL_TYPE_DATE:
case MYSQL_TYPE_TIME:
return 3;
case MYSQL_TYPE_TIME:
return MIN_TIME_WIDTH;
case MYSQL_TYPE_TIME2:
return max_display_length_for_temporal2_field(MIN_TIME_WIDTH, metadata);
case MYSQL_TYPE_TIMESTAMP:
return 4;
return MAX_DATETIME_WIDTH;
case MYSQL_TYPE_TIMESTAMP2:
return max_display_length_for_temporal2_field(MAX_DATETIME_WIDTH, metadata);
case MYSQL_TYPE_DATETIME:
return 8;
return MAX_DATETIME_WIDTH;
case MYSQL_TYPE_DATETIME2:
return max_display_length_for_temporal2_field(MAX_DATETIME_WIDTH, metadata);
@ -160,10 +139,10 @@ max_display_length_for_field(enum_field_types sql_type, unsigned int metadata)
*/
case MYSQL_TYPE_TINY_BLOB:
return uint_max(1 * 8);
return my_set_bits(1 * 8);
case MYSQL_TYPE_MEDIUM_BLOB:
return uint_max(3 * 8);
return my_set_bits(3 * 8);
case MYSQL_TYPE_BLOB:
/*
@ -171,11 +150,11 @@ max_display_length_for_field(enum_field_types sql_type, unsigned int metadata)
blobs are of type MYSQL_TYPE_BLOB. In that case, we have to look
at the length instead to decide what the max display size is.
*/
return uint_max(metadata * 8);
return my_set_bits(metadata * 8);
case MYSQL_TYPE_LONG_BLOB:
case MYSQL_TYPE_GEOMETRY:
return uint_max(4 * 8);
return my_set_bits(4 * 8);
default:
return ~(uint32) 0;
@ -205,7 +184,7 @@ int compare_lengths(Field *field, enum_field_types source_type, uint16 metadata)
" target_length: %lu, target_type: %u",
(unsigned long) source_length, source_type,
(unsigned long) target_length, field->real_type()));
int result= compare(source_length, target_length);
int result= source_length < target_length ? -1 : source_length > target_length;
DBUG_PRINT("result", ("%d", result));
DBUG_RETURN(result);
}