add list-dependent-views
Thu May 7 12:01:18 PDT 2009 tomi.borbely@gmail.com
* add list-dependent-views
Warning: CRC errors found. These are probably harmless but should be repaired.
See 'darcs gzcrcs --help' for more information.
diff -rN -u old-cl-rdbms/ddl.lisp new-cl-rdbms/ddl.lisp
--- old-cl-rdbms/ddl.lisp 2014-07-31 22:52:27.000000000 -0700
+++ new-cl-rdbms/ddl.lisp 2014-07-31 22:52:27.000000000 -0700
@@ -196,9 +196,15 @@
(def (function e) list-views ()
(database-list-views *database*))
+(def (function e) list-dependent-views (table column)
+ (database-list-dependent-views table column *database*))
+
(defgeneric database-list-views (database)
(:documentation "Returns the list of view names present in the database."))
+(defgeneric database-list-dependent-views (table column database)
+ (:documentation "Returns the list of view names that depends on the specified column."))
+
;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Create, drop sequence
diff -rN -u old-cl-rdbms/postgresql/ddl.lisp new-cl-rdbms/postgresql/ddl.lisp
--- old-cl-rdbms/postgresql/ddl.lisp 2014-07-31 22:52:27.000000000 -0700
+++ new-cl-rdbms/postgresql/ddl.lisp 2014-07-31 22:52:27.000000000 -0700
@@ -44,3 +44,15 @@
(execute
(format nil "select indexname from pg_indexes where tablename = '~A'"
(string-downcase name)))))
+
+(defmethod database-list-dependent-views (table column (database postgresql))
+ (execute
+ (format nil "select distinct c3.relname
+ from pg_attribute a
+ JOIN pg_class c ON (a.attrelid=c.oid)
+ JOIN pg_depend d ON (d.refobjid=c.oid AND d.refobjsubid=a.attnum)
+ JOIN pg_class c2 ON (d.classid=c2.oid AND c2.relname='pg_rewrite')
+ JOIN pg_rewrite r ON (d.objid=r.oid)
+ JOIN pg_class c3 ON (r.ev_class=c3.oid)
+ where c.relname='~A' and a.attname='~A' AND c3.relkind='v'"
+ (string-downcase table) (string-downcase column))))