Author: sskracic
Date: 2004-11-22 18:10:35 +0100 (Mon, 22 Nov 2004)
New Revision: 118
Modified:
users/sskracic/bin/pgcompare.tcl
Log:
Added support for passing arguments to pg_dump,
which is internally invoked to collect database
metadata.
Modified: users/sskracic/bin/pgcompare.tcl
===================================================================
--- users/sskracic/bin/pgcompare.tcl 2004-11-19 18:53:29 UTC (rev 117)
+++ users/sskracic/bin/pgcompare.tcl 2004-11-22 17:10:35 UTC (rev 118)
@@ -22,6 +22,14 @@
-s shows identical objects only (implies -1 -2, ignores -12)
-d shows different objects only (implies -1 -2, ignores -12)
-h -? shows this help text
+ -p \"opts\" option to be passed to pg_dump which is internally called
+ by this utility. Options must be enclosed in quotes if
+ they contain more than one word, for example
+ -p \"-h pgserver.example.com -U dummy\". IMPORTANT:
+ -p option may be specified *twice*. If that's the case,
+ the first occurrence will be used to connect to db1,
+ and the second for db2. Useful when databases reside on
+ different hosts, or should be accessed by different users.
-- end of options
Multiple options can be specified, although this doesn't
@@ -32,6 +40,9 @@
set err [list]
set filter "*"
+set pgdump_opts(db1) ""
+set pgdump_opts(db2) ""
+set pcount 0
set options [list]
for {set optionc 0} {$optionc < [llength $argv]} {incr optionc} {
set arg [lindex $argv $optionc]
@@ -39,6 +50,20 @@
switch -exact -- $opt {
"-" { break }
"t" { set filter [lindex $argv [incr optionc]] ; lappend options $opt }
+ "p" {
+ set opts [lindex $argv [incr optionc]]
+ incr pcount
+ if {$pcount > 2} {
+ lappend err "-p option cannot be used more than twice"
+ } elseif {$pcount == 1} {
+ set pgdump_opts(db1) $opts
+ set pgdump_opts(db2) $opts
+ } else {
+ # This is the second occurrence. Apply the options
+ # for second db connection only.
+ set pgdump_opts(db2) $opts
+ }
+ }
"n" -
"1" -
"2" -
@@ -109,7 +134,7 @@
set dbname [set $dbindex]
puts "Obtaining schema for $dbname"
- set dbschema [exec pg_dump -s $dbname]
+ set dbschema [eval exec pg_dump -s $pgdump_opts($dbindex) $dbname]
foreach type [array names types -glob $filter] {
puts " Fetching definition for object type: $type"
|