Trashed Postgres template1

I twisted into psql and renamed template0 and template1 before implementing them. Now I get "permission to reject to copy the database" template1 "from within psql and format the command line when trying to recreate template1.

To save time, is there anything else I need to know about template1 regarding read / write permissions of the OS in / data / base or provision on template1, etc.

TIA

+3
source share
3 answers

You must tell PostGreSQL what template1the template is. If you do not, you will not be allowed to copy it unless you own it:

UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';

/src/backend/commands/dbcommands.c ( Google), . :

/*
 * Permission check: to copy a DB that 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)));
}

,

+6

" 1"?

- "template1" "template0". - "template0" .

- .

+2

? , , :

UPDATE pg_database SET datistemplate = TRUE, datname = 'template0' WHERE datname = 'current_template0_name';

UPDATE pg_database SET datistemplate = TRUE, datname = 'template1' WHERE datname = 'current_template1_name';
+1

All Articles