X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=db-aodbc%2Faodbc-sql.lisp;h=f357e59b7923fce2bfab986876c2751244118a67;hb=62dbd27811c4141f0a0c357f11e5b5968e10aaa6;hp=bbe655e7c83988fbd58a63b2804ddcccbd11bb0a;hpb=db9892632e6eb7869aea7a94c16b523a82de1501;p=clsql.git diff --git a/db-aodbc/aodbc-sql.lisp b/db-aodbc/aodbc-sql.lisp index bbe655e..f357e59 100644 --- a/db-aodbc/aodbc-sql.lisp +++ b/db-aodbc/aodbc-sql.lisp @@ -19,25 +19,23 @@ (in-package #:clsql-aodbc) ;; interface foreign library loading routines -(defmethod clsql-base-sys:database-type-library-loaded ((database-type (eql :aodbc))) +(defmethod clsql-sys:database-type-library-loaded ((database-type (eql :aodbc))) "T if foreign library was able to be loaded successfully. " (when (find-package :dbi) ;; finds Allegro's DBI (AODBC) package t)) -(defmethod clsql-base-sys:database-type-load-foreign ((databae-type (eql :aodbc))) +(defmethod clsql-sys:database-type-load-foreign ((databae-type (eql :aodbc))) t) (when (find-package :dbi) - (clsql-base-sys:database-type-load-foreign :aodbc)) - -(defmethod database-initialize-database-type ((database-type (eql :aodbc))) - t) + (clsql-sys:database-type-load-foreign :aodbc)) ;; AODBC interface (defclass aodbc-database (database) - ((aodbc-conn :accessor database-aodbc-conn :initarg :aodbc-conn))) + ((aodbc-conn :accessor database-aodbc-conn :initarg :aodbc-conn) + (aodbc-db-type :accessor database-aodbc-db-type :initform :unknown))) (defmethod database-name-from-spec (connection-spec (database-type (eql :aodbc))) @@ -73,11 +71,12 @@ (setf (database-aodbc-conn database) nil) t) -(defmethod database-query (query-expression (database aodbc-database) result-types) +(defmethod database-query (query-expression (database aodbc-database) result-types field-names) #+aodbc-v2 (handler-case (dbi:sql query-expression :db (database-aodbc-conn database) - :types result-types) + :types result-types + :column-names field-names) (clsql-error (e) (error e)) (error () @@ -156,11 +155,11 @@ ;;; Sequence functions (defun %sequence-name-to-table (sequence-name) - (concatenate 'string "_clsql_seq_" (sql-escape sequence-name))) + (concatenate 'string "_CLSQL_SEQ_" (sql-escape sequence-name))) (defun %table-name-to-sequence-name (table-name) (and (>= (length table-name) 11) - (string= (subseq table-name 0 11) "_clsql_seq_") + (string-equal (subseq table-name 0 11) "_CLSQL_SEQ_") (subseq table-name 11))) (defmethod database-create-sequence (sequence-name @@ -184,9 +183,8 @@ (defmethod database-list-sequences ((database aodbc-database) &key (owner nil)) (declare (ignore owner)) - (mapcar #'(lambda (s) (%table-name-to-sequence-name (car s))) - (database-query "SHOW TABLES LIKE '%clsql_seq%'" - database nil))) + (warn "database-list-sequences not implemented for AODBC.") + nil) (defmethod database-list-tables ((database aodbc-database) &key (owner nil)) @@ -202,6 +200,20 @@ (string-equal "TABLE" (nth 3 row))) collect (nth 2 row)))) +(defmethod database-list-views ((database aodbc-database) + &key (owner nil)) + (declare (ignore owner)) + #+aodbc-v2 + (multiple-value-bind (rows col-names) + (dbi:list-all-database-tables :db (database-aodbc-conn database)) + (declare (ignore col-names)) + ;; TABLE_SCHEM is hard-coded in second column by ODBC Driver Manager + ;; TABLE_NAME in third column, TABLE_TYPE in fourth column + (loop for row in rows + when (and (not (string-equal "information_schema" (nth 1 row))) + (string-equal "VIEW" (nth 3 row))) + collect (nth 2 row)))) + (defmethod database-list-attributes ((table string) (database aodbc-database) &key (owner nil)) (declare (ignore owner)) @@ -224,6 +236,11 @@ (loop for row in rows collect (nth pos row)))))) +(defmethod database-list-indexes ((database aodbc-database) + &key (owner nil)) + (warn "database-list-indexes not implemented for AODBC.") + nil) + (defmethod database-set-sequence-position (sequence-name (position integer) (database aodbc-database)) @@ -241,8 +258,7 @@ (car (database-query (concatenate 'string "SELECT last_value,is_called FROM " table-name) - database - :auto)))) + database :auto nil)))) (cond ((char-equal (schar (second tuple) 0) #\f) (database-execute-command @@ -261,8 +277,7 @@ (caar (database-query (concatenate 'string "SELECT last_value FROM " (%sequence-name-to-table sequence-name)) - database - :auto)))) + database :auto nil)))) (defmethod database-create (connection-spec (type (eql :aodbc))) (warn "Not implemented.")) @@ -273,6 +288,16 @@ (defmethod database-probe (connection-spec (type (eql :aodbc))) (warn "Not implemented.")) -#+ignore -(when (clsql-base-sys:database-type-library-loaded :aodbc) - (clsql-base-sys:initialize-database-type :database-type :aodbc)) +;;; Backend capabilities + +(defmethod database-underlying-type ((database aodbc-database)) + (database-aodbc-db-type database)) + +(defmethod db-backend-has-create/destroy-db? ((db-type (eql :aodbc))) + nil) + +(defmethod database-initialize-database-type ((database-type (eql :aodbc))) + t) + +(when (clsql-sys:database-type-library-loaded :aodbc) + (clsql-sys:initialize-database-type :database-type :aodbc))