Re: template0 database comment - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: template0 database comment
Date
Msg-id 201103141538.p2EFcgC13734@momjian.us
Whole thread Raw
In response to Re: template0 database comment  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: template0 database comment
List pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Tom Lane wrote:
> >> Yeah, I think that the right way to approach this is to have initdb
> >> comment *both* of those databases.  I don't like that specific wording
> >> for template0 though.  Maybe
> >>
> >> template0: unmodified copy of original template1 database
> >> template1: default template for new databases
>
> > Tom, the current comment for "template1" is "default template database".
> > Do you like your above wording better?  It does make it slighly longer.
>
> Actually that's Greg's wording.  Yeah I do like it better.  If you don't
> already know what a template database is, "template1: default template
> database" is going to convey precisely nothing to you.  Greg's version
> at least gives you the information that it has got something to do with
> making new databases, which would probably be enough to prompt people to
> go look in the right part of the docs.

OK, I have modified the comments to be clearer about their purpose:

    test=> \l+
       Name    |                Description
    -----------+--------------------------------------------
     postgres  | default administrative connection database
     template0 | unmodifiable empty database
     template1 | default template for new databases

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
new file mode 100644
index acd2514..b2da1cf
*** a/src/bin/initdb/initdb.c
--- b/src/bin/initdb/initdb.c
*************** make_template0(void)
*** 1976,1981 ****
--- 1976,1983 ----
          "REVOKE CREATE,TEMPORARY ON DATABASE template1 FROM public;\n",
          "REVOKE CREATE,TEMPORARY ON DATABASE template0 FROM public;\n",

+         "COMMENT ON DATABASE template0 IS 'unmodifiable empty database';\n",
+
          /*
           * Finally vacuum to clean up dead rows in pg_database
           */
*************** make_postgres(void)
*** 2011,2016 ****
--- 2013,2019 ----
      const char **line;
      static const char *postgres_setup[] = {
          "CREATE DATABASE postgres;\n",
+         "COMMENT ON DATABASE postgres IS 'default administrative connection database';\n",
          NULL
      };

diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h
new file mode 100644
index 6419d65..ee4c858
*** a/src/include/catalog/pg_database.h
--- b/src/include/catalog/pg_database.h
*************** typedef FormData_pg_database *Form_pg_da
*** 71,77 ****
  #define Anum_pg_database_datacl            12

  DATA(insert OID = 1 (  template1 PGUID ENCODING "LC_COLLATE" "LC_CTYPE" t t -1 0 0 1663 _null_));
! SHDESCR("default template database");
  #define TemplateDbOid            1

  #endif   /* PG_DATABASE_H */
--- 71,77 ----
  #define Anum_pg_database_datacl            12

  DATA(insert OID = 1 (  template1 PGUID ENCODING "LC_COLLATE" "LC_CTYPE" t t -1 0 0 1663 _null_));
! SHDESCR("default template for new databases");
  #define TemplateDbOid            1

  #endif   /* PG_DATABASE_H */

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Macros for time magic values
Next
From: Dave Page
Date:
Subject: Re: GSoC 2011 - Mentors? Projects?