From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Eugen Nedelcu <eugen(at)sifolt(dot)ro> |
Cc: | PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: thousands comma numeric formatting in psql |
Date: | 2005-07-14 06:45:44 |
Message-ID: | 200507140645.j6E6jix14659@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Thanks, fixed, and applied. I also centralized the malloc into a
function. We could use pg_malloc, but that doesn't export out to
/scripts, where this is shared. We will fix that some day, but not
right now.
---------------------------------------------------------------------------
Eugen Nedelcu wrote:
> On Mon, Jul 11, 2005 at 11:37:17PM -0400, Bruce Momjian wrote:
> >
> > Did you do a 'make clean' before testing? I can't reproduce any failure
> > here. Can you supply a number that is failing, like this:
> >
> > SELECT 1000000;
> >
> > ---------------------------------------------------------------------------
> >
>
> The bug is in the following code:
>
> new_str = malloc(new_len) and every one of
> char *my_cell = malloc(....)
>
> Ring a bell?
>
> The corect form is:
>
> new_str = malloc(new_len + 1),
> char *my_cell = malloc(.... + 1)
>
> because of the null character that must terminate the string (\0)
>
> The error apears of course randomly (more probably for a query which
> returns many rows)
>
> Regarding locale aproach, it is trivial to replace langinfo with
> localeconv:
>
> struct lconv *l = localeconv();
> char *dec_point = l->decimal_point;
>
> instead of:
>
> #include langinfo.h
> char *dec_point = nl_langinfo(__DECIMAL_POINT);
>
> I used langinfo because in linux libc it is considered
> "The Elegant and Fast Way" of using locale and conforms with
> X/Open portability guide that every modern Unix follows
> (Solaris, Linux, latest FreeBSD).
>
> Regarding locale vs. \pset numericsep, for me it doesn't matter
> which one is used. I consider the patch very usefull, and I think
> that other guys that use psql daily for working with financial data
> will appreciate it too.
>
> With a quick setting like \pset numericsep ',' all my numeric fields
> will appear in easy readable form. I must underline that to_char is
> a backend function and we talk here about a little psql feature which
> makes life a little easier (for me at least).
>
--
Bruce Momjian | http://candle.pha.pa.us
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
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/plain | 7.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Neil Conway | 2005-07-14 07:13:55 | Re: A minor patch to mark xml/xslt functions immutable |
Previous Message | Pavel Stehule | 2005-07-14 06:38:32 | Re: PL/PGSQL: Dynamic Record Introspection |