Revision 8834
Added by Aaron Marcuse-Kubitza about 11 years ago
util.sh | ||
---|---|---|
166 | 166 |
echo_func "$@" |
167 | 167 |
if test -z "$source"; then |
168 | 168 |
: "${table:?}"; mk_table_esc |
169 |
if test -z "$limit"; then source="$table_esc" |
|
170 |
else source="(SELECT * FROM $table_esc LIMIT $limit)" |
|
169 |
if test -z "$limit"; then local source="$table_esc"
|
|
170 |
else local source="(SELECT * FROM $table_esc LIMIT $limit)"
|
|
171 | 171 |
fi |
172 | 172 |
fi |
173 |
: "${pg_copy_format=CSV HEADER}"
|
|
173 |
local pg_copy_format="${pg_copy_format-CSV HEADER}"
|
|
174 | 174 |
|
175 | 175 |
psql "$@" <<<"COPY $source TO STDOUT $pg_copy_format;" |
176 | 176 |
} |
Also available in: Unified diff
bugfix: *{.sh,run}: use `local` when setting default values for params to prevent these values from leaking into the calling context, where it may have unexpected effects (e.g. pg_copy_to would permanently set $source, which would then be used on the next invocation of pg_copy_to instead of regenerating $source from the next $table value). this involves using ${var-default} or ${var:-default} to return the value to the local statement instead of setting it directly with ${var=default} or ${var:=default}.