Skip to content
This repository
Browse code

Merge pull request #104 from dark-panda/pg-dump-enhancements

pg_dump enhancements
  • Loading branch information...
commit 9cca892132219e89299750d501d4693a98f5f5ee 2 parents b46f6e7 + 1b2dabc
Julien Nicoulaud authored September 11, 2012

Showing 1 changed file with 31 additions and 2 deletions. Show diff stats Hide diff stats

  1. 33  src/_pgsql_utils
33  src/_pgsql_utils
@@ -96,6 +96,23 @@ _pgsql_tables () {
96 96
         $( psql $_pgsql_params[@] -Aqt -c $_pgsql_table_sql $db 2>/dev/null )
97 97
 }
98 98
 
  99
+_pgsql_schemas () {
  100
+    local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
  101
+    _pgsql_get_identity
  102
+
  103
+    local db
  104
+    db=${line[1]:-${PGDATABASE:-$LOGNAME}}
  105
+
  106
+    local _pgsql_schema_sql="select n.nspname \
  107
+        from pg_catalog.pg_namespace n \
  108
+        where n.nspname !~ '^pg_' \
  109
+            and n.nspname <> 'information_schema' \
  110
+        order by 1;"
  111
+
  112
+    compadd "$@" - \
  113
+        $( psql $_pgsql_params[@] -Aqt -c $_pgsql_schema_sql $db 2>/dev/null )
  114
+}
  115
+
99 116
 _pgsql_databases () {
100 117
     local _pgsql_user _pgsql_port _pgsql_host _pgsql_params
101 118
     _pgsql_get_identity
@@ -165,24 +182,36 @@ _pg_dump () {
165 182
         {-b,--blobs}'[dump blobs as well]' \
166 183
         {-c,--clean}'[include clean cmds in dump]' \
167 184
         {-C,--create}'[include createdb cmds in dump]' \
  185
+        {-E+,--encoding=}':database encoding:_pgsql_encodings' \
168 186
         {-d,--inserts}'[use INSERT not COPY]' \
169 187
         {-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \
170 188
         {-f+,--file=}':output file:_files' \
171 189
         {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
172 190
         {-i,--ignore-version}'[ignore version mismatch]' \
173  
-        {-n+,--schema=}':schema to dump:' \
  191
+        {-n+,--schema=}':schema to dump:_pgsql_schemas' \
  192
+        {-N+,--exclude-schema=}':schema to NOT dump:_pgsql_schemas' \
174 193
         {-o,--oids}'[dump objects identifiers for every table]' \
175 194
         {-O,--no-owner}'[dont recreate as same owner]' \
176 195
         {-R,--no-reconnect}'[dont output connect]' \
177 196
         {-s,--schema-only}'[no data, only schema]' \
178 197
         {-S+,--superuser=}':superuser name:_pgsql_users' \
179 198
         {-t+,--table=}':table to dump:_pgsql_tables' \
  199
+        {-T+,--exclude-table=}':table to NOT dump:_pgsql_tables' \
180 200
         {-v,--verbose}'[verbose mode]' \
181 201
         {-V,--version}'[display client version]' \
182 202
         {-x,--no-{acl,privileges}}'[dont dump ACLs]' \
183 203
         -X+':option:_values "option" use-set-session-authorization disable-triggers' \
184 204
         {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \
185  
-        ':PostgreSQL database:_pgsql_databases'
  205
+        ':PostgreSQL database:_pgsql_databases' \
  206
+        --section=':dump named section:_values "section" pre-data data post-data' \
  207
+        --disable-dollpgar-quoting'[disable dollar quoting, use SQL standard quoting]' \
  208
+        --disable-triggers'[disable triggers during data-only restore]' \
  209
+        --no-security-labels'[do not dump security label assignments]' \
  210
+        --no-tablespaces'[do not dump tablespace assignments]' \
  211
+        --no-unlogged-table-data'[do not dump unlogged table data]' \
  212
+        --quote-all-identifiers'[quote all identifiers, even if not key words]' \
  213
+        --serializable-deferrable'[wait until the dump can run without anomalies]' \
  214
+        --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]'
186 215
 }
187 216
 
188 217
 _createdb () {

0 notes on commit 9cca892

Please sign in to comment.
Something went wrong with that request. Please try again.