Re: [GENERAL] libpq confusion - Mailing list pgsql-general

From Thomas Delrue
Subject Re: [GENERAL] libpq confusion
Date
Msg-id 1759465.Pq9tdH2gog@null
Whole thread Raw
In response to Re: [GENERAL] libpq confusion  (Igor Korot <ikorot01@gmail.com>)
List pgsql-general
On Wednesday, September 20, 2017 1:47:05 PM EDT Igor Korot wrote:
>Thx.
>So it is referring to the command not a "command returning no data". ;-)

assumingcreate table t (c int);

select c from t;- PQresultStatus(result) == PGRES_TUPLES_OK- PQntuples(result) == number or rows returned (int)
insert into t(c)values(1);- PQresultStatus(result) ==PGRES_COMMAND_OK- PQcmdTuples(result) == "1" (note: char*)
insert into t(c)values(1) returning c;- PQresultStatus(result) ==PGRES_TUPLES_OK- PQntuples(result) == 1 (int)

>On Wed, Sep 20, 2017 at 1:42 PM, John R Pierce <pierce@hogranch.com> wrote:
>> On 9/20/2017 10:34 AM, Igor Korot wrote:
>> >From the documentation:
>> https://www.postgresql.org/docs/9.1/static/libpq-exec.html
>> 
>> [quote]
>> PGRES_COMMAND_OK
>> 
>> Successful completion of a command returning no data.
>> [/quote]
>> 
>> No data = no rows, right?
>> 
>> from that same page, a bit farther down, clarifying the potentially
>> confusing wording.
>> 
>> If the result status is PGRES_TUPLES_OK, then the functions described below
>> can be used to retrieve the rows returned by the query. Note that a SELECT
>> command that happens to retrieve zero rows still shows PGRES_TUPLES_OK.
>> PGRES_COMMAND_OK is for commands that can never return rows (INSERT,
>> UPDATE,
>> etc.). A response of PGRES_EMPTY_QUERY might indicate a bug in the client
>> software.

pgsql-general by date:

Previous
From: Jerry Sievers
Date:
Subject: Re: [GENERAL] Up to date conventional wisdom re max shared_buffer size?
Next
From: Jerry Sievers
Date:
Subject: Re: [GENERAL] Up to date conventional wisdom re max shared_buffer size?