On Wed, Jul 24, 2013 at 11:44 PM, Andrew Bartley ambart...@gmail.com 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
On Thu, Jul 25, 2013 at 8:44 AM, Andrew Bartley ambart...@gmail.com 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
--
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
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
Luca Ferrari fluca1...@infinito.it 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$
On Thu, Jul 25, 2013 at 3:02 PM, Tom Lane t...@sss.pgh.pa.us wrote:
Luca Ferrari fluca1...@infinito.it 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
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)
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 |
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
giuseppe.brocc...@2ndquadrant.itwrote:
Unrelated to the OP's question, the suggestion above could be more
Klint Gore wrote:
[see below or the top posting police will arrive on my doorstep :)]
Devi wrote:
Hi,
CREATE RULE dosen't require any lock. It is carried out in the parser
level. But there will be ACCESS SHARE lock over the tables which are
being queried are acquired automatically.
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
request sit
Hi,
CREATE RULE dosen't require any lock. It is carried out in the parser
level. But there will be ACCESS SHARE lock over the tables which are being
queried are acquired automatically.
Thanks
DEVI.G
- Original Message -
From: Tim Rupp [EMAIL PROTECTED]
To:
[see below or the top posting police will arrive on my doorstep :)]
Devi wrote:
Hi,
CREATE RULE dosen't require any lock. It is carried out in the parser
level. But there will be ACCESS SHARE lock over the tables which are
being queried are acquired automatically.
Thanks
DEVI.G
-
13 matches
Mail list logo