RE: libpq debug log - Mailing list pgsql-hackers

From tsunakawa.takay@fujitsu.com
Subject RE: libpq debug log
Date
Msg-id TYAPR01MB2990D25983F7D9CC06BE36AEFE699@TYAPR01MB2990.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: libpq debug log  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
List pgsql-hackers
From: Kyotaro Horiguchi <horikyota.ntt@gmail.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
confusingto see the pointer value changed inside functions.  (And a pointer itself is an allergy for some people, not
tomention a pointer to ointer...)  Also, libpq uses cursors for network I/O buffers.  So, I think the patch can be as
itis 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}




pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: SSL SNI
Next
From: Amit Langote
Date:
Subject: Re: crash during cascaded foreign key update