From: | "Chris Fischer" <Chris(dot)Fischer(at)channeladvisor(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: newid() in postgres |
Date: | 2007-04-11 16:21:24 |
Message-ID: | D45F1ECA30B59A4F96208F86532F901F1434037D@rdu-caex-01.channeladvisor.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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;
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Edson | 2007-04-11 16:21:33 | Select taking excessively long; Request help streamlining. |
Previous Message | Magnus Hagander | 2007-04-11 16:20:46 | Re: [GENERAL] programmatic way to fetch latest release for a given major.minor version |