;;;; original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: classes.cl,v 1.1 2002/05/13 16:22:08 kevin Exp $
+;;;; $Id: classes.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;; *************************************************************************
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-sys)
+(in-package :clsql-base-sys)
(defclass database ()
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: conditions.cl,v 1.1 2002/05/13 16:22:08 kevin Exp $
+;;;; $Id: conditions.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;; *************************************************************************
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-sys)
+(in-package :clsql-base-sys)
;;; Conditions
(define-condition clsql-condition ()
;;;; onShoreD to support UncommonSQL front-end
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: db-interface.cl,v 1.1 2002/05/13 16:22:08 kevin Exp $
+;;;; $Id: db-interface.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai, and onShoreD
;;;; *************************************************************************
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-sys)
+(in-package :clsql-base-sys)
(defgeneric database-type-load-foreign (database-type)
(:documentation
"The internal generic implementation for checking if
database type library loaded successfully."))
-(defgeneric database-type (database-type)
+(defgeneric database-type (database)
(:documentation
"Returns database type")
- (:method (database-type)
- (declare (ignore database-type))
+ (:method (database)
(signal-nodb-error database)))
;;;; Programmers: Kevin M. Rosenberg
;;;; Date Started: May 2002
;;;;
-;;;; $Id: initialize.cl,v 1.1 2002/05/14 16:23:37 kevin Exp $
+;;;; $Id: initialize.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;; *************************************************************************
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-sys)
+(in-package :clsql-base-sys)
(defvar *loaded-database-types* nil
"Contains a list of database types which have been defined/loaded.")
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: package.cl,v 1.5 2002/05/20 17:46:34 kevin Exp $
+;;;; $Id: package.cl,v 1.6 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;; core packages.
(eval-when (:compile-toplevel :load-toplevel :execute)
-(defpackage :clsql-sys
+(defpackage :clsql-base-sys
(:use :common-lisp)
(:export
;; "Private" exports for use by interface packages
#:database-read-large-object
#:database-delete-large-object
- ;; Shared exports for re-export by CLSQL
-
+ ;; Shared exports for re-export by CLSQL-BASE
.
#1=(#:clsql-condition
#:clsql-error
#:clsql-exists-error
#:clsql-closed-error
#:clsql-closed-error-database
+
#:*loaded-database-types*
#:reload-database-types
#:*default-database-type*
#:closed-database
#:find-database
#:database-name-from-spec
- #:connect
- #:disconnect
- #:query
- #:execute-command
- #:map-query
- #:do-query
- ;; functional.cl
- #:insert-records
- #:delete-records
- #:update-records
- #:with-database
+ ;; accessors for database class
+ #:name
+ #:connection-spec
+ #:transaction
+ #:transaction-level
+ #:conn-pool
;; utils.cl
#:number-to-sql-string
#:float-to-sql-string
#:sql-escape-quotes
-
- ;; For UncommonSQL support
- #:sql-ident
- #:list-tables
- #:list-attributes
- #:attribute-type
- #:create-sequence
- #:drop-sequence
- #:sequence-next
-
- ;; Pooled connections
- #:disconnect-pooled
- #:find-or-create-connection-pool
-
- ;; Transactions
- #:with-transaction
- #:commit-transaction
- #:rollback-transaction
- #:add-transaction-commit-hook
- #:add-transaction-rollback-hook
-
- ;; Large objects (Marc B)
- #:create-large-object
- #:write-large-object
- #:read-large-object
- #:delete-large-object
))
- (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
+ (:documentation "This is the INTERNAL SQL-Interface package of CLSQL-BASE."))
-(defpackage #:clsql
- (:import-from #:clsql-sys . #1#)
+(defpackage #:clsql-base
+ (:import-from :clsql-base-sys . #1#)
(:export . #1#)
- (:documentation "This is the SQL-Interface package of CLSQL."))
+ (:documentation "This is the SQL-Interface package of CLSQL-BASE."))
);eval-when
-(defpackage #:clsql-user
- (:use #:common-lisp #:clsql)
- (:documentation "This is the user package for experimenting with CLSQL."))
+
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Mar 2002
;;;;
-;;;; $Id: utils.cl,v 1.3 2002/05/19 16:05:22 kevin Exp $
+;;;; $Id: utils.cl,v 1.4 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;; *************************************************************************
(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
-(in-package :clsql-sys)
+(in-package :clsql-base-sys)
(defun number-to-sql-string (num)
(etypecase num
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: clsql-aodbc.system,v 1.5 2002/05/18 17:37:48 kevin Exp $
+;;;; $Id: clsql-aodbc.system,v 1.6 2002/05/27 17:19:29 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
:binary-pathname "CL-LIBRARY:clsql;interfaces;aodbc;bin;"
:components ((:file "aodbc-package")
(:file "aodbc-sql" :depends-on ("aodbc-package")))
- :depends-on (:clsql))
+ :depends-on (:clsql-base))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: clsql.system,v 1.14 2002/05/15 17:19:42 kevin Exp $
+;;;; $Id: clsql.system,v 1.15 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
:source-pathname "CL-LIBRARY:clsql;sql;"
:source-extension "cl"
:binary-pathname "CL-LIBRARY:clsql;sql;bin;"
- :components ((:file "pool")
+ :components ((:file "package")
+ (:file "pool" :depends-on ("package"))
(:file "loop-extension")
(:file "sql" :depends-on ("pool"))
(:file "transactions" :depends-on ("sql"))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: aodbc-package.cl,v 1.1 2002/03/23 14:04:52 kevin Exp $
+;;;; $Id: aodbc-package.cl,v 1.2 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defpackage :clsql-aodbc
(:nicknames :aodbc)
- (:use :common-lisp :clsql-sys)
+ (:use :common-lisp :clsql-base-sys)
(:export #:aodbc-database)
(:documentation "This is the CLSQL interface to Allegro's AODBC"))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: aodbc-sql.cl,v 1.10 2002/05/13 22:05:21 kevin Exp $
+;;;; $Id: aodbc-sql.cl,v 1.11 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(when (find-package :dbi) ;; finds Allegro's DBI (AODBC) package
t))
-(defmethod clsql-sys:database-type-load-foreign ((databae-type (eql :aodbc)))
+(defmethod clsql-base-sys:database-type-load-foreign ((databae-type (eql :aodbc)))
t)
(when (find-package :dbi)
- (clsql-sys:database-type-load-foreign :aodbc))
+ (clsql-base-sys:database-type-load-foreign :aodbc))
(defmethod database-initialize-database-type ((database-type (eql :aodbc)))
t)
list))))
-(when (clsql-sys:database-type-library-loaded :aodbc)
- (clsql-sys:initialize-database-type :database-type :aodbc))
+(when (clsql-base-sys:database-type-library-loaded :aodbc)
+ (clsql-base-sys:initialize-database-type :database-type :aodbc))
;;;; Programmers: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: mysql-loader.cl,v 1.17 2002/05/18 17:37:48 kevin Exp $
+;;;; $Id: mysql-loader.cl,v 1.18 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defvar *mysql-library-loaded* nil
"T if foreign library was able to be loaded successfully")
-(defmethod clsql-sys:database-type-library-loaded ((database-type (eql :mysql)))
+(defmethod clsql-base-sys:database-type-library-loaded ((database-type (eql :mysql)))
*mysql-library-loaded*)
-(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :mysql)))
+(defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :mysql)))
(let ((mysql-path
(uffi:find-foreign-library *mysql-library-candidate-names*
*mysql-library-candidate-directories*
mysql-path *clsql-mysql-library-filename*))))
-(clsql-sys:database-type-load-foreign :mysql)
+(clsql-base-sys:database-type-load-foreign :mysql)
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: mysql-sql.cl,v 1.21 2002/05/25 15:57:28 kevin Exp $
+;;;; $Id: mysql-sql.cl,v 1.22 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
;;;; Added field types
(defpackage :clsql-mysql
- (:use :common-lisp :clsql-sys :mysql :clsql-uffi)
+ (:use :common-lisp :clsql-base-sys :mysql :clsql-uffi)
(:export #:mysql-database)
(:documentation "This is the CLSQL interface to MySQL."))
list)))
-(when (clsql-sys:database-type-library-loaded :mysql)
- (clsql-sys:initialize-database-type :database-type :mysql)
- (setq clsql:*default-database-type* :mysql)
+(when (clsql-base-sys:database-type-library-loaded :mysql)
+ (clsql-base-sys:initialize-database-type :database-type :mysql)
(pushnew :mysql cl:*features*))
;;;; Programmers: Kevin M. Rosenberg and onShore Development Inc\r
;;;; Date Started: Mar 2002\r
;;;;\r
-;;;; $Id: mysql-usql.cl,v 1.5 2002/04/27 21:48:08 kevin Exp $\r
+;;;; $Id: mysql-usql.cl,v 1.6 2002/05/27 17:19:30 kevin Exp $\r
;;;;\r
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg\r
;;;; and by onShore Development Inc.\r
\r
;; Misc USQL functions\r
\r
+#|\r
#+ignore\r
(defmethod database-output-sql ((expr clsql-sys::sql-typecast-exp) \r
(database mysql-database))\r
(make-instance 'clsql-sys::sql-typecast-exp\r
:modifier 'int8\r
:components val)))\r
+|#\r
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-socket-sql.cl,v 1.12 2002/05/13 22:05:21 kevin Exp $
+;;;; $Id: postgresql-socket-sql.cl,v 1.13 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
(in-package :cl-user)
(defpackage :clsql-postgresql-socket
- (:use :common-lisp :clsql-sys :postgresql-socket)
+ (:use :common-lisp :clsql-base-sys :postgresql-socket)
(:export #:postgresql-socket-database)
(:documentation "This is the CLSQL socket interface to PostgreSQL."))
(defmethod database-type-library-loaded ((database-type (eql :postgresql-socket)))
t)
-(defmethod clsql-sys:database-type-load-foreign ((database-type (eql :postgresql-socket)))
+(defmethod clsql-base-sys:database-type-load-foreign ((database-type (eql :postgresql-socket)))
t)
-(clsql-sys:database-type-load-foreign :postgresql-socket)
+(clsql-base-sys:database-type-load-foreign :postgresql-socket)
;; Field type conversion
(setf (postgresql-socket-result-set-done result-set) t)
(wait-for-query-results (database-connection database)))))))
-(when (clsql-sys:database-type-library-loaded :postgresql-socket)
- (clsql-sys:initialize-database-type :database-type :postgresql-socket))
+(when (clsql-base-sys:database-type-library-loaded :postgresql-socket)
+ (clsql-base-sys:initialize-database-type :database-type :postgresql-socket))
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-loader.cl,v 1.11 2002/05/18 17:37:49 kevin Exp $
+;;;; $Id: postgresql-loader.cl,v 1.12 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(defvar *postgresql-library-loaded* nil
"T if foreign library was able to be loaded successfully")
-(defmethod clsql-sys:database-type-library-loaded ((database-type
+(defmethod clsql-base-sys:database-type-library-loaded ((database-type
(eql :postgresql)))
*postgresql-library-loaded*)
-(defmethod clsql-sys:database-type-load-foreign ((database-type
+(defmethod clsql-base-sys:database-type-load-foreign ((database-type
(eql :postgresql)))
(let ((libpath (uffi:find-foreign-library
"libpq"
(setq *postgresql-library-loaded* t)
(warn "Can't load PostgreSQL client library ~A" libpath))))
-(clsql-sys:database-type-load-foreign :postgresql)
+(clsql-base-sys:database-type-load-foreign :postgresql)
;;;; Original code by Pierre R. Mai
;;;; Date Started: Feb 2002
;;;;
-;;;; $Id: postgresql-sql.cl,v 1.17 2002/05/14 16:29:53 kevin Exp $
+;;;; $Id: postgresql-sql.cl,v 1.18 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
(in-package :cl-user)
(defpackage :clsql-postgresql
- (:use :common-lisp :clsql-sys :postgresql :clsql-uffi)
+ (:use :common-lisp :clsql-base-sys :postgresql :clsql-uffi)
(:export #:postgresql-database)
(:documentation "This is the CLSQL interface to PostgreSQL."))
(lo-create (database-conn-ptr database)
(logior postgresql::+INV_WRITE+ postgresql::+INV_READ+)))
+
+#+mb-original
(defmethod database-write-large-object (object-id (data string) (database postgresql-database))
(let ((ptr (database-conn-ptr database))
(length (length data))
)))
result))
+(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))
+ (database-execute-command "begin" 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))
+ (database-execute-command (if result "commit" "rollback") database)))
+ result))
+
;; (MB) the begin/commit/rollback stuff will be removed when with-transaction wil be implemented
+;; (KMR) Can't use with-transaction since that function is in high-level code
(defmethod database-read-large-object (object-id (database postgresql-database))
(let ((ptr (database-conn-ptr database))
(buffer nil)
(defmethod database-delete-large-object (object-id (database postgresql-database))
(lo-unlink (database-conn-ptr database) object-id))
-(when (clsql-sys:database-type-library-loaded :postgresql)
- (clsql-sys:initialize-database-type :database-type :postgresql)
+(when (clsql-base-sys:database-type-library-loaded :postgresql)
+ (clsql-base-sys:initialize-database-type :database-type :postgresql)
(pushnew :postgresql cl:*features*))
--- /dev/null
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name: package.cl
+;;;; Purpose: Package definition for CLSQL (high-level) interface
+;;;; Programmers: Kevin M. Rosenberg based on
+;;;; Original code by Pierre R. Mai
+;;;; Date Started: Feb 2002
+;;;;
+;;;; $Id: package.cl,v 1.16 2002/05/27 17:19:45 kevin Exp $
+;;;;
+;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
+;;;; and Copyright (c) 1999-2001 by Pierre R. Mai
+;;;;
+;;;; CLSQL users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the Lisp Lesser GNU Public License
+;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
+;;;; *************************************************************************
+
+(declaim (optimize (debug 3) (speed 3) (safety 1) (compilation-speed 0)))
+(in-package :cl-user)
+
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defpackage :clsql-sys
+ (:nicknames :clsql)
+ (:use :common-lisp :clsql-base-sys)
+ (:import-from
+ :clsql-base
+ .
+ #1=(
+ #:clsql-condition
+ #:clsql-error
+ #:clsql-simple-error
+ #:clsql-warning
+ #:clsql-simple-warning
+ #:clsql-invalid-spec-error
+ #:clsql-invalid-spec-error-connection-spec
+ #:clsql-invalid-spec-error-database-type
+ #:clsql-invalid-spec-error-template
+ #:clsql-connect-error
+ #:clsql-connect-error-database-type
+ #:clsql-connect-error-connection-spec
+ #:clsql-connect-error-errno
+ #:clsql-connect-error-error
+ #:clsql-sql-error
+ #:clsql-sql-error-database
+ #:clsql-sql-error-expression
+ #:clsql-sql-error-errno
+ #:clsql-sql-error-error
+ #:clsql-database-warning
+ #:clsql-database-warning-database
+ #:clsql-database-warning-message
+ #:clsql-exists-condition
+ #:clsql-exists-condition-new-db
+ #:clsql-exists-condition-old-db
+ #:clsql-exists-warning
+ #:clsql-exists-error
+ #:clsql-closed-error
+ #:clsql-closed-error-database
+
+ #:*loaded-database-types*
+ #:reload-database-types
+ #:*default-database-type*
+ #:*initialized-database-types*
+ #:initialize-database-type
+
+ #:database
+ #:database-name
+ #:closed-database
+ #:database-name-from-spec))
+ (:export
+ ;; sql.cl
+ #:*connect-if-exists*
+ #:connected-databases
+ #:*default-database*
+ #:find-database
+ #:connect
+ #:disconnect
+ #:query
+ #:execute-command
+ #:map-query
+ #:do-query
+
+ ;; functional.cl
+ #:insert-records
+ #:delete-records
+ #:update-records
+ #:with-database
+
+ ;; For High-level UncommonSQL compatibility
+ #:sql-ident
+ #:list-tables
+ #:list-attributes
+ #:attribute-type
+ #:create-sequence
+ #:drop-sequence
+ #:sequence-next
+
+ ;; Pooled connections
+ #:disconnect-pooled
+ #:find-or-create-connection-pool
+
+ ;; Transactions
+ #:with-transaction
+ #:commit-transaction
+ #:rollback-transaction
+ #:add-transaction-commit-hook
+ #:add-transaction-rollback-hook
+
+ ;; Large objects (Marc B)
+ #:create-large-object
+ #:write-large-object
+ #:read-large-object
+ #:delete-large-object
+
+ .
+ #1#
+ )
+ (:documentation "This is the INTERNAL SQL-Interface package of CLSQL."))
+
+ ) ;eval-when
+
+(defpackage #:clsql-user
+ (:use #:common-lisp #:clsql)
+ (:documentation "This is the user package for experimenting with CLSQL."))
;;;; Programmers: Marc Battyani
;;;; Date Started: Apr 2002
;;;;
-;;;; $Id: transactions.cl,v 1.4 2002/05/13 16:55:07 marc.battyani Exp $
+;;;; $Id: transactions.cl,v 1.5 2002/05/27 17:19:30 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(status :initform nil :accessor status))) ;can be nil :rolled-back or :commited
(defmethod database-start-transaction ((database closed-database))
- (signal-closed-database-error database))
+ (error 'clsql-closed-database-error database))
(defmethod database-start-transaction (database)
(unless (transaction database)
(execute-command "BEGIN" :database database))))
(defmethod database-end-transaction ((database closed-database))
- (signal-closed-database-error database))
+ (error 'clsql-closed-database-error database))
(defmethod database-end-transaction (database)
(if (> (transaction-level database) 0)
(when (and (transaction database)(not (status (transaction database))))
(setf (status (transaction database)) :commited)))
-(defun add-transaction-commit-hook (database abort-hook)
+(defun add-transaction-commit-hook (database commit-hook)
(when (transaction database)
- (push abort-hook (abort-hooks (transaction database)))))
+ (push commit-hook (commit-hooks (transaction database)))))
(defun add-transaction-rollback-hook (database rollback-hook)
(when (transaction database)
;;;; Programmers: Kevin M. Rosenberg and onShore Development Inc
;;;; Date Started: Mar 2002
;;;;
-;;;; $Id: usql.cl,v 1.8 2002/05/19 16:26:06 kevin Exp $
+;;;; $Id: usql.cl,v 1.9 2002/05/27 17:19:31 kevin Exp $
;;;;
;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;; and onShore Development Inc
to *default-database*."
(database-attribute-type attribute table database))
-(defun add-attribute (table attribute &key (database *default-database*))
- "Add the ATTRIBUTE to TABLE. The ATTRIBUTE sepcification must
-include a type argument. The optional keyword argument :database
-specifies the database to operation on, defaulting to
-*default-database*."
- (database-add-attribute table attribute database))
-
-(defun rename-attribute (table oldatt newname
- &key (database *default-database*))
- (error "(rename-attribute ~a ~a ~a ~a) is not implemented" table oldatt newname database))
-
-
-(defclass %sql-expression ()
- ())
-
-;; For SQL Identifiers of generic type
-(defclass sql-ident (%sql-expression)
- ((name
- :initarg :name
- :initform "NULL"))
- (:documentation "An SQL identifer."))
-
-(defmethod make-load-form ((sql sql-ident) &optional environment)
- (declare (ignore environment))
- (with-slots (name)
- sql
- `(make-instance 'sql-ident :name ',name)))
-
-
(defun create-sequence (name &key (database *default-database*))
(database-create-sequence name database))
(defun sequence-next (name &key (database *default-database*))
(database-sequence-next name database))
-(defclass sql-value-exp (%sql-expression)
- ((modifier
- :initarg :modifier
- :initform nil)
- (components
- :initarg :components
- :initform nil))
- (:documentation
- "An SQL value expression.")
- )
-
-(defclass sql-typecast-exp (sql-value-exp)
- ()
- (:documentation
- "An SQL typecast expression.")
- )
-(defvar +null-string+ "NULL")
-
-(defvar *sql-stream* nil
- "stream which accumulates SQL output")
-
-(defmethod output-sql ((expr %sql-expression) &optional
- (database *default-database*))
- (declare (ignore database))
- (write-string +null-string+ *sql-stream*))
-
-(defmethod sql-output ((expr t))
- (declare (ignore expr))
- "")
-
-(defmethod print-object ((self %sql-expression) stream)
- (print-unreadable-object
- (self stream :type t)
- (write-string (sql-output self) stream)))
-
-
-;; Methods for translating high-level table classes to low-level functions
-
-(defmethod database-list-attributes ((table sql-ident) database)
- (database-list-attributes (string-downcase
- (symbol-name (slot-value table 'name)))
- database)
- )
-(defmethod database-attribute-type (attribute (table sql-ident) database)
- (database-attribute-type attribute (string-downcase
- (symbol-name (slot-value table 'name)))
- database))