Re: datistemplate of pg_database does not behave as per description in documentation

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Rajeev rastogi <rajeev(dot)rastogi(at)huawei(dot)com>
Subject: Re: datistemplate of pg_database does not behave as per description in documentation
Date: 2014-03-27 12:07:54
Message-ID: CABUevEwfrJ6v9Ju9mYLzDF3v9-d8=w3xbLWt=rtFma3ziy8f=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mar 27, 2014 12:45 PM, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Magnus Hagander <magnus(at)hagander(dot)net> writes:
> > On Thu, Mar 27, 2014 at 9:12 AM, Rajeev rastogi
> > <rajeev(dot)rastogi(at)huawei(dot)com>wrote:
> >> But current code does not behave in this manner. Even if dbistemplate
of
> >> database is false, still it allows to be used as template database.
>
> > AFAICT, the *only* thing datistemplate is used is to set parameters in
> > autovacuum.
>
> Huh? The code comment is perfectly clear:
>
> /*
> * Permission check: to copy a DB that's not marked datistemplate, you
> * must be superuser or the owner thereof.
> */
> if (!src_istemplate)
> {
> if (!pg_database_ownercheck(src_dboid, GetUserId()))
> ereport(ERROR,
> (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
> errmsg("permission denied to copy database \"%s\"",
> dbtemplate)));
> }
>
> I agree we need to make the docs match the code, but changing behavior
> that's been like that for ten or fifteen years isn't the answer.

Hah, I hadn't done more than git grep for datistemplate :-) that's what I
get for taking shortcuts...

But yes, fixing the documentation is what I advocate as well.

> (Changing code and failing to adjust the adjacent comment is even less
> of an answer.)

I didn't even look at the suggested patch..

/Magnus

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2014-03-27 12:19:05 Re: Missing pfree in logical_heap_rewrite_flush_mappings()
Previous Message Tom Lane 2014-03-27 12:02:35 Something flaky in the "relfilenode mapping" infrastructure