thousands comma numeric formatting in psql

From: Eugen Nedelcu <eugen(at)sifolt(dot)ro>
To: pgsql-patches(at)postgresql(dot)org
Subject: thousands comma numeric formatting in psql
Date: 2005-06-21 05:42:16
Message-ID: 20050621054216.GA367@sifolt.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Hello,

This is my first post to this list.
Sorry if my english it's not so good. It's not my native language.

I'm interrested to now if someone think that having a feature like
'thousands comma delimited numeric formatting' in psql it's a
usefull thing.

I've made a patch for psql that adds this feature, so issuing a
select like this:

my_database=> select 1234567.89;

results in:

?column?
--------------
1,234,567.89

This feature is toggle on/off with a backslash command ('\n'):

my_database=> \n
Numeric formatting is off.

my_database=> select 1234567.89;

?column?
--------------
1234567.89

For me, psql it's still the best client for postgres, faster and
flexible than graphic ones. And having tables with many numeric
columns witch contain huge numbers make difficult to read this
numbers.

One solution to deal with this is to use to_char function, but for
complex selects against multiple tables it's not a good option.

Another one is to make a custom function that works like this:

select my_function(... complex subselect ...);

but this seems ugly to me.

By adding the '\n' switch to psql I can make any complex select and
have all numeric fields in result formatted in easy readable form.

I'm not an expert in postgresql, so if someone thinks there is an
easier way to deal with numeric fields, please share.

If my idea is considered usefull I can post the patch to this list.

Best regards,
Eugen.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message ITAGAKI Takahiro 2005-06-21 05:43:57 Re: [PATCHES] O_DIRECT for WAL writes
Previous Message Oliver Jowett 2005-06-21 04:57:10 Re: Escape handling in strings

Browse pgsql-patches by date

  From Date Subject
Next Message ITAGAKI Takahiro 2005-06-21 05:43:57 Re: [PATCHES] O_DIRECT for WAL writes
Previous Message Mark Kirkwood 2005-06-21 04:44:36 Re: TODO Item - Return compressed length of TOAST datatypes