@@ -61,8 +61,8 @@ global PgAcVar CurrentDB
61
61
foreach module {mainlib database tables queries visualqb forms views functions reports scripts users sequences schema help preferences} {
62
62
source [file join $PgAcVar(PGACCESS_HOME) lib $module .tcl]
63
63
}
64
- set PgAcVar(currentdb,host) localhost
65
- set PgAcVar(currentdb,pgport) 5432
64
+ set PgAcVar(currentdb,host) [default_pg_host]
65
+ set PgAcVar(currentdb,pgport) [default_pg_port]
66
66
set CurrentDB {}
67
67
set PgAcVar(tablist) [list Tables Queries Views Sequences Functions Reports Forms Scripts Users Schema]
68
68
set PgAcVar(activetab) {}
@@ -73,6 +73,19 @@ global PgAcVar CurrentDB
73
73
Preferences::load
74
74
}
75
75
76
+ proc default_pg_host {} {
77
+ return localhost
78
+ }
79
+
80
+ proc default_pg_port {} {
81
+ global env
82
+ if {[info exists env(PGPORT)]} {
83
+ return $env(PGPORT)
84
+ } else {
85
+ return 5432
86
+ }
87
+ }
88
+
76
89
proc {wpg_exec} {db cmd} {
77
90
global PgAcVar
78
91
set PgAcVar(pgsql,cmd) " never executed"
@@ -165,15 +178,20 @@ global PgAcVar CurrentDB
165
178
166
179
167
180
proc {main} {argc argv} {
168
- global PgAcVar CurrentDB tcl_platform
169
- load libpgtcl[info sharedlibextension]
181
+ global PgAcVar CurrentDB tcl_platform env
182
+ if {[info exists env(PGLIB)]} {
183
+ set libpgtclpath [file join $env(PGLIB) libpgtcl]
184
+ } else {
185
+ set libpgtclpath {libpgtcl}
186
+ }
187
+ load ${libpgtclpath} [info sharedlibextension]
170
188
catch {Mainlib::draw_tabs}
171
189
set PgAcVar(opendb,username) {}
172
190
set PgAcVar(opendb,password) {}
173
191
if {$argc >0} {
174
192
set PgAcVar(opendb,dbname) [lindex $argv 0]
175
- set PgAcVar(opendb,host) localhost
176
- set PgAcVar(opendb,pgport) 5432
193
+ set PgAcVar(opendb,host) [default_pg_host]
194
+ set PgAcVar(opendb,pgport) [default_pg_port]
177
195
Mainlib::open_database
178
196
} elseif {$PgAcVar(pref,autoload) && ($PgAcVar(pref,lastdb) !=" " )} {
179
197
set PgAcVar(opendb,dbname) $PgAcVar(pref,lastdb)
0 commit comments