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
Hello Bart,
Sorry about the somewhat late response, my Internet access is limited at the moment.
Thanks for the quality bug report. I pushed something that should fix this to the repo. For some reason I never had any problems with this bug, even though I do get the create-table warning all the time (the tests even get it, do they fail on your setup?). Good catch about the use of 'socket' instead of ',socket-name' too. Let me know if this patch solves your problem.
Regards, Marijn
postmodern-devel@common-lisp.net