Re: xmlserialize bug - extra empty row at the end

Поиск
Список
Период
Сортировка
От Jim Jones
Тема Re: xmlserialize bug - extra empty row at the end
Дата
Msg-id 79b7c5b9-f033-dd16-3917-d0b2dc6b0d2b@uni-muenster.de
обсуждение исходный текст
Ответ на xmlserialize bug - extra empty row at the end  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
On 24.04.23 03:18, Tom Lane wrote:
> I wouldn't actually *use* pchomp here, because that induces an 
> unnecessary
> copy of the result string.  I had in mind more like copying pchomp's code
> to count up the trailing newline(s) and then pass a corrected length
> to cstring_to_text_with_len.
Changed.
> You could simplify matters by doing that in all cases, too.  It should
> never find anything to remove in the non-indented case, but the check
> should be of negligible cost in context.

I'm not sure I understood it correctly.

The non-indented cases should never find anything and indented cases 
with CONTENT strings do not add trailing newlines, so this is only 
applicable with DOCUMENT .. INDENT, right?

Something like this would suffice?

if(xmloption_arg != XMLOPTION_DOCUMENT)
     result = (text *) xmlBuffer_to_xmltype(buf);
else
{
     int    len = xmlBufferLength(buf);
     const char *xmloutput = (const char *) xmlBufferContent(buf);

     while (len > 0 && xmloutput[len - 1] == '\n')
         len--;

     result = cstring_to_text_with_len(xmloutput, len);
}

If we really agree on manually removing the trailing newlines I will 
open a CF entry for this.

Best, Jim


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Andrey M. Borodin"
Дата:
Сообщение: Re: New committers: Nathan Bossart, Amit Langote, Masahiko Sawada
Следующее
От: Jesper Pedersen
Дата:
Сообщение: Re: New committers: Nathan Bossart, Amit Langote, Masahiko Sawada