Re: BUG #18647: INSERT statements execute functions twice.
От | Greg Sabino Mullane |
---|---|
Тема | Re: BUG #18647: INSERT statements execute functions twice. |
Дата | |
Msg-id | CAKAnmm+H1+sxxqUKi3DgboVjFMKYjOusDJMYHC1tgRfF1isW+Q@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: BUG #18647: INSERT statements execute functions twice. (Todd Brandys <brandystodd@gmail.com>) |
Ответы |
Re: BUG #18647: INSERT statements execute functions twice.
|
Список | pgsql-bugs |
More detail is still needed. We don't have access to your schemas and functions. But at first glance, there is something else going on, not explained by the given code. Try to remove the unimportant parts and get it down to a reproducible test case. For example, here is a test case showing the expected behavior on Postgres 16:
NOTICE: Inside mynextval!
INSERT 0 1
create function mynextval(text) returns text language plpgsql as $$ BEGIN RAISE NOTICE 'Inside mynextval!'; RETURN 'x'; END; $$;
create table foo(a text, b text);
greg=# insert into foo values (mynextval('abc'));
NOTICE: Inside mynextval!
INSERT 0 1
INSERT 0 1
greg=# insert into foo values (mynextval('abc'), mynextval('def'));
NOTICE: Inside mynextval!
NOTICE: Inside mynextval!
INSERT 0 1
NOTICE: Inside mynextval!
INSERT 0 1
greg=# insert into foo select mynextval('abc'), mynextval('def');
NOTICE: Inside mynextval!
NOTICE: Inside mynextval!
INSERT 0 1
NOTICE: Inside mynextval!
NOTICE: Inside mynextval!
INSERT 0 1
greg=# insert into foo select x from mynextval('abc') x;
NOTICE: Inside mynextval!
INSERT 0 1
NOTICE: Inside mynextval!
INSERT 0 1
greg=# insert into foo select mynextval('def') from mynextval('abc') x;
NOTICE: Inside mynextval!NOTICE: Inside mynextval!
INSERT 0 1
Cheers,
Greg
В списке pgsql-bugs по дате отправления: