Eliminating phase 3 requirement for varlen increases via ALTER COLUMN - Mailing list pgsql-patches

From Jonah H. Harris
Subject Eliminating phase 3 requirement for varlen increases via ALTER COLUMN
Date
Msg-id 36e682920610261131o19a4e45emf65327988017802e@mail.gmail.com
Whole thread Raw
Responses Re: Eliminating phase 3 requirement for varlen increases via ALTER COLUMN
List pgsql-patches
The attached patch handles the simple case where a user wants to
increase the user-defined storage size of a variable length object,
such as VARCHAR or NUMERIC, without having to rebuild the table.

It does so by verifying that no transform was defined and testing
whether the user simply requested an increase to the size of a
variable length column.  If so, it skips type coercion and no longer
performs ATRewriteTables; instead, it allows ATExecAlterColumnType to
update the catalog to reflect said increase to the attribute's typmod
(as it currently does) and skips phase 3.  The former way to perform
this was by manually updating the catalog.

The current case of ALTERing a column to it's current data type
specification (often used to forcibly reclaim dropped column space)
has been maintained.

Use case:
CREATE TABLE test_tbl (
    test_id    NUMERIC(10) NOT NULL,
    test_name VARCHAR(32) NOT NULL,
    PRIMARY KEY (test_id));

ALTER TABLE test_tbl ALTER COLUMN test_name TYPE VARCHAR(64);

I can't find any case where this doesn't work... but perhaps you guys
know of some.

--
Jonah H. Harris, Software Architect | phone: 732.331.1300
EnterpriseDB Corporation            | fax: 732.331.1301
33 Wood Ave S, 2nd Floor            | jharris@enterprisedb.com
Iselin, New Jersey 08830            | http://www.enterprisedb.com/

Attachment

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: GUC description cleanup
Next
From: Tom Lane
Date:
Subject: Re: GUC description cleanup