From daniel at dbrunner.de Wed Nov 27 14:01:51 2013 From: daniel at dbrunner.de (Daniel Brunner) Date: Wed, 27 Nov 2013 15:01:51 +0100 Subject: Parsing for double precision not working yet Message-ID: <5295FB4F.5070901@dbrunner.de> [NB: Marjin, I already posted this issue on Github] Hello! There is a problem with columns with double precision. Test case: --8<-- (pomo:query "create table ftest (value double precision)") (pomo:query "insert into ftest values ($1)" (coerce 100.10 'double-float)) --8<-- This fails with: --8<-- Database error 22P02: invalid input syntax for type double precision: "100.0999984741211D0" [Condition of type CL-POSTGRES-ERROR:DATA-EXCEPTION] --8<-- A short patch in cl-postgres/sql-string.lisp could solve that problem: --8<-- diff --git a/cl-postgres/sql-string.lisp b/cl-postgres/sql-string.lisp index 3157d30..4dff4be 100644 --- a/cl-postgres/sql-string.lisp +++ b/cl-postgres/sql-string.lisp @@ -84,6 +84,8 @@ whether the string should be escaped before being put into a query.") (princ-to-string arg)) (:method ((arg float)) (format nil "~f" arg)) + (:method ((arg double-float)) + (format nil "~,,,,,,'EE" arg)) (:method ((arg ratio)) ;; Possible optimization: we could probably build up the same binary structure postgres --8<-- Best wishes, Daniel From marijnh at gmail.com Thu Nov 28 12:24:47 2013 From: marijnh at gmail.com (Marijn Haverbeke) Date: Thu, 28 Nov 2013 13:24:47 +0100 Subject: Parsing for double precision not working yet In-Reply-To: <5295FB4F.5070901@dbrunner.de> References: <5295FB4F.5070901@dbrunner.de> Message-ID: Yes, see my response on github. No need to send through multiple channels. On Wed, Nov 27, 2013 at 3:01 PM, Daniel Brunner wrote: > [NB: Marjin, I already posted this issue on Github] > > Hello! > > There is a problem with columns with double precision. > > Test case: > --8<-- > (pomo:query "create table ftest (value double precision)") > (pomo:query "insert into ftest values ($1)" (coerce 100.10 'double-float)) > --8<-- > > This fails with: > --8<-- > Database error 22P02: invalid input syntax for type double precision: > "100.0999984741211D0" > [Condition of type CL-POSTGRES-ERROR:DATA-EXCEPTION] > --8<-- > > A short patch in cl-postgres/sql-string.lisp could solve that problem: > > --8<-- > diff --git a/cl-postgres/sql-string.lisp b/cl-postgres/sql-string.lisp > index 3157d30..4dff4be 100644 > --- a/cl-postgres/sql-string.lisp > +++ b/cl-postgres/sql-string.lisp > @@ -84,6 +84,8 @@ whether the string should be escaped before being put > into a query.") > (princ-to-string arg)) > (:method ((arg float)) > (format nil "~f" arg)) > + (:method ((arg double-float)) > + (format nil "~,,,,,,'EE" arg)) > (:method ((arg ratio)) > ;; Possible optimization: we could probably build up the same > binary structure postgres > --8<-- > > > Best wishes, > Daniel > From sebyte at smolny.plus.com Tue Nov 12 10:43:25 2013 From: sebyte at smolny.plus.com (Sebastian Tennant) Date: Tue, 12 Nov 2013 10:43:25 +0000 Subject: A question about connection pooling, and the many ways to connect. References: Message-ID: Hello Marijn, Quoth Marijn Haverbeke : > You're right, you have to use local connection and specify that you > want them to be pooled. (This model has much less overhead -- a single > synchronization point -- than a model where a single handle can be > used in a multi-threaded way.) This touches on something I've wanted to clarify for some time, namely, best practise for connecting to a database when using Postmodern in web application code. 1. Don't use a single, permanent connection, established at web server start time. This may work fine in development but will soon stall in production. Rather, wrap database operations in WITH-CONNECTION forms and always use pooled connections. 2. Avoid multiple WITH-CONNECTION forms (nested or otherwise) within the code handling a single HTTP request. 3. Leave *MAX-POOL-SIZE* bound to NIL (unlimited) at least to begin with. The number of pooled connections only grows when a new connection is needed and all others are busy. The size of the pool will therefore reflect the latest peak in web server traffic. Any and all corrections, clarifications or refinements to my thinking very much appreciated. Sebastian -- Emacs' AlsaPlayer - Music Without Jolts Lightweight, full-featured and mindful of your idyllic happiness. http://home.gna.org/eap