Re: question on UPDATE rules

From: wieck(at)debis(dot)com (Jan Wieck)
To: Matthew Denny <mdenny(at)CS(dot)Berkeley(dot)EDU>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: question on UPDATE rules
Date: 2000-04-22 10:02:51
Message-ID: m12iwkV-0003knC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> I have a rule defined as the following:
>
> CREATE RULE fooBar AS ON
> UPDATE TO VectorMessageTable WHERE new.acks = (SELECT
> numReplicas FROM VectorTable vt WHERE vt.ID =
> new.ID) DO (DELETE FROM VectorMessageTable WHERE ID = new.ID AND
> versionNum = new.versionNum);
>
> if I call:
>
> UPDATE VectorMessageTable SET acks =
> <corresponding-numReplicas-from-VectorTable>
>
> Then I the update goes through, but none of the records are
> deleted. However, if I run any other subsequent update on these tuples in
> VectorMessageTable (even ones that change the acks value) then the
> rule fires and the tuples are deleted. The crux of the problem seems
> to be that the "new" pseudo-relation seems to be returning old values,
> as this is the only way I can explain this behavior. Has anyone else
> experienced this problem? If so, a workaround would be greatly
> appreciated.

Sorry, but I haven't understood what you really want the rule
to do. Maybe you can give me enought of your schema plus
some sample queries with comments what you want the rule then
to do.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2000-04-22 17:12:36 Re: TOAST (was: BLOB)
Previous Message Jan Wieck 2000-04-22 08:52:03 Re: TOAST (was: BLOB)