aboutsummaryrefslogtreecommitdiffstats
path: root/src/_pgsql_utils
diff options
context:
space:
mode:
authorJ Smith <dark.panda@gmail.com>2012-09-10 01:01:38 -0400
committerJ Smith <dark.panda@gmail.com>2012-09-10 01:18:33 -0400
commitcfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e (patch)
treeb5e69d3c20ffc724f8824fc60513e46299c5923e /src/_pgsql_utils
parentConnect to template1 when getting the list of databases. (diff)
downloadzsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.tar
zsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.tar.gz
zsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.tar.bz2
zsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.tar.lz
zsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.tar.xz
zsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.tar.zst
zsh-completions-cfb8da6fb2e5c34040bed02ad22f7e8ef1b73b2e.zip
Get the list of encodings from the database cluster.
Diffstat (limited to 'src/_pgsql_utils')
-rw-r--r--src/_pgsql_utils33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/_pgsql_utils b/src/_pgsql_utils
index 19281b9..4ad55d9 100644
--- a/src/_pgsql_utils
+++ b/src/_pgsql_utils
@@ -107,6 +107,16 @@ _pgsql_databases () {
compadd "$@" - $( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 2>/dev/null )
}
+_pgsql_encodings () {
+ local _pgsql_user
+ _pgsql_get_identity
+
+ local _pgsql_db_sql
+ _pgsql_db_sql="select pg_encoding_to_char(i) from generate_series(0,100) i;"
+
+ compadd "$@" - $( psql $_pgsql_params[@] -Atq -c $_pgsql_db_sql template1 )
+}
+
##
## The actual completion code for the commands
@@ -185,7 +195,7 @@ _createdb () {
{-q,--quiet}'[non verbose mode]' \
{-D+,--location=}':database location:_directories' \
{-T+,--template=}':database template:_pgsql_databases' \
- {-E+,--encoding=}':database encoding:_values "encoding" $_pgsql_encodings[@]' \
+ {-E+,--encoding=}':database encoding:_pgsql_encodings' \
':PostgreSQL database:' \
':comment:'
}
@@ -222,7 +232,7 @@ _vacuumdb () {
}
_pgsql_utils () {
- local _pgsql_common_opts _pgsql_encodings
+ local _pgsql_common_opts
_pgsql_common_opts=(
{-\?,--help}'[display help]'
@@ -232,25 +242,6 @@ _pgsql_utils () {
{-W,--password}'[prompt for password]'
)
- # Taken from
- # <http://www.postgresql.org/docs/7.4/static/multibyte.html#CHARSET-TABLE>.
- # It'd be real nice if postgres could tell us these...
- _pgsql_encodings=(
- SQL_ASCII
- EUC_{JP,CN,KR,TW}
- JOHAB
- UNICODE
- MULE_INTERNAL
- LATIN{1,2,3,4,5,6,7,8,9,10}
- ISO_8859_{5,6,7,8}
- KOI8
- WIN
- ALT
- WIN1256
- TCVN
- WIN874
- )
-
case "$service" in
psql) _psql "$@" ;;
pg_dump) _pg_dump "$@" ;;