Re: Optional postgres database not so optional in 8.1 - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Optional postgres database not so optional in 8.1
Date
Msg-id 437CD21F.5090400@dunslane.net
Whole thread Raw
In response to Re: Optional postgres database not so optional in 8.1  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Optional postgres database not so optional in 8.1  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers

Tom Lane wrote:

>"Michael Paesold" <mpaesold@gmx.at> writes:
>  
>
>>It's the '-l' option (list all databases) that does not honor the database 
>>given on the command line.
>>This does not work, if the postgres database is dropped in 8.1:
>>    
>>
>
>  
>
>>psql -l template1
>>    
>>
>
>It does seem a bit inconsistent that psql wouldn't connect to the
>specified database in order to do -l, if one is specified.
>Anyone want to look and see if it's easy to change?
>  
>


The relevant code in startup.c reads:

       pset.db = PQsetdbLogin(options.host, options.port, NULL, NULL,           options.action == ACT_LIST_DB ?
"postgres": options.dbname,                              username, password);
 


I think we could probably just change the expression to something like:
      options.action == ACT_LIST_DB  && options.dbname == NULL ? 
"postgres" : options.dbname


cheers

andrew



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Optional postgres database not so optional in 8.1
Next
From: "Magnus Hagander"
Date:
Subject: Re: [ADMIN] ERROR: could not read block