I am using libpq for my C/C++ application to interface with PostgreSQL.
My queries are parameterised and in text (not binary) format (using PQexecParams
), and they return data that might be a text
, text[]
, int4range
, or other complex types. However, libpq seems to format strings based on rules that don't seem to be well-documented.
For example, for a string array, libpq returns something like that:
{abc,def,"h,h","h\"h",h'h,"h h"}
when the array, in C style, would look like this:
{"abc","def","h,h","h\"h","h'h","h h"}
libpq seems to place double quotes and escape characters (\
) where it deems fit.
For a string (not string array), libpq will instead not place double quotes at all.
As any printable character might possibly be stored in my strings, is there a way to force libpq or PostgreSQL to return strings and string arrays in a consistent format for easy consumption by my C/C++ application?