| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Forest Wilkinson <fspam(at)home(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: are NEW and OLD rule attributes broken? |
| Date: | 2001-05-18 19:20:47 |
| Message-ID: | 22865.990213647@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Forest Wilkinson <fspam(at)home(dot)com> writes:
> What's going on here? My rule inserted a new row into bar, but the fooid
> it used was not the new value inserted into foo. It looks like my rule is
> inserting "nextval('foo_fooid_seq')" into the bar table, rather than
> inserting the new primary key from the foo table. Is this the intended
> behavior?
NEW and OLD are effectively macros, not variables. So yes, you get
extra evaluations of nextval() this way. I think there are cases where
that is actually what you want (not in this case obviously :-(). It
would be fairly difficult to change, anyway.
> How can I get the result I want?
If you want to copy the data actually inserted, a trigger is a much
better bet than a rule.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ловпаче Айдамир | 2001-05-18 23:30:04 | Why indexes are not used when scanning from functions? |
| Previous Message | Forest Wilkinson | 2001-05-18 18:36:17 | are NEW and OLD rule attributes broken? |