Re: thousands comma numeric formatting in psql - Mailing list pgsql-patches

From Eugen Nedelcu
Subject Re: thousands comma numeric formatting in psql
Date
Msg-id 20050718081459.GA385@sifolt.ro
Whole thread Raw
In response to Re: thousands comma numeric formatting in psql  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: thousands comma numeric formatting in psql
List 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

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: PL/PGSQL: Dynamic Record Introspection
Next
From: Simon Riggs
Date:
Subject: Re: Constraint Exclusion (Partitioning) - Initial Review