unpack_sql_state not called?

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: unpack_sql_state not called?
Date: 2021-08-30 23:32:41
Message-ID: CAHut+PuYituuD1-VVZUNcmCQuc3ZzZMPoO57POgm8tnXOkwJAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi. I noticed some code that seems the same as the nearby function
unpack_sql_state, and I wondered why it is not just calling it?

For example,

diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index a3e1c59..d91ed98 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -3313,7 +3313,7 @@ send_message_to_frontend(ErrorData *edata)
const char *sev;
char tbuf[12];
int ssval;
- int i;
+ char *ssbuf;

/* 'N' (Notice) is for nonfatal conditions, 'E' is for errors */
pq_beginmessage(&msgbuf, (edata->elevel < ERROR) ? 'N' : 'E');
@@ -3326,15 +3326,10 @@ send_message_to_frontend(ErrorData *edata)

/* unpack MAKE_SQLSTATE code */
ssval = edata->sqlerrcode;
- for (i = 0; i < 5; i++)
- {
- tbuf[i] = PGUNSIXBIT(ssval);
- ssval >>= 6;
- }
- tbuf[i] = '\0';
+ ssbuf = unpack_sql_state(ssval);

pq_sendbyte(&msgbuf, PG_DIAG_SQLSTATE);
- err_sendstring(&msgbuf, tbuf);
+ err_sendstring(&msgbuf, ssbuf);

/* M field is required per protocol, so always send something */
pq_sendbyte(&msgbuf, PG_DIAG_MESSAGE_PRIMARY);

------
Kind Regards,
Peter Smith.
Fujitsu Australia

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-08-31 00:11:00 Re: Can we get rid of repeated queries from pg_dump?
Previous Message Ranier Vilela 2021-08-30 23:18:45 Re: Avoid choose invalid number of partitions (src/backend/executor/nodeAgg.c)