Re: Number of updated rows with LibPQ

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: Number of updated rows with LibPQ
Дата
Msg-id c0bc0696-02b0-41b8-8e1c-75cb726e78de@manitou-mail.org
обсуждение исходный текст
Ответ на Re: Number of updated rows with LibPQ  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: Number of updated rows with LibPQ
Список pgsql-general
    Laurenz Albe wrote:

> > Or is there a libpq API on PGresult that would allow to get the type
> > of statement the result is from?
>
> The command tag is not what you look at.

Yet that's what psql does. from PrintQueryResult():

    /* if it's INSERT/UPDATE/DELETE RETURNING, also print status */
    if (last || pset.show_all_results)
    {
        cmdstatus = PQcmdStatus(result);
        if (strncmp(cmdstatus, "INSERT", 6) == 0 ||
            strncmp(cmdstatus, "UPDATE", 6) == 0 ||
            strncmp(cmdstatus, "DELETE", 6) == 0)
            PrintQueryStatus(result, printStatusFout);
    }



> You simply check the result from an INSERT statement.  If it is
> PGRES_TUPLES_OK, it must have been INSERT ... RETRUNING.

Or a SELECT, or an UPDATE RETURNING, or a DELETE RETURNING.
The code still need to look at PQcmdStatus() to learn which kind it is,
if it needs to know this.


Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite



В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [libpq] OIDs of extension types? Of custom types?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: How to return argument data type from sql function