Skip site navigation (1) Skip section navigation (2)

Re: Connection without database name

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 (view raw or flat)
Thread:
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/

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2004-12-23 16:05:35
Subject: Re: Bgwriter behavior
Previous:From: Tom LaneDate: 2004-12-23 15:48:39
Subject: Re: join selectivity

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group