Re: Insert UUID GEN 4 Value - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Insert UUID GEN 4 Value
Date
Msg-id 67869175-6d10-9ac0-4e71-2fcb996f313d@aklaver.com
Whole thread Raw
In response to Re: Insert UUID GEN 4 Value  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 05/31/2018 06:39 AM, Tom Lane wrote:
> Adrian Klaver <adrian.klaver@aklaver.com> writes:
>> My suspicion is it had to do with this from a post upstream:
>> "When I tried it, I am getting an error: Invalid input syntax for UUID:
>> uuid_generate_v4(),"
> 
> Yeah.  We haven't seen the actual query yet, but I'm betting the OP
> really wrote
> 
>     INSERT ... , 'uuid_generate_v4()', ...
> 
> not
> 
>     INSERT ... , uuid_generate_v4(), ...
> 
> There might be some layers of client-side parameter mangling obscuring
> what's actually happening.


I would tend to agree:

\d uuid_test
              Table "public.uuid_test"
   Column  | Type | Collation | Nullable | Default
----------+------+-----------+----------+---------
  uuid_fld | uuid |

insert into uuid_test values (uuid_generate_v4());
INSERT 0 1

select * from uuid_test ;
                uuid_fld
--------------------------------------
  f4bc853b-0c05-437b-904a-825cc6d3ea7b

In Python(using psycopg2) which is what the OP is using;

cur.execute("INSERT INTO uuid_test values(uuid_generate_v4())")

con.commit()

cur.execute("SELECT uuid_fld FROM uuid_test")

rs = cur.fetchall()

rs
[('f4bc853b-0c05-437b-904a-825cc6d3ea7b',),
  ('9e55f5ea-c504-4847-8674-05202ec499c6',)]




 From this post:

https://www.postgresql.org/message-id/CAA6wQLLVpjtxAhPy3K1f63WtvqjK4QrzBLKjeh0PDUOyCvbT2Q%40mail.gmail.com

the OP seems to be on the right track. So something else is happening.

> 
>             regards, tom lane
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Dennis Gearon
Date:
Subject: Re: Insert UUID GEN 4 Value
Next
From: Adrian Klaver
Date:
Subject: Re: Insert UUID GEN 4 Value