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 -N -r1.3.2.1 -r1.3.2.2 --- openacs-4/packages/schema-browser/tcl/schema-browser-procs-postgresql.tcl 31 Jan 2003 14:55:28 -0000 1.3.2.1 +++ openacs-4/packages/schema-browser/tcl/schema-browser-procs-postgresql.tcl 31 Jan 2003 21:57:58 -0000 1.3.2.2 @@ -121,7 +121,7 @@ return $return_string } -ad_proc sb_get_indexes { table_name { html_anchors_p "f" } } { +ad_proc sb_get_indexes { table_name { html_anchors_p "f" } {pki {}}} { Create statements for indexes on table_name. } { @@ -142,6 +142,10 @@ join pg_am a on (index_class.relam = a.oid) order by index_name"] + if {![empty_string_p $pki]} { + lappend indexes [list {PRIMARY KEY} { UNIQUE} {} $pki] + } + foreach index $indexes { foreach {index_name uniqueness index_type indkey} $index {} @@ -166,8 +170,10 @@ foreach indid [split $indkey " "] { - append return_string $sep$cname($indid) - set sep ", " + if {[info exists cname($indid)]} { + append return_string $sep$cname($indid) + set sep ", " + } } append return_string ");" unset cname @@ -186,7 +192,7 @@ This code is *horribly* convoluted, mostly a result of the non-obvious way that the needed information is organized in the PG system catalogs. - +g Feel free to clean this up if you want! @author Don Baccus, though he hates to admit to writing such ugly code (dhogaza@pacifier.com)