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

Function pqInternalNotice

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

* pqInternalNotice - produce an internally-generated notice message * * A format string and optional arguments can be passed. Note that we do * libpq_gettext() here, so callers need not. * * The supplied text is taken as primary message (ie., it should not include * a trailing newline, and should not be more than one line). */

Source from the content-addressed store, hash-verified

871 * a trailing newline, and should not be more than one line).
872 */
873void
874pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...)
875{
876 char msgBuf[1024];
877 va_list args;
878 PGresult *res;
879
880 if (hooks->noticeRec == NULL)
881 return; /* nobody home to receive notice? */
882
883 /* Format the message */
884 va_start(args, fmt);
885 vsnprintf(msgBuf, sizeof(msgBuf), libpq_gettext(fmt), args);
886 va_end(args);
887 msgBuf[sizeof(msgBuf) - 1] = '\0'; /* make real sure it's terminated */
888
889 /* Make a PGresult to pass to the notice receiver */
890 res = PQmakeEmptyPGresult(NULL, PGRES_NONFATAL_ERROR);
891 if (!res)
892 return;
893 res->noticeHooks = *hooks;
894
895 /*
896 * Set up fields of notice.
897 */
898 pqSaveMessageField(res, PG_DIAG_MESSAGE_PRIMARY, msgBuf);
899 pqSaveMessageField(res, PG_DIAG_SEVERITY, libpq_gettext("NOTICE"));
900 pqSaveMessageField(res, PG_DIAG_SEVERITY_NONLOCALIZED, "NOTICE");
901 /* XXX should provide a SQLSTATE too? */
902
903 /*
904 * Result text is always just the primary message + newline. If we can't
905 * allocate it, substitute "out of memory", as in pqSetResultError.
906 */
907 res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, false);
908 if (res->errMsg)
909 sprintf(res->errMsg, "%s\n", msgBuf);
910 else
911 res->errMsg = libpq_gettext("out of memory\n");
912
913 /*
914 * Pass to receiver, then free it.
915 */
916 res->noticeHooks.noticeRec(res->noticeHooks.noticeRecArg, res);
917 PQclear(res);
918}
919
920/*
921 * pqAddTuple

Callers 10

pqGetIntFunction · 0.85
pqGetInt64Function · 0.85
pqPutIntFunction · 0.85
ifFunction · 0.85
pqEndcopy3Function · 0.85
PQsetvalueFunction · 0.85
check_field_numberFunction · 0.85
check_tuple_field_numberFunction · 0.85
check_param_numberFunction · 0.85
PQcmdTuplesFunction · 0.85

Calls 5

libpq_gettextFunction · 0.85
PQmakeEmptyPGresultFunction · 0.85
pqSaveMessageFieldFunction · 0.85
pqResultAllocFunction · 0.85
PQclearFunction · 0.85

Tested by

no test coverage detected