From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Hao Lee <mixtrue@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: It's seems that the function "do_text_output_multiline" does not suit for format "line1\nline2\n...lineN".
Date: Mon, 23 May 2016 14:21:59 -0400
Message-ID: <15227.1464027719@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKJS1f9v5vTC0fbynvutKO2HPpMJWQPhWAyDMHxJo1cTT=t=Tw@mail.gmail.com>
References: <CAGoxFiFPAGyPAJLcFxTB5cGhTW2yOVBDYeqDugYwV4dEd1L_Ag@mail.gmail.com>
<CAKJS1f9v5vTC0fbynvutKO2HPpMJWQPhWAyDMHxJo1cTT=t=Tw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
David Rowley <david.rowley@2ndquadrant.com> writes:
> On 20 May 2016 at 19:13, Hao Lee <mixtrue@gmail.com> wrote:
>> Today, I am do some works on adding some customized featues to PostgreSQL 9.6 beta1. But, when i do some output to psql using the fuction "do_text_output_multiline" with the string just like mentioned in mail tilte, such as "this is a\ntest for\nnew blank.". the PostgreSQL may lead to corruption in this function, and i debugged it that found this function can not dealt with the boundaries properly. The original function code as :
> Thanks for reporting this. It does seem pretty broken. I guess we've
> only gotten away with this due to EXPLAIN output lines always having a
> \n at the end of them, but we should fix this.
Agreed.
> Your proposed fix looks a little bit confused. You could have just
> removed the eol += len; as testing if (eol) in the else will never be
> true as that else is only being hit because eol is NULL.
I think really the right fix is "eol = text + len" rather than modifying
the loop condition. Almost certainly, that is what the original coder
intended, but typo'd the statement and nobody ever noticed.
> I shuffled things around in there a bit and came up with the attached fix.
I didn't like this version because it duplicated the string-conversion
code, which admittedly is only one line, but not a very simple line.
I pushed something based on "eol = text + len" instead.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.rowley@2ndquadrant.com, mixtrue@gmail.com
Subject: Re: It's seems that the function "do_text_output_multiline" does not suit for format "line1\nline2\n...lineN".
In-Reply-To: <15227.1464027719@sss.pgh.pa.us>
References: <CAGoxFiFPAGyPAJLcFxTB5cGhTW2yOVBDYeqDugYwV4dEd1L_Ag@mail.gmail.com> <CAKJS1f9v5vTC0fbynvutKO2HPpMJWQPhWAyDMHxJo1cTT=t=Tw@mail.gmail.com> <15227.1464027719@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox