Unix Technical Forum

Optional postgres database not so optional in 8.1

This is a discussion on Optional postgres database not so optional in 8.1 within the pgsql Hackers forums, part of the PostgreSQL category; --> On Fri, 18 Nov 2005 05:29 am, Tom Lane wrote: > It does seem a bit inconsistent that psql ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 04-11-2008, 06:51 AM
Philip Yarra
 
Posts: n/a
Default Re: Optional postgres database not so optional in 8.1

On Fri, 18 Nov 2005 05:29 am, Tom Lane wrote:
> 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?


It also breaks the ability to psql -l against older installations: e.g. this
is psql 8.1 trying to list databases on a 8.0.3 DB server:

$ psql -l -hdev2 -dtemplate1
psql: FATAL: database "postgres" does not exist

I'm told we never promise to make \l and \d work across client/server
versions, but if this is related, it'd be nice if the fix made this work
again too.

Regards, Philip.
--

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan

-----------------
Utiba Pty Ltd
This message has been scanned for viruses and
dangerous content by Utiba mail server and is
believed to be clean.


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-11-2008, 06:51 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Optional postgres database not so optional in 8.1



Andrew Dunstan wrote:

>>
>> 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?
>>
>>

>
>
> options.action == ACT_LIST_DB && options.dbname == NULL ?
> "postgres" : options.dbname
>


Tested, and worked fine.

Committed on Head and 8.1 branches.

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 04-11-2008, 06:52 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Optional postgres database not so optional in 8.1


I now notice that "pg_ctl -w start" fails if the postgres db is missing.
I am not sure that changing pg_ctl to use this rather than template1 was
a good thing, and it can't be overridden. I suggest we revert that
particular change - it seems to me to confer little to no benefit,
unlike the case with createdb etc.

cheers

andrew



Andrew Dunstan wrote:

>
>
> Andrew Dunstan wrote:
>
>>>
>>> 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?
>>>
>>>

>>
>>
>> options.action == ACT_LIST_DB && options.dbname == NULL ?
>> "postgres" : options.dbname
>>

>
> Tested, and worked fine.
>
> Committed on Head and 8.1 branches.
>
> cheers
>
> andrew
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 04-11-2008, 06:52 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Optional postgres database not so optional in 8.1



Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>
>
>>I now notice that "pg_ctl -w start" fails if the postgres db is missing.
>>I am not sure that changing pg_ctl to use this rather than template1 was
>>a good thing, and it can't be overridden. I suggest we revert that
>>particular change - it seems to me to confer little to no benefit,
>>unlike the case with createdb etc.
>>
>>

>
>pg_ctl -w is already incredibly fragile because it needs a working
>password-free login name. Rather than worrying about whether the
>database name exists, what we ought to do is invent the long-awaited
>"ping" extension to the postmaster protocol --- something that would
>just ask "are you up and ready to accept connections" without having
>to specify a valid user *or* database name.
>
>You can sort of do this today if you are willing to examine the error
>message that comes back from the postmaster, but I think it'd be cleaner
>to have an official protocol extension.
>
>



Actually, it looks like pg_ctl already does this:

if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
"postgres", NULL, NULL)) != NULL &&
(PQstatus(conn) == CONNECTION_OK ||
(strcmp(PQerrorMessage(conn),
PQnoPasswordSupplied) == 0)))
{
PQfinish(conn);
success = true;
break;
}


cheers

andrew


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 04-11-2008, 06:52 AM
Tom Lane
 
Posts: n/a
Default Re: Optional postgres database not so optional in 8.1

Andrew Dunstan <andrew@dunslane.net> writes:
> I now notice that "pg_ctl -w start" fails if the postgres db is missing.
> I am not sure that changing pg_ctl to use this rather than template1 was
> a good thing, and it can't be overridden. I suggest we revert that
> particular change - it seems to me to confer little to no benefit,
> unlike the case with createdb etc.


pg_ctl -w is already incredibly fragile because it needs a working
password-free login name. Rather than worrying about whether the
database name exists, what we ought to do is invent the long-awaited
"ping" extension to the postmaster protocol --- something that would
just ask "are you up and ready to accept connections" without having
to specify a valid user *or* database name.

You can sort of do this today if you are willing to examine the error
message that comes back from the postmaster, but I think it'd be cleaner
to have an official protocol extension.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #16 (permalink)  
Old 04-11-2008, 07:07 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Optional postgres database not so optional in 8.1


I never saw a followup to this. Is someone working on a ping protocol
extension, or should we revert pg_ctl to using template1 on the ground
that it does a poor man's ping anyway?

cheers

andrew

Andrew Dunstan wrote:

>
>
> Tom Lane wrote:
>
>> Andrew Dunstan <andrew@dunslane.net> writes:
>>
>>
>>> I now notice that "pg_ctl -w start" fails if the postgres db is
>>> missing. I am not sure that changing pg_ctl to use this rather than
>>> template1 was a good thing, and it can't be overridden. I suggest we
>>> revert that particular change - it seems to me to confer little to
>>> no benefit, unlike the case with createdb etc.
>>>

>>
>>
>> pg_ctl -w is already incredibly fragile because it needs a working
>> password-free login name. Rather than worrying about whether the
>> database name exists, what we ought to do is invent the long-awaited
>> "ping" extension to the postmaster protocol --- something that would
>> just ask "are you up and ready to accept connections" without having
>> to specify a valid user *or* database name.
>>
>> You can sort of do this today if you are willing to examine the error
>> message that comes back from the postmaster, but I think it'd be cleaner
>> to have an official protocol extension.
>>
>>

>
>
> Actually, it looks like pg_ctl already does this:
>
> if ((conn = PQsetdbLogin(NULL, portstr, NULL, NULL,
> "postgres", NULL, NULL)) != NULL &&
> (PQstatus(conn) == CONNECTION_OK ||
> (strcmp(PQerrorMessage(conn),
> PQnoPasswordSupplied) == 0)))
> {
> PQfinish(conn);
> success = true;
> break;
> }
>
>


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:32 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com