I was just wondering if anyone could help me create a mysql function UUID_SHORT() for mysql, as the version I’m using doesn’t have that function.
From what I saw, the function essentially calls
(server_id & 255) << 56
+ (server_startup_time_in_seconds << 24)
+ incremented_variable++;
But I have no idea how to make that into a function that I could use.
So again, all I’m looking for is some help recreating the function for use in an older version of mysql, I don’t/can’t upgrade, and don’t care about auto-incremented fields.
The math part should be fairly straightforward. As for the counter, I guess the only way to implement that would be using a tiny table holding one value that you increment each time. Tip: Make sure to lock the table in your function before reading it, and unlock after writing.