Bug #44763 ndb_restore - timestamp data is printed in wrong format when using --print-data
| Submitted: | 9 May 2009 20:07 | Modified: | 8 Mar 2010 20:56 |
|---|---|---|---|
| Reporter: | Johan Andersson | Email Updates: | |
| Status: | In progress | Impact on me: | |
| Category: | MySQL Cluster: Cluster (NDB) storage engine | Severity: | S3 (Non-critical) |
| Version: | mysql-5.1-telco-6.3 | OS: | Any |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
| Tags: | ndb_restore, timestamp | ||
[9 May 2009 20:07]
Johan Andersson
[11 May 2009 13:08]
Jonathan Miller
mysql-5.1.31-ndb-6.3.22, mysql-5.1.32-ndb-7.0.5 mysqldump?
[11 May 2009 20:00]
Hartmut Holzgraefe
Suggested change (this opens another can of worms due to different
time zone handling in DATETIME and TIMESTAMP though ...):
=== modified file 'storage/ndb/src/ndbapi/NdbRecAttr.cpp'
--- storage/ndb/src/ndbapi/NdbRecAttr.cpp 2009-04-08 22:28:04 +0000
+++ storage/ndb/src/ndbapi/NdbRecAttr.cpp 2009-05-11 19:55:02 +0000
@@ -500,8 +500,20 @@ ndbrecattr_print_formatted(NdbOut& out,
break;
case NdbDictionary::Column::Timestamp:
{
- time_t time = r.u_32_value();
- out << (uint)time;
+ time_t time_result = r.u_32_value();
+ struct tm tm_result;
+ char asc_result[20];
+
+ gmtime_r(&time_result, &tm_result);
+ sprintf(asc_result, "%4d-%02d-%02d/%02d:%02d:%02d",
+ tm_result.tm_year + 1900,
+ tm_result.tm_mon + 1,
+ tm_result.tm_mday,
+ tm_result.tm_hour,
+ tm_result.tm_min,
+ tm_result.tm_sec);
+
+ out << asc_result;
}
break;
case NdbDictionary::Column::Blob:
[17 Sep 2009 7:25]
Johan Andersson
what happens?
[8 Mar 2010 19:09]
John David Duncan
"TIMESTAMP values are converted from the current time zone to UTC for storage, and converted back from UTC to the current time zone for retrieval." So, ndb_restore will report timestamps in UTC, but mysql will want them in local time.
[8 Mar 2010 20:48]
John David Duncan
Patch submitted, based on Hartmut's, but changing gmtime_r to localtime_r. I think this should make the output consistent with other data types such as Datetime. Caveat: the timestamp fields in the file created by ndb_restore are expressed in the time zone where ndb_restore was run. If you were to load this file into a server in some other time zone, the data there would be corrupted.
[8 Mar 2010 20:56]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/102616 3132 John David Duncan 2010-03-08 bug#44763 : print Timestamp fields as YYYY-MM-DD/HH:MM:SS in local time zone, so that ``ndb_restore --print-data'' output can be loaded back into mysql.
[27 Aug 2013 14:02]
Joffrey MICHAIE
Hi, will this patch ever be pushed into ndb tree ? Still happening in latest 7.2 Regards, Joffrey
[28 May 1:12]
MySQL Admin
Posted by developer: Bug status updated to 'In progress'
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.060 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.