Re: A little RULE help?
От | Vik Fearing |
---|---|
Тема | Re: A little RULE help? |
Дата | |
Msg-id | 4e9b5b67-8966-4dfb-dcf9-6023c3b8fff1@2ndquadrant.com обсуждение исходный текст |
Ответ на | RE: A little RULE help? (Steven Winfield <Steven.Winfield@cantabcapital.com>) |
Ответы |
RE: A little RULE help?
|
Список | pgsql-general |
On 01/26/2018 04:19 PM, Steven Winfield wrote: > Back to my original attempt at writing an UPDATE rule… > > CREATE RULE rule_test_update AS ON UPDATE TO rule_test_view DO INSTEAD ( > > UPDATE rule_test SET tt = tstzrange(lower(tt), > CURRENT_TIMESTAMP, '[)') WHERE id = OLD.id; > > INSERT INTO rule_test (tt, foo, bar) VALUES > (tstzrange(CURRENT_TIMESTAMP, NULL, '[)'), NEW.foo, NEW.bar) RETURNING *; > > ); > > …I wondered whether the pseudo relations NEW and OLD were somehow being > modified by the first command (the UPDATE), such that the second command > (INSERT) could not function properly. No. It's because your view's WHERE clause is being added to your INSERT and of course nothing matches, so nothing gets inserted. > That would fit with what I observe, but I’m not sure how I go about > proving EXPLAIN > or fixing it. Don't use RULEs. -- Vik Fearing +33 6 46 75 15 36 http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
В списке pgsql-general по дате отправления: