Closed Bug 301676 Opened 19 years ago Closed 17 years ago

[PostgreSQL] Bugzilla::DB::Pg does not support using a local socket

Categories

(Bugzilla :: Database, defect)

2.20
All
Linux
defect
Not set
minor

Tracking

()

RESOLVED FIXED
Bugzilla 3.0

People

(Reporter: ondrej, Assigned: emmanuel)

References

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b3) Gecko/20050712 Firefox/1.0+
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b3) Gecko/20050712 Firefox/1.0+

It is a common case to set $db_host = '' when I want to use local (UNIX) sockets
to connect to postgres server. It seems to me you have a bug in the connect()
that disallows using empty host. It leads checksetup.pl to output:
Can't connect to the database.
Error: could not translate host name "dbname=template1" to address: Name or
service not known
  Is your database installed and up and running?
  Do you havethe correct username and password selected in localconfig?
I think there is something like pg_connect("dbhost=$db_host dbname=template1
dbuser...");
You should check db_host for empty string and ommit the dbhost part.

Reproducible: Always

Steps to Reproduce:
1.edit localconfig file
2.set $db_host = '';
3.run ./checksetup.pl

Actual Results:  
Error: could not translate host name "dbname=template1" to address: Name or
service not known
  Is your database installed and up and running?
  Do you havethe correct username and password selected in localconfig?

Expected Results:  
Connect to database template1 using local socket.
Version: unspecified → 2.20
I have to mark this bug as a blocker as it prevents me from testing without
changing my server's configuration.
For those who need a workaround and have no problem with modifying their
configuration:
set $db_host = 'localhost';
and add this line to your pg_hba.conf
host $db_name $db_user 127.0.0.1/32 md5
host template1 $db_user 127.0.0.1/32 md5

replace variables with values from your config.
Severity: normal → blocker
It's quite common to have to turn on listening on localhost for Pg. The docs
(which are forthcoming) specify that you have to do it. You have to change the
configuration anyhow, to allow access for the "bugs" user.

Bugzilla::DB::Pg does not currently use/support $db_sock, it's true.

That would be a valid enhancement for 2.22.
Severity: blocker → minor
Status: UNCONFIRMED → NEW
Ever confirmed: true
Hardware: PC → All
Summary: Postgres configuration should allow empty db_host → [PostgreSQL] Bugzilla::DB::Pg does not support using a local socket
Target Milestone: --- → Bugzilla 2.22
It's quite common that admins don't want to allow listening on localhost in
Postgres.
Yeah. And I plan to implement the ability to do that for 2.22. The patch will go
on this bug, when it happens, most likely, so you can probably apply the patch
to a 2.20 installation if you desire.
Blocks: meta-pg
We are freezing the code for 3.0 in two weeks and we don't expect this bug to be fixed on time.
Target Milestone: Bugzilla 2.22 → ---
I actually ought to fix this for 3.0.
Assignee: database → mkanat
Target Milestone: --- → Bugzilla 3.0
Taking
Status: NEW → ASSIGNED
Attachment #274061 - Flags: review?
I didn't see what I was assigning to mkanat.
Sorry for the spam.
Assignee: mkanat → eseyman
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Attachment #274061 - Attachment is patch: true
Attachment #274061 - Attachment mime type: text/x-patch → text/plain
Comment on attachment 274061 [details] [diff] [review]
Patch to use the default local domain socket when no hostname is specified

Sure, works for me.
Attachment #274061 - Flags: review? → review+
Comment on attachment 274061 [details] [diff] [review]
Patch to use the default local domain socket when no hostname is specified

>--- ./Bugzilla/DB/Pg.pm.301676	2007-07-26 22:12:24.000000000 +0200
>+    my $dsn = "DBI:Pg";
>+    $dsn .= ":dbname=$dbname";

  These two lines don't have to be separate, though. That can be fixed on checkin.
This is a small change for a useful gain, so it's OK for 3.0 also.
Flags: approval3.0+
Flags: approval+
tip:

Checking in Bugzilla/DB/Pg.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Pg.pm,v  <--  Pg.pm
new revision: 1.24; previous revision: 1.23
done

3.0:

Checking in Bugzilla/DB/Pg.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Pg.pm,v  <--  Pg.pm
new revision: 1.23.2.1; previous revision: 1.23
done
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: