-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-33710 Implement UUID_TIMESTAMP() function #4496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
MDEV-33710 Implement UUID_TIMESTAMP() function #4496
Conversation
…v1 and UUIDv7 values
5bbed91 to
9aa596f
Compare
|
I have some concern about the tests... it's not easy to validate the UUID values used there.
We can test a couple of random values, plus corner cases: min and max value for timestamp variable, and for UUID |
|
Strangely, there is a different result outpoutted in amd64-debian-11-debug-ps-embedded test run: Please take a look |
|
i think the test failing is a timezone issue (exact 5.30 HRS), ill fix that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @varundeepsaini for the update, and besides such aquick one!
The PR moves in the right direction. Still some work to be done.
plugin/type_uuid/mysql-test/type_uuid/func_uuid_timestamp.result
Outdated
Show resolved
Hide resolved
plugin/type_uuid/item_uuidfunc.cc
Outdated
|
|
||
| my_time_t seconds; | ||
| ulong usec; | ||
| const uchar *buf= (const uchar *) uuid.to_lex_cstring().str; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No functions really need uchar (except the newly added one, which we can change), also uuid is natively stored in char, so why make a conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mi_ prefix functions use uchar (they do cast it themselves tho, i can remove it from here but again, the cast is still there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean? where??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysys/my_uuid.c
Outdated
| Bytes 6-7: version (4 bits) + sub-millisecond precision (12 bits) | ||
| */ | ||
|
|
||
| my_bool my_uuid_extract_ts(const uchar *uuid, my_time_t *seconds, ulong *usec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use just int.
Or alternatively, bool, with true meaning success
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well use bool here since there are only two result types.
Note for both int and bool: I hear that the convention is 1/true = error (which one might consider “timestamp invalid” to be one) and 0/false = no error.
|
Never mind the failing appveyor, it is used to be failing. However it may be useful to check the results, as it can reveal some windows build quirks (for example msvc doesn't like bool vs int mismatch, and has a 32-bit |
ParadoxV5
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just passing by
mysys/my_uuid.c
Outdated
| return 1; | ||
| } | ||
|
|
||
| if (version == 1) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beginner question: Would a switch block work here?
mysys/my_uuid.c
Outdated
| Bytes 6-7: version (4 bits) + sub-millisecond precision (12 bits) | ||
| */ | ||
|
|
||
| my_bool my_uuid_extract_ts(const uchar *uuid, my_time_t *seconds, ulong *usec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well use bool here since there are only two result types.
Note for both int and bool: I hear that the convention is 1/true = error (which one might consider “timestamp invalid” to be one) and 0/false = no error.
|
@FooBarrior the my_uuic.c file is being compiled as c hence when trying to use bool it is triggering this macro should i switch to int / my_bool ? |
Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
|
Generated the UUIDs from https://www.uuidgenerator.net/ |
d5dd95d to
acd4413
Compare
Signed-off-by: Varun Deep Saini <varun.23bcs10048@ms.sst.scaler.com>
acd4413 to
879c14c
Compare
Description
Adds
UUID_TIMESTAMP(uuid)function to extract timestamps from UUIDv1 and UUIDv7 values. ReturnsNULLfor other versions (e.g., v4) or invalid input.Release Notes
New function:
UUID_TIMESTAMP(uuid)- Returns the generation timestamp from UUIDv1/v7 asTIMESTAMP(6).How can this PR be tested?
Basing the PR against the correct MariaDB version
mainbranch.PR quality check