Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c4f7a6b

Browse files
committed
Refactor one conversion of SQLSTATE to string in elog.c
unpack_sql_state() has been introduced in d46bc44 to refactor the unpacking of a SQLSTATE into a string, but it forgot one code path when sending error reports to clients that could make use of it. This changes the code to also use unpack_sql_state() there, simplifying a bit the code. Author: Peter Smith Discussion: https://postgr.es/m/CAHut+PuYituuD1-VVZUNcmCQuc3ZzZMPoO57POgm8tnXOkwJAA@mail.gmail.com
1 parent de1d4fe commit c4f7a6b

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/backend/utils/error/elog.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -3312,8 +3312,6 @@ send_message_to_frontend(ErrorData *edata)
33123312
/* New style with separate fields */
33133313
const char *sev;
33143314
char tbuf[12];
3315-
int ssval;
3316-
int i;
33173315

33183316
/* 'N' (Notice) is for nonfatal conditions, 'E' is for errors */
33193317
pq_beginmessage(&msgbuf, (edata->elevel < ERROR) ? 'N' : 'E');
@@ -3324,17 +3322,8 @@ send_message_to_frontend(ErrorData *edata)
33243322
pq_sendbyte(&msgbuf, PG_DIAG_SEVERITY_NONLOCALIZED);
33253323
err_sendstring(&msgbuf, sev);
33263324

3327-
/* unpack MAKE_SQLSTATE code */
3328-
ssval = edata->sqlerrcode;
3329-
for (i = 0; i < 5; i++)
3330-
{
3331-
tbuf[i] = PGUNSIXBIT(ssval);
3332-
ssval >>= 6;
3333-
}
3334-
tbuf[i] = '\0';
3335-
33363325
pq_sendbyte(&msgbuf, PG_DIAG_SQLSTATE);
3337-
err_sendstring(&msgbuf, tbuf);
3326+
err_sendstring(&msgbuf, unpack_sql_state(edata->sqlerrcode));
33383327

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

0 commit comments

Comments
 (0)