Skip to content

feat(connections): connect PostgreSQL through a local Unix socket - #3721

Merged
datlechin merged 8 commits into
mainfrom
feat/3619-postgres-unix-socket
Oct 20, 2026
Merged

datlechin merged 8 commits into
mainfrom
feat/3619-postgres-unix-socket

Conversation

@datlechin

@datlechin datlechin commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • PostgreSQL gets Connect Using > Socket. The field takes the socket folder or the .s.PGSQL.<port> file and suggests /tmp and /var/run/postgresql. Port stays visible since it names the socket file. A file path is saved as its folder plus the port from its name.
  • The suggestion field is a shared SuggestionComboBox; AWSProfileField now uses it too.
  • With Socket selected, the Network tab offers only Direct and hides SSL. The connection signs in with SSL off: libpq never uses TLS on a socket.
  • The plugin passes the folder to libpq as host with hostaddr='', so an inherited PGHOSTADDR cannot switch it to TCP. A relative path, a comma, a hidden character or a socket file path over 103 bytes fails before libpq dials (PostgreSQLLocalSocket).
  • postgresql:// URLs read host= and port= from the query and a percent-encoded host (%2Ftmp), as libpq does. An empty query port means 5432; an invalid one refuses the URL. Copy Connection String writes postgresql://user@localhost[:port]/db?host=/dir.
  • ~/.pgpass matching follows libpq: /tmp as localhost, any other folder by its path, with the socket's port.
  • A blank username in ~/.pgpass lookup now means the macOS login name, as in libpq. It used to match literally.
  • The form's ~/.pgpass status line updates again; refactor refactor(connection-form): native HIG rebuild + categorized chooser sheet #995 had removed its trigger.
  • Backup and Restore pass the folder and port to pg_dump and pg_restore with -h and -p.
  • Share links carry the port. Trust, URL matching, the connection list subtitle and the external-link alert name the socket file, so two servers in one folder stay distinct.
  • iOS refuses a synced PostgreSQL socket connection, as it does a MySQL one.
  • Updated on purpose: tests that used PostgreSQL as the engine without a socket now use Redshift: NetworkPaneLocalSocketTests, SocketPathPlaceholderTests, DatabaseConnectionLocalSocketTests, ConnectionImportLinkSocketTests, ConnectionURLFormatterTests, ConnectionURLParserSocketTests, and iOS ConnectionDetailFormatterTests.

Not in this PR

  • A TCP PostgreSQL connection still follows an inherited PGHOSTADDR. Only a socket host pins hostaddr.
  • postgresql:///db with no host still asks for a host. libpq would use /tmp; left so a templating mistake is not read as a socket.
  • The socket field key is still named on MySQLLocalSocket.fieldKey. Renaming it touches about 35 files across both apps.
  • iOS shows a synced PostgreSQL socket as its folder, not the socket file with its port.
  • The Linux app was not checked for a PostgreSQL socket mode.

Test plan

  • New suites: PostgreSQLLocalSocketTests, ConnectionURLPostgreSQLSocketTests, DatabaseConnectionPostgreSQLSocketTests, NetworkPanePostgreSQLSocketTests, plus NativeDumpRegistryTests and iOS IOSDriverFactoryRefusalTests cases.
  • apple/scripts/probes/check-postgresql-local-socket.sh against PostgreSQL 17.11 listening only on its socket with peer auth confirms the libpq behavior the code relies on.
  • Real build: the form set to Socket with an empty username returns Connected from Test Connection.
  • macOS 682 + 225 cases, iOS 34 cases, lint and localization checks passed locally.

Fixes #3619

@datlechin
datlechin enabled auto-merge (squash) October 20, 2026 22:13
@datlechin
datlechin merged commit a761675 into main Oct 20, 2026
8 checks passed
@datlechin
datlechin deleted the feat/3619-postgres-unix-socket branch October 21, 2026 03:57
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 this pull request may close these issues.

Connect to a local PostgreSQL server over its Unix socket

1 participant