精华内容
下载资源
问答
  • uuid_generate

    千次阅读 2013-04-10 16:52:13
    http://blog.chinaunix.net/uid-12567959-id-161022.html Name uuid_generate, uuid_generate_random, uuid_generate_time - create a newunique UUID value Synopsis #include uuid/uuid.h> void uuid_g

    http://blog.chinaunix.net/uid-12567959-id-161022.html

    Name

    uuid_generate, uuid_generate_random, uuid_generate_time - create a newunique UUID value

    Synopsis

    #include <uuid/uuid.h>

    void uuid_generate(uuid_t
    out);
    void uuid_generate_random(uuid_t
    out);
    void uuid_generate_time(uuid_t
    out);


    Description
    The uuid_generate function creates a new universally uniqueidentifier (UUID). The uuid will be generated based on high-quality randomnessfrom

    /dev/urandom, ifavailable. If it is not available, then uuid_generate

    will use an alternative algorithm which uses the current time, the localethernet MAC address (if available), and random data generated using apseudo-random generator.


    The uuid_generate_random function forces the use of the all-randomUUID format, even if a high-quality random number generator (i.e., /dev/urandom)is not available, in which case a pseudo-random generator will be subsituted.Note that the use of a pseudo-random generator may compromise the uniqueness ofUUID's generated in this fashion.


    The uuid_generate_time function forces the use of the alternativealgorithm which uses the current time and the local ethernet MAC address (ifavailable). This algorithm used to be the default one used to generate UUID,but because of the use of the ethernet MAC address, it can leak informationabout when and where the UUID was generated. This can cause privacy problems insome applications, so the uuid_generate function only uses thisalgorithm if a high-quality source of randomness is not available.


    The UUID is 16 bytes (128 bits) long, which gives approximately 3.4x10^38unique values (there are approximately 10^80 elemntary particles in theuniverse according to Carl Sagan's Cosmos). The new UUID can reasonablybe considered unique among all UUIDs created on the local system, and amongUUIDs created on other systems in the past and in the future.

    Return Value

    The newly created UUID is returned in the memory location pointed to by out.

    Conforming To

    OSF DCE 1.1

    Author

    Theodore Y. Ts'o

    Availability

    http://e2fsprogs.sourceforge.net/

    See Also

    uuid(3), uuidgen(1),uuid_clear(3), uuid_compare(3), uuid_copy(3), uuid_is_null(3), uuid_parse(3), uuid_time(3), uuid_unparse(3)

    Referenced By

    libuuid(3)
    展开全文
  • uuid_generate_v4()') }, reportId: { type: 'text', notNull: true }, userId: { type: 'text', notNull: true }, type: { type: 'text', notNull: true }, version: { type: '...
  • A UUID is designed as a number that is globally unique in space and time. Two calls to UUID() areexpected to generate two different values, even if these calls are performed on two separate computerst...

    A UUID is designed as a number that is globally unique in space and time. Two calls to UUID() are

    expected to generate two different values, even if these calls are performed on two separate computers

    that are not connected to each other.

    uuid是世界上唯一的,就算两个没有任何关系的计算机uuid也是不同的

    但是文档上却没有说到他是不是有序的,网上都说uuid是无序,我想一个场景试一下:

    场景解释:

    建一个表,里面有两个字段 uuid和时间。

    每一秒向这个表里插入一条数据,分别是 uuid()和now()

    插入一段时间之后,如果按id排序和按t_date排序得到的结果是一样的,那么应该可以证明uuid是有序的,如果排序结果不一样,那么是无序的。

    我这里两个进程同时插入,并且跑了两个小时

    模拟过程:

    在mysql 5.6上测试

    mysql> create table song( id char(36), t_date datetime);

    Query OK, 0 rows affected (0.00 sec)

    cat insert.sh

    #!/bin/bash

    while true; do

    mysql -h10.13.52.100 -P3306 -uroot -ptest  -e "insert into test.song select uuid(),now();"

    sleep 1

    done

    nohup sh insert.sh &

    nohup sh insert.sh &

    两个一起插入

    运行大概两个小时,停掉insert.sh后:

    mysql -h10.13.52.100 -P3306 -uroot -ptest  -e "select * from test.song order by t_date;" > a.log

    mysql -h10.13.52.100 -P3306 -uroot -ptest  -e "select * from test.song order by id;" > b.log

    diff a.log b.log  -y > c.log

    [root@10-13-59-213 ~]# vim c.log

    id      t_date                                                  id      t_date

    b6af9995-50d2-11e6-9d61-5254005ae15d    2016-07-23 20:41:01   | 0019655a-50d5-11e6-9d61-5254005ae15d    2016-07-23 20:57:24

    cc161c32-50d2-11e6-9d61-5254005ae15d    2016-07-23 20:41:37   | 001968e2-50d5-11e6-9d61-5254005ae15d    2016-07-23 20:57:24

    ccafd852-50d2-11e6-9d61-5254005ae15d    2016-07-23 20:41:38   <

    cd495dc1-50d2-11e6-9d61-5254005ae15d    2016-07-23 20:41:39   <

    从c.log中可以看到a.log和b.log的不同。 那么 uuid()是无序的

    转载请注明源出处

    QQ 273002188 欢迎一起学习

    QQ 群 236941212

    oracle,mysql,PG 相互交流

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25099483/viewspace-2122432/,如需转载,请注明出处,否则将追究法律责任。

    展开全文
  • MySQL's UUID function returns a UUIDv1 GUID. I'm looking for an easy way to generate random GUIDs (i.e. UUIDv4) in SQL.解决方案I've spent quite some time looking for a solution and came up with the ...

    bd96500e110b49cbb3cd949968f18be7.png

    MySQL's UUID function returns a UUIDv1 GUID. I'm looking for an easy way to generate random GUIDs (i.e. UUIDv4) in SQL.

    解决方案

    I've spent quite some time looking for a solution and came up with the following

    mysql function that generates a random UUID (i.e. UUIDv4) using standard MySQL

    functions. I'm answering my own question to share that in the hope that it'll be

    useful.

    -- Change delimiter so that the function body doesn't end the function declaration

    DELIMITER //

    CREATE FUNCTION uuid_v4()

    RETURNS CHAR(36)

    BEGIN

    -- Generate 8 2-byte strings that we will combine into a UUIDv4

    SET @h1 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

    SET @h2 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

    SET @h3 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

    SET @h6 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

    SET @h7 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

    SET @h8 = LPAD(HEX(FLOOR(RAND() * 0xffff)), 4, '0');

    -- 4th section will start with a 4 indicating the version

    SET @h4 = CONCAT('4', LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'));

    -- 5th section first half-byte can only be 8, 9 A or B

    SET @h5 = CONCAT(HEX(FLOOR(RAND() * 4 + 8)),

    LPAD(HEX(FLOOR(RAND() * 0x0fff)), 3, '0'));

    -- Build the complete UUID

    RETURN LOWER(CONCAT(

    @h1, @h2, '-', @h3, '-', @h4, '-', @h5, '-', @h6, @h7, @h8

    ));

    END

    //

    -- Switch back the delimiter

    DELIMITER ;

    Note: The pseudo-random number generation used (MySQL's RAND) is not

    cryptographically secure and thus has some bias which can increase the collision

    risk.

    展开全文
  • 写这个程序之前需要知道UUID,UUID是全球唯一标识码,所以保证了数字的唯一性。安装uuid工具链:sudo apt-get install uuid-devuuid提供的API:void uuid_generate...void uuid_generate_time(uuid_tout);int uui...
    写这个程序之前需要知道UUID,UUID是全球唯一标识码,所以保证了数字的唯一性。
    安装uuid工具链:sudo apt-get install uuid-dev
    uuid提供的API:
    void uuid_generate(uuid_tout);
    void uuid_generate_random(uuid_tout);
    void uuid_generate_time(uuid_tout);
    int uuid_generate_time_safe(uuid_tout);

    #include<stdio.h>
    #include<uuid/uuid.h>
    #include <unistd.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    void uuid_conver(char* source,char* desc){
    int i,j;
    for(i = 0,j= 0;i < 36;i++,j++){
    if(desc[i]=='-'){
    i++;
    }
    source[j] = toupper(desc[i]);
    }
    source[j] = '\0';
    }
    int main(int argc, const char *argv[])
    {
    uuid_t uu;
    char buf[100];
    uuid_generate_random(uu);
    uuid_unparse(uu,buf);
    printf("%s\n",buf);
    char buff[40];
    uuid_conver(buff,buf);
    printf("%s\n",buff);
    return 0;
    }
    ===================================================
    更多内容关注我的博客:草原上有什么
    展开全文
  • 4) Adds an option to use ::uuid_generate_time() to generate UUIDs, and defaults to ::uuid_generate() instead of ::uuid_generate_random(). uuid_generate() defaults to uuid_generate_random(), but has ...
  • <div><p>Under JRuby I am calling UUID.generate quite often. I see a case in my logs where two successive calls returns the same UUID. Looking at the code, I see this comment: <pre><code> ruby # The ...
  • ./vcl.dIi0L05v.c:896:6: error: no previous prototype for ‘generate_uuid’ [-Werror=missing-prototypes] cc1: all warnings being treated as errors <p>Running C-compiler failed, exited with 1 <p>VCL...
  • I downloaded precompiled binaries for the server install (which does not include tsm_system_time). I am unfamiliar with python, and its corresponding psycopg2 library. <p>I would like to learn how ...
  • Change how we calculate GUID

    2020-11-22 07:40:28
    <div><p>Previously, we used uuid_generate_time which used the MAC address of the machine as part of the calculation. This is leading to problems when we run on virtual machines as many of the machines...
  • "guid" uuid NOT NULL DEFAULT uuid_generate_v4(), "data" jsonb, "create_time" timestamptz(6) DEFAULT now(), CONSTRAINT "test_pkey" PRIMARY KEY ("guid") ); 报错: ERROR: function uuid_generate_v4...
  • I want to generate time based UUID in java - java.util.UUID.randomUUID() genrates a UUID version 4. How to generate a version 1 (time based) UUID ? Is there a separate library for that or is it some h...
  • /usr/local/include/uuid/uuid.h /usr/local/lib/python2.7/site-packages/libmount/__init__.py /usr/local/lib/python2.7/site-packages/libmount/__init__.pyc /usr/local/lib/python2.7/site-packages/libmount/...
  • We would like it if the module allowed an option to automatically generate a hash of the module parameters and include it in the launch configuration name. Right now, we have to manually update the ...
  • generate_name': None, 'generation': None, 'initializers': None, 'labels': None, 'name': 'xxxx-xxxx', 'namespace': 'xxxx', 'owner_...
  • start_time = 1573843758 watcher = -1 </code></pre> <p>I attempted to query both tables today and was met with the following output: ✅<strong>kolide_touchid_user_config</strong></p> <pre>...
  • checking for uuid_generate in -luuid... no checking for asciidoc... no checking for xmlto... no configure: WARNING: You are building an unreleased version of CZMQ and asciidoc or xmlto are not ...
  • CMake does not need to re-run because G:/xmr-stak-master/CMakeFiles/generate.stamp is up-to-date. FinalizeBuildStatus: Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild"...
  • Lumber doesnt like UUID

    2020-12-08 18:20:53
    concurrency_stamp uuid NOT NULL DEFAULT uuid_generate_v1mc(), phone_number character varying(50), phone_number_confirmed boolean NOT NULL DEFAULT false, two_factor_enabled boolean NOT NULL DEFAULT...
  • PG SQL funcation

    2019-06-23 10:17:00
    create extension IF NOT EXISTS "uuid-ossp" ;...--select uuid_generate_v4(); --select current_timestamp; --select * from (select *,row_number() over(partition by merchant_id order by create_time ...
  • I would expect that every time a <code>s3.list_objects</code> is called, one of the response is returned and then <strong>popped</strong> from the responses stack. That doesn't seem to be the case...
  • comments, they generate extra noise for issue followers and do not help prioritize the request</li><li>If you are interested in working on this issue or have submitted a pull request, please leave a ...
  • com.djrapitops.plan.api.exceptions.database.DBOpException: SQL Failed: SELECT SUM(survival_time) as survival, SUM(creative_time) as creative, SUM(adventure_time) as adventure, SUM(spectator_...
  • PostgreSQL 扩展安装

    2020-04-21 17:31:22
    一、安装扩展 无需本地操作,内置含有包可直接命令行安装 CREATE EXTENSION "uuid-ossp";... id uuid DEFAULT uuid_generate_v4() NOT NULL PRIMARY KEY, data varchar(255), created_at timestamp with time z...
  • uuid_generate_v4"() PRIMARY KEY, "createdDate" timestamp without time zone NOT NULL DEFAULT now(), "updatedDate" timestamp without time zone NOT NULL DEFAULT now(), "name&#...
  • # coding:utf-8 """ 生成随机数 """ import random import time import uuid from hashlib import md5 ...def generate_rand_id(sstr=None): """ 生成一组16进制的随机数,32位 :param sstr: :...
  • deploy/gpu/generate_multi_gpu.py | 18 +- deploy/kube/config_example.py | 2 + deploy/kube/create_secrets.py | 2 + deploy/kube/delete.sh | 2 + deploy/kube/deployments/coco.yaml | 10...
  • pause_time_between_batches = "PT0S" } } # required when using rolling upgrade policy health_probe_id = var.azure["public_ip"] ? azurerm_lb_probe.this[0].id : "" ...
  • <div><p>Hi Graham <p>I just spotted that I can't install mod_wsgi-standalone under (Anaconda) python 3.7 in MacOS Catalina (10.15.7). Works fine for python 3.8. I can also install mod_wsgi in ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 391
精华内容 156
关键字:

uuid_generate_time