| From: | Isaac Morland <isaac(dot)morland(at)gmail(dot)com> |
|---|---|
| To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: xmlserialize bug - extra empty row at the end |
| Date: | 2023-04-23 12:41:55 |
| Message-ID: | CAMsGm5eEhP5AnmmLANEPzwzm062WXOpjSCaSqCfFETdmz8bQUA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sun, 23 Apr 2023 at 01:31, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> Hi
>
> maybe I found a bug in xmlserialize
>
> SELECT xmlserialize(DOCUMENT '<foo><bar><val x="y">42</val></bar></foo>'
> AS varchar INDENT);
>
> (2023-04-23 07:27:53) postgres=# SELECT xmlserialize(DOCUMENT
> '<foo><bar><val x="y">42</val></bar></foo>' AS varchar INDENT);
> ┌─────────────────────────┐
> │ xmlserialize │
> ╞═════════════════════════╡
> │ <foo> ↵│
> │ <bar> ↵│
> │ <val x="y">42</val>↵│
> │ </bar> ↵│
> │ </foo> ↵│
> │ │
> └─────────────────────────┘
> (1 row)
>
> Looks so there is an extra empty row.
>
I wouldn't necessarily worry about this much. There is not, as such, an
extra blank line at the end; rather it is conventional that a text file
should end with a newline character. That is, conventionally every single
line in a text file ends with a newline character, meaning the only text
file that doesn't end with a newline is the empty file. You can see this in
tools like diff, which explicitly report "no newline at end of file" if the
file ends with a different character.
If you were to save the value to a file you would probably want it the way
it is.
That being said, this is a database column result and I agree it would look
more elegant if the blank line in the display were not there. I might go so
far as to change the psql display routines to not leave a blank line after
the content in the event it ends with a newline.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2023-04-23 14:48:09 | Re: xmlserialize bug - extra empty row at the end |
| Previous Message | Daniel Gustafsson | 2023-04-23 12:35:53 | Re: duplicate function declaration in multirangetypes_selfuncs.c |