Re: [PATCH] Provide rowcount for utility SELECTs
Bruce Momjian <bruce@momjian.us>
From: Bruce Momjian <bruce@momjian.us>
To: Boszormenyi Zoltan <zb@cybertec.at>
Cc: Robert Haas <robertmhaas@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Alvaro Herrera <alvherre@commandprompt.com>, Peter Eisentraut <peter_e@gmx.net>, Hans-Juergen Schoenig <hs@cybertec.at>, Pavel Stehule <pavel.stehule@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2010-02-14T03:15:26Z
Lists: pgsql-hackers
Attachments
- (unnamed) (text/plain)
Boszormenyi Zoltan wrote:
> >>> Ah, I didn't even see that that section needed to be updated. Good
> >>> catch. I'd suggest the following wording:
> >>>
> >>> For a <command>SELECT</command> or <command>CREATE TABLE AS</command>
> >>> command, the tag is SELECT rows... [and the rest as you have it]
> >>>
> >>> We should probably also retitle that section from "Retrieving Result
> >>> Information for Other Commands" to "Retrieving Other Result
> >>> Information" and adjust the text of the opening sentence similarly.
> >>>
> >>> Also I think you need to update the docs for PQcmdtuples to mention
> >>> that it not works for SELECT and CTAS.
> >>>
> >>>
> >> Ok, I will update libpq.sgml where this section resides.
> >> What's a CTA, btw? Do you mean CTE, a.k.a. "Common Table Expression"?
> >>
> >
> > Sorry, CTAS = CREATE TABLE AS SELECT.
> >
>
> Okay, new patch is attached. Please read the docs changes, and comment.
I have reviewed this patch and made some adjustments, attached. The
major change is that our return of "0 0" in certain cases must remain,
though I have improved the C comment explaining it with a separate CVS
commit:
/*
* If a command completion tag was supplied, use it. Otherwise use the
* portal's commandTag as the default completion tag.
*
* Exception: Clients expect INSERT/UPDATE/DELETE tags to have
* counts, so fake them with zeros. This can happen with DO INSTEAD
* rules if there is no replacement query of the same type as the
* original. We print "0 0" here because technically there is no
* query of the matching tag type, and printing a non-zero count for
* a different query type seems wrong, e.g. an INSERT that does
* an UPDATE instead should not print "0 1" if one row
* was updated. See QueryRewrite(), step 3, for details.
*/
I have removed the part of the patch that chagned "0 0"; it seems to
run fine without it. The rest of my adjustments were minor.
One major part of the patch seems to be the collection of the
PORTAL_ONE_SELECT switch label into the label below it, which is a nice
cleanup.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +