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 8/12] Guile-DBD-postgres: Fix handling of float point columns Date: Fri, 19 Sep 2008 09:17:49 -0500 Message-ID: <20080919141748.GH13684@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="Dx9iWuMxHO1cCoFc" X-Trace: ger.gmane.org 1221834275 8763 80.91.229.12 (19 Sep 2008 14:24:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Sep 2008 14:24:35 +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:25:32 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 1Kggsw-0001dv-N4 for guile-user@m.gmane.org; Fri, 19 Sep 2008 16:23:03 +0200 Original-Received: from localhost ([127.0.0.1]:52861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kggrv-0002Xr-7Y for guile-user@m.gmane.org; Fri, 19 Sep 2008 10:21:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KggoB-00016T-5W for guile-user@gnu.org; Fri, 19 Sep 2008 10:18:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KggoA-00015z-3f for guile-user@gnu.org; Fri, 19 Sep 2008 10:18:06 -0400 Original-Received: from [199.232.76.173] (port=57226 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kggo9-00015k-Q5 for guile-user@gnu.org; Fri, 19 Sep 2008 10:18:05 -0400 Original-Received: from rv-out-0708.google.com ([209.85.198.245]:41005) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Kggo9-0006si-65 for guile-user@gnu.org; Fri, 19 Sep 2008 10:18:05 -0400 Original-Received: by rv-out-0708.google.com with SMTP id k29so501645rvb.6 for ; Fri, 19 Sep 2008 07:18:04 -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=9j6Kaoc/eLIANzsE2P8VHPesw1m6cUwwWCdUFl4DS78=; b=D6E7OKB9ab3jP10NhqGiIeWVjZIg01nGWiHhvzQ33Cx9x40EzrCtqPbgnKle7RlcMX kQhwbDa2EroNUdbPbsYD31BTj9m2paJKBffhmHE36OvfvtSzGYxgJXKbaHp9MguVmei/ uiOAzMfUs7nNcPMFEsHiEpgqEGgwvHZ47RTt4= 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=EEjatPTbY+J69u9wm6pNc89g56j0hvwRZ1ohXY2Mmb4pII1VkYKe5ocmronwcb4VVI JKsaEPKwPNr1OffOrH8lNsBxz7q9R36uTFllu6Sosm1INKhPYTs30nAtnhOhK+jvbIEz A2tiAVysuAAuF+j7mPG6JCZxj2JizjEUmYtX4= Original-Received: by 10.141.169.11 with SMTP id w11mr79083rvo.63.1221833884318; Fri, 19 Sep 2008 07:18:04 -0700 (PDT) Original-Received: from linas.org ( [67.100.217.179]) by mx.google.com with ESMTPS id 6sm1211168yxg.6.2008.09.19.07.18.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Sep 2008 07:18:03 -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:6791 Archived-At: --Dx9iWuMxHO1cCoFc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Database columns containing floating point and double values are not handled correctly; they are handled as ints. Fix this. Signed-off-by: Linas Vepstas --- src/guile-dbd-postgresql.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Index: guile-dbd-postgresql-2.0.0/src/guile-dbd-postgresql.c =================================================================== --- guile-dbd-postgresql-2.0.0.orig/src/guile-dbd-postgresql.c 2008-09-15 10:22:59.000000000 -0500 +++ guile-dbd-postgresql-2.0.0/src/guile-dbd-postgresql.c 2008-09-15 10:33:54.000000000 -0500 @@ -311,8 +311,6 @@ __postgresql_getrow_g_db_handle(gdbi_db_ SCM value; int type = PQftype(pgsqlP->res,f); if ((type >= 20 && type <= 24) || - type == 700 || - type == 701 || type == 1700 || type == 26 ) { @@ -320,6 +318,13 @@ __postgresql_getrow_g_db_handle(gdbi_db_ PQgetlength(pgsqlP->res,pgsqlP->lget,f)); value = scm_int2num(atoi(value_str)); } + else if (type == 700 || + type == 701 ) + { + value_str = (char*) strndup(PQgetvalue(pgsqlP->res,pgsqlP->lget,f), + PQgetlength(pgsqlP->res,pgsqlP->lget,f)); + value = scm_from_double(atof(value_str)); + } else if (type == 18 || type == 19 || type == 25 || --Dx9iWuMxHO1cCoFc 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) iQEVAwUBSNO0jISDRXfAOJJBAQI14gf/Xk5plR406xrnQjRbQn4TcOtA8Jk6y/9L b3Jkl8xPMeeH1/5YLdEuSPYYppxs1LTRxKWWNIet2NDru2CJLJOLsuwmo34iMKz6 /HmTXCSuxfrH8GGumTzs3TdwKt/8g34iXLtHztRPy/AWvaeJWaQn4zxUBsMi4tIr 3CC/uREFfZLf0WWsxx0V4GyVZXsv5sm6cYSGZX5ovWNiTNt/P8yDIZhpPYV6aIU1 1UajOUcrT+HlU+uxCAMu75OaZ1LV2op4Qmza2hhTvG2/+d30YQ6egLFklllA/jcJ Wg4i4P+M6udXCmu/EuxSFIJ05wCcObuuPMyZyDALXchJ6dSMUtq9bA== =5HT2 -----END PGP SIGNATURE----- --Dx9iWuMxHO1cCoFc--