Thread: Connection without database name
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@jabber.org Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
Michael Meskes <meskes@postgresql.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
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/