public inbox for [email protected]  
help / color / mirror / Atom feed
example for PGRES_COMMAND_OK
2+ messages / 2 participants
[nested] [flat]

* example for PGRES_COMMAND_OK
@ 2012-10-26 23:58 Josh Kupershmidt <[email protected]>
  2013-01-19 03:40 ` Re: example for PGRES_COMMAND_OK Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Josh Kupershmidt @ 2012-10-26 23:58 UTC (permalink / raw)
  To: pgsql-docs

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>


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: example for PGRES_COMMAND_OK
  2012-10-26 23:58 example for PGRES_COMMAND_OK Josh Kupershmidt <[email protected]>
@ 2013-01-19 03:40 ` Peter Eisentraut <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2013-01-19 03:40 UTC (permalink / raw)
  To: Josh Kupershmidt <[email protected]>; +Cc: pgsql-docs

On Fri, 2012-10-26 at 16:58 -0700, Josh Kupershmidt wrote:
> 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.

committed



-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2013-01-19 03:40 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26 23:58 example for PGRES_COMMAND_OK Josh Kupershmidt <[email protected]>
2013-01-19 03:40 ` Peter Eisentraut <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox