Re: sql DO in rule 9.0rc1

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sql DO in rule 9.0rc1
Date: 2010-09-10 17:39:16
Message-ID: AANLkTi=Zam0p-__GeRP4W3=sOTfQzivqHKZrEtuOqugc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 10, 2010 at 1:30 PM, A.M. <agentm(at)themactionfaction(dot)com> wrote:
> On Sep 9, 2010, at 8:31 PM, Jeff Davis wrote:
>> On Thu, 2010-09-09 at 17:07 -0400, A.M. wrote:
>>> Is there a technical limitation which prevents DO from being used in rules or am I missing something with this?
>>>
>>> CREATE RULE test_update AS ON UPDATE TO test DO INSTEAD DO $$
>>>                 BEGIN;
>>>                 RAISE NOTICE 'hello';
>>>                 END;
>>>               $$;
>>>
>>> Cheers,
>>> M
>>
>>> From the docs here:
>>
>>    http://www.postgresql.org/docs/9.0/static/sql-createrule.html
>>
>> I see:
>>
>>    "Valid commands are SELECT, INSERT, UPDATE, DELETE, or NOTIFY."
>>
>> And I assume that DO is a separate command that is not valid for a rule
>> such as this.
>>
>> As a workaround, you can make a named function and do "SELECT
>> myfunction()" as the INSTEAD clause.
>
> Perhaps I should have posted to -hackers instead, but I was really wondering if there were some real technical limitation to having this implemented. Does "DO" have any sort of context which can be applied? It seems that NEW and OLD would have to be pushed into that context.

IDK...functions do everything 'DO' does, and support returning data,
which is necessary to support RETURNING. Rules are already fairly
capricious and problematic and I doubt any proposal that doesn't fix
or work around their basic flaws will get much traction.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2010-09-10 17:44:17 Re: sql DO in rule 9.0rc1
Previous Message Arjen Nienhuis 2010-09-10 17:39:08 Re: Post Install / Secure PostgreSQL