Skip to content

Commit 5280309

Browse files
committed
psql tab completion for CREATE DATABASE ... TEMPLATE ...
Sehrope Sarkuni, reviewed by Merlin Moncure & Vitaly Burovoy with some editing by me
1 parent 40b449a commit 5280309

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/bin/psql/tab-complete.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,11 @@ static const SchemaQuery Query_for_list_of_matviews = {
599599
" OR '\"' || nspname || '\"' ='%s') "
600600

601601
#define Query_for_list_of_template_databases \
602-
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\
603-
" WHERE substring(pg_catalog.quote_ident(datname),1,%d)='%s' AND datistemplate"
602+
"SELECT pg_catalog.quote_ident(d.datname) "\
603+
" FROM pg_catalog.pg_database d "\
604+
" JOIN pg_catalog.pg_roles r ON r.rolname = CURRENT_USER "\
605+
" WHERE substring(pg_catalog.quote_ident(d.datname),1,%d)='%s' "\
606+
" AND (d.datistemplate OR r.rolsuper OR d.datdba = r.oid)"
604607

605608
#define Query_for_list_of_databases \
606609
"SELECT pg_catalog.quote_ident(datname) FROM pg_catalog.pg_database "\

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy