Re: [PATCH] Add pretty-printed XML output option

Поиск
Список
Период
Сортировка
От Jim Jones
Тема Re: [PATCH] Add pretty-printed XML output option
Дата
Msg-id 3a3d7963-7f30-9e0a-5e7c-11382fed425a@uni-muenster.de
обсуждение исходный текст
Ответ на Re: [PATCH] Add pretty-printed XML output option  (Peter Smith <smithpb2250@gmail.com>)
Ответы Re: [PATCH] Add pretty-printed XML output option  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 09.02.23 02:01, Peter Smith wrote:
> OTOH, if you are having to check for NULL doc anyway, maybe it's just
> as easy only doing that up-front. Then you could quick-exit the
> function without calling xmlDocDumpFormatMemory etc. in the first
> place. For example:
>
> doc = xml_parse(arg, XMLOPTION_DOCUMENT, false, GetDatabaseEncoding(), NULL);
> if (!doc)
>     return 0;

I see your point. If I got it right, you're suggesting the following 
change in the PG_TRY();

    PG_TRY();
     {

         int nbytes;

         if(!doc)
             xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,
                     "could not parse the given XML document");

         xmlDocDumpFormatMemory(doc, &xmlbuf, &nbytes, 1);

         if(!nbytes || xmlerrcxt->err_occurred)
             xml_ereport(xmlerrcxt, ERROR, ERRCODE_INTERNAL_ERROR,
                     "could not indent the given XML document");


         initStringInfo(&buf);
         appendStringInfoString(&buf, (const char *)xmlbuf);

     }

.. which will catch the doc == NULL before calling xmlDocDumpFormatMemory.

Is it what you suggest?

Thanks a lot for the thorough review!

Best, Jim




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

Предыдущее
От: Masahiko Sawada
Дата:
Сообщение: Re: [PoC] Improve dead tuple storage for lazy vacuum
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [PATCH] Add pretty-printed XML output option