Re: RULE vs. SEQUENCE

From: Jan Wieck <janwieck(at)Yahoo(dot)com>
To: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
Cc: Hannu Krosing <hannu(at)tm(dot)ee>, Jan Wieck <janwieck(at)Yahoo(dot)com>, pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: RULE vs. SEQUENCE
Date: 2000-09-04 14:34:03
Message-ID: 200009041434.JAA02259@jupiter.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Karel Zak wrote:
> > > But executor can knows that somethig was already executed, we can mark
> > > some already executed expressions in rewriter and not execute it again in
> > > final executor... like:
> > ...
> > >
> > > IMHO this is a good point for 7.2 ...
> >
> > But if instead of nextval() you had random(), would you still want to execute
> > it
> > only once ? And how should postgres know ?
>
> Talking you still about RULEs?

Yes, he is.

>
> ...I don't undestand you. What is a 'NEW' in RULE? I (and probably more
> users) expect that new data from tuple which go into original table. Right?

Most people would expect that - but it is the targetlist
expression of this column from the query which fired the
rule! That's a little difference.

> Not ... if you use sequence. IMHO it's not "feature" but nice bug that
> crash your data integrity...

The PostgreSQL rule system is based on a general productional
query rewrite rule system, designed decades ago without
thinking about column values like nextval() or random(). The
usage of those expressions in a query firing rules leads to
unpredictable results.

To understand how rules work in detail you should read
chapter 8 of the programmers manual.

Jan

--

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-09-04 16:29:16 Re: OO inheritance implementation
Previous Message Peter Mount 2000-09-04 14:18:50 The next release