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

Implement a psql command. #38

Closed
wants to merge 1 commit into from
Closed

Conversation

fluca1978
Copy link
Collaborator

Could be an implementation to avoid problems reported in issue #31.
The problem is that often there is a system-wide installed PostgreSQL
and/or client interfaces (psql). When using psql the user
gets the system wide that could be incompatible with the installed PostgreSQL
version from pgenv.
Using the psql command it is possible to run the version installed along-side
the PostgreSQL version used by pgenv.

Could be an implementation to avoid problems reported in issue theory#31.
The problem is that often there is a system-wide installed PostgreSQL
and/or client interfaces (`psql`). When using `psql` the user
gets the system wide that could be incompatible with the installed PostgreSQL
version from pgenv.
Using the `psql` command it is possible to run the version installed along-side
the PostgreSQL version `use`d by pgenv.
@fluca1978
Copy link
Collaborator Author

Could it be worth making the "machinery" to allow for running any $PGDATA/bin executables?
I imagine something like:

$ pgenv use 12.0
$ pgenv cmd psql -U luca template1 # $PGDATA/bin/psql -U luca template1
$ pgenv cmd pg_config --libs            # $PGDATA/bin/pg_config --libs

so that even scripts outside the pgenv environment can get a kind of wrapper to execute "rightmost" commands against the database?

@theory
Copy link
Owner

theory commented Oct 17, 2019

Aren’t psql and pg_config already in the path after pgenv use 12.0?

@theory
Copy link
Owner

theory commented Oct 17, 2019

Could fix the original issue by pretending the pgenv path to the $PATH environment variable, rather than appending it, no?

@fluca1978
Copy link
Collaborator Author

Could fix the original issue by pretending the pgenv path to the $PATH environment variable, rather than appending it, no?

We don't modify PATH from within pgenv.
My personal usage is to have a fixed entry in my PATH that points to $PGENV_ROOT/pgsql/bin, so whenever I'm using a pgenv instance I've got preprended to any system wide path.
However, my doubt in prepending the path within the script is for external tools (e.g., testing) that could not have such variable inherited (and this is also true for your shell).
Kind of a chicken-egg problem for me to decide.

@fluca1978
Copy link
Collaborator Author

Another possible solution could be to warn the user, after a use or start if the current executable are not in the PATH. Or implement a kind of shell command that opens a new shell with all variables (PATH, PGDATA etc) set up correctly.

@theory
Copy link
Owner

theory commented Oct 20, 2019

Oh yeah, I have the path closer to the front of my $PATH variable. It think that's the way to do it. I like the idea of a warning on use or start.

@fluca1978
Copy link
Collaborator Author

See commit 5cb7d4c that warns the user if the path does not include the PGENV one or if it has another PostgreSQL binary path before.

I'm closing this PR.

@fluca1978 fluca1978 closed this Oct 21, 2019
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.

2 participants