Project

General

Profile

« Previous | Next » 

Revision 10774

lib/sh/db.sh: pg_dump(): added create_schema= flag to remove CREATE SCHEMA statements (useful if the schema already exists)

View differences:

lib/sh/db.sh
312 312
}
313 313

  
314 314
pg_dump() # usage: [schema=...] [struct=1 | data=1] [compress=1] [owners=1] \
315
# pg_dump [opts...] >out
315
# [create_schema=] pg_dump [opts...] >out
316 316
{
317
	echo_func; kw_params struct data plain owners; local struct="${struct-1}"
317
	echo_func; kw_params struct data plain owners create_schema
318
	local struct="${struct-1}" create_schema="${create_schema-1}"
318 319
	
319 320
	# subset
320 321
	if test "$schema"; then set -- --schema="\"$schema\"" "$@"; fi
......
327 328
	if test "$data"    ; then set -- "$@" --data-only  ; fi
328 329
	if test ! "$owners"; then set -- "$@" --no-owner   ; fi
329 330
	
330
	pg_cmd "$@"
331
	(
332
		# filter output
333
		if test ! "$create_schema"; then
334
			fd=1 redirs= filter_fd sed 's/^CREATE SCHEMA/--&/'
335
		fi
336
		
337
		pg_cmd "$@"
338
	)
331 339
}
332 340

  
333 341
fi

Also available in: Unified diff