Обсуждение: BUG #2572: ALTER TABLE ADD COLUMN

Поиск
Список
Период
Сортировка

BUG #2572: ALTER TABLE ADD COLUMN

От
"Emil J."
Дата:
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.

Re: BUG #2572: ALTER TABLE ADD COLUMN

От
Michael Fuhr
Дата:
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