r9450: 22 May 2004 Kevin Rosenberg
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 23 May 2004 10:51:02 +0000 (10:51 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 23 May 2004 10:51:02 +0000 (10:51 +0000)
        * Version 2.10.21 released
        * sql/sequences.lisp: Move generic sequence functions here from db-sqlite,
        db-odbc, and db-aodbc.

28 files changed:
ChangeLog
clsql-odbc.asd
clsql.asd
db-aodbc/aodbc-sql.lisp
db-mysql/mysql-objects.lisp
db-odbc/Makefile
db-odbc/odbc-api.lisp
db-odbc/odbc-constants.lisp
db-odbc/odbc-dbi.lisp
db-odbc/odbc-ff-interface.lisp
db-odbc/odbc-loader.lisp
db-odbc/odbc-package.lisp
db-odbc/odbc-sql.lisp
db-sqlite/Makefile
db-sqlite/sqlite-sql.lisp
debian/changelog
sql/Makefile
sql/db-interface.lisp
sql/generic-odbc.lisp
sql/generic-postgresql.lisp
sql/generics.lisp
sql/package.lisp
sql/sequences.lisp [new file with mode: 0644]
tests/Makefile
tests/benchmarks.lisp
tests/test-basic.lisp
tests/test-time.lisp
tests/utils.lisp

index 09f04898e992d243d4eb5f8904041da82a23436a..361840bad3391191c78b029ae37e0b13305875b6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 22 May 2004 Kevin Rosenberg
        * Version 2.10.21 released
 22 May 2004 Kevin Rosenberg
        * Version 2.10.21 released
+       * sql/sequences.lisp: Move generic sequence functions here from db-sqlite,
+       db-odbc, and db-aodbc.
        * sql/*.lisp: Add db-type parameter to generic functions READ-SQL-VALUE,
        DATABASE-GET-TYPE-SPECIFIER, and OUTPUT-SQL-VALUE-AS-TYPE. Update methods to use these.
        * sql/generic-postgresql.lisp, sql/generic-odbc.lisp: New files
        * sql/*.lisp: Add db-type parameter to generic functions READ-SQL-VALUE,
        DATABASE-GET-TYPE-SPECIFIER, and OUTPUT-SQL-VALUE-AS-TYPE. Update methods to use these.
        * sql/generic-postgresql.lisp, sql/generic-odbc.lisp: New files
index 82b3fbd7fd5482cbc12de9c39868dd9abcc56512..ca2ec199cccf1ed6359c27e74e1dc778f96d6be5 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:   Kevin M. Rosenberg
 ;;;; Created:  April 2004
 ;;;;
 ;;;; Author:   Kevin M. Rosenberg
 ;;;; Created:  April 2004
 ;;;;
-;;;; $Id: clsql-odbc.asd 8850 2004-04-07 16:07:46Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 200d42 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 200d42 by Kevin M. Rosenberg
 ;;;;
index bc128ace30178ac20b640245c31da3fb61eb2a84..c7b3d9297a4e72aa46b06152c7560fcef7a83809 100644 (file)
--- a/clsql.asd
+++ b/clsql.asd
@@ -69,7 +69,8 @@ oriented interface."
               (:module :generic
                        :pathname ""
                       :components ((:file "generic-postgresql")
               (:module :generic
                        :pathname ""
                       :components ((:file "generic-postgresql")
-                                   (:file "generic-odbc"))
+                                   (:file "generic-odbc")
+                                   (:file "sequences"))
                       :depends-on (:functional))))))
      
 
                       :depends-on (:functional))))))
      
 
index a43fb188dab9eac61c5271c95ad075ba9defdde8..8a6ee00b8f630da9d6304b922ebb879c021a1ac3 100644 (file)
 
 
 
 
 
 
-;;; Sequence functions
-
-(defun %sequence-name-to-table (sequence-name)
-  (concatenate 'string "_CLSQL_SEQ_" (sql-escape sequence-name)))
-
-(defun %table-name-to-sequence-name (table-name)
-  (and (>= (length table-name) 11)
-       (string-equal (subseq table-name 0 11) "_CLSQL_SEQ_")
-       (subseq table-name 11)))
-
-(defmethod database-create-sequence (sequence-name
-                                    (database aodbc-database))
-  (let ((table-name (%sequence-name-to-table sequence-name)))
-    (database-execute-command
-     (concatenate 'string "CREATE TABLE " table-name
-                 " (last_value int NOT NULL PRIMARY KEY, increment_by int, min_value int, is_called char(1))")
-     database)
-    (database-execute-command 
-     (concatenate 'string "INSERT INTO " table-name
-                 " VALUES (1,1,1,'f')")
-     database)))
-
-(defmethod database-drop-sequence (sequence-name
-                                  (database aodbc-database))
-  (database-execute-command
-   (concatenate 'string "DROP TABLE " (%sequence-name-to-table sequence-name)) 
-   database))
-
-(defmethod database-list-sequences ((database aodbc-database)
-                                    &key (owner nil))
-  (declare (ignore owner))
-  (warn "database-list-sequences not implemented for AODBC.")
-  nil)
-
-
-(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))
-  (database-execute-command
-   (format nil "UPDATE ~A SET last_value=~A,is_called='t'" 
-          (%sequence-name-to-table sequence-name)
-           position)
-   database)
-  position)
-
-(defmethod database-sequence-next (sequence-name (database aodbc-database))
-  (without-interrupts
-   (let* ((table-name (%sequence-name-to-table sequence-name))
-         (tuple
-          (car (database-query 
-                (concatenate 'string "SELECT last_value,is_called FROM " 
-                             table-name)
-                database :auto nil))))
-     (cond
-       ((char-equal (schar (second tuple) 0) #\f)
-       (database-execute-command
-        (format nil "UPDATE ~A SET is_called='t'" table-name)
-        database)
-       (car tuple))
-       (t
-       (let ((new-pos (1+ (car tuple))))
-        (database-execute-command
-         (format nil "UPDATE ~A SET last_value=~D" table-name new-pos)
-         database)
-        new-pos))))))
-            
-(defmethod database-sequence-last (sequence-name (database aodbc-database))
-  (without-interrupts
-   (caar (database-query 
-         (concatenate 'string "SELECT last_value FROM " 
-                      (%sequence-name-to-table sequence-name))
-         database :auto nil))))
-
 (defmethod database-create (connection-spec (type (eql :aodbc)))
   (warn "Not implemented."))
 
 (defmethod database-create (connection-spec (type (eql :aodbc)))
   (warn "Not implemented."))
 
index bbe52324fe2d0466849e51f49c741f5c02dac7ca..a118f479f2a12949a516cbe4f2ec9cbb0f6e535a 100644 (file)
@@ -6,7 +6,7 @@
 ;;;; Purpose:  CLSQL Object layer for MySQL
 ;;;; Created:  May 2004
 ;;;;
 ;;;; Purpose:  CLSQL Object layer for MySQL
 ;;;; Created:  May 2004
 ;;;;
-;;;; $Id: mysql-sql.lisp 9403 2004-05-19 23:46:45Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; CLSQL users are granted the rights to distribute and use this software
 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
 ;;;;
 ;;;; CLSQL users are granted the rights to distribute and use this software
 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
index 2b79dcbc9b434578e5060465dfe2b58ed63865a8..1003d8a68eaeea24bf1950a024ec83c5123e3e03 100644 (file)
@@ -5,7 +5,7 @@
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
-#  CVS Id:   $Id: Makefile 8153 2003-11-11 15:28:36Z kevin $
+#  CVS Id:   $Id$
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
index 4706c15c3d88aedf481e2c09dfe9855dffb2c505..b17af024651a85554ea5d8ce8754fb7d83d7e4c0 100644 (file)
@@ -6,7 +6,7 @@
 ;;;; Purpose:  Low-level ODBC API using UFFI
 ;;;; Authors:  Kevin M. Rosenberg and Paul Meurer
 ;;;;
 ;;;; Purpose:  Low-level ODBC API using UFFI
 ;;;; Authors:  Kevin M. Rosenberg and Paul Meurer
 ;;;;
-;;;; $Id: odbc-package.lisp 7061 2003-09-07 06:34:45Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
index 5ca1f2ac860114cd66378a702bff6edffa38ebae..e967729e63559d6209b8e8ef20cb72b40cf56c6b 100644 (file)
@@ -6,7 +6,7 @@
 ;;;; Purpose:  Constants for UFFI interface to ODBC
 ;;;; Authors:  Kevin M. Rosenberg and Paul Meurer
 ;;;;
 ;;;; Purpose:  Constants for UFFI interface to ODBC
 ;;;; Authors:  Kevin M. Rosenberg and Paul Meurer
 ;;;;
-;;;; $Id: odbc-package.lisp 7061 2003-09-07 06:34:45Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
index eee8ad62c317c2ce80f474a5c095574710593606..634a43e2601f101cc9b19e51d6aea0be108925a5 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:  Kevin M. Rosenberg
 ;;;; Create:  April 2004
 ;;;;
 ;;;; Author:  Kevin M. Rosenberg
 ;;;; Create:  April 2004
 ;;;;
-;;;; $Id: odbc-sql.lisp 8983 2004-04-12 21:16:48Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
index 4fbb8356dc6884378e460ba4e889845e29892a61..96c9c5187c411a11c63663b3734c567bf3c51521 100644 (file)
@@ -6,7 +6,7 @@
 ;;;; Purpose:  Function definitions for UFFI interface to ODBC
 ;;;; Author:   Kevin M. Rosenberg
 ;;;;
 ;;;; Purpose:  Function definitions for UFFI interface to ODBC
 ;;;; Author:   Kevin M. Rosenberg
 ;;;;
-;;;; $Id: odbc-package.lisp 7061 2003-09-07 06:34:45Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
index 52dc8f7c36936a37d32e45ed62ebbc1376f93e27..eb045477d1da0cfe97b10ebbe69f1a932a14d3ea 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmers:   Kevin M. Rosenberg
 ;;;; Date Started:  April 2004
 ;;;;
 ;;;; Programmers:   Kevin M. Rosenberg
 ;;;; Date Started:  April 2004
 ;;;;
-;;;; $Id: odbc-loader.lisp 8270 2003-11-25 06:37:14Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;;
index 583d9a76dbc5d98fec24f2f9aa7f7ee900603fca..71cd96d7efc99058ad7ced7e2504e14bf37839d8 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:   Kevin M. Rosenberg
 ;;;; Created:  April 2004
 ;;;;
 ;;;; Author:   Kevin M. Rosenberg
 ;;;; Created:  April 2004
 ;;;;
-;;;; $Id: odbc-package.lisp 7061 2003-09-07 06:34:45Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
 ;;;;
index 862c99188490b1f597f5fd1c31a23783c6e6165c..e1ad0c234d03333177ae3c4798777880076ef1ef 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Feb 2002
 ;;;;
-;;;; $Id: odbc-sql.lisp 8983 2004-04-12 21:16:48Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
   
 
 
   
 
 
-
-;;; Sequence functions
-
-(defun %sequence-name-to-table (sequence-name)
-  (concatenate 'string "_CLSQL_SEQ_" (sql-escape sequence-name)))
-
-(defun %table-name-to-sequence-name (table-name)
-  (and (>= (length table-name) 11)
-       (string-equal (subseq table-name 0 11) "_CLSQL_SEQ_")
-       (subseq table-name 11)))
-
-(defmethod database-create-sequence (sequence-name
-                                    (database odbc-database))
-  (let ((table-name (%sequence-name-to-table sequence-name)))
-    (database-execute-command
-     (concatenate 'string "CREATE TABLE " table-name
-                 " (last_value int NOT NULL PRIMARY KEY, increment_by int, min_value int, is_called char(1))")
-     database)
-    (database-execute-command 
-     (concatenate 'string "INSERT INTO " table-name
-                 " VALUES (1,1,1,'f')")
-     database)))
-
-(defmethod database-drop-sequence (sequence-name
-                                  (database odbc-database))
-  (database-execute-command
-   (concatenate 'string "DROP TABLE " (%sequence-name-to-table sequence-name)) 
-   database))
-
-(defmethod database-list-sequences ((database odbc-database)
-                                    &key (owner nil))
-  (declare (ignore owner))
-  ;; FIXME: Underlying database backend stuff should come from that backend
-  
-  (case (database-odbc-db-type database)
-    (:mysql
-     (mapcan #'(lambda (s)
-                (let ((sn (%table-name-to-sequence-name (car s))))
-                  (and sn (list sn))))
-            (database-query "SHOW TABLES" database nil nil)))
-    ((:postgresql :postgresql-socket)
-     (mapcar #'(lambda (s) (%table-name-to-sequence-name (car s)))
-           (database-query "SELECT RELNAME FROM pg_class WHERE RELNAME LIKE '%clsql_seq%'" 
-                           database nil nil)))))
-
-
-(defmethod database-set-sequence-position (sequence-name
-                                           (position integer)
-                                           (database odbc-database))
-  (database-execute-command
-   (format nil "UPDATE ~A SET last_value=~A,is_called='t'" 
-          (%sequence-name-to-table sequence-name)
-           position)
-   database)
-  position)
-
-(defmethod database-sequence-next (sequence-name (database odbc-database))
-  (without-interrupts
-   (let* ((table-name (%sequence-name-to-table sequence-name))
-         (tuple
-          (car (database-query 
-                (concatenate 'string "SELECT last_value,is_called FROM " 
-                             table-name)
-                database :auto nil))))
-     (cond
-       ((char-equal (schar (second tuple) 0) #\f)
-       (database-execute-command
-        (format nil "UPDATE ~A SET is_called='t'" table-name)
-        database)
-       (car tuple))
-       (t
-       (let ((new-pos (1+ (car tuple))))
-        (database-execute-command
-         (format nil "UPDATE ~A SET last_value=~D" table-name new-pos)
-         database)
-        new-pos))))))
-            
-(defmethod database-sequence-last (sequence-name (database odbc-database))
-  (without-interrupts
-   (caar (database-query 
-         (concatenate 'string "SELECT last_value FROM " 
-                      (%sequence-name-to-table sequence-name))
-         database :auto nil))))
-
 (defmethod database-create (connection-spec (type (eql :odbc)))
   (declare (ignore connection-spec))
   (warn "Not implemented."))
 (defmethod database-create (connection-spec (type (eql :odbc)))
   (declare (ignore connection-spec))
   (warn "Not implemented."))
index 2b79dcbc9b434578e5060465dfe2b58ed63865a8..1003d8a68eaeea24bf1950a024ec83c5123e3e03 100644 (file)
@@ -5,7 +5,7 @@
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
-#  CVS Id:   $Id: Makefile 8153 2003-11-11 15:28:36Z kevin $
+#  CVS Id:   $Id$
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
index d6352e965dbcddf23b9e877574d1655c5bb08121..3c6d31ea7e70d46e44e7e912c98afdfa706d29eb 100644 (file)
 
 ;;; Object listing
 
 
 ;;; Object listing
 
-(defmethod database-list-tables ((database sqlite-database) &key owner)
+(defmethod database-list-tables-and-sequences ((database sqlite-database) &key owner)
   (declare (ignore owner))
   ;; Query is copied from .table command of sqlite comamnd line utility.
   (declare (ignore owner))
   ;; Query is copied from .table command of sqlite comamnd line utility.
+  (mapcar #'car (database-query
+                "SELECT name FROM sqlite_master WHERE type='table' UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name"
+                database nil nil)))
+
+(defmethod database-list-tables ((database sqlite-database) &key owner)
   (remove-if #'(lambda (s)
                  (and (>= (length s) 11)
                       (string-equal (subseq s 0 11) "_CLSQL_SEQ_")))
   (remove-if #'(lambda (s)
                  (and (>= (length s) 11)
                       (string-equal (subseq s 0 11) "_CLSQL_SEQ_")))
-             (mapcar #'car (database-query
-                            "SELECT name FROM sqlite_master WHERE type='table' UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name"
-                            database nil nil))))
+            (database-list-tables-and-sequences database :owner owner)))
 
 (defmethod database-list-views ((database sqlite-database)
                                 &key (owner nil))
 
 (defmethod database-list-views ((database sqlite-database)
                                 &key (owner nil))
                  (if (string-equal (fourth field-info) "0")
                      1 0)))))
 
                  (if (string-equal (fourth field-info) "0")
                      1 0)))))
 
-(defun %sequence-name-to-table-name (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_")
-       (subseq table-name 11)))
-
-
-(defmethod database-create-sequence (sequence-name
-                                    (database sqlite-database))
-  (let ((table-name (%sequence-name-to-table-name sequence-name)))
-    (database-execute-command
-     (concatenate 'string "CREATE TABLE " table-name
-                 " (last_value integer PRIMARY KEY, increment_by integer, min_value integer, is_called char(1))")
-     database)
-    (database-execute-command 
-     (concatenate 'string "INSERT INTO " table-name
-                 " VALUES (1,1,1,'f')")
-     database)))
-
-(defmethod database-drop-sequence (sequence-name
-                                  (database sqlite-database))
-  (database-execute-command
-   (concatenate 'string "DROP TABLE " (%sequence-name-to-table-name sequence-name)) 
-   database))
-
-(defmethod database-list-sequences ((database sqlite-database)
-                                    &key (owner nil))
-  (declare (ignore owner))
-  (mapcan #'(lambda (s)
-              (let ((sn (%table-name-to-sequence-name (car s))))
-                (and sn (list sn))))
-          (database-query
-           "SELECT name FROM sqlite_master WHERE type='table' UNION ALL SELECT name FROM sqlite_temp_master WHERE type='table' ORDER BY name"
-           database nil nil)))
-
-(defmethod database-sequence-next (sequence-name (database sqlite-database))
-  (without-interrupts
-   (let* ((table-name (%sequence-name-to-table-name sequence-name))
-         (tuple
-          (car (database-query 
-                (concatenate 'string "SELECT last_value,is_called FROM " 
-                             table-name)
-                database :auto nil))))
-     (cond
-       ((char-equal (schar (second tuple) 0) #\f)
-       (database-execute-command
-        (format nil "UPDATE ~A SET is_called='t'" table-name)
-        database)
-       (car tuple))
-       (t
-       (let ((new-pos (1+ (car tuple))))
-        (database-execute-command
-         (format nil "UPDATE ~A SET last_value=~D" table-name new-pos)
-         database)
-        new-pos))))))
-            
-(defmethod database-sequence-last (sequence-name (database sqlite-database))
-  (without-interrupts
-   (caar (database-query 
-         (concatenate 'string "SELECT last_value FROM " 
-                      (%sequence-name-to-table-name sequence-name))
-           database :auto nil))))
-
-(defmethod database-set-sequence-position (sequence-name
-                                           (position integer)
-                                           (database sqlite-database))
-  (database-execute-command
-   (format nil "UPDATE ~A SET last_value=~A,is_called='t'" 
-          (%sequence-name-to-table-name sequence-name)
-           position)
-   database)
-  position)
-
 (defmethod database-create (connection-spec (type (eql :sqlite)))
   (declare (ignore connection-spec))
   ;; databases are created automatically by SQLite
 (defmethod database-create (connection-spec (type (eql :sqlite)))
   (declare (ignore connection-spec))
   ;; databases are created automatically by SQLite
index cc1424b4fea68c91a9b5acb1c93d9318b0edc9f0..0bf4e1278dcb04035d56c1932a7936e946d0fd07 100644 (file)
@@ -1,3 +1,9 @@
+cl-sql (2.10.21-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Sun, 23 May 2004 04:50:44 -0600
+
 cl-sql (2.10.20-1) unstable; urgency=low
 
   * New upstream
 cl-sql (2.10.20-1) unstable; urgency=low
 
   * New upstream
index 2b79dcbc9b434578e5060465dfe2b58ed63865a8..1003d8a68eaeea24bf1950a024ec83c5123e3e03 100644 (file)
@@ -5,7 +5,7 @@
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
-#  CVS Id:   $Id: Makefile 8153 2003-11-11 15:28:36Z kevin $
+#  CVS Id:   $Id$
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
index 3c2f7468326d3adc9ce2c9cd67699ca1864f544d..939af1fa68ff89356e7f35bc4d8a56ca258348cf 100644 (file)
@@ -174,16 +174,21 @@ if unable to destory."))
 
 (defgeneric database-get-type-specifier (type args database db-underlying-type)
   (:documentation "Return the type SQL type specifier as a string, for
 
 (defgeneric database-get-type-specifier (type args database db-underlying-type)
   (:documentation "Return the type SQL type specifier as a string, for
-the given lisp type and parameters.")
-  (:method (type args database db-underlying-type)
-          (declare (ignore type args db-type))
-          (signal-no-database-error database)))
+the given lisp type and parameters."))
 
 (defgeneric database-list-tables (database &key owner)
   (:documentation "List all tables in the given database")
   (:method ((database t) &key owner)
           (declare (ignore owner))
           (signal-no-database-error database)))
 
 (defgeneric database-list-tables (database &key owner)
   (:documentation "List all tables in the given database")
   (:method ((database t) &key owner)
           (declare (ignore owner))
           (signal-no-database-error database)))
+
+(defgeneric database-list-tables-and-sequences (database &key owner)
+  (:documentation "List all tables in the given database, may include seqeneces")
+  (:method ((database t) &key owner)
+          (declare (ignore owner))
+          (signal-no-database-error database))
+  (:method ((database database) &key owner)
+          (database-list-tables database :owner owner)))
  
 (defgeneric database-list-views (database &key owner)
   (:documentation "List all views in the DATABASE.")
  
 (defgeneric database-list-views (database &key owner)
   (:documentation "List all views in the DATABASE.")
index 8601ed624fe019a9a26a7bf243fbb26b7a22e49c..b83e8cacd854f9f370a238a8f3bf4fbd67f53a59 100644 (file)
@@ -1,7 +1,7 @@
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
 ;;;;
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
 ;;;;
-;;;; $Id$
+;;;; $Id$
 ;;;;
 ;;;; Generic ODBC layer, used by db-odbc and db-aodbc backends
 ;;;;
 ;;;;
 ;;;; Generic ODBC layer, used by db-odbc and db-aodbc backends
 ;;;;
index 45ad1fb5b58a0c1581af93f3b0e4b2ed42b02356..6716d14eabac8673c7dabebbc0135d81c03eac6d 100644 (file)
@@ -1,7 +1,7 @@
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
 ;;;;
 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
 ;;;; *************************************************************************
 ;;;;
-;;;; $Id$
+;;;; $Id$
 ;;;;
 ;;;; Generic postgresql layer, used by db-postgresql and db-postgresql-socket
 ;;;;
 ;;;;
 ;;;; Generic postgresql layer, used by db-postgresql and db-postgresql-socket
 ;;;;
index 817547d884440e04feb981204a501e5749ef05f3..f4b28483051979d289987550b5452b4b36443c2d 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:   Kevin M. Rosenberg based on
 ;;;; Created:  Apr 2004
 ;;;;
 ;;;; Author:   Kevin M. Rosenberg based on
 ;;;; Created:  Apr 2004
 ;;;;
-;;;; $Id: db-interface.lisp 9123 2004-04-21 20:34:42Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;;
index 8b4475ec78dd05e1cc765b31f591e5525a333816..f196f5bd7ce46ec0d33683cffd834082ad033b22 100644 (file)
      #:database-dump-result-set
      #:database-store-next-row
      #:database-list-tables
      #:database-dump-result-set
      #:database-store-next-row
      #:database-list-tables
+     #:database-list-tables-and-sequences
      #:database-table-exists-p
      #:database-list-views
      #:database-view-exists-p
      #:database-table-exists-p
      #:database-list-views
      #:database-view-exists-p
diff --git a/sql/sequences.lisp b/sql/sequences.lisp
new file mode 100644 (file)
index 0000000..1e3ef9e
--- /dev/null
@@ -0,0 +1,93 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;;
+;;;; $Id:$
+;;;;
+;;;; Generic sequence implementation. Backends should use native sequences if
+;;;; are available.
+;;;;
+;;;; This file is part of CLSQL.
+;;;;
+;;;; 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.
+;;;; *************************************************************************
+
+(in-package #:clsql-sys)
+
+(defclass generic-database (database)
+  ()
+  (:documentation "Encapsulate same behavior across backends."))
+
+
+;;; Sequence functions
+
+(defun %sequence-name-to-table (sequence-name database)
+  (concatenate 'string
+              (convert-to-db-default-case "_CLSQL_SEQ_" database)
+              (sql-escape sequence-name)))
+
+(defun %table-name-to-sequence-name (table-name database)
+  (and (>= (length table-name) 11)
+       (string-equal (subseq table-name 0 11)
+                    (convert-to-db-default-case "_CLSQL_SEQ_" database))
+       (subseq table-name 11)))
+
+(defmethod database-create-sequence (sequence-name database)
+  (let ((table-name (%sequence-name-to-table sequence-name database)))
+    (database-execute-command
+     (concatenate 'string "CREATE TABLE " table-name
+                 " (last_value int NOT NULL PRIMARY KEY, increment_by int, min_value int, is_called char(1))")
+     database)
+    (database-execute-command 
+     (concatenate 'string "INSERT INTO " table-name
+                 " VALUES (1,1,1,'f')")
+     database)))
+
+(defmethod database-drop-sequence (sequence-name database)
+  (database-execute-command
+   (concatenate 'string "DROP TABLE " (%sequence-name-to-table sequence-name database)) 
+   database))
+
+(defmethod database-list-sequences (database &key (owner nil))
+  (declare (ignore owner))
+  (mapcan #'(lambda (s)
+             (let ((sn (%table-name-to-sequence-name s database)))
+               (and sn (list sn))))
+         (database-list-tables-and-sequences database)))
+
+(defmethod database-set-sequence-position (sequence-name (position integer) database)
+  (database-execute-command
+   (format nil "UPDATE ~A SET last_value=~A,is_called='t'" 
+          (%sequence-name-to-table sequence-name database)
+           position)
+   database)
+  position)
+
+(defmethod database-sequence-next (sequence-name database)
+  (without-interrupts
+   (let* ((table-name (%sequence-name-to-table sequence-name database))
+         (tuple
+          (car (database-query 
+                (concatenate 'string "SELECT last_value,is_called FROM " 
+                             table-name)
+                database :auto nil))))
+     (cond
+       ((char-equal (schar (second tuple) 0) #\f)
+       (database-execute-command
+        (format nil "UPDATE ~A SET is_called='t'" table-name)
+        database)
+       (car tuple))
+       (t
+       (let ((new-pos (1+ (car tuple))))
+        (database-execute-command
+         (format nil "UPDATE ~A SET last_value=~D" table-name new-pos)
+         database)
+        new-pos))))))
+            
+(defmethod database-sequence-last (sequence-name database)
+  (without-interrupts
+   (caar (database-query 
+         (concatenate 'string "SELECT last_value FROM " 
+                      (%sequence-name-to-table sequence-name database))
+         database :auto nil))))
index 2b79dcbc9b434578e5060465dfe2b58ed63865a8..1003d8a68eaeea24bf1950a024ec83c5123e3e03 100644 (file)
@@ -5,7 +5,7 @@
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
 #  Programer:    Kevin M. Rosenberg
 #  Date Started: Mar 2002
 #
-#  CVS Id:   $Id: Makefile 8153 2003-11-11 15:28:36Z kevin $
+#  CVS Id:   $Id$
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
 #
 # This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
 #
index ec281d4df860e77f1b49864b6e8b3ffc36abf853..66800eb530df19c37fb88fb5eb3a1fa4c6f82920 100644 (file)
@@ -3,7 +3,7 @@
 ;;;; File:    benchmarks.lisp
 ;;;; Authors: Kevin Rosenberg
 ;;;; Created: 03/05/2004
 ;;;; File:    benchmarks.lisp
 ;;;; Authors: Kevin Rosenberg
 ;;;; Created: 03/05/2004
-;;;; Updated: $Id: test-init.lisp 9212 2004-05-03 18:44:03Z kevin $
+;;;; Updated: $Id$
 ;;;;
 ;;;; Benchmark suite
 ;;;;
 ;;;;
 ;;;; Benchmark suite
 ;;;;
index 516eeb23bcd46ba2c2981ceaef919ad70f7f39f6..de3e719fb3e08ad7750d34945a8d9b458954a163 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:  Kevin M. Rosenberg
 ;;;; Created: Mar 2002
 ;;;;
 ;;;; Author:  Kevin M. Rosenberg
 ;;;; Created: Mar 2002
 ;;;;
-;;;; $Id: tests.lisp 8926 2004-04-10 21:12:52Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;;
index 32ab17182016de9a1f48f48d93afc0a18e794249..92cf022ac46bff5b45a9f3135fff5610c1e690d7 100644 (file)
@@ -1,5 +1,5 @@
 ;;; -*- Mode: Lisp -*-
 ;;; -*- Mode: Lisp -*-
-;;; $Id: test-time.lisp,v 1.10 2004/03/08 18:00:53 jesse Exp $
+;;; $Id$
 ;;;
 ;;; Copyright (c) 2000, 2001 onShore Development, Inc.
 ;;;
 ;;;
 ;;; Copyright (c) 2000, 2001 onShore Development, Inc.
 ;;;
index bacc9ff92d18af91254862a2ebbb771e2c645735..8e274d9e40686c6be6289d4685a76115ae503a14 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Author:  Kevin M. Rosenberg
 ;;;; Created: Mar 2002
 ;;;;
 ;;;; Author:  Kevin M. Rosenberg
 ;;;; Created: Mar 2002
 ;;;;
-;;;; $Id: tests.lisp 8926 2004-04-10 21:12:52Z kevin $
+;;;; $Id$
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;;
 ;;;;
 ;;;; This file, part of CLSQL, is Copyright (c) 2002-2004 by Kevin M. Rosenberg
 ;;;;