Re: Composite types as parameters - Mailing list pgsql-hackers

From Elijah Stone
Subject Re: Composite types as parameters
Date
Msg-id 363ec928-b0b8-c1eb-2f88-47d43c18ba7@elronnd.net
Whole thread Raw
In response to Re: Composite types as parameters  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Composite types as parameters  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Sat, 26 Jun 2021, Tom Lane wrote:
> You probably would have better results from specifying the composite 
> type explicitly in the query:
>
> PQexecParams("insert into sometable values($1::composite, ...);",
>
> I gather from the complaint that you're currently doing something that 
> causes the Param to be typed as a generic "record", which is problematic 
> since the record's details are not available from anyplace.  But if you 
> cast it directly to a named composite type, that should work.
>
> If it still doesn't work, please provide a more concrete example.

Thanks, unfortunately adding the explicit cast doesn't help.  I've 
attached a minimal runnable example.

I am serializing as a generic record, so it occurs to me that another 
solution would be to use the actual type of the composite in question. 
(Though it also seems to me that my code should work as-is.)  Is there a 
way to discover the OID of a composite type?  And is the wire format the 
same as for a generic record?

  -E
Attachment

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [PATCH] Make jsonapi usable from libpq
Next
From: Julien Rouhaud
Date:
Subject: Re: [HACKERS] Preserving param location