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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-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

Browse pgsql-bugs by date

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

Browse pgsql-hackers by date

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