BUG #2572: ALTER TABLE ADD COLUMN

Started by Emil J.over 19 years ago2 messagesbugs
Jump to latest
#1Emil J.
EmilJ@pyton.sk

The following bug has been logged online:

Bug reference: 2572
Logged by: Emil J.
Email address: emilj@pyton.sk
PostgreSQL version: 8.1.4
Operating system: Windows XP
Description: ALTER TABLE ADD COLUMN
Details:

I create some function (PLPGSQL):

.....
BEGIN
ALTER TABLE sch.table ADD COLUMN abc INTEGER;
RETURN NULL;
END;

After i called it, nothing happend. No Error, No Exception, No effect - no
column added.

#2Michael Fuhr
mike@fuhr.org
In reply to: Emil J. (#1)
Re: BUG #2572: ALTER TABLE ADD COLUMN

On Sat, Aug 12, 2006 at 11:53:08AM +0000, Emil J. wrote:

I create some function (PLPGSQL):

.....
BEGIN
ALTER TABLE sch.table ADD COLUMN abc INTEGER;
RETURN NULL;
END;

After i called it, nothing happend. No Error, No Exception, No effect - no
column added.

Works here. Is it possible that the calling transaction rolled
back or that it hadn't committed yet and you looked at the table
in another transaction? Can you provide a complete test case?

Example:

test=> CREATE TABLE foo (id integer);
CREATE TABLE
test=> CREATE FUNCTION test() RETURNS void AS $$
test$> BEGIN
test$> ALTER TABLE foo ADD COLUMN newcol integer;
test$> END;
test$> $$ LANGUAGE plpgsql;
CREATE FUNCTION
test=> \d foo
Table "public.foo"
Column | Type | Modifiers
--------+---------+-----------
id | integer |

test=> SELECT test();
test
------

(1 row)

test=> \d foo
Table "public.foo"
Column | Type | Modifiers
--------+---------+-----------
id | integer |
newcol | integer |

--
Michael Fuhr