From bc8ef1555755679a9ff03c4ea69cd4f2c02fc3c4 Mon Sep 17 00:00:00 2001 From: J Smith Date: Mon, 10 Sep 2012 16:36:27 -0400 Subject: [PATCH] Add _pgsql_schemas to grab the list of schemas for pg_dump. --- src/_pgsql_utils | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/_pgsql_utils b/src/_pgsql_utils index b60f852..84f680e 100644 --- a/src/_pgsql_utils +++ b/src/_pgsql_utils @@ -96,6 +96,23 @@ _pgsql_tables () { $( psql $_pgsql_params[@] -Aqt -c $_pgsql_table_sql $db 2>/dev/null ) } +_pgsql_schemas () { + local _pgsql_user _pgsql_port _pgsql_host _pgsql_params + _pgsql_get_identity + + local db + db=${line[1]:-${PGDATABASE:-$LOGNAME}} + + local _pgsql_schema_sql="select n.nspname \ + from pg_catalog.pg_namespace n \ + where n.nspname !~ '^pg_' \ + and n.nspname <> 'information_schema' \ + order by 1;" + + compadd "$@" - \ + $( psql $_pgsql_params[@] -Aqt -c $_pgsql_schema_sql $db 2>/dev/null ) +} + _pgsql_databases () { local _pgsql_user _pgsql_port _pgsql_host _pgsql_params _pgsql_get_identity @@ -171,7 +188,7 @@ _pg_dump () { {-f+,--file=}':output file:_files' \ {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \ {-i,--ignore-version}'[ignore version mismatch]' \ - {-n+,--schema=}':schema to dump:' \ + {-n+,--schema=}':schema to dump:_pgsql_schemas' \ {-o,--oids}'[dump objects identifiers for every table]' \ {-O,--no-owner}'[dont recreate as same owner]' \ {-R,--no-reconnect}'[dont output connect]' \