summaryrefslogtreecommitdiff
path: root/sql/compat56.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-12-12 14:07:27 +0400
committerAlexander Barkov <bar@mariadb.com>2018-12-12 14:07:27 +0400
commitc8774408cb99ca5167fcefd57a35c37dfc003513 (patch)
tree7663b014a10f36157cc0ab642531dd7c36a1a385 /sql/compat56.cc
parentc353b2a8fc10e16107ee6c7e26877f4243d4eaef (diff)
downloadmariadb-git-c8774408cb99ca5167fcefd57a35c37dfc003513.tar.gz
MDEV-17968 Error 174 "Fatal error during initialization of handler" from storage engine Aria upon DELETE from partitioned table
Diffstat (limited to 'sql/compat56.cc')
-rw-r--r--sql/compat56.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/sql/compat56.cc b/sql/compat56.cc
index d1cb8b0042c..2c444243934 100644
--- a/sql/compat56.cc
+++ b/sql/compat56.cc
@@ -20,6 +20,19 @@
#include "myisampack.h"
#include "my_time.h"
+
+static uint my_max_usec_value[7]
+{
+ 0,
+ 900000,
+ 990000,
+ 999000,
+ 999900,
+ 999990,
+ 999999
+};
+
+
/*** MySQL56 TIME low-level memory and disk representation routines ***/
/*
@@ -397,19 +410,21 @@ void my_timestamp_from_binary(struct timeval *tm, const uchar *ptr, uint dec)
case 0:
default:
tm->tv_usec= 0;
- break;
+ return;
case 1:
case 2:
tm->tv_usec= ((int) ptr[4]) * 10000;
break;
case 3:
case 4:
- tm->tv_usec= mi_sint2korr(ptr + 4) * 100;
+ tm->tv_usec= (uint) mi_uint2korr(ptr + 4) * 100;
break;
case 5:
case 6:
- tm->tv_usec= mi_sint3korr(ptr + 4);
+ tm->tv_usec= (uint) mi_uint3korr(ptr + 4);
}
+ // The binary data my be corrupt. Cut fractional seconds to the valid range.
+ set_if_smaller(tm->tv_usec, my_max_usec_value[dec]);
}