From 5921809d49e27ca6ed87c33a08d126c05da10488 Mon Sep 17 00:00:00 2001 From: J Smith Date: Mon, 10 Sep 2012 16:20:56 -0400 Subject: [PATCH 1/5] Add the -E/--encoding option for pg_dump. --- src/_pgsql_utils | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pgsql_utils b/src/_pgsql_utils index 1f95130..b60f852 100644 --- a/src/_pgsql_utils +++ b/src/_pgsql_utils @@ -165,6 +165,7 @@ _pg_dump () { {-b,--blobs}'[dump blobs as well]' \ {-c,--clean}'[include clean cmds in dump]' \ {-C,--create}'[include createdb cmds in dump]' \ + {-E+,--encoding=}':database encoding:_pgsql_encodings' \ {-d,--inserts}'[use INSERT not COPY]' \ {-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \ {-f+,--file=}':output file:_files' \ From bc8ef1555755679a9ff03c4ea69cd4f2c02fc3c4 Mon Sep 17 00:00:00 2001 From: J Smith Date: Mon, 10 Sep 2012 16:36:27 -0400 Subject: [PATCH 2/5] 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]' \ From d1e2e96be840f28fcf1516c9f61225f38ad75fc4 Mon Sep 17 00:00:00 2001 From: J Smith Date: Mon, 10 Sep 2012 16:37:11 -0400 Subject: [PATCH 3/5] Add the -N/--exclude-schema option for pg_dump. --- src/_pgsql_utils | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pgsql_utils b/src/_pgsql_utils index 84f680e..1705610 100644 --- a/src/_pgsql_utils +++ b/src/_pgsql_utils @@ -189,6 +189,7 @@ _pg_dump () { {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \ {-i,--ignore-version}'[ignore version mismatch]' \ {-n+,--schema=}':schema to dump:_pgsql_schemas' \ + {-N+,--exclude-schema=}':schema to NOT 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]' \ From 625eaa58ce693ddc5ddfebc2234817c17b6c3387 Mon Sep 17 00:00:00 2001 From: J Smith Date: Mon, 10 Sep 2012 16:38:07 -0400 Subject: [PATCH 4/5] Add the -T/--exclude-table option for pg_dump. --- src/_pgsql_utils | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pgsql_utils b/src/_pgsql_utils index 1705610..1095949 100644 --- a/src/_pgsql_utils +++ b/src/_pgsql_utils @@ -196,6 +196,7 @@ _pg_dump () { {-s,--schema-only}'[no data, only schema]' \ {-S+,--superuser=}':superuser name:_pgsql_users' \ {-t+,--table=}':table to dump:_pgsql_tables' \ + {-T+,--exclude-table=}':table to NOT dump:_pgsql_tables' \ {-v,--verbose}'[verbose mode]' \ {-V,--version}'[display client version]' \ {-x,--no-{acl,privileges}}'[dont dump ACLs]' \ From 1b2dabcd2eed1cfc729812721721457cf440d4df Mon Sep 17 00:00:00 2001 From: J Smith Date: Mon, 10 Sep 2012 16:40:33 -0400 Subject: [PATCH 5/5] Add a bunch of additional options for pg_dump. --- src/_pgsql_utils | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/_pgsql_utils b/src/_pgsql_utils index 1095949..b7bddd4 100644 --- a/src/_pgsql_utils +++ b/src/_pgsql_utils @@ -202,7 +202,16 @@ _pg_dump () { {-x,--no-{acl,privileges}}'[dont dump ACLs]' \ -X+':option:_values "option" use-set-session-authorization disable-triggers' \ {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \ - ':PostgreSQL database:_pgsql_databases' + ':PostgreSQL database:_pgsql_databases' \ + --section=':dump named section:_values "section" pre-data data post-data' \ + --disable-dollpgar-quoting'[disable dollar quoting, use SQL standard quoting]' \ + --disable-triggers'[disable triggers during data-only restore]' \ + --no-security-labels'[do not dump security label assignments]' \ + --no-tablespaces'[do not dump tablespace assignments]' \ + --no-unlogged-table-data'[do not dump unlogged table data]' \ + --quote-all-identifiers'[quote all identifiers, even if not key words]' \ + --serializable-deferrable'[wait until the dump can run without anomalies]' \ + --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]' } _createdb () {