Re: very long record lines in expanded psql output

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Platon Pronko <platon7pronko(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: very long record lines in expanded psql output
Date: 2023-05-19 11:02:05
Message-ID: 20230519110205.updpbjiuqgbox6gp@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022-Jul-25, Andrew Dunstan wrote:

> Committed. There were a couple of bits missing, which I filled in, and I
> changed the behaviour when the option is given without an argument, so
> that instead of resetting it the current value is shown, similarly to
> how most pset options work.

I was translating the new messages introduced by this commit, and
decided to unify them. While doing so, I notice that the feature
misbehaves when you give it a string value that doesn't match any valid
value: it just resets the value to 0, which is entirely the wrong thing.
For other settings, we first verify that the given value is valid, and
only then we change the setting.

So I came up with the attached. While at it, I noticed that we have
other uses of atoi() there, most notably pager_min_lines. My first
impulse was to just to do the same as for xheader_width, namely to test
whether the atoid result is zero, and not change in that case. But then
I noticed we're already using variables.c facilities, so I decided to do
likewise; this results in simpler code. So we're now stricter, because
variables.c rejects trailing junk after the number. (123asd was
previously parsed as 123, now it's an error.)

There remain atoi uses in this code, and aside from the atoi()-induced
behavior of making any non-number input set it to 0, it does stuff like

=# \pset border 65538asd
Border style is 2.

because border style is short int, so this value overflows it. Same
happens with 'columns'. However, this is all very old code and nobody
seems to have complained.

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"¿Cómo puedes confiar en algo que pagas y que no ves,
y no confiar en algo que te dan y te lo muestran?" (Germán Poo)

Attachment Content-Type Size
0001-Tweak-xheader_width-input-parsing.patch text/x-diff 2.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2023-05-19 11:02:24 Re: The documentation for READ COMMITTED may be incomplete or wrong
Previous Message Joel Jacobson 2023-05-19 09:24:27 New COPY options: DELIMITER NONE and QUOTE NONE