ne 23. 4. 2023 v 14:42 odesílatel Isaac Morland <isaac.morl...@gmail.com> napsal:
> On Sun, 23 Apr 2023 at 01:31, Pavel Stehule <pavel.steh...@gmail.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. > psql shows to display content without changes. I don't think it should be fixed on the client side. But it can be easily fixed on the server side. I think there is some code that tries to clean the end lines already. regards Pavel