RE: libpq debug log

From: "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>
To: "iwata(dot)aya(at)fujitsu(dot)com" <iwata(dot)aya(at)fujitsu(dot)com>, 'Kyotaro Horiguchi' <horikyota(dot)ntt(at)gmail(dot)com>
Cc: "alvherre(at)alvh(dot)no-ip(dot)org" <alvherre(at)alvh(dot)no-ip(dot)org>, "tgl(at)sss(dot)pgh(dot)pa(dot)us" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "k(dot)jamison(at)fujitsu(dot)com" <k(dot)jamison(at)fujitsu(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: RE: libpq debug log
Date: 2021-03-18 08:51:02
Message-ID: TYAPR01MB2990D25983F7D9CC06BE36AEFE699@TYAPR01MB2990.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
> + pqTraceOutputR(const char *message, FILE *f)
> + {
> + int cursor = 0;
> +
> + pqTraceOutputInt32(message, &cursor, f);
>
> I don't understand the reason for spliting message and &cursor here.
>
> + pqTraceOutputR(const char *message, FILE *f)
> + {
> + char *p = message;
> +
> + pqTraceOutputInt32(&p, f);
>
> works well.

Yes, that would also work. But I like the separate cursor + fixed starting point here, probably because it's sometimes confusing to see the pointer value changed inside functions. (And a pointer itself is an allergy for some people, not to mention a pointer to ointer...) Also, libpq uses cursors for network I/O buffers. So, I think the patch can be as it is now.

> +static void
> +pqTraceOutputT(const char *message, int end, FILE *f)
> +{
> + int cursor = 0;
> + int nfields;
> + int i;
> +
> + nfields = pqTraceOutputInt16(message, &cursor, f);
> +
> + for (i = 0; i < nfields; i++)
> + {
> + pqTraceOutputString(message, &cursor, end, f);
> + pqTraceOutputInt32(message, &cursor, f);
> + pqTraceOutputInt16(message, &cursor, f);
> + pqTraceOutputInt32(message, &cursor, f);
> + pqTraceOutputInt16(message, &cursor, f);
> + pqTraceOutputInt32(message, &cursor, f);
> + pqTraceOutputInt16(message, &cursor, f);
> + }
> +}
>
> I didn't looked closer, but lookong the usage of the variable "end",
> something's wrong in the function.

Ah, end doesn't serve any purpose. I guess the compiler emitted a warning "end is not used". I think end can be removed.

Regards
Takayuki Tsunakawa}

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2021-03-18 09:42:35 Re: crash during cascaded foreign key update
Previous Message Magnus Hagander 2021-03-18 08:48:57 Re: SSL SNI