+12 Aug 2006 Kevin Rosenberg <kevin@rosenberg.net>
+ * Version 3.6.5
+ * sql/generic-postgresql.lisp: Add slot for has-table-pg_roles to
+ lazily cache if pg_roles tables exist. Selectively use SQL from
+ Joel's previous patch if pg_roles table exists. Should now work
+ with both postgresql 7.4 and 8.x.
+
12 Aug 2006 Kevin Rosenberg <kevin@rosenberg.net>
* Version 3.6.4
* clsql.asd: Add support for c:\etc\clsql-init.lisp as possible
+cl-sql (3.6.5-1) unstable; urgency=low
+
+ * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org> Sat, 12 Aug 2006 15:18:47 -0600
+
cl-sql (3.6.4-1) unstable; urgency=low
* New upstream
(in-package #:clsql-sys)
(defclass generic-postgresql-database (database)
- ()
+ ((has-table-pg_roles :type boolean :reader has-table-pg_roles :initform nil))
(:documentation "Encapsulate same behavior across postgresql and postgresql-socket backends."))
(format nil " AND (NOT (relowner=1))"))
(t "")))
+(defun has-table (name database)
+ (let ((name-retrieved
+ (caar (database-query
+ (format nil "SELECT relname FROM pg_class WHERE relname='~A'"
+ name)
+ database nil nil))))
+ (if (and (stringp name-retrieved) (plusp (length name-retrieved)))
+ t
+ nil)))
+
+(defmethod slot-unbound (class (obj generic-postgresql-database)
+ (slot (eql 'has-table-pg_roles)))
+ ;; Lazily cache slot value
+ (setf (slot-value obj 'has-table-pg_roles) (has-table "pg_roles" obj)))
+
(defun database-list-objects-of-type (database type owner)
(mapcar #'car
(database-query
(format nil
- "SELECT relname FROM pg_class WHERE (relkind = '~A')~A"
- #+nil
- (if (not (eq owner :all))
- ;; The below query fails on versions of postgresql
- ;; (such as 7.4) that lack the pg_roles table
+ (if (and (has-table-pg_roles database)
+ (not (eq owner :all)))
"
SELECT c.relname
FROM pg_catalog.pg_class c