guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 8/12] Guile-DBD-postgres: Fix handling of float point columns


From: Linas Vepstas
Subject: [PATCH 8/12] Guile-DBD-postgres: Fix handling of float point columns
Date: Fri, 19 Sep 2008 09:17:49 -0500
User-agent: Mutt/1.5.15+20070412 (2007-04-11)


Database columns containing floating point and double values
are not handled correctly; they are handled as ints. Fix this.

Signed-off-by: Linas Vepstas <address@hidden>

---
 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 ||

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]