| 3238 | } |
| 3239 | |
| 3240 | char * |
| 3241 | PQresultVerboseErrorMessage(const PGresult *res, |
| 3242 | PGVerbosity verbosity, |
| 3243 | PGContextVisibility show_context) |
| 3244 | { |
| 3245 | PQExpBufferData workBuf; |
| 3246 | |
| 3247 | /* |
| 3248 | * Because the caller is expected to free the result string, we must |
| 3249 | * strdup any constant result. We use plain strdup and document that |
| 3250 | * callers should expect NULL if out-of-memory. |
| 3251 | */ |
| 3252 | if (!res || |
| 3253 | (res->resultStatus != PGRES_FATAL_ERROR && |
| 3254 | res->resultStatus != PGRES_NONFATAL_ERROR)) |
| 3255 | return strdup(libpq_gettext("PGresult is not an error result\n")); |
| 3256 | |
| 3257 | initPQExpBuffer(&workBuf); |
| 3258 | |
| 3259 | pqBuildErrorMessage3(&workBuf, res, verbosity, show_context); |
| 3260 | |
| 3261 | /* If insufficient memory to format the message, fail cleanly */ |
| 3262 | if (PQExpBufferDataBroken(workBuf)) |
| 3263 | { |
| 3264 | termPQExpBuffer(&workBuf); |
| 3265 | return strdup(libpq_gettext("out of memory\n")); |
| 3266 | } |
| 3267 | |
| 3268 | return workBuf.data; |
| 3269 | } |
| 3270 | |
| 3271 | char * |
| 3272 | PQresultErrorField(const PGresult *res, int fieldcode) |
no test coverage detected