Обсуждение: INSERT in 7.0

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

INSERT in 7.0

От
Karel Zak - Zakkr
Дата:


What is changed on INSERT/max() in v7.0? (CVS - today).

See:

--- new version:

template1=> select * from pg_group;groname | grosysid | grolist
---------+----------+---------_dummy_ |        0 | {}
(1 row)

template1=> INSERT INTO pg_group VALUES ('abg_root', max(grosysid)+1, '{}');
ERROR:  attribute 'grosysid' not found


--- old version (6.5):

template1=> select * from pg_group;
groname|grosysid|grolist
-------+--------+-------
_dummy_|       0|{}
(1 row)

template1=> INSERT INTO pg_group VALUES ('abg_root', max(grosysid)+1, '{}');
INSERT 10173952 1

                        Karel



Re: [HACKERS] INSERT in 7.0

От
Tom Lane
Дата:
Karel Zak - Zakkr <zakkr@zf.jcu.cz> writes:
> What is changed on INSERT/max() in v7.0? (CVS - today).

> template1=> INSERT INTO pg_group VALUES ('abg_root', max(grosysid)+1, '{}');
> ERROR:  attribute 'grosysid' not found

That's the way it should work, AFAICS.  VALUES() isn't supposed to
contain anything except constant expressions.  Perhaps what you are
after would be more properly expressed as

INSERT INTO pg_group SELECT 'abg_root', max(grosysid)+1, '{}' FROM pg_group;

6.5 may have accepted the other, but it was an artifact of extremely
broken code...
        regards, tom lane