diff options
author | Tatiana A. Nurnberg <azundris@mysql.com> | 2008-07-10 03:58:30 +0200 |
---|---|---|
committer | Tatiana A. Nurnberg <azundris@mysql.com> | 2008-07-10 03:58:30 +0200 |
commit | 0833d668474a768b0b8a6e170d602097b7b43c73 (patch) | |
tree | 11ba6a48502e556020f3fd23702d204f13833a98 /mysql-test/t/func_misc.test | |
parent | b93fcb9b0ed5458802159cd8cc25d2e7d6e7b3c7 (diff) | |
download | mariadb-git-0833d668474a768b0b8a6e170d602097b7b43c73.tar.gz |
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.
Also handle the case where we count into the future
when several UUIDs are generated in one "tick", and
then the next call is late enough for us to unwind
some but not all of those borrowed ticks.
Lastly, handle the case where we keep borrowing and
borrowing until the tick-counter overflows by also
changing into a new "numberspace" by creating a new
random suffix.
mysql-test/r/func_misc.result:
Show that time-part of UUIDs is correct now.
mysql-test/t/func_misc.test:
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).
No test for unwinding of borrowed ticks as
this a) is a race and b) depends on what timer
we get.
sql/item_strfunc.cc:
correct offset for date/time-part of UUID.
also make sure that when we counted into
the future earlier (several UUIDs generated
in same tick), we only give back as many
"borrowed" ticks as we can without duplicating
past timestamps. If our tick-counter overflows
before we can give back, or if the system-clock
is set back (by user or Daylight Saving Time),
we create a new random suffix to avoid
collisions and clear the tick-counter.
Diffstat (limited to 'mysql-test/t/func_misc.test')
-rw-r--r-- | mysql-test/t/func_misc.test | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 36c18979154..93fe94ec94f 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -417,5 +417,24 @@ drop table t1; # SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; +# +# 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 5.0 tests |