From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Linas Vepstas Newsgroups: gmane.lisp.guile.user Subject: [PATCH 10/12] Guile-DBD-postgres: Fix off-by-one when fetching rows Date: Fri, 19 Sep 2008 09:20:41 -0500 Message-ID: <20080919142040.GJ13684@linas.org> References: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="I/5syFLg1Ed7r+1G" X-Trace: ger.gmane.org 1221834438 9731 80.91.229.12 (19 Sep 2008 14:27:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Sep 2008 14:27:18 +0000 (UTC) Cc: Guile User Mailing List To: Maurizio Boriani Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Sep 19 16:28:14 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kggv6-0002jt-Mn for guile-user@m.gmane.org; Fri, 19 Sep 2008 16:25:19 +0200 Original-Received: from localhost ([127.0.0.1]:34513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kggu4-0003ZJ-Qr for guile-user@m.gmane.org; Fri, 19 Sep 2008 10:24:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kggqs-0002F2-V8 for guile-user@gnu.org; Fri, 19 Sep 2008 10:20:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kggqs-0002Eb-0V for guile-user@gnu.org; Fri, 19 Sep 2008 10:20:54 -0400 Original-Received: from [199.232.76.173] (port=46933 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kggqr-0002EQ-Mq for guile-user@gnu.org; Fri, 19 Sep 2008 10:20:53 -0400 Original-Received: from rv-out-0708.google.com ([209.85.198.242]:38646) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kggqr-0007ag-5M for guile-user@gnu.org; Fri, 19 Sep 2008 10:20:53 -0400 Original-Received: by rv-out-0708.google.com with SMTP id k29so502613rvb.6 for ; Fri, 19 Sep 2008 07:20:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:from; bh=YK5KKqgBqn/h4tof1bmfHUQ/hSjz6tbfBup0OoFiCYc=; b=uFs4fE1xhbEeSAgbclSNCLm07BU5KR7i2k2kFOLHk6mVjC5XUQIPj1IyLeUhLsZUhk wId4y9E87cJHjBwF9nOHbNCDfd24s8ujUZbL7Lb5bkJNu6173toG5owgZznXoU2oNYVw LM1oKIMwHiiFXT88isbQQEH/CmEoGs2lRyo8c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:from; b=sl3ugbws4uJ8W4VcOZe/XjrZhtg0aSjdNWlwB1cKK6v0zUPO4pi7OyFJVMRTykpdu9 b/xtO7H5fYwpDQltM0mYpf5emhivnM4Pk052QnKN8adgcPmtqaIQwDnOWqz6oeuGphp+ E0gWu5tGP3KTQU7hm/42qkyXN/gRPiIU/hTgg= Original-Received: by 10.140.139.3 with SMTP id m3mr84340rvd.44.1221834052504; Fri, 19 Sep 2008 07:20:52 -0700 (PDT) Original-Received: from linas.org ( [67.100.217.179]) by mx.google.com with ESMTPS id 34sm1204364yxm.0.2008.09.19.07.20.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Sep 2008 07:20:52 -0700 (PDT) Content-Disposition: inline In-Reply-To: <3ae3aa420809190645o2fe2b746id80f53c5cb123e5b@mail.gmail.com> User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6793 Archived-At: --I/5syFLg1Ed7r+1G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable It appears that the current postgres dbd code will return one less row than the database actually contains, which is a disaster if=20 the database holds only one row! Fix this. Signed-off-by: Linas Vepstas --- src/guile-dbd-postgresql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: guile-dbd-postgresql-2.0.0/src/guile-dbd-postgresql.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- guile-dbd-postgresql-2.0.0.orig/src/guile-dbd-postgresql.c 2008-09-15 1= 4:10:33.000000000 -0500 +++ guile-dbd-postgresql-2.0.0/src/guile-dbd-postgresql.c 2008-09-15 14:11:= 02.000000000 -0500 @@ -299,7 +299,7 @@ __postgresql_getrow_g_db_handle(gdbi_db_ pgsqlP->lget =3D 0; return (SCM_BOOL_F); } - else if (pgsqlP->lget =3D=3D (PQntuples(pgsqlP->res) - 1)) + else if (pgsqlP->lget =3D=3D PQntuples(pgsqlP->res)) { pgsqlP->res =3D PQgetResult(pgsqlP->pgsql); } --I/5syFLg1Ed7r+1G Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQEVAwUBSNO1OISDRXfAOJJBAQKyOQf9GHC7H2JCkPWo64i6cj+GcdN3OnDx+aLJ 8zsI8VArhY/gA4QENhgNyaiHEfbL00XdneaSPEp864QyOyKNVIO1my+jOSK/KOXB M6bZLp6jPV7SrTu1OEzt0WwQeS/+LRkrYm85UdvzFdUlZpA+OB0f9Is66YTFK7G6 xbseQUklky9/8aqFanBL8kVhrNBjPLPlO4Yuqj0Lr7iwlTFr/347BxEjs1awMK3M kmtYzEYfPfDmohT2CAP67/oO0gv0aOMGeqNnWIKPb5rfi23yiVTLS2QZZMuuJ2uF iVNT3Tqk70gm8t2KS26VkChhvVUJgGSGrjN1uA1BsjQESrzlWDM36w== =jPm8 -----END PGP SIGNATURE----- --I/5syFLg1Ed7r+1G--