public inbox for [email protected]
help / color / mirror / Atom feedFrom: Josh Kupershmidt <[email protected]>
To: pgsql-docs <[email protected]>
Subject: example for PGRES_COMMAND_OK
Date: Fri, 26 Oct 2012 16:58:13 -0700
Message-ID: <CAK3UJRG262OrX4jVZJXvWRFQqQ_B1HaY2qK_r28Efb3wOJDPog@mail.gmail.com> (raw)
Hi all,
This libpq page:
http://www.postgresql.org/docs/current/static/libpq-exec.html#LIBPQ-PQRESULTSTATUS
has claimed since at least the 7.x days:
| PGRES_COMMAND_OK is for commands that can never return rows (INSERT,
UPDATE, etc.)
However, as of 8.2 we support the popular INSERT ... RETURNING and
UPDATE ... RETURNING, both of which will naturally give a successful
PQresultStatus() of PGRES_TUPLES_OK. So I think this explanation
deserves an amendment. We could just change the example commands to
e.g. TRUNCATE for simplicity, but I do like that the current example
commands are INSERT and UPDATE, since it reinforces the notion that a
plain INSERT or UPDATE affecting no rows would still return
PGRES_COMMAND_OK.
Suggested change attached.
Josh
Attachments:
[application/octet-stream] libpq.PGRES_COMMAND_OK.diff (1.1K, 2-libpq.PGRES_COMMAND_OK.diff)
download | inline diff:
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
new file mode 100644
index 255c5c1..a6a179e
*** a/doc/src/sgml/libpq.sgml
--- b/doc/src/sgml/libpq.sgml
*************** ExecStatusType PQresultStatus(const PGre
*** 2445,2451 ****
command that happens to retrieve zero rows still shows
<literal>PGRES_TUPLES_OK</literal>.
<literal>PGRES_COMMAND_OK</literal> is for commands that can never
! return rows (<command>INSERT</command>, <command>UPDATE</command>,
etc.). A response of <literal>PGRES_EMPTY_QUERY</literal> might
indicate a bug in the client software.
</para>
--- 2445,2452 ----
command that happens to retrieve zero rows still shows
<literal>PGRES_TUPLES_OK</literal>.
<literal>PGRES_COMMAND_OK</literal> is for commands that can never
! return rows (<command>INSERT</command> or <command>UPDATE</command>
! without a <literal>RETURNING</literal> clause,
etc.). A response of <literal>PGRES_EMPTY_QUERY</literal> might
indicate a bug in the client software.
</para>
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: example for PGRES_COMMAND_OK
In-Reply-To: <CAK3UJRG262OrX4jVZJXvWRFQqQ_B1HaY2qK_r28Efb3wOJDPog@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox