Re: DELETE...RETURNING problem with libpq
От | Brice André |
---|---|
Тема | Re: DELETE...RETURNING problem with libpq |
Дата | |
Msg-id | CAOBG12nZ5fOB7=TeMezVdC9s5rmX-g+3FtW=6cJE8gtRZGcnhw@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: DELETE...RETURNING problem with libpq (Guillaume Lelarge <guillaume@lelarge.info>) |
Ответы |
Re: DELETE...RETURNING problem with libpq
|
Список | pgsql-sql |
Hello Guillaume,
Thanks for your answer.- When executing the SQL statement from pgadmin, I get my 81 columns marked as deleted and I get the 81 row results to the query.
- Whe executing it from your script, the function PQexecPrepared does not return 'PGRES_TUPLES_OK' anymore. It now returns 'PGRES_COMMAND_OK'.
- From your program, the 81 rows are marked as deleted, as expected.
- From your program, PQntuples returns the "0" string.
- I did not try from php, but I expect same behaviour as with my real program...
So, once modified, this example behaves like my program.
I suppose that php and pgadmin use the same interface to execute the query. So, I suppose that there should be a solution to my problem... Do you think it's a bug in my version of libpq ? Or maybe is it related to the fact that I use prepared statement ?
I joined my little test program to this e-mail.
Thanks in advance,
Brice
2013/5/26 Guillaume Lelarge <guillaume@lelarge.info>
On Sat, 2013-05-25 at 14:49 +0200, Brice André wrote:It works for me with PQntuples.
> Hi Wolfe,
>
> First, thanks for your help.
>
> I tried your code, but it does not work... the function returns a string :
> "0". When I check, this command properly modifies one row, as expected.
>You'll find my test case attached. It's C code, not C++, but I guess it
> I don't know if it may help, but just in case... The DELETE operation is
> not performed on a table : it is performed on a view. I have a rule on that
> view that, instead of performing a delete on the corresponding table,
> performs an update with table entry tagged as deleted (in a dedicated
> column of the table). This code (sql part) works for years and, when
> executing this command by other ways (php and pgadmin), it deletes and
> returns expected data. With libpq, it deletes, but does not return anything.
>
won't be a big issue :)
It gives me this result:
$ ./example
connection OK
prepare OK
execute OK
ntuples: 81
cleanup OK
81 is the number of lines to delete. If I launch it another time, it
gives me 0 as all the rows have already been deleted.
Hope it helps.
--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com
Вложения
В списке pgsql-sql по дате отправления: