[pg-cvs] CVS pg
emarsden
emarsden at common-lisp.net
Sun Nov 26 18:05:11 UTC 2006
Update of /project/pg/cvsroot/pg
In directory clnet:/tmp/cvs-serv5864
Modified Files:
v3-protocol.lisp
Log Message:
Make sure we consume the ReadyForQuery packet that is generated when
closing a prepared statement or portal, or the packet can be
misinterpreted by a later query, leading to data loss. Fix from Robert
J. Macomber.
--- /project/pg/cvsroot/pg/v3-protocol.lisp 2006/11/20 20:50:36 1.29
+++ /project/pg/cvsroot/pg/v3-protocol.lisp 2006/11/26 18:05:11 1.30
@@ -485,8 +485,8 @@
(defun do-followup-query (connection)
"Does the followup of a query"
- (let ((tuples '())
- (attributes '())
+ (let ((tuples (list))
+ (attributes (list))
(result (make-pgresult :connection connection)))
(loop
:for packet = (read-packet connection)
@@ -592,6 +592,7 @@
((#\Z) ;; ReadyForQuery
(let ((status (read-from-packet packet :byte)))
+ (declare (ignore status))
(when got-data-p
(return-from do-followup-query result))))
@@ -613,12 +614,11 @@
((#\2 #\1 #\3)
(return-from do-followup-query result))
- ((#\n)
+ ((#\n) ;; NoData
(setf got-data-p t))
;; error messages will already have been handled in READ-PACKET
((#\E)
- (error "not reached!")
(setq got-data-p t))
;; notice messages will already have been handled in READ-PACKET
@@ -929,7 +929,9 @@
(loop :for packet = (read-packet connection)
:do
(case (pg-packet-type packet)
- ((#\3 #\Z) ;; CloseComplete or ReadyForQuery
+ ((#\3)
+ t)
+ ((#\Z) ;; CloseComplete or ReadyForQuery
(return))
(t
(warn "Got unexpected packet in PG-CLOSE: ~S, resetting connection" packet)
More information about the Pg-cvs
mailing list