X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=interfaces%2Fpostgresql%2Fpostgresql-sql.cl;h=7e9d6e89a4051d5bedf0f8ea86ba4443707d2c9b;hb=dce3b76e9ea80c3782e1077d64730aff251f92b6;hp=4104afa13048ba37f1c421c2a0c36ddfb9f418dd;hpb=0fe44ce81f47c779d9695c9211668b4780bf4216;p=clsql.git diff --git a/interfaces/postgresql/postgresql-sql.cl b/interfaces/postgresql/postgresql-sql.cl index 4104afa..7e9d6e8 100644 --- a/interfaces/postgresql/postgresql-sql.cl +++ b/interfaces/postgresql/postgresql-sql.cl @@ -8,7 +8,7 @@ ;;;; Original code by Pierre R. Mai ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: postgresql-sql.cl,v 1.14 2002/04/23 18:28:02 kevin Exp $ +;;;; $Id: postgresql-sql.cl,v 1.16 2002/05/10 08:05:48 marc.battyani Exp $ ;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; and Copyright (c) 1999-2001 by Pierre R. Mai @@ -87,6 +87,9 @@ ((conn-ptr :accessor database-conn-ptr :initarg :conn-ptr :type pgsql-conn-def))) +(defmethod database-type ((database postgresql-database)) + :postgresql) + (defmethod database-name-from-spec (connection-spec (database-type (eql :postgresql))) (check-connection-spec connection-spec database-type @@ -125,6 +128,7 @@ (make-instance 'postgresql-database :name (database-name-from-spec connection-spec database-type) + :connection-spec connection-spec :conn-ptr connection))))) @@ -281,23 +285,22 @@ (lo-create (database-conn-ptr database) (logior postgresql::+INV_WRITE+ postgresql::+INV_READ+))) -;; (MB)the begin/commit/rollback stuff will be removed when with-transaction wil be implemented -(defmethod database-write-large-object ( object-id (data string) (database postgresql-database)) +(defmethod database-write-large-object (object-id (data string) (database postgresql-database)) (let ((ptr (database-conn-ptr database)) (length (length data)) (result nil) (fd nil)) - (unwind-protect - (progn - (database-execute-command "begin" database) - (setf fd (lo-open ptr object-id postgresql::+INV_WRITE+)) - (when (>= fd 0) - (when (= (lo-write ptr fd data length) length) - (setf result t)))) - (progn - (when (and fd (>= fd 0)) - (lo-close ptr fd)) - (database-execute-command (if result "commit" "rollback") database))) + (with-transaction (:database database) + (unwind-protect + (progn + (setf fd (lo-open ptr object-id postgresql::+INV_WRITE+)) + (when (>= fd 0) + (when (= (lo-write ptr fd data length) length) + (setf result t)))) + (progn + (when (and fd (>= fd 0)) + (lo-close ptr fd)) + ))) result)) ;; (MB) the begin/commit/rollback stuff will be removed when with-transaction wil be implemented