[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#72229: pg_wrapper breaks psql database selection



Michael Wildpaner wrote:
  >
  >Package: postgresql-client
  >Version: 7.0.2-5
  >
  >if no database name is given to psql, pg_wrapper appends the arguments
  >"-d" "template1" to the newly constructed argv.

Yes, I think it is time for a rethink on this.  There are definitely
disadvantages in connecting users to template1 by default, since
unwanted tables are likely to get created there and then copied to
all new databases.

I have to take account of this major difference between PostgreSQL as
distributed upstream and postgresql as a Debian package: a locally
built and installed upstream version can reasonably default to a database
by the user's name; a Debian postgresql cannot assume that the user is
able to create new databases and ought therefore to provide a reasonable
default that he can connect to.  If there is no default, a message
should be printed telling the user whom he should consult.

1. I should use any environment variables that are already
set; it is definitely a bug not to do this.

2. If the database name is still blank, I should try connections
in this order:

	a) as defined by ~/.psqlrc          | current upstream default at
	b) user's name                      | version 7.0.2-x
	c) locally-configured default database
           (ideally, it should be the default database on PGHOST, but
            there is no mechanism for reading that)
	d) if connection still fails, print an error message and abort

3. There should be added to the configuration
(/etc/postgresql/postmaster.init) the following:

# The default database to which psql should connect if none is
# specified on the command line and there is none defined in ~/.psqlrc
# and there is no database which has the same name as the user's login.
# If this is undefined, an unspecified connection will fail.
PG_DEFAULT_DATABASE=

# Whether to report progress in finding and connecting to a default
# database when none is specified on the command line (yes/no).
PG_DEFAULT_VERBOSE=yes



Comments please?

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Therefore when thou doest thine alms, do not sound a 
      trumpet before thee, as the hypocrites do in the 
      synagogues and in the streets, that they may have 
      glory of men. Verily I say unto you, They have their 
      reward. But when thou doest alms, let not thy left 
      hand know what thy right hand doeth; That thine alms 
      may be in secret; and thy Father which seeth in secret
      himself shall reward thee openly."       Matthew 6:2-4




Reply to: