Re: Possible bug concerning LASTOID in 7.2

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Coax <coax(at)shell1(dot)cornernet(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, Fernando Nasser <fnasser(at)redhat(dot)com>
Subject: Re: Possible bug concerning LASTOID in 7.2
Date: 2002-02-25 23:29:11
Message-ID: 25372.1014679751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Coax <coax(at)shell1(dot)cornernet(dot)com> writes:
> [ insert with an ON INSERT DO UPDATE ... rule ]

> Here's the output of PG7.1.2:
> test=# INSERT INTO forum (group_forum_id,posted_by,subject,body,date,is_followup_to,thread_id,most_recent_date) VALUES ('88760', '192470', 'asdfasdfsqdf', 'blah', '1014405669','0','625864','1014405669');
> INSERT 80942390 1
> test=# \echo :LASTOID
> 80942390

> However, here's the output from PG7.2:

> test=# INSERT INTO forum (group_forum_id,posted_by,subject,body,date,is_followup_to,thread_id,most_recent_date) VALUES ('88760', '192470', 'asdfasdfsqdf', 'blah', '1014405669','0','625864','1014405669')
> test-# ;
> UPDATE 0
> test=# \echo :LASTOID
> 0

I suspect the proximate cause of this is that we changed 7.2 so that
rule actions for an INSERT are done after the INSERT, not beforehand.
This is a good idea from most points of view, but it's annoying that
it's affecting the returned command tag. I tend to agree that that's
a bug, and that the tag ought to reflect the given command not any
queries generated by rules. However, it might be difficult to fix.

Fernando, does your command-tag patch help with this at all?

Another thing to think about: if the given query is suppressed entirely
by an ON INSERT DO INSTEAD rule, what tag should be returned?

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Justin 2002-02-26 03:58:18 Re: Full bug list
Previous Message Tom Lane 2002-02-25 18:55:44 Re: missing foreign key fails silently using COPY