MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Tatjana A Nuernberg Date:April 10 2008 1:39pm
Subject:bk commit into 4.1 tree (tnurnberg:1.2714) BUG#35848
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of tnurnberg. When tnurnberg does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-04-10 15:39:29+02:00, tnurnberg@stripped +3 -0
  Bug#35848: UUID() returns UUIDs with the wrong time
  
  offset for time part in UUIDs was 1/1000 of what it
  should be. In other words, offset was off.

  mysql-test/r/func_misc.result@stripped, 2008-04-10 15:39:28+02:00, tnurnberg@stripped +14 -0
    Show that time-part of UUIDs is correct now.

  mysql-test/t/func_misc.test@stripped, 2008-04-10 15:39:28+02:00, tnurnberg@stripped +19 -0
    Show that time-part of UUIDs is correct now
    by replicating the C-code's resultin SQL.
    Results also decode to expect date-data on
    command-line (external validation).

  sql/item_strfunc.cc@stripped, 2008-04-10 15:39:28+02:00, tnurnberg@stripped +2 -1
    correct offset for date/time-part of UUID

diff -Nrup a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
--- a/mysql-test/r/func_misc.result	2006-10-03 15:33:41 +02:00
+++ b/mysql-test/r/func_misc.result	2008-04-10 15:39:28 +02:00
@@ -96,4 +96,18 @@ DROP TABLE t1;
 select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
 export_set(3, _latin1'foo', _utf8'bar', ',', 4)
 foo,foo,bar,bar
+select @@session.time_zone into @save_tz;
+set @@session.time_zone='UTC';
+select uuid() into @my_uuid;
+select mid(@my_uuid,15,1);
+mid(@my_uuid,15,1)
+1
+select 24 * 60 * 60 * 1000 * 1000 * 10 into @my_uuid_one_day;
+select concat('0',mid(@my_uuid,16,3),mid(@my_uuid,10,4),left(@my_uuid,8)) into @my_uuidate;
+select floor(conv(@my_uuidate,16,10)/@my_uuid_one_day) into @my_uuid_date;
+select 141427 + datediff(curdate(),'1970-01-01') into @my_uuid_synthetic;
+select @my_uuid_date - @my_uuid_synthetic;
+@my_uuid_date - @my_uuid_synthetic
+0
+set @@session.time_zone=@save_tz;
 End of 4.1 tests
diff -Nrup a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
--- a/mysql-test/t/func_misc.test	2006-08-24 02:02:28 +02:00
+++ b/mysql-test/t/func_misc.test	2008-04-10 15:39:28 +02:00
@@ -88,4 +88,23 @@ DROP TABLE t1;
 #
 select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
 
+#
+# Bug #35848: UUID() returns UUIDs with the wrong time
+#
+select @@session.time_zone into @save_tz;
+
+# make sure all times are UTC so the DayNr won't differ
+set @@session.time_zone='UTC';
+select uuid() into @my_uuid;
+# if version nibble isn't 1, the following calculations will be rubbish
+select mid(@my_uuid,15,1);
+select 24 * 60 * 60 * 1000 * 1000 * 10 into @my_uuid_one_day;
+select concat('0',mid(@my_uuid,16,3),mid(@my_uuid,10,4),left(@my_uuid,8)) into @my_uuidate;
+select floor(conv(@my_uuidate,16,10)/@my_uuid_one_day) into @my_uuid_date;
+select 141427 + datediff(curdate(),'1970-01-01') into @my_uuid_synthetic;
+# these should be identical; date part of UUID should be current date
+select @my_uuid_date - @my_uuid_synthetic;
+
+set @@session.time_zone=@save_tz;
+
 --echo End of 4.1 tests
diff -Nrup a/sql/item_strfunc.cc b/sql/item_strfunc.cc
--- a/sql/item_strfunc.cc	2007-01-11 14:44:59 +01:00
+++ b/sql/item_strfunc.cc	2008-04-10 15:39:28 +02:00
@@ -2959,7 +2959,8 @@ static char clock_seq_and_node_str[]="-0
 
 /* number of 100-nanosecond intervals between
    1582-10-15 00:00:00.00 and 1970-01-01 00:00:00.00 */
-#define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * 1000 * 10 )
+#define UUID_TIME_OFFSET ((ulonglong) 141427 * 24 * 60 * 60 * \
+                          1000 * 1000 * 10)
 
 #define UUID_VERSION      0x1000
 #define UUID_VARIANT      0x8000
Thread
bk commit into 4.1 tree (tnurnberg:1.2714) BUG#35848Tatjana A Nuernberg10 Apr