Re: Composite types as parameters

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Elijah Stone <elronnd(at)elronnd(dot)net>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Composite types as parameters
Date: 2021-06-26 15:42:03
Message-ID: 3013946.1624722123@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Elijah Stone <elronnd(at)elronnd(dot)net> writes:
> I want to execute a query like this:

> PQexecParams("insert into sometable values($1, ...);", paramValues[0] = serialize some record, ...)

> However this fails in coerce_record_to_complex(), because it receives a
> node of type Param, but it can only handle RowExpr and Var.

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Arne Roland 2021-06-26 15:50:49 Re: PATCH: generate fractional cheapest paths in generate_orderedappend_path
Previous Message Andrew Dunstan 2021-06-26 15:01:07 Re: pgsql: Fix pattern matching logic for logs in TAP tests of pgbench