aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Grittner <kgrittn@postgresql.org>2016-09-11 15:37:27 -0500
committerKevin Grittner <kgrittn@postgresql.org>2016-09-11 15:37:27 -0500
commit52803098ab26051c0c9802f3c19edffc90de8843 (patch)
treebb8ae24d1088e1bbbefb9af874fae54b44fc01db
parent40b449ae84dcf71177d7749a7b0c582b64dc15f0 (diff)
downloadpostgresql-52803098ab26051c0c9802f3c19edffc90de8843.tar.gz
postgresql-52803098ab26051c0c9802f3c19edffc90de8843.zip
psql tab completion for CREATE DATABASE ... TEMPLATE ...
Sehrope Sarkuni, reviewed by Merlin Moncure & Vitaly Burovoy with some editing by me
-rw-r--r--src/bin/psql/tab-complete.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 019f75a3760..3e2f0846e79 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -599,8 +599,11 @@ static const SchemaQuery Query_for_list_of_matviews = {
" OR '\"' || nspname || '\"' ='%s') "
#define Query_for_list_of_template_databases \
-"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
-" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s' AND datistemplate"
+"SELECT pg_catalog.quote_ident(d.datname) "\
+" FROM pg_catalog.pg_database d "\
+" JOIN pg_catalog.pg_roles r ON r.rolname = CURRENT_USER "\
+" WHERE substring(pg_catalog.quote_ident(d.datname),1,%d)='%s' "\
+" AND (d.datistemplate OR r.rolsuper OR d.datdba = r.oid)"
#define Query_for_list_of_databases \
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\