Re: Unhappy thoughts about pg_dump and objects inherited from template1 - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Unhappy thoughts about pg_dump and objects inherited from template1
Date
Msg-id 26709.973698983@sss.pgh.pa.us
Whole thread Raw
In response to Re: Unhappy thoughts about pg_dump and objects inherited from template1  (Philip Warner <pjw@rhyme.com.au>)
Responses Re: Unhappy thoughts about pg_dump and objects inherited from template1  (Philip Warner <pjw@rhyme.com.au>)
List pgsql-hackers
Philip Warner <pjw@rhyme.com.au> writes:
> Just seems like we'd be forcing non-standard syntax on ourselves when/if
> CREATE DATABASE becomes CREATE SCHEMA; I would assume that the two
> statements would become synonymous?

No, I don't think so --- we already have WITH LOCATION and WITH
ENCODING, neither of which look like schema-level properties to me.

> [Minor aside: would 'FROM TEMPLATE' be better?]

WITH is already embedded in the CREATE DATABASE syntax.

> Question: if I issue a "CREATE DATABASE foo WITH TEMPLATE 'my-favorite-db'"
> will I just get a copy of the specified database, including data?

If we allow it, that's what would happen.  Seems like a potential
security hole though ... should we restrict the set of clonable
templates somehow?

It occurs to me that the current implementation of CREATE DATABASE
assumes that no changes are actively going on in the cloned database;
for example, you'd miss copying any pages that are sitting in dirty
buffers in shared memory.  So trying to copy an active database this
way is a recipe for trouble.  Probably better restrict it to identified
template databases.  Maybe only allow cloning from DBs that are named
templateNNN?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Unhappy thoughts about pg_dump and objects inherited from template1
Next
From: Philip Warner
Date:
Subject: Re: Unhappy thoughts about pg_dump and objects inherited from template1