Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1egv5E-0000ca-0m for pgsql-general@arkaria.postgresql.org; Wed, 31 Jan 2018 16:18:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egv5C-0002Jv-QH for pgsql-general@arkaria.postgresql.org; Wed, 31 Jan 2018 16:17:58 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1egv5C-0002Jm-F1 for pgsql-general@lists.postgresql.org; Wed, 31 Jan 2018 16:17:58 +0000 Received: from host3.dynacom.ondsl.gr ([62.103.35.211] helo=smadev.internal.net) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1egv57-0006O9-2j for pgsql-general@lists.postgresql.org; Wed, 31 Jan 2018 16:17:57 +0000 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id w0VGHmAj068639 for ; Wed, 31 Jan 2018 18:17:49 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: A little RULE help? To: pgsql-general@lists.postgresql.org References: <4e9b5b67-8966-4dfb-dcf9-6023c3b8fff1@2ndquadrant.com> From: Achilleas Mantzios Message-ID: <37bb1acf-d4bb-0557-846e-11393645dd4d@matrix.gatewaynet.com> Date: Wed, 31 Jan 2018 18:17:48 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------88CA3320322C555F5C03F592" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------88CA3320322C555F5C03F592 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 31/01/2018 18:02, David G. Johnston wrote: > On Wed, Jan 31, 2018 at 8:39 AM, Steven Winfield >wrote: > > > Don't use RULEs. > -- > Vik Fearing +33 6 46 75 15 36 > 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 --------------88CA3320322C555F5C03F592 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 31/01/2018 18:02, David G. Johnston wrote:
On Wed, Jan 31, 2018 at 8:39 AM, Steven Winfield <Steven.Winfield@cantabcapital.com> wrote:


Don't use RULEs.
--
Vik Fearing +33 6 46 75 15 36
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.​

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
--------------88CA3320322C555F5C03F592--