X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=db-odbc%2Fodbc-sql.lisp;h=b36833e28ec8ddf745fdc6b1a5651bf80b13efd3;hp=79fd4a5f092d307955168c88f50e84a1bd50774f;hb=0b35694f3659e5ee739ea72ce74d798c3f0ddb73;hpb=e567409d9fff3f7231c2a0bb69b345e19de2b246 diff --git a/db-odbc/odbc-sql.lisp b/db-odbc/odbc-sql.lisp index 79fd4a5..b36833e 100644 --- a/db-odbc/odbc-sql.lisp +++ b/db-odbc/odbc-sql.lisp @@ -7,8 +7,6 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id$ -;;;; ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; ;;;; CLSQL users are granted the rights to distribute and use this software @@ -26,35 +24,50 @@ ;; ODBC interface (defclass odbc-database (generic-odbc-database) - ((odbc-db-type :accessor database-odbc-db-type))) + ()) + +(defclass odbc-postgresql-database (generic-odbc-database + generic-postgresql-database) + ()) (defmethod database-name-from-spec (connection-spec (database-type (eql :odbc))) - (check-connection-spec connection-spec database-type (dsn user password &key connection-string completion window-handle)) + (check-connection-spec connection-spec database-type + (dsn user password &key connection-string completion window-handle)) (destructuring-bind (dsn user password &key connection-string completion window-handle) connection-spec (declare (ignore password connection-string completion window-handle)) (concatenate 'string dsn "/" user))) (defmethod database-connect (connection-spec (database-type (eql :odbc))) - (check-connection-spec connection-spec database-type (dsn user password &key connection-string completion window-handle)) + (check-connection-spec connection-spec database-type + (dsn user password &key connection-string completion window-handle)) (destructuring-bind (dsn user password &key connection-string (completion :no-prompt) window-handle) connection-spec (handler-case (let ((db (make-instance 'odbc-database - :name (database-name-from-spec connection-spec :odbc) - :database-type :odbc - :dbi-package (find-package '#:odbc-dbi) - :odbc-conn - (odbc-dbi:connect :user user - :password password - :data-source-name dsn - :connection-string connection-string - :completion completion - :window-handle window-handle)))) + :name (database-name-from-spec connection-spec :odbc) + :database-type :odbc + :connection-spec connection-spec + :dbi-package (find-package '#:odbc-dbi) + :odbc-conn + (odbc-dbi:connect :user user + :password password + :data-source-name dsn + :connection-string connection-string + :completion completion + :window-handle window-handle)))) (store-type-of-connected-database db) ;; Ensure this database type is initialized so can check capabilities of ;; underlying database (initialize-database-type :database-type database-type) - db) + (if (eql :postgresql (database-underlying-type db)) + (make-instance 'odbc-postgresql-database + :name (database-name-from-spec connection-spec :odbc) + :database-type :odbc + :connection-spec connection-spec + :dbi-package (find-package '#:odbc-dbi) + :odbc-db-type :postgresql + :odbc-conn (clsql-sys::odbc-conn db)) + db)) #+ignore (error () ;; Init or Connect failed (error 'sql-connection-error @@ -62,8 +75,8 @@ :connection-spec connection-spec :message "Connection failed"))))) -(defmethod database-underlying-type ((database odbc-database)) - (database-odbc-db-type database)) +(defmethod database-underlying-type ((database generic-odbc-database)) + (clsql-sys::database-odbc-db-type database)) (defun store-type-of-connected-database (db) (let* ((odbc-conn (clsql-sys::odbc-conn db)) @@ -89,7 +102,7 @@ ((or (search "oracle" server-name :test #'char-equal) (search "oracle" dbms-name :test #'char-equal)) :oracle)))) - (setf (database-odbc-db-type db) type))) + (setf (clsql-sys::database-odbc-db-type db) type)))