Re: psql: add \pset true/false

From: Matthijs van der Vleuten <matthijs(at)zr40(dot)nl>
To: PostgreSQL hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Marko Tiikkaja <marko(at)joh(dot)to>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: psql: add \pset true/false
Date: 2015-10-29 12:28:57
Message-ID: 9F653AC9-A596-45F4-B1FE-3808F2DC7FC9@zr40.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 29 Oct 2015, at 08:50, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> On Thu, Oct 29, 2015 at 1:32 AM, Marko Tiikkaja <marko(at)joh(dot)to> wrote:
>>> 2. If you're the sort of person liable to be confused by t/f, you
>>> probably aren't in the target audience for psql anyway.
>>
>> Really? The difference between t/f is that the vertical squiggle is
>> flipped, THAT'S IT. Consider:
>>
>> t t f f f
>> f t f t f
>>
>> Saying that I'm not target audience for not being able to see WTF is going
>> on above I find offending.
>
> Sorry, no offense intended. It's really just never happened to me
> that I've had a problem with this, and I've been using psql for quite
> a few years now. I do agree that if you have a bunch of values in a
> row it's more apt to be confusing than with just one, but they won't
> normally be as closely spaced as you have them there, because psql
> inserts spacing and borders and column headers are usually more than
> one character.

I have had exactly this situation a week ago. I was testing the output of an algorithm that is supposed to have exactly one true value per input id.

In the first screenshot, psql_true_false_off.png, you see the output of psql unpatched. Notice how there’s barely any obvious difference between ’t’ and ‘f’. It’s hard to verify that the supposed output is correct. There’s also some column with all-false values, I would need to carefully examine all the f and t characters to find that.

In the second screenshot, psql_true_false_on.png, I applied Marko’s patch and set a colorful emoji character as the display string for true and false. Now it’s relatively easy to verify that there’s exactly one true value. In addition, it’s hard to miss that the first column is always false (for this particular range). I wasn’t looking for that, but this presentation made it strikingly obvious. In the first screenshot, it would remain hidden. (Did you notice the two columns there that have all false values?)

I’ve been testing Marko’s patch for a few months now, and I’ve found it helps a lot in recognizing booleans in many contexts.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-10-29 12:29:21 Re: [HACKERS] Replication slots and isolation levels
Previous Message Vladimir Borodin 2015-10-29 11:35:27 Re: [ADMIN] Replication slots and isolation levels