Skip site navigation (1) Skip section navigation (2)

Re: thousands comma numeric formatting in psql

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Eugen Nedelcu <eugen(at)sifolt(dot)ro>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: thousands comma numeric formatting in psql
Date: 2005-07-10 03:46:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
Eugen Nedelcu wrote:
> Hello,
> I have included my patch attached to this mail.
> I have made the changes to deal with locale settings from client
> environment. So now you can start psql like this:
> (export LC_ALL=ro_RO; psql -U user db)
> and have numeric formatting with '.' as thousands separator and
> ',' as decimal point, or
> (export LC_ALL=en_US; psql -U user db)
> and have numeric formatting with ',' as thousands separator and
> '.' as decimal point. This formatting is default when locale is 'C'
> You can set any locale and numeric formatting code will take it in
> consideration.
> This patch is for version 7.3.2. The steps for install is:
> 1) cp thousands_comma.diff $POSTGRES_DIR/src/bin/psql
> 2) cd $POSTGRES_DIR/src/bin/psql
> 3) patch -p0 < thousands_comma.diff
> 4) ../../../configure && make

I have heavily modified your patch and have applied it.  Instead of
using langinfo, I used a \pset variable numericsep. (We can talk about
adding langinfo detection later.)  By default, it is off, ''.  If you
set it to '.', the decimal marker will be ','.  This also allows
separators like ' ' too so numebers can appear as 100 000.

I have also added documentation.

  Bruce Momjian                        |
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to


pgsql-hackers by date

Next:From: Márcio A. SeppDate: 2005-07-10 07:26:26
Subject: Hide source code
Previous:From: Stephen FrostDate: 2005-07-10 00:29:56
Subject: Re: another roles related question

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-07-10 03:53:24
Subject: Re: [patch 1/2] Add implementation of SHA256/384/512
Previous:From: Ilia KantorDate: 2005-07-09 18:02:24
Subject: A minor patch to mark xml/xslt functions immutable

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group