MCPcopy Create free account
hub / github.com/apache/cloudberry / PQresultVerboseErrorMessage

Function PQresultVerboseErrorMessage

src/interfaces/libpq/fe-exec.c:3240–3269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3238}
3239
3240char *
3241PQresultVerboseErrorMessage(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
3271char *
3272PQresultErrorField(const PGresult *res, int fieldcode)

Callers 1

exec_command_errverboseFunction · 0.85

Calls 4

libpq_gettextFunction · 0.85
initPQExpBufferFunction · 0.85
pqBuildErrorMessage3Function · 0.85
termPQExpBufferFunction · 0.85

Tested by

no test coverage detected