Re: Number of updated rows with LibPQ

2022-10-14 Thread Dominique Devienne
On Fri, Oct 14, 2022 at 4:39 PM Daniel Verite wrote: > 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, Thanks Daniel. This is exactly what I needed. --DD PS: Now I wonder whether PQcmdTuples() points to the sam

Re: Number of updated rows with LibPQ

2022-10-14 Thread Daniel Verite
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 prin

Re: Number of updated rows with LibPQ

2022-10-14 Thread Laurenz Albe
On Fri, 2022-10-14 at 13:52 +0200, Dominique Devienne wrote: > On Wed, Oct 5, 2022 at 8:17 PM Tom Lane wrote: > > Laurenz Albe writes: > > > On Wed, 2022-10-05 at 16:38 +0200, Dominique Devienne wrote: > > > Yes, you have to use PQcmdTuples(), and you have to convert the string to > > > an integ

Re: Number of updated rows with LibPQ

2022-10-14 Thread Guillaume Lelarge
Le ven. 14 oct. 2022 à 13:52, Dominique Devienne a écrit : > On Wed, Oct 5, 2022 at 8:17 PM Tom Lane wrote: > > Laurenz Albe writes: > > > On Wed, 2022-10-05 at 16:38 +0200, Dominique Devienne wrote: > > > Yes, you have to use PQcmdTuples(), and you have to convert the string > to an integer. >

Re: Number of updated rows with LibPQ

2022-10-14 Thread Dominique Devienne
On Wed, Oct 5, 2022 at 8:17 PM Tom Lane wrote: > Laurenz Albe writes: > > On Wed, 2022-10-05 at 16:38 +0200, Dominique Devienne wrote: > > Yes, you have to use PQcmdTuples(), and you have to convert the string to > > an integer. > > But don't worry: the result will *not* be "INSERT 0 5", it will

Re: Number of updated rows with LibPQ

2022-10-05 Thread Tom Lane
Laurenz Albe writes: > On Wed, 2022-10-05 at 16:38 +0200, Dominique Devienne wrote: >> For selects, I have [PQnTuples][2], but what to do on INSERT, UPDATE, DELETE? >> Parse the result of PQcmdTuples myself??? If so, what's the 0 in the >> INSERT below? > Yes, you have to use PQcmdTuples(), and y

Re: Number of updated rows with LibPQ

2022-10-05 Thread Laurenz Albe
On Wed, 2022-10-05 at 16:38 +0200, Dominique Devienne wrote: > Hi, > > Is there a way to programmatically now how many rows an UPDATE did update? > I've read about [PQcmdTuples][1], but surely I shouldn't have to parse > that string, no? > For selects, I have [PQnTuples][2], but what to do on INSE

Number of updated rows with LibPQ

2022-10-05 Thread Dominique Devienne
Hi, Is there a way to programmatically now how many rows an UPDATE did update? I've read about [PQcmdTuples][1], but surely I shouldn't have to parse that string, no? For selects, I have [PQnTuples][2], but what to do on INSERT, UPDATE, DELETE? Parse the result of PQcmdTuples myself??? If so, what