[ptop-hackers] [ANNOUNCE] PostgreSQL top (ptop) 3.6.1 Beta 3 released

Mark Wong markwkm at gmail.com
Thu Jan 31 15:12:28 UTC 2008


On Jan 31, 2008 4:42 AM, Tommy Gildseth <tommy.gildseth at usit.uio.no> wrote:
> Mark Wong wrote:
> > On Tue, 29 Jan 2008 12:44:01 +0100
> > Tommy Gildseth <tommy.gildseth at usit.uio.no> wrote
> >> Hi!
> >>
> >> In addition, I noticed that if you did not specify a database name, it
> >> would not be possible to specify a username or password, as it would
> >> pass f.ex username=foo as the database name.
> >> I've attached a patch with these changes, if you find this usefull.
> >>
> >
> > Hi Tommy,
> >
> > Thanks for the patch!  Regarding the database name, I believe what I
> > had done is when unspecified it will default to DBUSER environment or
> > the username.  I sort of forget the order of preference here.  Otherwise
> > it will use what is specified.  But maybe I screwed that up so I'll
> > take a closer look.
> Yes, the default behaviour when database name isn't specfied in the call
> to PQconnectdb is to assume the same as the user name:
> PQconnectdb:
> dbname
>     The database name. Defaults to be the same as the user name.
>
> The problem I think is that in ptop.c, you construct the
> connectionstring like this:
> sprintf(conninfo, "port=%d dbname=%s %s %s %s", dbport,
>                 dbname, socket, dbusername, password);
>
> meaning that if the dbname variable is empty, it will take one of the
> following arguments(ie. user=foo) as the database name. I couldn't find
> anywhere that any other value than "" or sprintf(dbname, "%s", optarg);
> is being assigned to dbname, so unless you explicitly supply an argument
> -U, you'll end up with a connectionstring like "port=5432 dbname="
>
> I'm guessing that if you don't specify a dbname, username or password
> (and now, socket), this works just fine, but as soon as you add f.ex a
> username after that, you get "port=5432 dbname= user=foo", which I'm
> guessing isn't quite what you intended?||||

Right, but having "dbname=" does behave as you just described, at
least on linux. :)  I don't remember if I tried it where I omit dbname
completely.

Regards,
Mark


More information about the ptop-hackers mailing list