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

Add support for Unix sockets on Windows #1199

Closed
enocom opened this issue May 5, 2022 · 2 comments · Fixed by jackc/pgconn#114
Closed

Add support for Unix sockets on Windows #1199

enocom opened this issue May 5, 2022 · 2 comments · Fixed by jackc/pgconn#114

Comments

@enocom
Copy link
Contributor

enocom commented May 5, 2022

Windows has added support for Unix sockets. Postgres also includes support for Unix sockets on Windows:

On Unix, an absolute path name begins with a slash. On Windows, paths starting with drive letters are also recognized.

Right now, pgx (through pgconn) does not support using a Unix socket on Windows and instead assumes all Unix sockets begin with a forward slash. If pgx were to change this assumption, pgx would support Unix sockets on Windows. Using a forked copy of pgconn, I've verified this change works on Windows Server 2019.

Here are the two places that would need to change:

  1. https://github.com/jackc/pgconn/blob/beb4e2cfbcd7f41e6389254496cc5feae7d99d9c/pgconn.go#L190
  2. https://github.com/jackc/pgconn/blob/84e8238fa074e88b15e2737f4d8a0a8abb1ae6bf/config.go#L106

Rather than:

if strings.HasPrefix(fb.Host, "/") {
  // ...
}

The code could be:

if strings.HasPrefix(fb.Host, "/") || isWindowsPath(fb.Host) {
  // ...
}

where isWindowsPath checks if the provided string begins with a capital letter A-Z followed by a colon and a backslash (e.g., C:\).

Would there be any interest in accepting this feature request?

@jackc
Copy link
Owner

jackc commented May 6, 2022

Sounds good to me.

@enocom
Copy link
Contributor Author

enocom commented May 6, 2022

I'll send a PR.

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

Successfully merging a pull request may close this issue.

2 participants