From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | Thomas Kellerer <spam_eater(at)gmx(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Confused about CASE |
Date: | 2008-03-01 02:04:17 |
Message-ID: | 21048.1204337057@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> It looks like the problem is that relkind is of the somewhat odd
> PostgreSQL type "char" not an actual char(1), so with the else in there it
> appears to try to force the unknown literals into that type which only
> takes the first character. It will probably work if you cast in the else,
> like "else CAST(c.relkind as CHAR(1))".
Right, the problem is that all the string literals are "unknown" and
don't force a type decision, so the "char" type gets chosen as the
result type of the CASE, and then the literals get coerced to that.
If you explicitly cast any one of the CASE output expressions to text
--- either relkind, or any of the constants --- the behavior is as the
OP expects.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-03-01 02:17:46 | Re: Querying Headers |
Previous Message | Scott Marlowe | 2008-03-01 01:29:03 | Re: SERIAL and Primary Key |