Re: Drop or disable or bypass "_return" rule on select on a view.

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Shashwat Arghode <shashwatarghode(at)gmail(dot)com>, pgsql novice <pgsql-novice(at)postgresql(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Drop or disable or bypass "_return" rule on select on a view.
Date: 2015-05-28 14:17:38
Message-ID: CAHyXU0wPyZjvyekSCf2s2AsefHFfwXY_HkNt_PnSM4jepF5CmQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

On Thu, May 28, 2015 at 8:53 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Shashwat Arghode <shashwatarghode(at)gmail(dot)com> writes:
>> I am using postgres 9.3.4 and have an on_select rule "_return" on a view.
>> I want to drop or disable or bypass that rule.
>> Is there any way it can be done without dropping the view??
>
> No. I don't exactly see the point, either --- what do you imagine a view
> without an ON SELECT rule would be good for?
>
> Perhaps what you want is to replace the view with CREATE OR REPLACE VIEW,
> which is basically equivalent to updating its ON SELECT rule. But simply
> dropping the rule without immediately replacing it would leave the view
> nonfunctional.

Yeah. If disabling the view is truly what's desired, and disabling a
view is defined as returning no data, you'd want to change:

CREATE OR REPLACE VIEW v AS SELECT ....

with

CREATE OR REPLACE VIEW v AS SELECT .... LIMIT 0;

Another option of course would be to drop it, but that would require
dealing with dependencies. Still another option would be to have any
query against the view return an immediate exception:

CREATE OR REPLACE VIEW v AS SELECT .... WHERE (SELECT false FROM Error('test'));

Error() being a thin wrapper to plpgsql 'raise exception'.

merlin

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Faisal Karim 2015-05-28 19:34:07 Re: [NOVICE] Drop or disable or bypass "_return" rule on select on a view.
Previous Message Tom Lane 2015-05-28 13:53:33 Re: Drop or disable or bypass "_return" rule on select on a view.

Browse pgsql-sql by date

  From Date Subject
Next Message Faisal Karim 2015-05-28 19:34:07 Re: [NOVICE] Drop or disable or bypass "_return" rule on select on a view.
Previous Message Tom Lane 2015-05-28 13:53:33 Re: Drop or disable or bypass "_return" rule on select on a view.