1

I am trying to debug my C program that accesses a postgres database.

I would like to dump the contents of PGresult using some postgres provided routine, where the PGresult is from a command that is not a SELECT.

Is there a postgres provided routine that will dump PGresult in a human readable way?

I will add that as an option to the logging that will dump the contents of PGresult.

I previously asked this question: How to dump PGresult and the answer is good for SELECTs, but it is not good for other commands.

[edit] I am looking to dump it for debugging purposes. So, if I set logging to debug level, I would like to see whatever information is in PGreturn. I am hoping there is some function that will do this. I also hope it trims out information that is not relevant. I have not looked at the Postgres source code to see what is available.

Community
  • 1
  • 1
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125

1 Answers1

0

With the function

char *PQresultErrorField(const PGresult *res, int fieldcode);

you can get various information on the status of the performed operation, including severity, sqlstate, main and detail error messages, hint message and several others. See details in the documentation.

klin
  • 112,967
  • 15
  • 204
  • 232