From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Laurenz Albe" <laurenz(dot)albe(at)cybertec(dot)at> |
Cc: | Dominique Devienne <ddevienne(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Number of updated rows with LibPQ |
Date: | 2022-10-14 14:39:13 |
Message-ID: | c0bc0696-02b0-41b8-8e1c-75cb726e78de@manitou-mail.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-10-14 14:55:57 | Re: How to return argument data type from sql function |
Previous Message | Tom Lane | 2022-10-14 14:35:09 | Re: [libpq] OIDs of extension types? Of custom types? |