diff -rN -u old-pg/pg-tests.lisp new-pg/pg-tests.lisp
--- old-pg/pg-tests.lisp	2006-09-05 04:39:16.000000000 -0400
+++ new-pg/pg-tests.lisp	2006-09-05 04:39:16.000000000 -0400
@@ -205,10 +205,10 @@
            (progn
              (pg-exec conn "CREATE TABLE fib (n INTEGER, fibn INT8)")
              (setq created t)
-             (funwrap 'fib)
+             #+cmu (funwrap 'fib)
              (time (setq non-memoized (fib 40)))
              #+cmu (fwrap 'fib #'memoize-fib :user-data conn)
-             (update-fwrappers 'fib)    ; remove stale conn user-data object
+             #+cmu (update-fwrappers 'fib)    ; remove stale conn user-data object
              (time (setq memoized (fib 40)))
              (format t "~S" (pg-exec conn "SELECT COUNT(n) FROM fib"))
              (assert (eql non-memoized memoized)))
@@ -312,6 +312,35 @@
   (with-test-connection (conn)
     (pg-exec conn "DROP TABLE pgmt")))
 
+#+(and sbcl sb-thread)
+(defun test-multiprocess ()
+  (format *debug-io* "Testing multiprocess database access~%")
+  (with-test-connection (conn)
+    (pg-exec conn "CREATE TABLE pgmt (a TEXT, b INTEGER, C FLOAT)"))
+  (let ((dio *debug-io*))
+    (flet ((producer ()
+             (with-test-connection (conn)
+               (dotimes (i 5000)
+                 (if (= (mod i 1000) 0) (format dio "~&thread: ~s producing ~a"
+                                                sb-thread:*current-thread* i))
+                 (pg-exec conn (format nil "INSERT INTO pgmt VALUES (~S, ~D, ~F)" i i i))
+                 (when (zerop (mod i 100))
+                   (pg-exec conn "COMMIT WORK")))))
+           (consumer ()
+             (with-test-connection (conn)
+               (dotimes (i 10)
+                 (sleep 1)
+                 (format dio "~&consumer on ~a" i)
+                 (let ((res (pg-exec conn "SELECT count(*) FROM pgmt")))
+                   (format *debug-io* "  Consumer sees ~D rows~%"
+                           (first (pg-result res :tuple 0))))))))
+      (let ((prs (loop :for x :from 0 :below 3
+                       :collect (sb-thread:make-thread #'producer :name "PG data producer")))
+            (co (sb-thread:make-thread #'consumer :name "PG data consumer")))
+        (loop :while (some 'sb-thread:thread-alive-p (append prs (list co)))
+              :do (sleep 5))))
+    (with-test-connection (conn)
+      (pg-exec conn "DROP TABLE pgmt"))))
 
 (defun test-pbe ()
   (with-test-connection (conn)
@@ -349,6 +378,42 @@
           (when created
             (pg-exec conn "DROP TABLE count_test")))))))
 
+(defun test-pbe-text ()
+  (with-test-connection (conn)
+    (when (pg-supports-pbe conn)
+      (format *debug-io* "~&Testing pbe...")
+      (let ((res nil)
+            (count 0)
+            (created nil))
+        (unwind-protect
+             (progn
+               (pg-exec conn "CREATE TABLE pbe_text_test(key int, val text)")
+               (setq created t)
+               (format *debug-io* "~&table created")
+               (pg-prepare conn "ct_insert"
+                           "INSERT INTO pbe_text_test VALUES ($1, $2)"
+                           '("int4" "text"))
+               (loop :for i :from 1 :to 100
+                     :do
+                     (pg-bind conn
+                              "ct_portal" "ct_insert"
+                              `((:int32 ,i)
+                                (:string ,(format nil "~a" (* i i)))))
+                     (pg-execute conn "ct_portal")
+                     (pg-close-portal conn "ct_portal"))
+               (format *debug-io* "~&data inserted")
+               (setq res (pg-exec conn "SELECT count(val) FROM pbe_text_test"))
+               (assert (eql 100 (first (pg-result res :tuple 0))))
+               (setq res (pg-exec conn "SELECT sum(key) FROM pbe_text_test"))
+               (assert (eql 5050 (first (pg-result res :tuple 0))))
+               ;; this iterator does the equivalent of the sum(key) SQL statement
+               ;; above, but on the client side.
+               (pg-for-each conn "SELECT key FROM pbe_text_test"
+                            (lambda (tuple) (incf count (first tuple))))
+               (assert (= 5050 count)))
+          (when created
+            (pg-exec conn "DROP TABLE pbe_text_test")))))))
+
 (defun test-copy-in-out ()
   (with-test-connection (conn)
     (ignore-errors

