Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgUo2-0004iA-Bd for pgsql-sql@arkaria.postgresql.org; Sun, 26 May 2013 06:51:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UgUo1-0000yA-4S for pgsql-sql@arkaria.postgresql.org; Sun, 26 May 2013 06:51:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UgUnz-0000y1-6i for pgsql-sql@postgresql.org; Sun, 26 May 2013 06:51:47 +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 1UgUnl-0003DH-5u for pgsql-sql@postgresql.org; Sun, 26 May 2013 06:51:46 +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 D8AD4642C98; Sun, 26 May 2013 08:51:31 +0200 (CEST) Message-ID: <1369551079.3087.4.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: Sun, 26 May 2013 08:51:19 +0200 In-Reply-To: References: <1369483241.9028.140661235555577.5F2DB852@webmail.messagingengine.com> Content-Type: multipart/mixed; boundary="=-JwJf+KH+OQATxJCqQVSc" 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 --=-JwJf+KH+OQATxJCqQVSc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit On Sat, 2013-05-25 at 14:49 +0200, Brice André wrote: > 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. > It works for me with PQntuples. > 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. > You'll find my test case attached. It's C code, not C++, but I guess it 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 --=-JwJf+KH+OQATxJCqQVSc Content-Type: application/x-compressed-tar; name="example.tgz" Content-Disposition: attachment; filename="example.tgz" Content-Transfer-Encoding: base64 H4sIAESwoVEAA+1Ye2/aSBDPv/hTTLlGgoiHDQZ0yeUkkjiEK68AaSpdK7Sx 12DF2I7XziU69bvfeNcGQxtF7YWcevVPVW3Pe2d2ltnQB7L0bFrd2yFkRKvR EM+muvGMsafUlIZcryOjvicr9Zra2IPGLoNKELKA+AB789CybRIu6RNyz/F/ UNC4/ka49Crszt6Fj6jAza26p+uv1upx/WutZgPpitpSW3sg7yKYbfzk9T8d a+2pBtP2SU8DL7yxLb0SKFCQAKErYDkBnVNfKh5JUiz7vqtdJ6L3CrQnXHai 9bTTaaRyPh7216ZQrzuYaOMpdAfTYcpFrDCnDvVJQGeM+hZlBaUEiiyn3I2v MDLLYTPuC4YDOEPNKObhOgoM4WyIHiZTrX2WCGwGAtcX2liDQqBUMMhjcG0D X4ow1qZX40F30AHOOZL+65K8KpL+75Nbalr2Tnb3c/1fr9fX579ci/q/2Wpm /f8aGHXOuz3tTJucYkvk490AZSBwF1r6bZk4Rtm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Lj1R3q+HuB3hVnuhhhN6 2zXmS5CPpM/ZwP0DIpn/K3MrsOaO6+9gvuXzv/r0/V9WamL+V1qNphrd/xu1 evb3v1dB9Z7oYbi03ax7M2TIkCFDhgwZMmTIkCFDhv8t/gF6EggzACgAAA== --=-JwJf+KH+OQATxJCqQVSc 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 --=-JwJf+KH+OQATxJCqQVSc--