Hello, The PGresult structure returned on COPY ... FROM provides a handful of information (https://www.postgresql.org/docs/13/libpq-copy.html): number of fields expected and whether they are binary or not.
However it doesn't provide the types expected. For binary copy the exact type is important: playing with it, it seems that no cast whatsoever is applied and the errors reported are relatively low level. For instance, passing an int4 value to an int8 field causes a "protocol_violation: insufficient data left in message"; the other way around is greeted with "invalid_binary_representation: incorrect binary data format". Naively, it would seem that once a "COPY ... FROM STDIN" is executed successfully, the server has a pretty good idea of what data types it is expecting. I'm wondering: is it absurd to ask for this info to be returned as RowDescription and to be exposed by the libpq PQftype()? Cheers -- Daniele