Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong error message while PG.connect on Windows #404

Closed
larskanis opened this issue Oct 4, 2021 · 3 comments
Closed

Wrong error message while PG.connect on Windows #404

larskanis opened this issue Oct 4, 2021 · 3 comments

Comments

@larskanis
Copy link
Collaborator

larskanis commented Oct 4, 2021

On Windows the async API doesn't raise a correct error message. If a wrong database name was provided this looks like so:

$ irb -Ilib -rpg
irb(main):001:0> c=PG.connect dbname:'Entwicklun'
c:/Users/kanis/ruby-pg/lib/pg/connection.rb:509:in `async_connect_or_reset': server closed the connection unexpectedly (PG::ConnectionBad)
        This probably means the server terminated abnormally
        before or while processing the request.
        from c:/Users/kanis/ruby-pg/lib/pg/connection.rb:529:in `async_connect'
        from c:/Users/kanis/ruby-pg/lib/pg.rb:67:in `connect'
        from (irb):1:in `<main>'
        from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in `<top (required)>'
        from C:/Ruby30-x64/bin/irb.cmd:31:in `load'
        from C:/Ruby30-x64/bin/irb.cmd:31:in `<main>'

irb(main):002:0> PG::Connection.async_api=false
irb(main):003:0> c=PG.connect dbname:'Entwicklun'
c:/Users/kanis/ruby-pg/lib/pg.rb:67:in `initialize': FATAL:  Datenbank \xBBEntwicklun\xAB existiert nicht (PG::ConnectionBad)
        from c:/Users/kanis/ruby-pg/lib/pg.rb:67:in `new'

In contrast it raises the right message when async_api=false is set or when running on Linux.

@larskanis
Copy link
Collaborator Author

This issue is discussed in postgresql hackers list here: https://www.postgresql.org/message-id/90b34057-4176-7bb0-0dbb-9822a5f6425b%40greiz-reinsdorf.de

@larskanis
Copy link
Collaborator Author

It only happens when both client and server are running on Windows.

@larskanis
Copy link
Collaborator Author

The patch has landed on postgres master branch and will be backported to all active branches. See postgres/postgres@4cd2928

larskanis added a commit that referenced this issue Jan 7, 2022
The fix is on postgres master and is backported to all active branches.
See postgres/postgres@4cd2928
and #404
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant