Re: RETURNING and DO INSTEAD ... Intentional or not?
От | Richard Huxton |
---|---|
Тема | Re: RETURNING and DO INSTEAD ... Intentional or not? |
Дата | |
Msg-id | 46E82CAF.7000705@archonet.com обсуждение исходный текст |
Ответ на | Re: RETURNING and DO INSTEAD ... Intentional or not? (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: RETURNING and DO INSTEAD ... Intentional or not?
|
Список | pgsql-hackers |
Tom Lane wrote: > Josh Berkus <josh@agliodbs.com> writes: >> A Hibernate developer pointed out the following odd behavior to me in 8.2.1: > >> create table test ( test1 text ); >> create table test2 ( test_col text ); >> create rule test_insert as on insert to test do instead insert into test2 >> values ( NEW.test1 ) RETURNING test2.test_col; > >> postgres=# insert into test values ( 'joe' ); >> INSERT 0 1 > >> ... no RETURNING. > > It would surely be quite broken for an INSERT that has *not* got a > returning clause to spit data at you, don't you think? > > What the RETURNING clause in the rule does is let you define the data > that should be returned if the rewritten INSERT had a returning clause > to start with. Sorry - haven't got a CSV download here, or I'd check myself. Does this just allow an INSERT...RETURNING inside the rule, or could it be something like: CREATE RULE ... AS ON INSERT ... DO INSTEAD SELECT f(NEW.test1); -- Richard Huxton Archonet Ltd
В списке pgsql-hackers по дате отправления: