Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: uuid_short替换
【TiDB Usage Environment】Testing
【TiDB Version】6.1.0
【Encountered Problem】
In MySQL, the uuid_short function can be replaced with what function or solution in TiDB?
You can refer to the source code to create one~
ulonglong uuid_value;
void uuid_short_init()
{
uuid_value = ((((ulonglong) server_id) << 56) + (((ulonglong) server_start_time) << 24));
}
longlong Item_func_uuid_short::val_int()
{
ulonglong val;
mysql_mutex_lock(&LOCK_uuid_generator);
val = uuid_value++;
mysql_mutex_unlock(&LOCK_uuid_generator);
return (longlong) val;
}
This function is not supported in TiDB, you can try this:
mysql> begin; select @@tidb_current_ts; rollback;
Query OK, 0 rows affected (0.001 sec)
+--------------------+
| @@tidb_current_ts |
+--------------------+
| 434832859614150657 |
+--------------------+
1 row in set (0.001 sec)
Adding a timestamp or something similar should be about right.
Do we need to add a rollback for this? Very meticulous!
This topic will be automatically closed 60 days after the last reply. No new replies are allowed.