Search Postgresql Archives

Re: newid() in postgres

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a PL/pgsql implementation I wrote.....I'm sure critics will be
able to improve upon it:

CREATE or REPLACE FUNCTION "common"."newid"()
RETURNS "pg_catalog"."varchar" AS 
$BODY$
DECLARE
  v_seed_value varchar(32);
BEGIN
select 
md5(
inet_client_addr()::varchar ||
timeofday() ||
inet_server_addr()::varchar ||
to_hex(inet_client_port()) 
)
into v_seed_value;

return (substr(v_seed_value,1,8) || '-' ||
        substr(v_seed_value,9,4) || '-' ||
        substr(v_seed_value,13,4) || '-' ||
        substr(v_seed_value,17,4) || '-' ||
        substr(v_seed_value,21,12));
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE SECURITY DEFINER;


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux