Re: BUG #5028: CASE returns ELSE value always when type is "char"

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"
Date: 2009-09-01 16:40:43
Message-ID: h7jiqa$268d$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


It appears the problem is with the "char" being in the ELSE expression,
not being in the CASE expression

[local]:playpen=> select c.relkind, CASE c.relkind WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN
's' THEN 'special' WHEN 'c' THEN 'composite type' WHEN 't' THEN 'toast'
ELSE c.relkind::char
playpen-> END from (select 'r'::"char" AS relkind) c;
relkind | relkind
---------+---------
r | table
(1 row)

Time: 0.674 ms
[local]:playpen=> select c.relkind, CASE c.relkind WHEN 'r' THEN 'table'
WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN
's' THEN 'special' WHEN 'c' THEN 'composite type' WHEN 't' THEN 'toast'
ELSE c.relkind::"char"
playpen-> END from (select 'r'::char AS relkind) c;
relkind | relkind
---------+---------
r | t
(1 row)

Joseph Shraibman wrote:
> The following bug has been logged online:
>
> Bug reference: 5028
> Logged by: Joseph Shraibman
> Email address: jks(at)selectacast(dot)net
> PostgreSQL version: 8.3.7
> Operating system: Linux
> Description: CASE returns ELSE value always when type is "char"
> Details:
>
> [local]:playpen=> SELECT version();
> version
>
> ----------------------------------------------------------------------------
> -------------------------------
> PostgreSQL 8.3.7 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC)
> 4.1.2 20080704 (Red Hat 4.1.2-44)
> (1 row)
>
> Time: 1.658 ms
> [local]:playpen=>
> [local]:playpen=> select c.relkind, CASE c.relkind WHEN 'r' THEN 'table'
> WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's'
> THEN 'special' WHEN 'c' THEN 'composite type' WHEN 't' THEN 'toast' ELSE
> c.relkind
> playpen-> END from (select 'r'::"char" AS relkind) c;
> relkind | relkind
> ---------+---------
> r | t
> (1 row)
>
> Time: 1.407 ms
> [local]:playpen=>
> [local]:playpen=> select c.relkind, CASE c.relkind WHEN 'r' THEN 'table'
> WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's'
> THEN 'special' WHEN 'c' THEN 'composite type' WHEN 't' THEN 'toast'
> playpen-> END from (select 'r'::"char" AS relkind) c;
> relkind | case
> ---------+-------
> r | table
> (1 row)
>
> Time: 0.426 ms
> [local]:playpen=>
> [local]:playpen=>
> [local]:playpen=> select c.relkind, CASE c.relkind WHEN 'r' THEN 'table'
> WHEN 'v' THEN 'view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's'
> THEN 'special' WHEN 'c' THEN 'composite type' WHEN 't' THEN 'toast' ELSE
> c.relkind
> playpen-> END from (select 'r'::char AS relkind) c;
> relkind | relkind
> ---------+---------
> r | table
> (1 row)
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sam Mason 2009-09-01 16:49:25 Re: BUG #5028: CASE returns ELSE value always when type is "char"
Previous Message Merlin Moncure 2009-09-01 16:39:50 Re: BUG #5025: Aggregate function with subquery in 8.3 and 8.4.