Re: It's seems that the function "do_text_output_multiline" does not suit for format "line1\nline2\n...lineN".
От | Tom Lane |
---|---|
Тема | Re: It's seems that the function "do_text_output_multiline" does not suit for format "line1\nline2\n...lineN". |
Дата | |
Msg-id | 15227.1464027719@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: It's seems that the function "do_text_output_multiline" does not suit for format "line1\nline2\n...lineN". (David Rowley <david.rowley@2ndquadrant.com>) |
Список | pgsql-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 psqlusing the fuction "do_text_output_multiline" with the string just like mentioned in mail tilte, such as "this is a\ntestfor\nnew blank.". the PostgreSQL may lead to corruption in this function, and i debugged it that found this functioncan 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
В списке pgsql-hackers по дате отправления: