This is an automated email from the ASF dual-hosted git repository. yjhjstz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 32221f4499a32504e6b356a8fe05f0269fc812db Author: dh-cloud <[email protected]> AuthorDate: Mon Oct 10 10:24:53 2022 +0800 Forward complete QE notice messages (#11563) The QE notice message might be truncated because MPPnoticeReceiver() limited message length about 800 bytes sent to the client. The client should not see an incomplete notice message. This commit changes its behaviour, it allows QE messages of any length (include QE identifier) to send to the client. --- src/backend/cdb/dispatcher/cdbconn.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/backend/cdb/dispatcher/cdbconn.c b/src/backend/cdb/dispatcher/cdbconn.c index 1e06bff4c5..ead6301ab5 100644 --- a/src/backend/cdb/dispatcher/cdbconn.c +++ b/src/backend/cdb/dispatcher/cdbconn.c @@ -526,6 +526,7 @@ struct QENotice char line[10]; char *func; char *message; + char *whoami; char *detail; char *hint; char *context; @@ -558,11 +559,11 @@ MPPnoticeReceiver(void *arg, const PGresult *res) char *file = ""; char *line = NULL; char *func = ""; - char message[1024]; + char *message= "missing error text"; char *detail = NULL; char *hint = NULL; char *context = NULL; - + char whoami[200] = { 0 }; SegmentDatabaseDescriptor *segdbDesc = (SegmentDatabaseDescriptor *) arg; /* @@ -572,7 +573,8 @@ MPPnoticeReceiver(void *arg, const PGresult *res) if (!res || MyProcPort == NULL) return; - strcpy(message, "missing error text"); + if (segdbDesc && segdbDesc->whoami) + snprintf(whoami, sizeof(whoami), " (%s)", segdbDesc->whoami); for (pfield = res->errFields; pfield != NULL; pfield = pfield->next) { @@ -602,14 +604,7 @@ MPPnoticeReceiver(void *arg, const PGresult *res) sqlstate = pfield->contents; break; case PG_DIAG_MESSAGE_PRIMARY: - strncpy(message, pfield->contents, 800); - message[800] = '\0'; - if (segdbDesc && segdbDesc->whoami && strlen(segdbDesc->whoami) < 200) - { - strcat(message, " ("); - strcat(message, segdbDesc->whoami); - strcat(message, ")"); - } + message = pfield->contents; break; case PG_DIAG_MESSAGE_DETAIL: detail = pfield->contents; @@ -652,10 +647,11 @@ MPPnoticeReceiver(void *arg, const PGresult *res) char *bufptr; int file_len; int func_len; - int message_len; int detail_len; int hint_len; int context_len; + int message_len; + int whoami_len; /* * We use malloc(), because we are in a libpq callback, and we CANNOT @@ -680,10 +676,11 @@ MPPnoticeReceiver(void *arg, const PGresult *res) size = offsetof(QENotice, buf); SIZE_VARLEN_FIELD(file); SIZE_VARLEN_FIELD(func); - SIZE_VARLEN_FIELD(message); SIZE_VARLEN_FIELD(detail); SIZE_VARLEN_FIELD(hint); SIZE_VARLEN_FIELD(context); + SIZE_VARLEN_FIELD(message); + SIZE_VARLEN_FIELD(whoami); /* * Perform the allocation. Put a limit on the max size, as a sanity @@ -721,12 +718,15 @@ MPPnoticeReceiver(void *arg, const PGresult *res) COPY_VARLEN_FIELD(file); strlcpy(notice->line, line, sizeof(notice->line)); COPY_VARLEN_FIELD(func); - COPY_VARLEN_FIELD(message); COPY_VARLEN_FIELD(detail); COPY_VARLEN_FIELD(hint); COPY_VARLEN_FIELD(context); + /* Concatenate message and whoami string together */ + COPY_VARLEN_FIELD(message); + bufptr--; /* lets whoami overwrite '\0' byte of message body */ + COPY_VARLEN_FIELD(whoami); - Assert(bufptr - (char *) notice == size); + Assert(bufptr - (char *) notice == (size - 1)); /* Link it to the queue */ notice->next = NULL; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
