Revision 8796
Added by Aaron Marcuse-Kubitza over 11 years ago
local.run | ||
---|---|---|
9 | 9 |
|
10 | 10 |
export PATH="$bin_dir:$PATH" |
11 | 11 |
|
12 |
log_sql () { test "$verbosity" -ge 2; } |
|
13 |
|
|
14 |
alias mk_schema_esc="local schema_esc; mk_esc_name schema" |
|
15 |
alias mk_table_esc="local table_esc; mk_esc_name table" |
|
16 |
|
|
17 |
fi # load new aliases |
|
18 |
if self_being_included; then |
|
19 |
|
|
20 | 12 |
mysql () |
21 | 13 |
{ |
22 | 14 |
echo_func "$@" |
... | ... | |
45 | 37 |
echo_run env no_search_path=1 "$psql_cmd" --output /dev/fd/3 "$@" 3>&1 >&2 |
46 | 38 |
} |
47 | 39 |
|
48 |
pg_copy_to () |
|
49 |
{ |
|
50 |
echo_func "$@" |
|
51 |
: "${table:?}"; mk_table_esc |
|
52 |
: "${pg_copy_format=CSV HEADER}" |
|
53 |
psql <<<"COPY $table_esc TO STDOUT $pg_copy_format;" |
|
54 |
} |
|
55 |
|
|
56 |
pg_header () |
|
57 |
{ |
|
58 |
echo_func "$@" |
|
59 |
local pg_copy_format="CSV HEADER" |
|
60 |
pg_copy_to|echo_stdin |
|
61 |
} |
|
62 |
|
|
63 |
pg_export_table_no_header () |
|
64 |
{ |
|
65 |
echo_func "$@" |
|
66 |
local pg_copy_format="CSV" |
|
67 |
pg_copy_to |
|
68 |
} |
|
69 |
|
|
70 |
pg_export_table_to_dir_no_header () |
|
71 |
{ |
|
72 |
echo_func "$@" |
|
73 |
local table="$1"; shift; mk_table_esc |
|
74 |
local cols="$(pg_header "$table")" |
|
75 |
pg_export_table_no_header "$@" >"$exports_dir/$table.no_header.cols=$cols.csv" |
|
76 |
} |
|
77 |
|
|
78 | 40 |
fi |
Also available in: Unified diff
lib/runscripts/local.run: moved log_sql (), pg_* () to lib/util.sh because these do not depend on local external scripts in bin/