Make support/pg_bindir search for target PostgreSQL version
What does this merge request do and why?
Previously support/pg_bindir would return whatever version of
PostgreSQL was available in the local path. For asdf users, this
worked fine since .tool-versions specifies the target PostgreSQL
version (14.9 currently). However, for users of Homebrew or other
package managers, support/pg_bindir returns whatever is listed in
PATH, which could be a stale version of PostgreSQL.
To fix this, we reuse the logic in the PostgreSQL upgrader, which looks for specific versions based on the package manager available (Homebrew, apt, rtx). We then use the target version as the current bin dir, and only fallback to whatever is in the PATH if the target version isn't available.
How to set up and validate locally
On macOS:
- Disable
asdfby dropping it from the PATH. - Attempt to run
support/pg_bindir. This should return an error if no PostgreSQL version is available. - Run
brew install postgresql@13. - Run
support/pg_bindir. This should throw an error since PostgreSQL 14 is still not installed. - Run
brew install postgresql@14. - This should print
/opt/homebrew/Cellar/postgresql@14/14.9/bin.
Impacted categories
The following categories relate to this merge request:
-
gdk-reliability - e.g. When a GDK action fails to complete. -
gdk-usability - e.g. Improvements or suggestions around how the GDK functions. -
gdk-performance - e.g. When a GDK action is slow or times out.
Merge request checklist
-
This change is backward compatible. If not, please include steps to communicate to our users. -
Tests added for new functionality. If not, please raise an issue to follow-up. -
Documentation added/updated, if needed. -
Announcement added, if change is notable. -
gdk doctortest added, if needed. -
Add the ~highlightlabel if this MR should be included in theCHANGELOG.md.
Edited by Stan Hu