The following bug has been logged online:
Bug reference: 1290
Logged by: Troels Arvin
Email address: troels@arvin.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