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

BUG #1290: Default value and ALTER...TYPE

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1290: Default value and ALTER...TYPE
Date: 2004-10-20 17:01:37
Message-ID: 20041020170137.BA04A5A1086@www.postgresql.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
The following bug has been logged online:

Bug reference:      1290
Logged by:          Troels Arvin

Email address:      troels(at)arvin(dot)dk

PostgreSQL version: 8.0 Beta

Operating system:   Linux, Fedora Core 2 + stuff from Red Hat Rawhide

Description:        Default value and ALTER...TYPE

Details: 

In latest CVS (updated 2004-10-20 18:30 CEST), a too-large default column 
value seems to block the complete effects of an ALTER TABLE ... ALTER COLUMN 
... TYPE operation, see below: 

troels=# select version();
                                                version
---------------------------------------------------------------------------
----------------------------- 
 PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 
20040907 (Red Hat 3.4.2-2) 
(1 row)
 
troels=# create table lookat_feature(
troels(#   feature_id char(4),
troels(#   status varchar(2) default 'TODO'
troels(# );
CREATE TABLE
troels=# alter table lookat_feature
troels-#   alter column status type varchar(4);
ALTER TABLE
troels=# \d lookat_feature
                     Table "public.lookat_feature"
   Column   |         Type         |             Modifiers
------------+----------------------+-----------------------------------
 feature_id | character(4)         |
 status     | character varying(4) | default 'TODO'::character varying
 
troels=# insert into lookat_feature (feature_id) values('B034');
ERROR:  value too long for type character varying(2)


If instead, the "DEFAULT 'TODO'" is left out for the "status" column:

troels=# create table lookat_feature(
troels(#   feature_id char(4),
troels(#   status varchar(2)
troels(# );
CREATE TABLE
troels=# alter table lookat_feature
troels-#   alter column status type varchar(4);
ALTER TABLE
troels=# \d lookat_feature
         Table "public.lookat_feature"
   Column   |         Type         | Modifiers
------------+----------------------+-----------
 feature_id | character(4)         |
 status     | character varying(4) |
 
troels=# insert into lookat_feature (feature_id) values('B034');
INSERT 17073 1



Responses

pgsql-hackers by date

Next:From: Manfred SpraulDate: 2004-10-20 17:10:35
Subject: Re: Why frequently updated tables are an issue
Previous:From: Thomas SwanDate: 2004-10-20 16:01:43
Subject: Re: CSS

pgsql-bugs by date

Next:From: Tom LaneDate: 2004-10-20 18:07:29
Subject: Re: BUG #1290: Default value and ALTER...TYPE
Previous:From: Tom LaneDate: 2004-10-20 16:08:20
Subject: Re: bug 1201

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