Re: AUTO_INCREMENT patch

Поиск
Список
Период
Сортировка
От des@des.no (Dag-Erling Smørgrav)
Тема Re: AUTO_INCREMENT patch
Дата
Msg-id xzpd6fnwpyb.fsf@dwp.des.no
обсуждение исходный текст
Ответ на Re: AUTO_INCREMENT patch  (Rod Taylor <rbt@rbt.ca>)
Ответы Re: AUTO_INCREMENT patch  (Rod Taylor <rbt@rbt.ca>)
Список pgsql-hackers
Rod Taylor <rbt@rbt.ca> writes:
> CREATE OR REPLACE RULE rulename AS ON INSERT
>   TO tablename
>   DO INSTEAD
>    INSERT INTO tablename
>              ( id, col1, ...)
>       VALUES ( DEFAULT, NEW.col1, ...);
>

I now have a patch that adds support for the GENERATED ... AS ...
syntax and implements the "GENERATED BY DEFAULT AS IDENTITY" case.
I'm trying to figure out how to implement the other two cases
("GENERATED ALWAYS AS IDENTITY" and "GENERATED ALWAYS AS ( expr )").
I thought I'd try your trick:

des=# create table test ( id serial, word text );
NOTICE:  CREATE TABLE will create implicit sequence "test_id_seq" for SERIAL column "test.id"
CREATE TABLE
des=# create rule test_id_generate as
des-# on insert to test do instead
des-# insert into test ( id, word ) values ( default, new.word );
CREATE RULE
des=# insert into test ( id, word ) values ( 42, 'hello' );
ERROR:  infinite recursion detected in rules for relation "test"
des=# insert into test ( word ) values ( 'hello' );
ERROR:  infinite recursion detected in rules for relation "test"

any suggestions?

DES
--
Dag-Erling Smørgrav - des@des.no


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Carlos Guzman Alvarez
Дата:
Сообщение: Re: Identification of serial fields
Следующее
От: Rod Taylor
Дата:
Сообщение: Re: AUTO_INCREMENT patch