Re: RULE vs. SEQUENCE

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: RULE vs. SEQUENCE
Дата
Msg-id 200009041202.HAA02041@jupiter.jw.home
обсуждение исходный текст
Ответ на RULE vs. SEQUENCE  (Karel Zak <zakkr@zf.jcu.cz>)
Ответы Re: RULE vs. SEQUENCE
Список pgsql-hackers
Karel Zak wrote:
>
>
>  Hi,
>
>  I have a question... why RULE call nexval() and data in RULE statement are
> differend than data in original stmt.
   It's  a known "feature", and I don't know any way of changing   it.
   The problem is, that NEW.attname in a rule  means,  "whatever   is  in  the targetlist of the INSERT when applying
therule".   In your example, it'll be  a  call  to  nextval().  The  rule   system  doesn't  know  that  this
targetlistexpression has a   side-effect (incrementing the sequence).
 
   Thus, the rule creates a second query  which  does  it's  own   calls to nextval() when executed.

>  It's interesting feature (6.5, 7.0, 7.1...). How is a possible in RULE
> obtain same data as in 'aa' table for a default data from the sequence.
   The query rewrite rule system behaves like this since 4.2 (or   even earlier). Since 6.4 it does the right things
on UPDATE   and  DELETE  too.  Don't know when we introduced sequences or   better "functions that have such nasty
side-effects".


Jan

--

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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Karel Zak
Дата:
Сообщение: RULE vs. SEQUENCE
Следующее
От: Karel Zak
Дата:
Сообщение: Re: RULE vs. SEQUENCE