Narrow the scope of the variable outputstr in logicalrep_write_tuple - Mailing list pgsql-hackers

From japin
Subject Narrow the scope of the variable outputstr in logicalrep_write_tuple
Date
Msg-id MEYP282MB16699FA4A7CD57EB250E871FB6A40@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: Narrow the scope of the variable outputstr in logicalrep_write_tuple  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Re: Narrow the scope of the variable outputstr in logicalrep_write_tuple  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

I find that the outputstr variable in logicalrep_write_tuple() only use in
`else` branch, I think we can narrow the scope, just like variable outputbytes
in `if` branch (for more readable).

        /*
         * Send in binary if requested and type has suitable send function.
         */
        if (binary && OidIsValid(typclass->typsend))
        {
            bytea      *outputbytes;
            int         len;

            pq_sendbyte(out, LOGICALREP_COLUMN_BINARY);
            outputbytes = OidSendFunctionCall(typclass->typsend, values[i]);
            len = VARSIZE(outputbytes) - VARHDRSZ;
            pq_sendint(out, len, 4);    /* length */
            pq_sendbytes(out, VARDATA(outputbytes), len);   /* data */
            pfree(outputbytes);
        }
        else
        {
            pq_sendbyte(out, LOGICALREP_COLUMN_TEXT);
            outputstr = OidOutputFunctionCall(typclass->typoutput, values[i]);
            pq_sendcountedtext(out, outputstr, strlen(outputstr), false);
            pfree(outputstr);
        }

Attached is a samll patch to fix it.

-- 
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.


Attachment

pgsql-hackers by date:

Previous
From: Tatsuro Yamada
Date:
Subject: Re: list of extended statistics on psql
Next
From: Luc Vlaming
Date:
Subject: Re: Lazy JIT IR code generation to increase JIT speed with partitions