Project

General

Profile

« Previous | Next » 

Revision 9084

lib/sh/db.sh: pg_export(): for simplicity, always use a SELECT statement as the source. take any source query in \$query without () instead of \$source with (). this will also help make pg_export uniform with MySQL.

View differences:

db.sh
70 70
pg_export()
71 71
{
72 72
	echo_func
73
	if test ! "$source"; then
74
		: "${table:?}"; mk_table_esc
75
		if test ! "$limit"; then local source="$table_esc"
76
		else local source="(SELECT * FROM $table_esc LIMIT $limit)"
77
		fi
78
	fi
73
	mk_table_esc
74
	local query="${query:-SELECT * FROM $table_esc ${limit:+LIMIT $limit }}"
79 75
	local pg_copy_format="${pg_copy_format-CSV HEADER}"
80 76
	
81
	psql "$@" <<<"COPY $source TO STDOUT $pg_copy_format;"
77
	psql "$@" <<<"COPY ($query) TO STDOUT $pg_copy_format;"
82 78
}
83 79

  
84 80
pg_header()

Also available in: Unified diff