template0 database comment

Started by Bruce Momjianalmost 15 years ago28 messages
#1Bruce Momjian
bruce@momjian.us
1 attachment(s)

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

I plan to work on more system table and view comments for 9.2.

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

+ It's impossible for everything to be true. +

Attachments:

/rtmp/template0.difftext/x-diffDownload
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
new file mode 100644
index acd2514..ba9b688
*** 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 'only used by pg_dump';\n",
+ 
  		/*
  		 * Finally vacuum to clean up dead rows in pg_database
  		 */
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: template0 database comment

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+ "COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

regards, tom lane

#3Dave Page
dpage@pgadmin.org
In reply to: Tom Lane (#2)
Re: template0 database comment

On 3/12/11, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+ "COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

I'd like to lodge a formal objection to the use of the word
'approximately' in the above comment.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Bruce Momjian
bruce@momjian.us
In reply to: Dave Page (#3)
Re: template0 database comment

Dave Page wrote:

On 3/12/11, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+ "COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

I'd like to lodge a formal objection to the use of the word
'approximately' in the above comment.

OK, funny guys. ;-) Can someone give me the right text. Obviously I
don' know what template0 is used for either. Is it pg_dumpall perhaps?

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

+ It's impossible for everything to be true. +

#5Thom Brown
thom@linux.com
In reply to: Bruce Momjian (#4)
Re: template0 database comment

On 12 March 2011 13:59, Bruce Momjian <bruce@momjian.us> wrote:

Dave Page wrote:

On 3/12/11, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+          "COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

I'd like to lodge a formal objection to the use of the word
'approximately' in the above comment.

OK, funny guys.  ;-)  Can someone give me the right text.  Obviously I
don' know what template0 is used for either.  Is it pg_dumpall perhaps?

'original template database' ?

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#6Bruce Momjian
bruce@momjian.us
In reply to: Thom Brown (#5)
Re: template0 database comment

Thom Brown wrote:

On 12 March 2011 13:59, Bruce Momjian <bruce@momjian.us> wrote:

Dave Page wrote:

On 3/12/11, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+ ? ? ? ? ?"COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

I'd like to lodge a formal objection to the use of the word
'approximately' in the above comment.

OK, funny guys. ?;-) ?Can someone give me the right text. ?Obviously I
don' know what template0 is used for either. ?Is it pg_dumpall perhaps?

'original template database' ?

I like that. Perhaps "unmodified template database'?

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

+ It's impossible for everything to be true. +

#7Christopher Browne
cbbrowne@gmail.com
In reply to: Bruce Momjian (#4)
Re: template0 database comment

On Sat, Mar 12, 2011 at 8:59 AM, Bruce Momjian <bruce@momjian.us> wrote:

Dave Page wrote:

On 3/12/11, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+          "COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

I'd like to lodge a formal objection to the use of the word
'approximately' in the above comment.

OK, funny guys.  ;-)  Can someone give me the right text.  Obviously I
don' know what template0 is used for either.  Is it pg_dumpall perhaps?

Whaa?!?!

pg_dump has nothing to do with it. Only used by createdb

Possibilities include:
- 'base template database'
- 'base template (used if template1 is corrupted)'
- 'backup template (use if template1 corrupted)'

Contrast with template1
- 'default template for creation of new databases'

I dunno that those are the *best* wordings, but they may suggest one.
--
http://linuxfinances.info/info/linuxdistributions.html

#8Christopher Browne
cbbrowne@gmail.com
In reply to: Bruce Momjian (#6)
Re: template0 database comment

On Sat, Mar 12, 2011 at 9:14 AM, Bruce Momjian <bruce@momjian.us> wrote:

I like that.  Perhaps "unmodified template database'?

"why" tends to be more important than "what", particularly to a
confused DBA who's trying to figure out "why do they have all these
extra databases???"

Perhaps...
"backup template database - normally immutable, used if template1 is corrupted"

--
http://linuxfinances.info/info/linuxdistributions.html

#9Bruce Momjian
bruce@momjian.us
In reply to: Christopher Browne (#7)
Re: template0 database comment

Christopher Browne wrote:

On Sat, Mar 12, 2011 at 8:59 AM, Bruce Momjian <bruce@momjian.us> wrote:

Dave Page wrote:

On 3/12/11, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Bruce Momjian <bruce@momjian.us> writes:

People are confused about what template0 is for, so I created the
attached one-line patch to add a database comment to template0. No
initdb, I assume, becuase it is just a comment.

+ ? ? ? ? ?"COMMENT ON DATABASE template0 IS 'only used by pg_dump';\n",

No objection to the concept, but the actual text of this comment is
approximately 100% wrong.

I'd like to lodge a formal objection to the use of the word
'approximately' in the above comment.

OK, funny guys. ?;-) ?Can someone give me the right text. ?Obviously I
don' know what template0 is used for either. ?Is it pg_dumpall perhaps?

Whaa?!?!

pg_dump has nothing to do with it. Only used by createdb

Possibilities include:
- 'base template database'
- 'base template (used if template1 is corrupted)'
- 'backup template (use if template1 corrupted)'

Contrast with template1
- 'default template for creation of new databases'

I dunno that those are the *best* wordings, but they may suggest one.

I thought the big deal with template0 was it was used to find items that
were added to template1 by pg_dumpall.

I think Thom's idea of not describing its use but its contents might be
best, maybe "unmodifiable template database".

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

+ It's impossible for everything to be true. +

#10Greg Stark
gsstark@mit.edu
In reply to: Bruce Momjian (#4)
Re: template0 database comment

On Sat, Mar 12, 2011 at 1:59 PM, Bruce Momjian <bruce@momjian.us> wrote:

OK, funny guys.  ;-)  Can someone give me the right text.  Obviously I
don' know what template0 is used for either.  Is it pg_dumpall perhaps?

template0: unmodifiable pristine empty database
template1: default template for new databases

--
greg

#11Bruce Momjian
bruce@momjian.us
In reply to: Greg Stark (#10)
Re: template0 database comment

Greg Stark wrote:

On Sat, Mar 12, 2011 at 1:59 PM, Bruce Momjian <bruce@momjian.us> wrote:

OK, funny guys. ?;-) ?Can someone give me the right text. ?Obviously I
don' know what template0 is used for either. ?Is it pg_dumpall perhaps?

template0: unmodifiable pristine empty database
template1: default template for new databases

I think I like "unmodifiable empty database".

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

+ It's impossible for everything to be true. +

#12Tom Lane
tgl@sss.pgh.pa.us
In reply to: Greg Stark (#10)
Re: template0 database comment

Greg Stark <gsstark@mit.edu> writes:

On Sat, Mar 12, 2011 at 1:59 PM, Bruce Momjian <bruce@momjian.us> wrote:

OK, funny guys. ;-) Can someone give me the right text. Obviously I
don' know what template0 is used for either. Is it pg_dumpall perhaps?

template0: unmodifiable pristine empty database
template1: default template for new databases

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

The problem with Greg's wording is that it's falsifiable: it is possible
for someone to modify template0 if they're determined to mess things up.
So a description like "unmodifiable" is promising too much.

Shouldn't the "postgres" database get a comment too, while we're at it?
Perhaps "default database to connect to"?

regards, tom lane

#13Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#12)
Re: template0 database comment

On lör, 2011-03-12 at 12:01 -0500, Tom Lane wrote:

Shouldn't the "postgres" database get a comment too, while we're at
it? Perhaps "default database to connect to"?

That's not actually true, though. Maybe it's the "default database used
by administration programs"? In practice it might be "some otherwise
unused database that's occasionally useful". ;-)

#14Greg Stark
gsstark@mit.edu
In reply to: Tom Lane (#12)
Re: template0 database comment

On Sat, Mar 12, 2011 at 5:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

The problem with Greg's wording is that it's falsifiable: it is possible
for someone to modify template0 if they're determined to mess things up.
So a description like "unmodifiable" is promising too much.

Eh, it's possible for someone to make any part of the documentation
wrong if they're determined to mess things up enough. "Empty" is not
even technically correct since it has all the system tables and stuff.
But I think there's a point of diminishing returns where if we try to
come up with something that's technically 100% true it won't help a
user understand the key attributes that make template0 useful. Under
normal usage it has no user objects in it and it is hard to change
that which tries to guarantee that that fact remains true.

--
greg

#15Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#12)
Re: template0 database comment

On Mar 12, 2011, at 12:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Greg Stark <gsstark@mit.edu> writes:

On Sat, Mar 12, 2011 at 1:59 PM, Bruce Momjian <bruce@momjian.us> wrote:

OK, funny guys. ;-) Can someone give me the right text. Obviously I
don' know what template0 is used for either. Is it pg_dumpall perhaps?

template0: unmodifiable pristine empty database
template1: default template for new databases

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

The problem with Greg's wording is that it's falsifiable: it is possible
for someone to modify template0 if they're determined to mess things up.
So a description like "unmodifiable" is promising too much.

Shouldn't the "postgres" database get a comment too, while we're at it?
Perhaps "default database to connect to"?

A preposition is something you should try not to end a sentence with.

...Robert

#16Greg Stark
gsstark@mit.edu
In reply to: Robert Haas (#15)
Re: template0 database comment

On Sat, Mar 12, 2011 at 8:42 PM, Robert Haas <robertmhaas@gmail.com> wrote:

A preposition is something you should try not to end a sentence with.

Something to keep in mind when someone localises Postgres for Latin
which has this rule.

--
greg

#17Andrew Dunstan
andrew@dunslane.net
In reply to: Greg Stark (#16)
Re: template0 database comment

On 03/12/2011 04:24 PM, Greg Stark wrote:

On Sat, Mar 12, 2011 at 8:42 PM, Robert Haas<robertmhaas@gmail.com> wrote:

A preposition is something you should try not to end a sentence with.

Something to keep in mind when someone localises Postgres for Latin
which has this rule.

I assume Robert's comment was in jest, since it was in breach of the
rule it was stating.

cheers

andrew

#18Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#13)
1 attachment(s)
Re: template0 database comment

Peter Eisentraut wrote:

On l?r, 2011-03-12 at 12:01 -0500, Tom Lane wrote:

Shouldn't the "postgres" database get a comment too, while we're at
it? Perhaps "default database to connect to"?

That's not actually true, though. Maybe it's the "default database used
by administration programs"? In practice it might be "some otherwise
unused database that's occasionally useful". ;-)

Based on previous discussion I have developed a patch to add comments
for 'postgres' and 'template0' databases:

postgres=> \l+
...
postgres | default administrative database
template0 | unmodifiable empty database
template1 | default template database

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

+ It's impossible for everything to be true. +

Attachments:

/rtmp/db.difftext/x-diffDownload
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
new file mode 100644
index acd2514..2397932
*** 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 database';\n",
  		NULL
  	};
  
#19Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#12)
Re: template0 database comment

Tom Lane wrote:

Greg Stark <gsstark@mit.edu> writes:

On Sat, Mar 12, 2011 at 1:59 PM, Bruce Momjian <bruce@momjian.us> wrote:

OK, funny guys. ;-) Can someone give me the right text. Obviously I
don' know what template0 is used for either. Is it pg_dumpall perhaps?

template0: unmodifiable pristine empty database
template1: default template for new databases

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.

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

+ It's impossible for everything to be true. +

#20Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#19)
Re: template0 database comment

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.

regards, tom lane

#21Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#20)
1 attachment(s)
Re: template0 database comment

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. +

Attachments:

/rtmp/db.difftext/x-diffDownload
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 */
#22Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#21)
Re: template0 database comment

Applied. I did not bump the catalog version because they are just
comments. I assume that is the right procedure.

---------------------------------------------------------------------------

Bruce Momjian wrote:

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. +

[ text/x-diff is unsupported, treating like TEXT/PLAIN ]

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 */

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

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

+ It's impossible for everything to be true. +

#23Thom Brown
thom@linux.com
In reply to: Bruce Momjian (#22)
Re: template0 database comment

On 15 March 2011 15:26, Bruce Momjian <bruce@momjian.us> wrote:

Applied.  I did not bump the catalog version because they are just
comments.  I assume that is the right procedure.

*SNIP*

+             "COMMENT ON DATABASE postgres IS 'default administrative connection database';\n",

Default administrative connection database? Where's the "connection"
bit come from?

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#24Bruce Momjian
bruce@momjian.us
In reply to: Thom Brown (#23)
Re: template0 database comment

Thom Brown wrote:

On 15 March 2011 15:26, Bruce Momjian <bruce@momjian.us> wrote:

Applied. ?I did not bump the catalog version because they are just
comments. ?I assume that is the right procedure.

*SNIP*

+ ? ? ? ? ? ? "COMMENT ON DATABASE postgres IS 'default administrative connection database';\n",

Default administrative connection database? Where's the "connection"
bit come from?

There was discussion that 'postgres' is the database that is used for
performing administrative connections, e.g. createdb. Yeah, kind of
odd, but that's what it is used for.

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

+ It's impossible for everything to be true. +

#25Thom Brown
thom@linux.com
In reply to: Bruce Momjian (#24)
Re: template0 database comment

On 15 March 2011 15:37, Bruce Momjian <bruce@momjian.us> wrote:

Thom Brown wrote:

On 15 March 2011 15:26, Bruce Momjian <bruce@momjian.us> wrote:

Applied. ?I did not bump the catalog version because they are just
comments. ?I assume that is the right procedure.

*SNIP*

+ ? ? ? ? ? ? "COMMENT ON DATABASE postgres IS 'default administrative connection database';\n",

Default administrative connection database?  Where's the "connection"
bit come from?

There was discussion that 'postgres' is the database that is used for
performing administrative connections, e.g. createdb.  Yeah, kind of
odd, but that's what it is used for.

Hmm... there's actually no mention of that in the docs for such tools:
http://www.postgresql.org/docs/9.0/static/app-createdb.html

There's also little mention of this "administrative" database in the
docs beyond saying it's merely a copy of template1 used as a default
database for users and applications to connect to.

I also notice there's no choice but to use the "postgres" database
with these tools. Shouldn't we have an option that allows us to
specify an alternative database?

e.g.

createdb -d alternativedb newdb

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#26Thom Brown
thom@linux.com
In reply to: Thom Brown (#25)
1 attachment(s)
Re: template0 database comment

On 15 March 2011 15:51, Thom Brown <thom@linux.com> wrote:

On 15 March 2011 15:37, Bruce Momjian <bruce@momjian.us> wrote:

Thom Brown wrote:

On 15 March 2011 15:26, Bruce Momjian <bruce@momjian.us> wrote:

Applied. ?I did not bump the catalog version because they are just
comments. ?I assume that is the right procedure.

*SNIP*

+ ? ? ? ? ? ? "COMMENT ON DATABASE postgres IS 'default administrative connection database';\n",

Default administrative connection database?  Where's the "connection"
bit come from?

There was discussion that 'postgres' is the database that is used for
performing administrative connections, e.g. createdb.  Yeah, kind of
odd, but that's what it is used for.

Hmm... there's actually no mention of that in the docs for such tools:
http://www.postgresql.org/docs/9.0/static/app-createdb.html

There's also little mention of this "administrative" database in the
docs beyond saying it's merely a copy of template1 used as a default
database for users and applications to connect to.

I also notice there's no choice but to use the "postgres" database
with these tools.  Shouldn't we have an option that allows us to
specify an alternative database?

e.g.

createdb -d alternativedb newdb

And example patch attached.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

createdb_db_opt.patchapplication/octet-stream; name=createdb_db_opt.patchDownload
diff --git a/src/bin/scripts/createdb.c b/src/bin/scripts/createdb.c
index 9b72eac..94e791c 100644
--- a/src/bin/scripts/createdb.c
+++ b/src/bin/scripts/createdb.c
@@ -22,6 +22,7 @@ int
 main(int argc, char *argv[])
 {
 	static struct option long_options[] = {
+		{"database", required_argument, NULL, 'd'},
 		{"host", required_argument, NULL, 'h'},
 		{"port", required_argument, NULL, 'p'},
 		{"username", required_argument, NULL, 'U'},
@@ -44,6 +45,7 @@ main(int argc, char *argv[])
 
 	const char *dbname = NULL;
 	char	   *comment = NULL;
+	char	   *database = NULL;
 	char	   *host = NULL;
 	char	   *port = NULL;
 	char	   *username = NULL;
@@ -67,10 +69,13 @@ main(int argc, char *argv[])
 
 	handle_help_version_opts(argc, argv, "createdb", help);
 
-	while ((c = getopt_long(argc, argv, "h:p:U:wWeO:D:T:E:l:", long_options, &optindex)) != -1)
+	while ((c = getopt_long(argc, argv, "d:h:p:U:wWeO:D:T:E:l:", long_options, &optindex)) != -1)
 	{
 		switch (c)
 		{
+			case 'd':
+				database = optarg;
+				break;
 			case 'h':
 				host = optarg;
 				break;
@@ -162,6 +167,9 @@ main(int argc, char *argv[])
 		}
 	}
 
+	if (database == NULL)
+		database = "postgres";
+
 	if (dbname == NULL)
 	{
 		if (getenv("PGDATABASE"))
@@ -192,7 +200,7 @@ main(int argc, char *argv[])
 
 	appendPQExpBuffer(&sql, ";\n");
 
-	conn = connectDatabase(strcmp(dbname, "postgres") == 0 ? "template1" : "postgres",
+	conn = connectDatabase(strcmp(dbname, database) == 0 ? "template1" : database,
 						   host, port, username, prompt_password, progname);
 
 	if (echo)
@@ -256,6 +264,7 @@ help(const char *progname)
 	printf(_("  --help                       show this help, then exit\n"));
 	printf(_("  --version                    output version information, then exit\n"));
 	printf(_("\nConnection options:\n"));
+	printf(_("  -d, --database=DATABASE      database name to connect to (default: \"postgres\")\n"));
 	printf(_("  -h, --host=HOSTNAME          database server host or socket directory\n"));
 	printf(_("  -p, --port=PORT              database server port\n"));
 	printf(_("  -U, --username=USERNAME      user name to connect as\n"));
#27David Fetter
david@fetter.org
In reply to: Greg Stark (#16)
Re: template0 database comment

On Sat, Mar 12, 2011 at 09:24:38PM +0000, Greg Stark wrote:

On Sat, Mar 12, 2011 at 8:42 PM, Robert Haas <robertmhaas@gmail.com> wrote:

A preposition is something you should try not to end a sentence
with.

Something to keep in mind when someone localises Postgres for Latin
which has this rule.

Quidquid latine dictum sit, altum viditur. ;)

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

#28Bruce Momjian
bruce@momjian.us
In reply to: Thom Brown (#26)
Re: template0 database comment

Thom Brown wrote:

On 15 March 2011 15:51, Thom Brown <thom@linux.com> wrote:

On 15 March 2011 15:37, Bruce Momjian <bruce@momjian.us> wrote:

Thom Brown wrote:

On 15 March 2011 15:26, Bruce Momjian <bruce@momjian.us> wrote:

Applied. ?I did not bump the catalog version because they are just
comments. ?I assume that is the right procedure.

*SNIP*

+ ? ? ? ? ? ? "COMMENT ON DATABASE postgres IS 'default administrative connection database';\n",

Default administrative connection database? ?Where's the "connection"
bit come from?

There was discussion that 'postgres' is the database that is used for
performing administrative connections, e.g. createdb. ?Yeah, kind of
odd, but that's what it is used for.

Hmm... there's actually no mention of that in the docs for such tools:
http://www.postgresql.org/docs/9.0/static/app-createdb.html

There's also little mention of this "administrative" database in the
docs beyond saying it's merely a copy of template1 used as a default
database for users and applications to connect to.

I also notice there's no choice but to use the "postgres" database
with these tools. ?Shouldn't we have an option that allows us to
specify an alternative database?

e.g.

createdb -d alternativedb newdb

And example patch attached.

We have actually never gotten a request for this so it is hard to see
why we would add it.

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

+ It's impossible for everything to be true. +