Index: openacs-4/packages/schema-browser/tcl/schema-browser-procs-postgresql.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/schema-browser/tcl/schema-browser-procs-postgresql.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/schema-browser/tcl/schema-browser-procs-postgresql.tcl 15 Sep 2001 00:32:45 -0000 1.1 +++ openacs-4/packages/schema-browser/tcl/schema-browser-procs-postgresql.tcl 3 Jul 2002 08:30:12 -0000 1.2 @@ -269,7 +269,7 @@ if { $arg_count > 1 } { append foreign_key_sql "FOREIGN KEY ($on_var_part) " } - append foreign_key_sql "REFERENCES $refer_table ($refer_var_part)" + append foreign_key_sql "REFERENCES $refer_table ($refer_var_part)" } default { if { ![string equal $action "NOACTION"] } { @@ -295,6 +295,27 @@ set complex_foreign_keys [lindex $foreign_keys 1] set html "
"
+
+    # get table comments
+    # JCD: pg_description changed from 7.1 to 7.2 so do the correct query... 
+    if { [string match {7.[01]*} [db_version]]} {
+        if { [db_0or1row sb_get_table_comment "
+            select d.description 
+              from pg_class c, pg_description d
+             where c.relname = lower(:table_name) 
+               and d.objoid = c.relfilenode"] } {
+            append html "\n--[join [split $description "\n"] "\n-- "]"
+        }
+    } else { 
+        if { [db_0or1row sb_get_table_comment "
+            select d.description 
+              from pg_class c, pg_description d
+             where c.relname = lower(:table_name) 
+               and d.objoid = c.oid and objsubid = 0"] } {
+                append html "\n--[join [split $description "\n"] "\n-- "]"
+        }
+    }
+                   
     append html "\nCREATE TABLE [string tolower $table_name] ("
 
     if { [db_0or1row sb_get_primary_key "
@@ -316,6 +337,13 @@
     # DRB: This changes some PG internal types into SQL92 standard types for readability's
     # sake.
 
+    # JCD: pg_description changed from 7.1 to 7.2 so do the correct query... 
+    if { [string match {7.[01]*} [db_version]]} {
+        set pg_description_join "left join pg_description d on (a.oid = d.objoid)"
+    } else { 
+        set pg_description_join "left join pg_description d on (c.oid = d.objoid and a.attnum = d.objsubid)"
+    }
+
     db_foreach schema_browser_index_get_user_table_data "
         select
             a.attname as column_name,
@@ -346,7 +374,7 @@
              join pg_attribute a on (c.oid = a.attrelid and a.attnum > 0)
              join pg_type t on (a.atttypid = t.oid)
              left join pg_attrdef ad on (a.attrelid = ad.adrelid and a.attnum = ad.adnum)
-             left join pg_description d on (a.oid = d.objoid)
+             $pg_description_join
         order by a.attnum" -column_set column_info_set {
 
         lappend column_list [ns_set copy $column_info_set]