Re: Proposal: Solving the "Return proper effected tuple count

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Steve Howe <howe(at)carcass(dot)dhs(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Proposal: Solving the "Return proper effected tuple count
Date: 2002-09-09 01:52:45
Message-ID: 200209090152.g891qjR02204@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I liked option #2. I don't think the _last_ query in a rule should have
any special handling.

So, to summarize #2, we have:

if no INSTEAD,
return value of original command

if INSTEAD,
return tag of original command
return sum of all affected rows with the same tag
return OID if all INSERTs in the rule insert only one row, else zero

This INSERT behavior seems consistent with INSERTs inserting multiple
rows via INSERT INTO ... SELECT:

test=> create table x (y int);
inseCREATE TABLE
test=> insert into x select 1;
INSERT 507324 1
^^^^^^
test=> insert into x select 1 union select 2;
INSERT 0 2
^

I don't think we should add tuple counts from different commands, i.e.
adding UPDATE and DELETE counts just yeilds a totally meaningless
number.

I don't think there is any need/desire to add additional API routines to
handle multiple return values.

Can I get some votes on this? We have one user very determined to get a
fix, and the TODO.detail file has another user who really wants a fix.

---------------------------------------------------------------------------

> Proposal #2 (author: Tom lane):
> ---------------------------------
>
> Tom Lane's proposal, as posted on
> http://candle.pha.pa.us/mhonarc/todo.detail/return/msg00012.html,
> consists basically on the following:
>
> PQcmdStatus() ==> Should always return the same command type original
> submitted by the client.
>
> PQcmdTuples() ==> If no INSTEAD rule, return same output as for
> original command, ignoring other commands in the
> rule.If there is INSTEAD rules, use result of last
> command in the rewritten series, use result of last
> command of same type as original command or sum up
> the results of all the rewritten commands.
>
> (I particularly prefer the sum).
>
> PQoidValue() ==> If the original command was not INSERT, return 0.
> otherwise, if one INSERT, return it's original
> PQoidValue(). If more then one INSERT command
> applied, use last or other possibilities (please
> refer to the thread for details).

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-09-09 02:32:38 Australian Open Source Awards
Previous Message Steve Howe 2002-09-08 22:50:21 Proposal: Solving the "Return proper effected tuple count from complex commands [return]" issue