From: | Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Basil Bourque <basil(dot)list(at)me(dot)com> |
Subject: | Re: UUID can be written to row when passed as parameter/argument to a PL/pgSQL function. Feature or bug? |
Date: | 2011-04-15 02:19:05 |
Message-ID: | 201104141919.05931.adrian.klaver@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thursday, April 14, 2011 6:43:21 pm Basil Bourque wrote:
> If I pass the hex string representation of a UUID to a PL/pgSQL function as
> a varchar, that value cannot be used directly when writing to a row whose
> column data type is "uuid", in Postgres 9.0.x. Normally Postgres
> automatically converts a hex string to a 128-bit UUID value and back
> again.
>
> Is not doing so in a function a bug?
How about:
CREATE OR REPLACE FUNCTION public.uuid_write_(character varying)
RETURNS boolean
LANGUAGE plpgsql
AS $function$
BEGIN
INSERT INTO uuid_tbl_ ( uuid_col_ )
VALUES ( $1::uuid );
RETURN True;
END;
$function$
test(5432)aklaver=>select uuid_write_('34A94C40-453A-4A30-9404-128121E76570');
uuid_write_
-------------
t
(1 row)
>
> Note the success of this workaround.
>
> My blog post on this issue:
> http://crafted-software.blogspot.com/2011/04/passing-uuid-value-to-function
> -in.html
>
> --Basil Bourque
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Jerry Sievers | 2011-04-15 02:26:35 | Re: How can you have an Exclusive Lock on nothing? please help me understand this lock monitoring query output |
Previous Message | Basil Bourque | 2011-04-15 01:49:13 | Re: UUID can be written to row when passed as parameter/argument to a PL/pgSQL function. Feature or bug? |