Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgrME-0005Sw-CR for pgsql-sql@arkaria.postgresql.org; Mon, 27 May 2013 06:56:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UgrMD-0007mu-NB for pgsql-sql@arkaria.postgresql.org; Mon, 27 May 2013 06:56:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgrMC-0007mp-W9 for pgsql-sql@postgresql.org; Mon, 27 May 2013 06:56:37 +0000 Received: from 88-190-26-230.rev.dedibox.fr ([88.190.26.230] helo=sd-30687.dedibox.fr) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UgrM5-0002xv-7c for pgsql-sql@postgresql.org; Mon, 27 May 2013 06:56:36 +0000 Received: from [192.168.10.5] (AMontsouris-652-1-222-92.w92-128.abo.wanadoo.fr [92.128.101.92]) by sd-30687.dedibox.fr (Postfix) with ESMTPSA id 85CFA642CC1; Mon, 27 May 2013 08:56:28 +0200 (CEST) Message-ID: <1369637775.2987.7.camel@localhost.localdomain> Subject: Re: DELETE...RETURNING problem with libpq From: Guillaume Lelarge To: Brice =?ISO-8859-1?Q?Andr=E9?= Cc: Wolfe Whalen , "pgsql-sql@postgresql.org" Date: Mon, 27 May 2013 08:56:15 +0200 In-Reply-To: References: <1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com> <1369551079.3087.4.camel@localhost.localdomain> Content-Type: multipart/mixed; boundary="=-r6LOsdTX+4zKL9XMJxSp" X-Mailer: Evolution 3.6.4 (3.6.4-3.fc18) Mime-Version: 1.0 X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org --=-r6LOsdTX+4zKL9XMJxSp Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Hi, On Sun, 2013-05-26 at 20:35 +0200, Brice André wrote: > [...] > Thanks for your answer. > > Your example is working fine on my computer too (I had to adapt some > includes because my client is under Windows, but everything else was > fine...). > > But, this example is slightly different from my real code : in your > example, the delete on the rule really deletes the element. In my code, the > delete on the rule tags the element as deleted (with an UPDATE statement > and a dedicated column in t1 table). > Oh OK, I didn't understand that when I was working on the code. > I slightly changed your example to be more representative of my code. Here > are my results : > > - 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. > It does to me too. > 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 ? > It took me a while to understand the difference between pgadmin/psql and our little test program. Actually, the difference is that they don't use PQprepare and PQexecPrepared. I've attached the new code. With USE_PREPARED_STATEMENT defined at: * 0, it will simply do a PQexec of the real query * 1, it will do the usual PQprepare/PQexecPrepared * 2, it will do PQexec on the PREPARE statement, and PQexec on the EXECUTE statement (which is what both pgadmin and psql do) It works with 0 and 1, not with 2. I still have no idea why. It might be a bug, but I find it strange it's not been discovered since 8.4 (it also doesn't work on 9.3 beta 1). -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com --=-r6LOsdTX+4zKL9XMJxSp Content-Type: application/zip; name="example.zip" Content-Disposition: attachment; filename="example.zip" Content-Transfer-Encoding: base64 UEsDBAoAAAAAANtGu0IAAAAAAAAAAAAAAAAIABwAZXhhbXBsZS9VVAkAAz4D o1E/A6NRdXgLAAEE9AEAAAT0AQAAUEsDBBQAAAAIAOaiukJR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AAEAAYAAAAAAABAAAAtIFy AQAAZXhhbXBsZS9NYWtlZmlsZVVUBQADArChUXV4CwABBPQBAAAE9AEAAFBL AQIeAxQAAAAIANdGu0LZSA96MAMAABMMAAARABgAAAAAAAEAAAC0gWQCAABl eGFtcGxlL2V4YW1wbGUuY1VUBQADNgOjUXV4CwABBPQBAAAE9AEAAFBLBQYA AAAABAAEAFEBAADfBQAAAAA= --=-r6LOsdTX+4zKL9XMJxSp Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql --=-r6LOsdTX+4zKL9XMJxSp--