Re: BUG #5355: locale incorrectly comma-separates "(null)"

Lists: pgsql-bugs
From: "Andy Lester" <andy(at)petdance(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5355: locale incorrectly comma-separates "(null)"
Date: 2010-03-01 16:18:37
Message-ID: 201003011618.o21GIbmq043041@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5355
Logged by: Andy Lester
Email address: andy(at)petdance(dot)com
PostgreSQL version: 8.3.6
Operating system: Linux
Description: locale incorrectly comma-separates "(null)"
Details:

In my .psqlrc I have the following (among others)

\pset null '(null)'
\pset numericlocale on

When I select numeric columns that have NULL values, they show as "(nu,ll)".


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Andy Lester <andy(at)petdance(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5355: locale incorrectly comma-separates "(null)"
Date: 2010-03-01 18:38:05
Message-ID: 4B8C098D.7070905@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Andy Lester wrote:
> The following bug has been logged online:
>
> Bug reference: 5355
> Logged by: Andy Lester
> Email address: andy(at)petdance(dot)com
> PostgreSQL version: 8.3.6
> Operating system: Linux
> Description: locale incorrectly comma-separates "(null)"
> Details:
>
> In my .psqlrc I have the following (among others)
>
> \pset null '(null)'
> \pset numericlocale on
>
> When I select numeric columns that have NULL values, they show as "(nu,ll)".

Hmm, some of the other formats seem to handle numericlocale even worse :-( :

postgres=# \pset numericlocale on
Showing locale-adjusted numeric output.
postgres=# \pset format latex
Output format is latex.
postgres=# SELECT 1234::numeric, 'foobar' ;
\begin{tabular}{r | l}
\textit{numeric} & \textit{?column?} \\
\hline
1,234 & foo,bar \\
\end{tabular}

\noindent (1 row) \\

(note how 'foobar' got a comma in the middle.)

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Andy Lester <andy(at)petdance(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5355: locale incorrectly comma-separates "(null)"
Date: 2010-03-01 19:20:20
Message-ID: 4B8C1374.9020501@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Heikki Linnakangas wrote:
> Andy Lester wrote:
>> The following bug has been logged online:
>>
>> Bug reference: 5355
>> Logged by: Andy Lester
>> Email address: andy(at)petdance(dot)com
>> PostgreSQL version: 8.3.6
>> Operating system: Linux
>> Description: locale incorrectly comma-separates "(null)"
>> Details:
>>
>> In my .psqlrc I have the following (among others)
>>
>> \pset null '(null)'
>> \pset numericlocale on
>>
>> When I select numeric columns that have NULL values, they show as "(nu,ll)".
>
> Hmm, some of the other formats seem to handle numericlocale even worse :-( :
>
> postgres=# \pset numericlocale on
> Showing locale-adjusted numeric output.
> postgres=# \pset format latex
> Output format is latex.
> postgres=# SELECT 1234::numeric, 'foobar' ;
> \begin{tabular}{r | l}
> \textit{numeric} & \textit{?column?} \\
> \hline
> 1,234 & foo,bar \\
> \end{tabular}
>
> \noindent (1 row) \\
>
> (note how 'foobar' got a comma in the middle.)

Ok, here's a patch to fix both of those bugs. It moves the
responsibility of applying numeric locale up from the print_* functions
to the same place where the null string is applied. Less room for bugs
of omission like the latex format bug that way, and it's no longer
applied to the null string. This also makes the print_* code simpler.

I'll port this to back-branches and commit. Thanks for the report!

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
fix-numericlocale-1.patch text/x-diff 13.6 KB