Re: unpack_sql_state not called?

2021-09-01 Thread Peter Smith
Thanks for pushing!

--
Kind Regards,
Peter Smith.
Fujitsu Australia




Re: unpack_sql_state not called?

2021-08-30 Thread Michael Paquier
On Tue, Aug 31, 2021 at 02:01:02PM +1000, Peter Smith wrote:
> Do you want me to re-post it as a patch attachment?

No need.  Thanks.
--
Michael


signature.asc
Description: PGP signature


Re: unpack_sql_state not called?

2021-08-30 Thread Peter Smith
On Tue, Aug 31, 2021 at 11:31 AM Michael Paquier  wrote:
>
> On Tue, Aug 31, 2021 at 09:32:41AM +1000, Peter Smith wrote:
> > 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?
>
> This looks like a piece that could have been done in d46bc44, and
> would not matter performance-wise.  No objections from here to do
> this simplification.

Thanks. Do you want me to re-post it as a patch attachment?

--
Kind Regards,
Peter Smith.
Fujitsu Australia




Re: unpack_sql_state not called?

2021-08-30 Thread Michael Paquier
On Tue, Aug 31, 2021 at 09:32:41AM +1000, Peter Smith wrote:
> 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?

This looks like a piece that could have been done in d46bc44, and
would not matter performance-wise.  No objections from here to do
this simplification.
--
Michael


signature.asc
Description: PGP signature


unpack_sql_state not called?

2021-08-30 Thread Peter Smith
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;
chartbuf[12];
int ssval;
-   int i;
+   char   *ssbuf;

/* 'N' (Notice) is for nonfatal conditions, 'E' is for errors */
pq_beginmessage(, (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(, PG_DIAG_SQLSTATE);
-   err_sendstring(, tbuf);
+   err_sendstring(, ssbuf);

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

--
Kind Regards,
Peter Smith.
Fujitsu Australia