Opened 11 years ago

Closed 11 years ago

#647 closed defect (fixed)

Connection incorrectly requires a database named the same as the user name to exist

Reported by: Mike Toews Owned by: brentrobinson
Priority: major Milestone: 3.6.0
Component: PostgreSQL Provider Version: 3.4.0
Severity: 3 Keywords:
Cc: External ID:

Description

When attempting to connect to an OSGeo FDO Provider for PostgreSQL with a role without a self-named database, for example:

CREATE ROLE foouser LOGIN PASSWORD 'foopass' CREATEDB;

any attempt to make a connection in AutoCAD Map 3D 2011 has an error:

  • Login Failed: The specified credentials are not valid or the provider is unable to establish a connection

while the database log has the errors:

2010-05-10 18:38:21 PDT FATAL:  database "foouser" does not exist
2010-05-10 18:38:21 PDT FATAL:  database "foouser" does not exist

This type of error has a similar appearance as trying to connect from command-line using psql:

$ psql -U foouser
Password for user foouser:
psql: FATAL:  database "foouser" does not exist

since if no database is specified, then it is assumed to be self-named.

With libpq, the default database should be "postgres", since it exists and anyone can connect to it. Although I have not inspected the FDO code in detail, I suspect a default dbname is not supplied. See http://www.postgresql.org/docs/8.4/static/libpq-connect.html

An example: http://www.postgresql.org/docs/8.4/static/libpq-example.html

Change History (5)

comment:1 Changed 11 years ago by Mike Toews

As a workaround, either:

  • Use the postgres superuser account if you are the only user on the system
  • Create a dbname the same as your username

comment:2 Changed 11 years ago by Mike Toews

Summary: Use default dbname=postgresConnection incorrectly requires a database named the same as the user name to exist

comment:3 Changed 11 years ago by gregboone

Owner: changed from badreddinekaroui to brentrobinson

comment:4 Changed 11 years ago by brentrobinson

Status: newassigned

comment:5 Changed 11 years ago by brentrobinson

Resolution: fixed
Status: assignedclosed

Revision: 5789 Author: brentrobinson Date: 9:52:04 AM, Wednesday, November 03, 2010 Message: Ticket#647: Changed PostgreSQL provider behaviour for connecting when datastore connection parameter is not specified. Previously, the connection to the PostgreSQL (via PQsetdbLogin) was done with database=NULL, meaning that the database defaulted to one named the same as the user. However, the connect fails if no such database exists.

The fix was to connect to the postgres database when the datastore is not specified. In PostgreSQL 8.4, this database is always present and all users have access to it. However, to be on the safe side, if the connect fails, a 2nd connect with the original behaviour (database=NULL) is tried.


Modified : /trunk/Providers/GenericRdbms/Src/PostGis/Driver/connect.c Modified : /trunk/Providers/GenericRdbms/Src/PostGis/Driver/connect.h

Note: See TracTickets for help on using tickets.