aboutsummaryrefslogtreecommitdiffstats
path: root/src/_pgsql_utils
diff options
context:
space:
mode:
authorJ Smith <dark.panda@gmail.com>2022-01-27 18:23:03 -0400
committerJ Smith <dark.panda@gmail.com>2022-01-27 18:23:03 -0400
commit406167058b5eb0495e75c5579e5be665cf211557 (patch)
treeb24ce738f04a6a2329eae47efc14746994dca7aa /src/_pgsql_utils
parentMerge pull request #841 from paaguti/master (diff)
downloadzsh-completions-406167058b5eb0495e75c5579e5be665cf211557.tar
zsh-completions-406167058b5eb0495e75c5579e5be665cf211557.tar.gz
zsh-completions-406167058b5eb0495e75c5579e5be665cf211557.tar.bz2
zsh-completions-406167058b5eb0495e75c5579e5be665cf211557.tar.lz
zsh-completions-406167058b5eb0495e75c5579e5be665cf211557.tar.xz
zsh-completions-406167058b5eb0495e75c5579e5be665cf211557.tar.zst
zsh-completions-406167058b5eb0495e75c5579e5be665cf211557.zip
Add additional PostgreSQL completions for 13+ and reorganize
Diffstat (limited to 'src/_pgsql_utils')
-rw-r--r--src/_pgsql_utils185
1 files changed, 127 insertions, 58 deletions
diff --git a/src/_pgsql_utils b/src/_pgsql_utils
index 1e17dec..df0d096 100644
--- a/src/_pgsql_utils
+++ b/src/_pgsql_utils
@@ -183,34 +183,39 @@ _psql () {
_arguments -C -s "-*" \
"$_pgsql_common_opts[@]" \
- {-V,--version}'[display client version]' \
- {-a,--echo-all}'[print commands read]' \
- {-A,--no-align}'[unaligned output mode]' \
{-c+,--command=}':execute SQL command:' \
{-d+,--dbname=}':database to connect to:_pgsql_databases' \
+ {-f+,--file=}':SQL file to read:_files' \
+ {-l,--list}'[list databases]' \
+ {-v+,--set=,--variable=}':set SQL variable:' \
+ {-V,--version}'[output version information, then exit]' \
+ {-X,--no-psqlrc}'[don'\''t read ~/.psqlrc]' \
+ {-1,--single-transaction}'[restore as a single transaction]' \
+ {-\?,--help=}':display help:' \
+ \
+ {-a,--echo-all}'[print commands read]' \
{-b,--echo-errors}'[echo failed commands]' \
{-e,--echo-queries}'[display queries submitted]' \
{-E,--echo-hidden}'[display hidden queries]' \
{-L,--log-file=}'[send session log to file]' \
{-n,--no-readline}'[disable enhanced command line editing (readline)]' \
- {-f+,--file=}':SQL file to read:_files' \
- {-F+,--field-separator=}':field separator char:' \
- {-H,--html}'[HTML output]' \
- {-l,--list}'[list databases]' \
{-o+,--output=}':query output:_files' \
- {-P+,--pset=}':set psql variable:' \
{-q,--quiet}'[non verbose mode]' \
- {-R+,--record-separator=}':record separator char:' \
{-s,--single-step}'[prompt before each query]' \
{-S,--single-line}'[newline sends query]' \
+ \
+ {-A,--no-align}'[unaligned output mode]' \
+ --csv'[CSV (Comma-Separated Values) table output mode]' \
+ {-F+,--field-separator=}':field separator char:' \
+ {-H,--html}'[HTML output]' \
+ {-P+,--pset=}':set psql variable:' \
+ {-R+,--record-separator=}':record separator char:' \
{-t,--tuples-only}'[don'\''t display header/footer]' \
{-T+,--table-attr=}':HTML table options:' \
- -u'[prompt for username/password]' \
- {-v+,--set=,--variable=}':set SQL variable:' \
{-x,--expanded}'[one column per line]' \
{-z,--field-separator-zero}'[set field separator for unaligned output to zero byte]' \
{-0,--record-separator-zero}'[set record separator for unaligned output to zero byte]' \
- {-X,--no-psqlrc}'[don'\''t read ~/.psqlrc]' \
+ -u'[prompt for username/password]' \
':PostgreSQL database:_pgsql_databases' \
':PostgreSQL user:_pgsql_users'
}
@@ -221,55 +226,63 @@ _pg_dump () {
_arguments -C -s \
"$_pgsql_common_opts[@]" \
+ {-f+,--file=}':output file:_files' \
+ {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
+ {-j,--jobs=}'[use this many parallel jobs to dump]' \
+ {-v,--verbose}'[verbose mode]' \
+ {-V,--version}'[output version information, then exit]' \
+ {-Z+,--compress=}':compression level:_values "level" 9 8 7 6 5 4 3 2 1 0' \
+ --lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \
+ --no-sync'[do not wait for changes to be written safely to disk]' \
+ {-\?,--help}'[display help]' \
+ \
{-a,--data-only}'[dump only data]' \
{-b,--blobs}'[dump blobs as well]' \
+ {-B,--no-blobs}'[exclude large objects in dump]' \
{-c,--clean}'[include clean cmds in dump]' \
{-C,--create}'[include createdb cmds in dump]' \
+ {-e+,--extension=}'[dump the specified extension(s) only]' \
{-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' \
- {-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
- {-j,--jobs=}'[use this many parallel jobs to dump]' \
- {-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}'[don'\''t recreate as same owner]' \
- {-R,--no-reconnect}'[don'\''t output connect]' \
{-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}}'[don'\''t 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' \
- --section=':dump named section:_values "section" pre-data data post-data' \
--binary-upgrade'[for use by upgrade utilities only]' \
- --column-inserts'[dump data as INSERT commands with column names]' \
+ {-D,--{attribute,column}-inserts}'[use INSERT (cols) not COPY]' \
--disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \
--disable-triggers'[disable triggers during data-only restore]' \
--enable-row-security'[enable row security (dump only content user has access to)]' \
--exclude-table-data='[do NOT dump data for the named table(s)]' \
--if-exists'[use IF EXISTS when dropping objects]' \
+ --include-foreign-data='[include data of foreign servers]' \
--inserts'[dump data as INSERT commands, rather than COPY]' \
- --lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \
--load-via-partition-root'[load partitions via the root table]' \
--no-comments'[do not dump comments]' \
--no-publications'[do not dump publications]' \
--no-security-labels'[do not dump security label assignments]' \
+ --no-subscriptions'[do not dump subscriptions]' \
--no-synchronized-snapshots'[do not use synchronized snapshots in parallel jobs]' \
--no-tablespaces'[do not dump tablespace assignments]' \
+ --no-toast-compression'[do not dump TOAST compression methods]' \
--no-unlogged-table-data'[do not dump unlogged table data]' \
--on-conflict-do-nothing'[add ON CONFLICT DO NOTHING to INSERT commands]' \
--quote-all-identifiers'[quote all identifiers, even if not key words]' \
+ --rows-per-insert=['number of rows per INSERT'] \
+ --section=':dump named section:_values "section" pre-data data post-data' \
--serializable-deferrable'[wait until the dump can run without anomalies]' \
--snapshot='[use given snapshot for the dump]' \
--strict-names'[require table and/or schema include patterns to match at least one entity each]' \
- --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]'
+ --use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER]' \
+ \
+ {-i,--ignore-version}'[ignore version mismatch]' \
+ {-o,--oids}'[dump objects identifiers for every table]' \
+ {-R,--no-reconnect}'[don'\''t output connect]' \
+ -X+':option:_values "option" use-set-session-authorization disable-triggers' \
+ ':PostgreSQL database:_pgsql_databases'
}
_pg_restore () {
@@ -282,9 +295,11 @@ _pg_restore () {
{-f+,--file=}':output file:_files' \
{-F+,--format=}':output format:_values "format" "p[plain text]" "t[tar]" "c[custom]"' \
{-l,--list}'[list databases]' \
+ {-v,--verbose}'[verbose mode]' \
+ {-V,--version}'[output version information, then exit]' \
+ {-\?,--help}'[display help]' \
+ \
{-a,--data-only}'[dump only data]' \
- {-b,--blobs}'[include large objects in dump]' \
- {-B,--no-blobs}'[exclude large objects in dump]' \
{-c,--clean}'[include clean (drop) cmds before recreating]' \
{-C,--create}'[include createdb cmds in dump]' \
{-e,--exit-on-error}'[exit on error, default is to continue]' \
@@ -300,8 +315,6 @@ _pg_restore () {
{-T,--trigger=}':restore named trigger:' \
{-x,--no-privileges}'[skip restoration of access privileges (grant/revoke)]' \
{-1,--single-transaction}'[restore as a single transaction]' \
- {-v,--verbose}'[verbose mode]' \
- {-V,--version}'[display client version]' \
--disable-triggers'[disable triggers during data-only restore]' \
--enable-row-security'[enable row security]' \
--if-exists'[use IF EXISTS when dropping objects]' \
@@ -312,7 +325,12 @@ _pg_restore () {
--no-subscriptions'[do not restore subscriptions]' \
--no-tablespaces'[do not restore tablespace assignments]' \
--section=':dump named section:_values "section" pre-data data post-data' \
+ --strict-names'[require table and/or schema include patterns to match at least one entity each]' \
--use-set-session-authorization'[use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership]' \
+ \
+ {-b,--blobs}'[include large objects in dump]' \
+ {-B,--no-blobs}'[exclude large objects in dump]' \
+ \
"1: :_files"
}
@@ -322,11 +340,16 @@ _pg_dumpall () {
_arguments -C -s \
"$_pgsql_common_opts[@]" \
+ {-f+,--file=}':output file:_files' \
+ {-v,--verbose}'[verbose mode]' \
+ {-V,--version}'[output version information, then exit]' \
+ --lock-wait-timeout='[fail after waiting TIMEOUT for a table lock]' \
+ {-\?,--help}'[display help]' \
+ \
{-a,--data-only}'[dump only data]' \
{-c,--clean}'[include clean (drop) cmds before recreating]' \
+ {-E,--encoding=}'[dump the data in encoding]' \
{-g,--globals-only}'[dump only global objects, no databases]' \
- {-f+,--file=}':output file:_files' \
- {-o,--oids}'[dump objects identifiers for every table]' \
{-O,--no-owner}'[don'\''t recreate as same owner]' \
{-r,--roles-only}'[no databases or tablespaces, only roles]' \
{-s,--schema-only}'[no data, only schema]' \
@@ -337,12 +360,25 @@ _pg_dumpall () {
--column-inserts'[use INSERT with column names not COPY]' \
--disable-dollar-quoting'[disable dollar quoting, use SQL standard quoting]' \
--disable-triggers'[disable triggers during data-only restore]' \
+ --exclude-database=':exclude databases:_pgsql_databases' \
+ --extra-float-digits='[override default setting for extra_float_digits]' \
+ --if-exists'[use IF EXISTS when dropping objects]' \
--inserts'[use INSERT not COPY]' \
+ --load-via-partition-root'[pload partitions via the root table]' \
+ --no-comments'[do not dump comments]' \
+ --no-publications'[do not dump publications]' \
+ --no-role-passwords'[do not dump passwords for roles]' \
--no-security-labels'[do not dump security label assignments]' \
+ --no-subscriptions'[do not dump subscriptions]' \
+ --no-sync'[do not wait for changes to be written safely to disk]' \
--no-tablespaces'[do not dump tablespace assignments]' \
+ --no-toast-compression'[do not dump TOAST compression methods]' \
--no-unlogged-table-data'[do not dump unlogged table data]' \
+ --on-conflict-do-nothing'[add ON CONFLICT DO NOTHING to INSERT commands]' \
--quote-all-identifiers'[quote all identifiers, even if not key words]' \
- --use-set-session-authorization'[use SET SESSION AUTHORIZATION cmds instead of ALTER OWNER]'
+ --rows-per-insert='[number of rows per INSERT]' \
+ --use-set-session-authorization'[use SET SESSION AUTHORIZATION cmds instead of ALTER OWNER]' \
+ {-o,--oids}'[dump objects identifiers for every table]' \
}
_createdb () {
@@ -351,11 +387,20 @@ _createdb () {
_arguments -C -s \
"$_pgsql_common_opts[@]" \
+ {-D+,--tablespace=}'[default tablespace for the database]' \
{-e,--echo}'[display SQL queries]' \
- {-q,--quiet}'[non verbose mode]' \
- {-D+,--location=}':database location:_directories' \
- {-T+,--template=}':database template:_pgsql_databases' \
{-E+,--encoding=}':database encoding:_pgsql_encodings' \
+ {-l+,--locale=}'[locale settings for the database]' \
+ --lc-collate='[LC_COLLATE setting for the database]' \
+ --lc-ctype='[LC_CTYPE setting for the database]' \
+ {-O+,--owner=}':database user to own the new database:_pgsql_users' \
+ {-T+,--template=}':database template:_pgsql_databases' \
+ '--version[output version information, then exit]' \
+ {-\?,--help}'[display help]' \
+ \
+ --maintenance-db=':alternate maintenance database:_pgsql_databases' \
+ {-q,--quiet}'[non verbose mode]' \
+ --location=':database location (unsupported since PostgrSQL 8.0):_directories' \
':PostgreSQL database:' \
':comment:'
}
@@ -367,8 +412,12 @@ _dropdb () {
_arguments -C -s \
"$_pgsql_common_opts[@]" \
{-e,--echo}'[display SQL queries]' \
- {-q,--quiet}'[non verbose mode]' \
+ {-f,--force}'[try to terminate other connections before dropping]' \
{-i,--interactive}'[confirm before drop]' \
+ {-V,--version}'[output version information, then exit]' \
+ --if-exists'[don'\''t treport error if database does'\''t exist]' \
+ --maintenance-db=':alternate maintenance database:_pgsql_databases' \
+ {-q,--quiet}'[non verbose mode]' \
':PostgreSQL database:_pgsql_databases'
}
@@ -380,20 +429,28 @@ _vacuumdb () {
"$_pgsql_common_opts[@]" \
{-a,--all}'[vacuum all databases]' \
{-d+,--dbname=}':database to connect to:_pgsql_databases' \
- {-t+,--table=}':table to dump:_pgsql_tables' \
- {-f,--full}'[do full vacuuming]' \
- {-z,--analyze}'[update optimizer hints]' \
- {-Z,--analyze-only}'[only update optimizer statistics; no vacuum]' \
+ --disable-page-skipping'[disable all page-skipping behavior]' \
{-e,--echo}'[show the commands being sent to the server]' \
- {-q,--quiet}'[do not write any messages]' \
- {-v,--verbose}'[write a lot of output]' \
+ {-f,--full}'[do full vacuuming]' \
+ {-F,--freeze}'[freeze row transaction information]' \
+ --force-index-cleanup'[always remove index entries that point to dead tuples]' \
+ {-j,--jobs=}'[use this many concurrent connections to vacuum]' \
'--min-mxid-age=[minimum multixact ID age of tables to vacuum]' \
'--min-xid-age=[minimum transaction ID age of tables to vacuum]' \
+ --no-index-cleanup'[don'\''t remove index entries that point to dead tuples]' \
+ --no-process-toast'[skip the TOAST table associated with the table to vacuum]' \
+ --no-truncate'[don'\''t truncate empty pages at the end of the table]' \
+ {-P+,--parallel=}'[use this many background workers for vacuum, if available]' \
+ {-q,--quiet}'[do not write any messages]' \
'--skip-locked[skip relations that cannot be immediately locked]' \
- '--analyze-in-stages[only update optimizer statistics, in multiple]' \
- '--help[show this help, then exit]' \
- '--version[output version information, then exit]' \
- '--maintenance-db=[alternate maintenance database]' \
+ {-t+,--table=}':table to dump:_pgsql_tables' \
+ {-v,--verbose}'[write a lot of output]' \
+ {-V,--version}'[output version information, then exit]' \
+ {-z,--analyze}'[update optimizer hints]' \
+ {-Z,--analyze-only}'[only update optimizer statistics; no vacuum]' \
+ --analyze-in-stages'[only update optimizer statistics, in multiple stages for faster results; no vacuum]' \
+ {-\?,--help}'[display help]' \
+ --maintenance-db='[alternate maintenance database]' \
'1:PostgreSQL database:_pgsql_databases'
}
@@ -403,17 +460,15 @@ _createuser () {
_arguments -C -s \
"$_pgsql_common_opts[@]" \
- {-e,--echo}'[display SQL queries]' \
{-c,--connection-limit=}'[connection limit for role (default: no limit)]' \
{-d,--createdb}'[role can create new databases]' \
{-D,--no-createdb}'[role cannot create databases]' \
- {-E,--encrypted}'[encrypt stored password]' \
+ {-e,--echo}'[display SQL queries]' \
{-g,--role=}'[new role will be a member of this role]' \
{-i,--inherit}'[role inherits privileges of roles it is a member of (default)]' \
{-I,--no-inherit}'[role does not inherit privileges]' \
{-l,--login}'[role can login (default)]' \
{-L,--no-login}'[role cannot login]' \
- {-N,--unencrypted}'[do not encrypt stored password]' \
{-P,--pwprompt}'[assign a password to new role]' \
{-r,--createrole}'[role can create new roles]' \
{-R,--no-createrole}'[role cannot create roles]' \
@@ -422,6 +477,9 @@ _createuser () {
--interactive'[prompt for missing role name and attributes rather than using defaults]' \
--replication'[role can initiate replication]' \
--no-replication'[role cannot initiate replication]' \
+ {-E,--encrypted}'[encrypt stored password]' \
+ {-N,--unencrypted}'[do not encrypt stored password]' \
+ {-\?,--help}'[display help]'
}
_dropuser () {
@@ -433,6 +491,8 @@ _dropuser () {
{-e,--echo}'[display SQL queries]' \
{-q,--quiet}'[non verbose mode]' \
{-i,--interactive}'[prompt before deleting anything, and prompt for role name if not specified]' \
+ {-V,--version}'[output version information, then exit]' \
+ --if-exists'[don'\''t report error if user doesn'\''t exist]' \
':PostgreSQL user:_pgsql_users'
}
@@ -445,7 +505,9 @@ _initdb () {
--auth-host=':default authentication method for local TCP/IP connections:_values "auth methods" $_pgsql_auth_methods[@]' \
--auth-local=':default authentication method for local-socket connections:_values "auth methods" $_pgsql_auth_methods[@]' \
{-D+,--pgdata=}':location for this database cluster:_files' \
- {-E+,--encoding=}':set default encoding for new databases:' \
+ {-E+,--encoding=}':set default encoding for new databases:_pgsql_encodings' \
+ {-g,--allow-group-access}'[allow group readexecute on data directory]' \
+ {-k,--data-checksums}':use data page checksums:' \
--locale=':set default locale for new databases:' \
--lc-collate=':set the default locale for collate:' \
--lc-ctype=':set the default locale for ctype:' \
@@ -458,14 +520,19 @@ _initdb () {
{-T+,--text-search-config=}'[default text search configuration]' \
{-U+,--username=NAME}':database superuser name:' \
{-W,--pwprompt}'[prompt for a password for the new superuser]' \
- {-X+,--xlogdir=}':location for the transaction log directory:_files' \
+ {-X+,--waldir=}':location for the write-ahead log directory:_files' \
+ --xlogdir=':location for the transaction log directory (unsupported since PostgreSQL 10):_files' \
+ --wal-segsize='[size of WAL segments, in megabytes]' \
{-d,--debug}'[generate lots of debugging output]' \
+ --discard-caches'[set debug_discard_caches=1]' \
-L+':where to find the input files:_files' \
- {-k,--data-checksums}':use data page checksums:' \
- {-n,--noclean}'[do not clean up after errors]' \
- {-N,--nosync}':do not wait for changes to be written safely to disk:' \
+ {-n,--no-clean}'[do not clean up after errors]' \
+ {-N,--no-sync}':do not wait for changes to be written safely to disk:' \
+ --instructions'[do not print instructions for next steps]' \
{-s,--show}'[show internal settings]' \
{-S,--sync-only}'[only sync data directory]' \
+ {-V,--version}'[output version information, then exit]' \
+ {-\?,--help}'[display help]' \
':location for this database cluster:_files'
}
@@ -478,6 +545,7 @@ _pgsql_utils () {
{-p+,--port=}':database port number:_pgsql_ports'
{-U+,--username=}':connect as user:_pgsql_users'
{-W,--password}'[prompt for password]'
+ {-w,--no-password}'[never prompt for password]'
--role='[do SET ROLE before restore]'
)
@@ -500,6 +568,7 @@ _pgsql_utils () {
case "$service" in
psql) _psql "$@" ;;
pg_dump) _pg_dump "$@" ;;
+ pg_dumpall) _pg_dumpall "$@" ;;
pg_restore) _pg_restore "$@" ;;
createdb) _createdb "$@" ;;
dropdb) _dropdb "$@" ;;