pgenv special keywords: earliest and latestI recently added support for two different keywords in
pgenv: earliest and latest.
The idea is quite simple: instead of having to specify each time a PostgreSQL version number to work on, you can now specify one of the above keywords to jump immediately to the oldest or newest PostgreSQL version you have installed. Of course, the newest PostgreSQL version is the most recent on a version number basis (not installation time), and on the other hand the oldest is the one with the lesser version number among those installed.
Let’s understand the concept with an example:
% pgenv versions 12.1 pgsql-12.1 12.3 pgsql-12.3 12.4 pgsql-12.4 13.0 pgsql-13.0 9.6.20 pgsql-9.6.20
Among the versions installed above, we have that:
9.6.20is the oldest one, and therefore is mapped to
13.0is the newest one, and therefore is mapped to
newest. It is quite easy to demonstrate this by means of
% pgenv use earliest PostgreSQL 9.6.20 started Logging to /home/luca/git/misc/PostgreSQL/pgenv/pgsql/data/server.log
As you can see,
earliesthas been resolved to version
9.6.20; on the other hand
latestis going to be resolved to
% pgenv use latest PostgreSQL 9.6.20 stopped PostgreSQL 13.0 started Logging to /home/luca/git/misc/PostgreSQL/pgenv/pgsql/data/server.log
But that is not enough: you can also narrow down the scope of versions to a specific major number. For instance, in the
12branch we have installed
12.4, that means that
12.1is oldest version in the twelve branch, as far as
12.4is the newest one. You can filter by a version number specifying the major version number after the
% pgenv use latest 12 PostgreSQL 13.0 stopped PostgreSQL 12.4 started Logging to /home/luca/git/misc/PostgreSQL/pgenv/pgsql/data/server.log % pgenv use earliest 12 PostgreSQL 12.4 stopped PostgreSQL 12.1 started Logging to /home/luca/git/misc/PostgreSQL/pgenv/pgsql/data/server.log
Thanks to the addition of
latestit becomes more intuitive and easy to automate
pgenvusage, so that you don’t have to remember to which version of PostgreSQL you are referring to.
Thanks to this commit, it is now possible to issue a
buildcommand using the same special keywords as above.
As an example, specifying
pgenv build latest 13will install the latest available version in the
13major release, as well as
pgenv build latestwill install the very last available version among all. The word
earliestworks the opposite, even if I believe that building the very oldest PostgreSQL version could be a good way to have fun!