Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yxycy-0007Tt-Hz for pgsql-novice@arkaria.postgresql.org; Thu, 28 May 2015 14:17:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yxycx-00066C-UR for pgsql-novice@arkaria.postgresql.org; Thu, 28 May 2015 14:17:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yxycx-000662-96; Thu, 28 May 2015 14:17:43 +0000 Received: from mail-lb0-x235.google.com ([2a00:1450:4010:c04::235]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Yxycu-000398-41; Thu, 28 May 2015 14:17:42 +0000 Received: by lbbqq2 with SMTP id qq2so29244481lbb.3; Thu, 28 May 2015 07:17:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=93m32xATQH89NuDk1ldrkNvsEPL4lvMgpl6gp/4G6lQ=; b=EhOXC3um7wG9AyDkViBdLR12gYUGDzAiDlmxBKYQURIWnLd+DA+Goe7paanqJHGY+X q2S3Ywt/dmGNuNyS9aYiQs+VLAWC+Y9v3bptRR/cQrZhcUWJFgqYQiEtlOogQsg+yAOQ TAUll0RaIfwAcYFqd30y3/3ffNZzbTMkwPOdIwHElKqrrNdtBxXnLWiShEQV07VMy55c FQvt98Pshx2xRBqCJU3ubCMhRYzSKgEf+bZ9YDl7yiU2nnnbZy+iL32jXA3L5vR+lmgm UKUGTvDPWpq7cNBFr2t8Gzhxw4FNlLPhMibTeS69pdsn/kkATD30oH+DhVEdETMYiEew SKLw== MIME-Version: 1.0 X-Received: by 10.112.171.101 with SMTP id at5mr3168988lbc.66.1432822658848; Thu, 28 May 2015 07:17:38 -0700 (PDT) Received: by 10.112.55.6 with HTTP; Thu, 28 May 2015 07:17:38 -0700 (PDT) In-Reply-To: <10237.1432821213@sss.pgh.pa.us> References: <10237.1432821213@sss.pgh.pa.us> Date: Thu, 28 May 2015 09:17:38 -0500 Message-ID: Subject: Re: Drop or disable or bypass "_return" rule on select on a view. From: Merlin Moncure To: Tom Lane Cc: Shashwat Arghode , pgsql novice , pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-novice Precedence: bulk Sender: pgsql-novice-owner@postgresql.org On Thu, May 28, 2015 at 8:53 AM, Tom Lane wrote: > Shashwat Arghode 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 -- Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-novice