Re: BUG #5028: CASE returns ELSE value always when type is "char" - Mailing list pgsql-bugs

From Joseph Shraibman
Subject Re: BUG #5028: CASE returns ELSE value always when type is "char"
Date
Msg-id h7jiqa$268d$1@news.hub.org
Whole thread Raw
In response to BUG #5028: CASE returns ELSE value always when type is "char"  ("Joseph Shraibman" <jks@selectacast.net>)
List 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@selectacast.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)
>

pgsql-bugs by date:

Previous
From: Sam Mason
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"
Next
From: Joseph Shraibman
Date:
Subject: Re: BUG #5028: CASE returns ELSE value always when type is "char"