From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com> |
Cc: | Kevin Grittner <kgrittn(at)gmail(dot)com>, Sehrope Sarkuni <sehrope(at)jackdb(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [REVIEW] Tab Completion for CREATE DATABASE ... TEMPLATE ... |
Date: | 2016-09-12 01:07:33 |
Message-ID: | 7849.1473642453@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com> writes:
> On 9/11/16, Kevin Grittner <kgrittn(at)gmail(dot)com> wrote:
>> I was able to find cases during test which were not handled
>> correctly with either version, so I tweaked the query a little.
> Hmm. Which one? Attempt to "SET ROLE <grouprole>"?
> Unfortunately, I after reading your letter I realized that I missed a
> case (it is not working even with your version):
I wasn't aware that this patch was doing anything nontrivial ...
After looking at it I think it's basically uninformed about how to test
for ownership. An explicit join against pg_roles is almost never the
right way for SQL queries to do that. Lose the join and write it more
like this:
+"SELECT pg_catalog.quote_ident(d.datname) "\
+" FROM pg_catalog.pg_database d "\
+" WHERE substring(pg_catalog.quote_ident(d.datname),1,%d)='%s' "\
+" AND (d.datistemplate OR pg_catalog.pg_has_role(d.datdba, 'USAGE'))"
See the information_schema views for precedent.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-09-12 01:13:05 | Re: Re: [COMMITTERS] pgsql: Use LEFT JOINs in some system views in case referenced row doesn |
Previous Message | Noah Misch | 2016-09-12 01:01:53 | Re: Forbid use of LF and CR characters in database and role names |