PQftype(copy_rset) returns zero OIDs??? - Mailing list pgsql-general

From Dominique Devienne
Subject PQftype(copy_rset) returns zero OIDs???
Date
Msg-id CAFCRh-8BMj86X6DfpfQuV3NnTaH4eU+4=-MAwyhVKT98EThFMg@mail.gmail.com
Whole thread Raw
Responses Re: PQftype(copy_rset) returns zero OIDs???  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi.

For the first time, I'm checking the OIDs returned
(via the result set's PQftype API), by "regular" SELECT:

`select ... from tab`

and by a COPY TO BINARY:

`COPY (
 select ...
   from tab
) TO STDOUT WITH (FORMAT BINARY)`

And to my surprise, they are not!
The ones from the COPY are all zeros.

Is that normal?

The BINARY record format encodes the byte-size, not the OIDs of the (scalar) fields.
How is one supposed to "infer" the OIDs then?

Also, given that the select-clause can use expressions I think,
including casts, instead of just naming columns, "describing" the table doesn't help.

But even for a "plain" COPY, having to describe explicitly is one more round-trip,
and seems asymmetrical compared to the result-set of a regular select.

I'm both surprised and confused by this behavior.
And would appreciate some clarifications. Thanks, --DD

PS: libpq v16.1. v12 server.

pgsql-general by date:

Previous
From: David Rowley
Date:
Subject: Re: Behavior of debug_parallel_query=regress
Next
From: Ron Johnson
Date:
Subject: Re: PostgreSQL Guard