summaryrefslogtreecommitdiff
path: root/sql/field_conv.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-09-21 20:08:59 +0200
committerSergei Golubchik <serg@mariadb.org>2017-09-22 14:01:26 +0200
commita5e1f60b3167e0057e64166df06424f1fb96bec3 (patch)
treef6584c226dc30b8f038b593ce3243d9457e915b1 /sql/field_conv.cc
parentbc4409ab4ee3729f09151a4d7bdc6d95fdcaa3a1 (diff)
downloadmariadb-git-a5e1f60b3167e0057e64166df06424f1fb96bec3.tar.gz
bugfix: ALTER TABLE and TIMESTAMPs around DST change time
Implement a special Copy_func function for timestamps, that copies timestamps without converting them to MYSQL_TIME (the conversion is lossy around DST change time). This fixes ALTER TABLE part of main.old-mode test. This is 10.2 version of f4f48e06215
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r--sql/field_conv.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 85101fd5f0a..15df2c398a3 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -417,6 +417,16 @@ void Field::do_field_decimal(Copy_field *copy)
}
+void Field::do_field_timestamp(Copy_field *copy)
+{
+ Field_timestamp *f= static_cast<Field_timestamp*>(copy->from_field);
+ Field_timestamp *t= static_cast<Field_timestamp*>(copy->to_field);
+ ulong sec_part;
+ my_time_t ts= f->get_timestamp(&sec_part);
+ t->store_TIME(ts, sec_part);
+}
+
+
void Field::do_field_temporal(Copy_field *copy)
{
MYSQL_TIME ltime;
@@ -706,6 +716,16 @@ void Copy_field::set(Field *to,Field *from,bool save)
}
+Field::Copy_func *Field_timestamp::get_copy_func(const Field *from) const
+{
+ Field::Copy_func *copy= Field_temporal::get_copy_func(from);
+ if (copy == do_field_temporal && from->type() == MYSQL_TYPE_TIMESTAMP)
+ return do_field_timestamp;
+ else
+ return copy;
+}
+
+
Field::Copy_func *Field_temporal::get_copy_func(const Field *from) const
{
/* If types are not 100 % identical then convert trough get_date() */