Project

General

Profile

« Previous | Next » 

Revision 9649

lib/sh/db.sh: psql(): set $PG* connection env vars from our connection vars ($server, $user, etc.). use use_pg to import $database so it can be different from $database for MySQL

View differences:

lib/sh/db.sh
217 217

  
218 218
alias use_pg='declare prefix=pg_; import_vars; unset prefix'
219 219

  
220
fi # load new aliases
221
if self_being_included; then
222

  
220 223
psql() # usage: [stdin=copy_pstdin_file] psql <<<"cmds, e.g. \copy from pstdin"
221 224
{
222 225
	echo_func; kw_params stdin
223 226
	
227
	use_pg
228
	log+ -2
229
	local PGHOST="$server";       export PGHOST
230
	local PGUSER="$user";         export PGUSER
231
	local PGPASSWORD="$password"; export PGPASSWORD
232
	local PGDATABASE="$database"; export PGDATABASE
233
	log+ 2
234
	
224 235
	if can_log; then set -- --echo-all --echo-hidden "$@"; fi
225 236
	local redirs=("${redirs[@]}" '10<&0' "0<${stdin:-&20}" '13>&1')
226 237
		# not 11 (for 13) because it gives a "/dev/fd/11: Bad file descriptor"

Also available in: Unified diff