diff options
author | Alexander Barkov <bar@mnogosearch.org> | 2013-12-06 19:02:55 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mnogosearch.org> | 2013-12-06 19:02:55 +0400 |
commit | 1f4f425a2007c51eeee35f911a787fc7d82d977c (patch) | |
tree | ff5d6bbb9301e1eb0bcab28cc0a49464d37a9ada /sql/rpl_utility.cc | |
parent | 0afd2920738877f901ec224d0d75ad0205a501ef (diff) | |
download | mariadb-git-1f4f425a2007c51eeee35f911a787fc7d82d977c.tar.gz |
MDEV-5297 TIME(0), TIMESTAMP(0) and DATETIME(0) are self-incompatible during replication (upstream)
Fixed.
Diffstat (limited to 'sql/rpl_utility.cc')
-rw-r--r-- | sql/rpl_utility.cc | 58 |
1 files changed, 45 insertions, 13 deletions
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 590a5ae06ac..1f67dd6ee8f 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -47,6 +47,19 @@ uint32 uint_max(int bits) { /** + Calculate display length for MySQL56 temporal data types from their metadata. + It contains fractional precision in the low 16-bit word. +*/ +static uint32 +max_display_length_for_temporal2_field(uint32 int_display_length, + unsigned int metadata) +{ + metadata&= 0x00ff; + return int_display_length + metadata + (metadata ? 1 : 0); +} + + +/** Compute the maximum display length of a field. @param sql_type Type of the field @@ -109,17 +122,23 @@ max_display_length_for_field(enum_field_types sql_type, unsigned int metadata) case MYSQL_TYPE_DATE: case MYSQL_TYPE_TIME: - case MYSQL_TYPE_TIME2: return 3; + case MYSQL_TYPE_TIME2: + return max_display_length_for_temporal2_field(MIN_TIME_WIDTH, metadata); + case MYSQL_TYPE_TIMESTAMP: - case MYSQL_TYPE_TIMESTAMP2: return 4; + case MYSQL_TYPE_TIMESTAMP2: + return max_display_length_for_temporal2_field(MAX_DATETIME_WIDTH, metadata); + case MYSQL_TYPE_DATETIME: - case MYSQL_TYPE_DATETIME2: return 8; + case MYSQL_TYPE_DATETIME2: + return max_display_length_for_temporal2_field(MAX_DATETIME_WIDTH, metadata); + case MYSQL_TYPE_BIT: /* Decode the size of the bit field from the master. @@ -630,19 +649,32 @@ can_convert_field_to(Field *field, else DBUG_RETURN(false); } - else if (metadata == 0 && - ((field->real_type() == MYSQL_TYPE_TIMESTAMP2 && - source_type == MYSQL_TYPE_TIMESTAMP) || - (field->real_type() == MYSQL_TYPE_TIME2 && - source_type == MYSQL_TYPE_TIME) || - (field->real_type() == MYSQL_TYPE_DATETIME2 && - source_type == MYSQL_TYPE_DATETIME))) + else if ( + /* + Conversion from MariaDB TIMESTAMP(0), TIME(0), DATETIME(0) + to the corresponding MySQL56 types is non-lossy. + */ + (metadata == 0 && + ((field->real_type() == MYSQL_TYPE_TIMESTAMP2 && + source_type == MYSQL_TYPE_TIMESTAMP) || + (field->real_type() == MYSQL_TYPE_TIME2 && + source_type == MYSQL_TYPE_TIME) || + (field->real_type() == MYSQL_TYPE_DATETIME2 && + source_type == MYSQL_TYPE_DATETIME))) || + /* + Conversion from MySQL56 TIMESTAMP(N), TIME(N), DATETIME(N) + to the corresponding MariaDB or MySQL55 types is non-lossy. + */ + (metadata == field->decimals() && + ((field->real_type() == MYSQL_TYPE_TIMESTAMP && + source_type == MYSQL_TYPE_TIMESTAMP2) || + (field->real_type() == MYSQL_TYPE_TIME && + source_type == MYSQL_TYPE_TIME2) || + (field->real_type() == MYSQL_TYPE_DATETIME && + source_type == MYSQL_TYPE_DATETIME2)))) { /* TS-TODO: conversion from FSP1>FSP2. - Can do non-lossy conversion - from old TIME, TIMESTAMP, DATETIME - to MySQL56 TIME(0), TIMESTAMP(0), DATETIME(0). */ *order_var= -1; DBUG_RETURN(true); |