Skip to content

Connection to empty hostname fails #471

@larskanis

Description

@larskanis

pg-1.4.1 fails to connect to UnixSocket, when host is given but empty:

3.1.2 :002 > PG::VERSION
 => "1.4.1" 
3.1.2 :003 > PG.connect(host: "")
/home/local/COMCARD-NT/kanis/.rvm/gems/ruby-3.1.2/gems/pg-1.4.1/lib/pg/connection.rb:740:in `connect_to_hosts': PG::ConnectionBad
	from /home/local/COMCARD-NT/kanis/.rvm/gems/ruby-3.1.2/gems/pg-1.4.1/lib/pg/connection.rb:661:in `new'
	from /home/local/COMCARD-NT/kanis/.rvm/gems/ruby-3.1.2/gems/pg-1.4.1/lib/pg.rb:69:in `connect'
	from (irb):3:in `<main>'
	from /home/local/COMCARD-NT/kanis/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
	from /home/local/COMCARD-NT/kanis/.rvm/rubies/ruby-3.1.2/bin/irb:25:in `load'
	from /home/local/COMCARD-NT/kanis/.rvm/rubies/ruby-3.1.2/bin/irb:25:in `<main>'
3.1.2 :004 > PG.connect
 => #<PG::Connection:0x00007fb7d215c048 @last_status=4> 
3.1.2 :005 > 

This is a regression of pg-1.4.0 to 1.4.1. It succeeds in pg-1.3.5:

3.1.2 :002 > PG::VERSION
 => "1.3.5" 
3.1.2 :003 > PG.connect(host: "")
 => #<PG::Connection:0x00007fcd0544aa50> 
3.1.2 :004 > PG.connect
 => #<PG::Connection:0x00007fcd053991b0> 
3.1.2 :005 > 

OS: Ubuntu-22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions