summaryrefslogtreecommitdiff
path: root/sql/rpl_utility.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2016-02-25 18:19:55 +0100
committerSergei Golubchik <serg@mariadb.org>2016-02-25 18:19:55 +0100
commit00d1db7a38b17d4512a6ba5147926608aca5624d (patch)
treec2b28145304e9eacf79fcabaeb962a20d79fec93 /sql/rpl_utility.cc
parent0485328d030f4b742dac7b667e8ed099beb9e9f2 (diff)
parent0251232f8c3bca33b4dd15d6668105f3de9d024d (diff)
downloadmariadb-git-00d1db7a38b17d4512a6ba5147926608aca5624d.tar.gz
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/rpl_utility.cc')
-rw-r--r--sql/rpl_utility.cc43
1 files changed, 11 insertions, 32 deletions
diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc
index 244363e43ac..bdf5b7dea80 100644
--- a/sql/rpl_utility.cc
+++ b/sql/rpl_utility.cc
@@ -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"
@@ -23,30 +24,6 @@
#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);
}