Skip site navigation (1) Skip section navigation (2)

Re: CASE w/out ELSE hides typmod (was: How define a view that use a case operator for geometry field)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sandro Santilli <strk(at)keybit(dot)net>
Cc: aperi2007(at)gmail(dot)com, PostGIS Development Discussion <postgis-devel(at)postgis(dot)refractions(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: CASE w/out ELSE hides typmod (was: How define a view that use a case operator for geometry field)
Date: 2011-10-28 21:00:25
Message-ID: 29850.1319835625@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Sandro Santilli <strk(at)keybit(dot)net> writes:
> The same happens with any type, can be reproduced with something like this:

> =# CREATE VIEW test1 AS SELECT
>   CASE WHEN random() < 0.5 THEN 1::numeric(10, 0)
>   END;

> =# \d test1
>        View "test.test1"
>  Column |  Type   | Modifiers
> --------+---------+-----------
>  case   | numeric |

> =# CREATE VIEW test2 AS SELECT
>   CASE WHEN random() < 0.5 THEN 1::numeric(10, 0)
>   ELSE 0::numeric(10, 0)
>   END;

> =# \d test2
>          View "test.test2"
>  Column |     Type      | Modifiers
> --------+---------------+-----------
>  case   | numeric(10,0) |

> Maybe someone on pgsql-hackers can tell us more about this.

IIRC, the result of a CASE is only considered to have a defined typmod
if all arms of the CASE ... including ELSE ... have the identical
typmod.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-10-28 21:07:24
Subject: Re: So, is COUNT(*) fast now?
Previous:From: Simon RiggsDate: 2011-10-28 20:50:39
Subject: Re: So where are we on the open commitfest?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group