Re: PATCH: psql boolean display

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: phil(at)omniti(dot)com
Cc: Kevin(dot)Grittner(at)wicourts(dot)gov, pavel(dot)stehule(at)gmail(dot)com, robertmhaas(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org, thom(at)linux(dot)com, singh(dot)gurjeet(at)gmail(dot)com
Subject: Re: PATCH: psql boolean display
Date: 2012-08-20 23:09:35
Message-ID: 20120821.080935.580933286629672719.t-ishii@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Aug 20, 2012 6:28 PM, "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
> wrote:
>>
>> Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:
>>
>> > On occasions I have wanted psql to emit the full 'True'/'False'
>> > words instead of cryptic one-letter t/f, which can get lost on
>> > long rows that get wrapped around on screen. Writing long-winded
>> > CASE expressions to get the effect is too much for small ad-hoc
>> > queries.
>> >
>> > I thought of inventing a data type whose out-function would emit
>> > these strings, and tack a ::mybool to the expression I want
>> > modified. But that would break the applications if somebody pasted
>> > the same query in an application (JDBC or some such that
>> > understands boolean) and expected a boolean data type instead of a
>> > text output of an expression.
>>
>> The type itself does output true/false; it's just psql that uses
>> t/f.
>>
>> test=# select 'true'::boolean::text;
>> text
>> ------
>> true
>> (1 row)
>>
>> test=# select 'false'::boolean::text;
>> text
>> -------
>> false
>> (1 row)
>>
>> That has always seemed quite odd (and occasionally inconvenient) to
>> me.
>
> I think that may be from the cast. I didn't see any transformation in psql.
> Looked like it was raw output from the server.

Right. "t", "f" are generated in backend. See boolout() in
backend/utils/adt/bool.c for more details.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Johnston 2012-08-20 23:17:59 Re: temporal support patch
Previous Message Tom Lane 2012-08-20 23:08:12 Re: sha1, sha2 functions into core?