Re: Connection without database name

Lists: pgsql-hackers
From: Michael Meskes <meskes(at)postgresql(dot)org>
To: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Connection without database name
Date: 2004-12-23 09:46:26
Message-ID: 20041223094626.GA12781@1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Very early in its existance ecpg got an oracle compat hack that enabled
it to do a connect with just the username and use the database as
specified via PGDATABASE. It appears that this feature is not really
used as it seems it segfault for quite some amount of releases.

While trying ot fix it I found that the libpq function does not seem to
look for the environment anymore. Or is this an additional bug in my
library. Anyone, while it doesn't dump core anymore it still doesn't
work and I wonder if it's worth the hassle.

Does anyone object against removing this completely for 8.0?

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Connection without database name
Date: 2004-12-23 15:35:52
Message-ID: 28693.1103816152@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Meskes <meskes(at)postgresql(dot)org> writes:
> Very early in its existance ecpg got an oracle compat hack that enabled
> it to do a connect with just the username and use the database as
> specified via PGDATABASE. It appears that this feature is not really
> used as it seems it segfault for quite some amount of releases.

> While trying ot fix it I found that the libpq function does not seem to
> look for the environment anymore.

Sure it does.

$ PGDATABASE=foo psql
psql: FATAL: database "foo" does not exist
$ PGDATABASE=template1 psql
Welcome to psql 8.0.0rc2, the PostgreSQL interactive terminal.
...

regards, tom lane


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Connection without database name
Date: 2004-12-23 16:03:01
Message-ID: 20041223160300.GA55796@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 23, 2004 at 10:46:26AM +0100, Michael Meskes wrote:

> Very early in its existance ecpg got an oracle compat hack that enabled
> it to do a connect with just the username and use the database as
> specified via PGDATABASE. It appears that this feature is not really
> used as it seems it segfault for quite some amount of releases.

The following works for me in 8.0.0rc2 and 7.4.6, making the
connection based on PGDATABASE, PGUSER, etc.:

EXEC SQL BEGIN DECLARE SECTION;
char *target = "";
EXEC SQL END DECLARE SECTION;

EXEC SQL CONNECT TO :target;

The following, however, dumps core with a segmentation fault:

EXEC SQL CONNECT TO DEFAULT;

Here's a backtrace from 8.0.0rc2:

#0 0x280d5dcc in strdup () from /usr/lib/libc.so.4
#1 0x2806efac in ECPGconnect (lineno=17, c=0, name=0x0, user=0x0, passwd=0x0,
connection_name=0x8048800 "DEFAULT", autocommit=0) at connect.c:245
#2 0x804864e in main () at conntest.pgc:17

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/