1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: aodbc-sql.cl
6 ;;;; Purpose: Low-level interface for CLSQL AODBC backend
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Feb 2002
12 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
19 (in-package #:clsql-aodbc)
21 ;; interface foreign library loading routines
22 (defmethod clsql-sys:database-type-library-loaded ((database-type (eql :aodbc)))
23 "T if foreign library was able to be loaded successfully. "
24 (when (find-package :dbi) ;; finds Allegro's DBI (AODBC) package
27 (defmethod clsql-sys:database-type-load-foreign ((databae-type (eql :aodbc)))
30 (when (find-package :dbi)
31 (clsql-sys:database-type-load-foreign :aodbc))
36 (defclass aodbc-database (generic-odbc-database)
37 ((aodbc-conn :accessor database-aodbc-conn :initarg :aodbc-conn)
38 (aodbc-db-type :accessor database-aodbc-db-type :initform :unknown)))
40 (defmethod database-name-from-spec (connection-spec
41 (database-type (eql :aodbc)))
42 (check-connection-spec connection-spec database-type (dsn user password))
43 (destructuring-bind (dsn user password) connection-spec
44 (declare (ignore password))
45 (concatenate 'string dsn "/" user)))
47 (defmethod database-connect (connection-spec (database-type (eql :aodbc)))
48 (check-connection-spec connection-spec database-type (dsn user password))
50 (destructuring-bind (dsn user password) connection-spec
52 (make-instance 'aodbc-database
53 :name (database-name-from-spec connection-spec :aodbc)
55 :dbi-package (find-package '#:dbi)
57 (dbi:connect :user user
59 :data-source-name dsn))
62 (error () ;; Init or Connect failed
63 (error 'sql-connection-error
64 :database-type database-type
65 :connection-spec connection-spec
66 :message "Connection failed")))))
70 (defmethod database-create (connection-spec (type (eql :aodbc)))
71 (warn "Not implemented."))
73 (defmethod database-destroy (connection-spec (type (eql :aodbc)))
74 (warn "Not implemented."))
76 (defmethod database-probe (connection-spec (type (eql :aodbc)))
77 (warn "Not implemented."))
79 ;;; Backend capabilities
81 (defmethod database-underlying-type ((database aodbc-database))
82 (database-aodbc-db-type database))
84 (defmethod db-backend-has-create/destroy-db? ((db-type (eql :aodbc)))
87 (defmethod database-initialize-database-type ((database-type (eql :aodbc)))
90 (when (clsql-sys:database-type-library-loaded :aodbc)
91 (clsql-sys:initialize-database-type :database-type :aodbc))