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

fix(cargo-pgx): on init, lazy fetch version list #119

Merged

Conversation

Hoverbear
Copy link
Contributor

@Hoverbear Hoverbear commented Apr 16, 2021

While working on https://github.com/Hoverbear/pgx/tree/nix-flake, I determined that cargo-pgx pgx init would reach to network even if passed all pg_config versions it might want.

This patch defers the network call to fetch versions until it actually needs to be done.

This means a call like

cargo-pgx pgx init --pg10 postgresql-10.16/bin/pg_config --pg11 postgresql-11.11/bin/pg_config --pg12 postgresql-12.6/bin/pg_config --pg13 postgresql-13.2/bin/pg_config

Won't necessarily reach for network.

@Hoverbear Hoverbear self-assigned this Apr 16, 2021
default_pgx
for (pgver, pg_config_path) in versions {
let config = if pg_config_path == "download" {
if default_pgx.is_none() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanna do .get_or_insert() here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially did that too! However it ends up leaving the code more complicated, since you need to deal with the error from Pgx::default(...)?.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course. LGTM as-is.

Signed-off-by: Ana Hobden <operator@hoverbear.org>
@Hoverbear Hoverbear merged commit 094ccd6 into pgcentralfoundation:develop Apr 21, 2021
Hoverbear added a commit that referenced this pull request May 1, 2021
`pgx` v0.1.21 is a minor feature release with the following features:

* aarch64 support was added (#127)
* add Nix flake (#124)
* `cargo-pgx pgx init` does `initdb` (#123)
* Improve handling of feature flags (#118)
* Allow overriding function names and returning schema-qualified type (#117)
* update dependencies (#122).
* (docs) Add caveat about reconnecting after updating extension (#116)

There were the following fixes:

* (`cargo-pgx`) on init, lazy fetch version list (#119)

To upgrade, please run:

```
$ cargo install cargo-pgx --version 0.1.21
```

Also, make sure to update your Cargo.toml dependencies.

Signed-off-by: Ana Hobden <operator@hoverbear.org>
@Hoverbear Hoverbear mentioned this pull request May 1, 2021
Hoverbear added a commit that referenced this pull request May 1, 2021
`pgx` v0.1.21 is a minor feature release with the following features:

* aarch64 support was added (#127)
* add Nix flake (#124)
* `cargo-pgx pgx init` does `initdb` (#123)
* Improve handling of feature flags (#118)
* Allow overriding function names and returning schema-qualified type (#117)
* update dependencies (#122).
* (docs) Add caveat about reconnecting after updating extension (#116)

There were the following fixes:

* (`cargo-pgx`) on init, lazy fetch version list (#119)

To upgrade, please run:

```
$ cargo install cargo-pgx --version 0.1.21
```

Also, make sure to update your Cargo.toml dependencies.

Signed-off-by: Ana Hobden <operator@hoverbear.org>
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.

None yet

2 participants