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

Re: Bug #513: union all changes char(3) column definition

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>, stiening(at)cannon(dot)astro(dot)umass(dot)edu, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #513: union all changes char(3) column definition
Date: 2001-11-22 03:51:04
Message-ID: 27975.1006401064@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Added to TODO:
> 	* CREATE TABLE AS can not determine column lengths from expressions
> Seems it should be documented.  Do we throw an error in these cases?

No.  What we do right now is to generate non-length-constrained column
types for the created table.

Your TODO item is too pessimistic: we *do* determine the column length
in simple cases.  For example:

regression=# create table foo (f1 char(3));
CREATE
regression=# create table bar as select * from foo;
SELECT
regression=# \d bar
            Table "bar"
 Column |     Type     | Modifiers
--------+--------------+-----------
 f1     | character(3) |

However, in more complex cases we don't know the column length:

regression=# create table baz as select f1 || 'z' as f1 from foo;
SELECT
regression=# \d baz
         Table "baz"
 Column |  Type  | Modifiers
--------+--------+-----------
 f1     | bpchar |

The argument here is about how much intelligence it's reasonable to
expect the system to have.  It's very clearly not feasible to derive
a length limit automagically in every case.  How hard should we try?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2001-11-22 03:53:27
Subject: Re: Bug #513: union all changes char(3) column definition
Previous:From: Bruce MomjianDate: 2001-11-22 03:50:44
Subject: Re: beta3

pgsql-bugs by date

Next:From: Bruce MomjianDate: 2001-11-22 03:53:27
Subject: Re: Bug #513: union all changes char(3) column definition
Previous:From: Bruce MomjianDate: 2001-11-22 03:10:02
Subject: Re: Bug #513: union all changes char(3) column definition

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