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

Re: thousands comma numeric formatting in psql

From: Eugen Nedelcu <eugen(at)sifolt(dot)ro>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: thousands comma numeric formatting in psql
Date: 2005-07-18 08:14:59
Message-ID: 20050718081459.GA385@sifolt.ro (view raw or flat)
Thread:
Lists: pgsql-patches
In function format_numericsep() you have:

new_str = pg_local_malloc(len_numericseps(my_str) + 1),

instead of:

new_str = pg_local_malloc(len_with_numericsep(my_str) + 1)

Another bug is in function len_numericseps(). This apear for querys 
like:

select NULL::numeric; or
select * from table_with_numeric_fields; where one of numeric fields
have null values;

For such values, len_numericseps returns -1, instead of 0.

Instead of:

if (int_len % groupdigits != 0)
    sep_len = int_len / groupdigits;
else
    sep_len = int_len / groupdigits - 1;
    
you must have:

if (int_len % groupdigits != 0 || int_len == 0)
    sep_len = int_len / groupdigits;
else
    sep_len = int_len / groupdigits - 1;

Best Regards,
Eugen

In response to

Responses

pgsql-patches by date

Next:From: Simon RiggsDate: 2005-07-18 12:20:25
Subject: Re: Constraint Exclusion (Partitioning) - Initial Review
Previous:From: Tom LaneDate: 2005-07-18 05:32:38
Subject: Re: PL/PGSQL: Dynamic Record Introspection

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