Re: [GENERAL] Rule Question

2013-07-25 Thread Andrew Bartley
Thanks All, And thanks Tom, I did not realise a rule worked in that manner. Will now take that into account in the future. Thanks Andrew On 26 July 2013 02:02, Giuseppe Broccolo wrote: > > Unrelated to the OP's question, the suggestion above could be more simply >> rewritten as >> >> TG_OP

Re: [GENERAL] Rule Question

2013-07-25 Thread Giuseppe Broccolo
Unrelated to the OP's question, the suggestion above could be more simply rewritten as TG_OP = 'UPDATE' AND NEW.b IS DISTINCT FROM OLD.b You're right! :) Giuseppe. -- Giuseppe Broccolo - 2ndQuadrant Italy PostgreSQL Training, Services and Support giuseppe.brocc...@2ndquadrant.it | www.2ndQu

Re: [GENERAL] Rule Question

2013-07-25 Thread bricklen
On Thu, Jul 25, 2013 at 4:18 AM, Giuseppe Broccolo < giuseppe.brocc...@2ndquadrant.it> wrote: > (TG_OP = 'UPDATE' AND > (NEW.b != OLD.b OR > (NEW.b IS NULL AND OLD.b IS NOT NULL) OR > (NEW.b IS NOT NULL AND OLD.b IS NULL) >

Re: [GENERAL] Rule Question

2013-07-25 Thread Luca Ferrari
On Thu, Jul 25, 2013 at 3:02 PM, Tom Lane wrote: > Luca Ferrari writes: >> The original post was related to the update of b, so I guess it is >> better to limit the trigger scope to update on such column: > >> CREATE OR REPLACE FUNCTION b_mirror() RETURNS TRIGGER AS >> $mirror$ >> BEGIN >> NEW

Re: [GENERAL] Rule Question

2013-07-25 Thread Tom Lane
Luca Ferrari writes: > The original post was related to the update of b, so I guess it is > better to limit the trigger scope to update on such column: > CREATE OR REPLACE FUNCTION b_mirror() RETURNS TRIGGER AS > $mirror$ > BEGIN > NEW.a = NEW.b; > RETURN NEW; > END; > $mirror$ LANGUAGE plp

Re: [GENERAL] Rule Question

2013-07-25 Thread Luca Ferrari
The original post was related to the update of b, so I guess it is better to limit the trigger scope to update on such column: CREATE OR REPLACE FUNCTION b_mirror() RETURNS TRIGGER AS $mirror$ BEGIN NEW.a = NEW.b; RETURN NEW; END; $mirror$ LANGUAGE plpgsql; CREATE TRIGGER tr_b_mirror AFTER

Re: [GENERAL] Rule Question

2013-07-25 Thread Giuseppe Broccolo
I am trying to do something like this create table cats (a text,b text); create rule cats_test as on update to cats do set a = new.b; Can i manipulate column "a" sort of like this... or is there a better way. I think the easiest way to do this is to use a trigger like this: CREATE FUNCTI

Re: [GENERAL] Rule Question

2013-07-25 Thread Luca Ferrari
On Thu, Jul 25, 2013 at 8:44 AM, Andrew Bartley wrote: > create rule cats_test as on update to cats do set a = new.b; > I would use a column trigger attached to the 'a' column. Rules are better for query rewriting rather than from semantic changes. That's my opinion. Luca -- Sent via pgsql-g

Re: [GENERAL] Rule Question

2013-07-25 Thread Sergey Konoplev
On Wed, Jul 24, 2013 at 11:44 PM, Andrew Bartley wrote: > Hope this question is not too stupid but.. > > I am trying to do something like this > > create table cats (a text,b text); > > create rule cats_test as on update to cats do set a = new.b; > > Can i manipulate column "a" sort of like th

[GENERAL] Rule Question

2013-07-24 Thread Andrew Bartley
Hi all, Hope this question is not too stupid but.. I am trying to do something like this create table cats (a text,b text); create rule cats_test as on update to cats do set a = new.b; Can i manipulate column "a" sort of like this... or is there a better way. I would like to do this a

Re: [GENERAL] rule question

2008-02-29 Thread Scott Marlowe
On Fri, Feb 29, 2008 at 4:08 AM, Tim Rupp <[EMAIL PROTECTED]> wrote: > One other question. If the lock needed is exclusive, and more inserts > come in after it is requested, will Postgres schedule the rule to be > created before those new inserts are allowed to happen? Or can the rule > reques

Re: [GENERAL] rule question

2008-02-29 Thread Tim Rupp
matically. Thanks DEVI.G - Original Message - From: "Tim Rupp" <[EMAIL PROTECTED]> To: Sent: Friday, February 29, 2008 8:47 AM Subject: [GENERAL] rule question Hey list, Does CREATE RULE require an exclusive lock on the table it's making a rule for? For instance, if

Re: [GENERAL] rule question

2008-02-28 Thread Klint Gore
ks DEVI.G - Original Message - From: "Tim Rupp" <[EMAIL PROTECTED]> To: Sent: Friday, February 29, 2008 8:47 AM Subject: [GENERAL] rule question Hey list, Does CREATE RULE require an exclusive lock on the table it's making a rule for? For instance, if an insert is being

Re: [GENERAL] rule question

2008-02-28 Thread Devi
D]> To: Sent: Friday, February 29, 2008 8:47 AM Subject: [GENERAL] rule question Hey list, Does CREATE RULE require an exclusive lock on the table it's making a rule for? For instance, if an insert is being done on the table, and you do 'create rule', it will wait f

[GENERAL] rule question

2008-02-28 Thread Tim Rupp
Hey list, Does CREATE RULE require an exclusive lock on the table it's making a rule for? For instance, if an insert is being done on the table, and you do 'create rule', it will wait for said insert to finish? Thanks, -Tim ---(end of broadcast)---