@@ -17,17 +17,18 @@ import (
1717
1818// Register registers the SQL functions:
1919//
20- // uuid([version], [domain/namespace], [id/data])
21- //
22- // Generates a UUID as a string.
23- //
24- // uuid_str(u)
25- //
26- // Converts a UUID into a well-formed UUID string.
27- //
28- // uuid_blob(u)
29- //
30- // Converts a UUID into a 16-byte blob.
20+ // - uuid([ version [, domain/namespace, [ id/data ]]]):
21+ // to generate a UUID as a string,
22+ // - uuid_str(u):
23+ // to convert a UUID into a well-formed UUID string,
24+ // - uuid_blob(u):
25+ // to convert a UUID into a 16-byte blob,
26+ // - uuid_extract_version(u):
27+ // to extract the version of a RFC 4122 UUID,
28+ // - uuid_extract_timestamp(u):
29+ // to extract the timestamp of a version 1/2/6/7 UUID,
30+ // - gen_random_uuid(u):
31+ // to generate a version 4 (random) UUID.
3132func Register (db * sqlite3.Conn ) error {
3233 const flags = sqlite3 .DETERMINISTIC | sqlite3 .INNOCUOUS
3334 return errors .Join (
@@ -38,7 +39,8 @@ func Register(db *sqlite3.Conn) error {
3839 db .CreateFunction ("uuid_str" , 1 , flags , toString ),
3940 db .CreateFunction ("uuid_blob" , 1 , flags , toBlob ),
4041 db .CreateFunction ("uuid_extract_version" , 1 , flags , version ),
41- db .CreateFunction ("uuid_extract_timestamp" , 1 , flags , timestamp ))
42+ db .CreateFunction ("uuid_extract_timestamp" , 1 , flags , timestamp ),
43+ db .CreateFunction ("gen_random_uuid" , 0 , sqlite3 .INNOCUOUS , generate ))
4244}
4345
4446func generate (ctx sqlite3.Context , arg ... sqlite3.Value ) {
0 commit comments