Skip to content

Provide schema and count information inCursor #12

@helje5

Description

@helje5

It is often useful to have schema information for a fetch. That is for clients which allow the user or developer to enter arbitrary queries (to then reflect on results, e.g. to show them in a table w/ a proper column name header).

libpq provides this using the PQnfields function to get the number of columns returned, and then PQfname to extract the name associated with the column.

In addition libpq provides PQntuples which has the number of rows being returned in advance. That is also very useful (e.g. the preallocate result data structures with the proper size before fetching into them).

It's been a while since I looked at the raw protocol, but I all this information is readily available in the query response and doesn't require fetching all records.

https://www.postgresql.org/docs/11/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO

The PostgresValue, could also carry the actual PG OID type (maybe as a nice enum) similar to PQftype.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions