[postmodern-devel] bug in cl-postgres/protocol.lisp?

Bart Botta 00003b at gmail.com
Thu Mar 1 19:47:18 UTC 2007


Using version 7.4.7 of PostgreSQL, SBCL 1.0, postmodern 0.23, the
deftable/create-table example breaks due to

WARNING:
   Postgres warning: CREATE TABLE / PRIMARY KEY will create implicit
index "test_data_pkey" for table "test_data"

which causes cl-postgres::send-query to drop into the debugger with

Postgresql protocol error: Unexpected message received: 1
   [Condition of type CL-POSTGRES::PROTOCOL-ERROR]


If I read the code and postgres protocol docs correctly, this is due
to the way message-case handles NoticeResponse (#\N) messages,
specifically that it only reads 1 of #\E, #\N, or the expected
message, so when it receives both #\N and the expected message, the
caller gets out of sync.

Removing

   (#.(char-code #\N) (get-warning socket))

from the case and adding

        (when (= #.(char-code #\N) ,char-name)
          (get-warning socket)
          (setf ,char-name (read-uint1 ,socket-name))
          (setf ,size-name (read-uint4 ,socket-name)))

before the (case ,char-name ...) in message-case fixes the problem for
me, not sure if it is completely correct though, possibly should loop
in case there are multiple warnings?
(Also, shouldn't that (get-warning socket) and the get-error call use
,socket-name instead of socket?)

--
Bart



More information about the postmodern-devel mailing list