Re: how do you get there from here? - Mailing list pgsql-general

From Michael P. Soulier
Subject Re: how do you get there from here?
Date
Msg-id 49F5D5C3.8010007@mitel.com
Whole thread Raw
In response to how do you get there from here?  ("Michael P. Soulier" <michael_soulier@mitel.com>)
Responses Re: how do you get there from here?
List pgsql-general
Michael P. Soulier wrote:
> my $sql =<<EOF;
> ALTER TABLE instances ADD COLUMN udp_icpside_address_override inet
> DEFAULT NULL;
> ALTER TABLE instances ADD COLUMN udp_setside_address_override inet
> DEFAULT NULL;
> UPDATE instances SET udp_icpside_address_override =
> $udp_icpside_address_override;
> UPDATE instances SET udp_setside_address_override =
> $udp_setside_address_override;
> ALTER TABLE instances DROP COLUMN public_ip;
> ALTER TABLE instances DROP COLUMN public_ip_override;
> ALTER TABLE instances DROP COLUMN lan_mode;

Ok, using the default to set the value on the new column seems to avoid
this...

my $sql =<<EOF;
ALTER TABLE instances DROP COLUMN public_ip;
ALTER TABLE instances DROP COLUMN public_ip_override;
ALTER TABLE instances DROP COLUMN lan_mode;
ALTER TABLE instances ADD COLUMN udp_icpside_address_override inet
DEFAULT $udp_icpside_address_override;
ALTER TABLE instances ADD COLUMN udp_setside_address_override inet
DEFAULT $udp_setside_address_override;
ALTER TABLE instances ALTER COLUMN udp_icpside_address_override SET
DEFAULT NULL;
ALTER TABLE instances ALTER COLUMN udp_setside_address_override SET
DEFAULT NULL;
EOF

$dbh->do($sql);

But I don't understand why this was required. What's wrong with adding a
column and copying data into it in a transaction?

Mike


Attachment

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: find column OID types with information schema?
Next
From: Bill Moran
Date:
Subject: Re: PostgreSQL Object-Oriented Database?