On 31/01/2018 18:02, David G. Johnston wrote:
On Wed, Jan 31, 2018 at 8:39 AM, Steven Winfield <steven.winfi...@cantabcapital.com
<mailto:steven.winfi...@cantabcapital.com>>wrote:
Don't use RULEs.
--
Vik Fearing +33 6 46 75 15 36 <tel:+33%206%2046%2075%2015%2036>
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
Repeating this, as if I should already know this, is less helpful though.
It’s not as if the docs tells users to steer clear of RULEs.
If there is something I don’t understand, such as RULEs, I prefer to
experiment with it and ask questions if there is something I still don’t
follow. I thought this was the correct forum for
those questions.
The docs do suggest that rules are more difficult to do correctly.
https://www.postgresql.org/docs/10/static/rules-triggers.html
Few people use them which means they generally get less exposure to a variety
of circumstances during feature testing and use and the long-term maintenance
dynamics are larger.
That all said, if you can justify your use of them in a particular context you should probably just ignore those saying not to use them without the same knowledge of your situation. The reward may
be worth the risk/cost but the people yelling out for you to be careful are not doing so for the fun of it. You should at least heed it to the point of saying, "yes, I'm sure I want to do this".
We have used RULEs to handle insertions / deletions from non-trivial views. And
I can give this example if anyone wants.
Also we have used views to ignite smth like :
CREATE RULE account_credit_ins AS
ON INSERT TO account_credit DO INSTEAD SELECT
public.rule_disable('INSERT'::text) AS rule_disable;
where rule_disable is a function that just raises an exception with some
diagnostic text.
We dont make heavey use of RULEs, but I think they have their place.
David J.
--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt