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

[#292] Provide application version as a numeric value too #293

Closed
wants to merge 1 commit into from

Conversation

fluca1978
Copy link
Collaborator

This commit introduces two compile time macros:

  • PGAGROAL_VERSION is a string and contains the application version
    that will be shown in various application messages.
  • PGAGROAL_VERSION_NUM is a numeric value that can be used to compare
    the running version with another number, so for example to limit
    features or messages.

PGAGROAL_VERSION replaces the VERSION macro that was defined in
the main header file.

Moreover, the message printed at level INFO when booting the pooler
has been enhanced to show also the version that is starting, like for
instance:
pgagroal: v1.5.0 started on *:5432

See #253, #289, #290

Close #292

This commit introduces two compile time macros:
- PGAGROAL_VERSION is a string and contains the application version
that will be shown in various application messages.
- PGAGROAL_VERSION_NUM is a numeric value that can be used to compare
the running version with another number, so for example to limit
features or messages.

`PGAGROAL_VERSION` replaces the `VERSION` macro that was defined in
the main header file.

Moreover, the message printed at level INFO when booting the pooler
has been enhanced to show also the version that is starting, like for
instance:
    pgagroal: v1.5.0 started on *:5432

See agroal#253, agroal#289, agroal#290

Close agroal#292
@jesperpedersen
Copy link
Collaborator

jesperpedersen commented Jul 28, 2022

Lets do

PGAGROAL_VERSION_MAJOR 1
PGAGROAL_VERSION_MINOR 5
PGAGROAL_VERSION_PATCH 0

instead.

And, remove the v from the startup message

@fluca1978
Copy link
Collaborator Author

I've seen that in CmakeLists.txt there is already all the stuff we need: https://github.com/agroal/pgagroal/blob/master/CMakeLists.txt#L6. Cannot we declare that as compile time macros and use them within the program instead of defining again them in the source files?

By the way, I've already all the code for using three constants and functions to convert them into a unique number and string, so it just a matter of taste.

@jesperpedersen
Copy link
Collaborator

Yeah, we can use the constants from CMakeLists.txt

fluca1978 added a commit to fluca1978/pgagroal that referenced this pull request Jul 28, 2022
Three new constants are introduced here:
- PGAGROAL_MAJOR_VERSION (number)
- PGAGROAL_MINOR_VERSION (number)
- PGAGROAL_PATCH_VERSION (number)
- PGAGROAL_VERSION       (string)

that represent, as integer literals and string composition,
the parts of the version number.
The values are copied from the variables in the `CmakeLists.txt` file
that creates the building flow, so changing the values in a single
place changes and propagates the changes all over the source code.

A few utility functions have been introduced to compose the three
constant into a unique number that can be used to compare the version
currently running, so that features and/or message can be targeted as
conditionals.

Introduced functions are:
- pgagroal_version_as_number() returns an unique sortable version
number. For example, version 1.5.0 is returned as 15000, version 1.6.2
as 16002, and so on;
- pgagroal_version_number() returns the currently running version
number, that is invokes pgagroal_version_as_number() with the
predefined constants.

The `pgagroal_version_as_number()` accepts individual values, while
`pgagroal_version_number()` provides the currently running version
number. The idea is that, thanks to both the functions, it is possible
to check for a feature that depends on a version in a way like the
following one:

   if (pgagroal_version_numer() >=
             pgagroal_version_as_number(2,1,0))
       // version is greater than 2.1.0 !

The utility function `pgagroal_version_ge()` does exactly the above:
it accepts the three parts of a version number and checks if the
currently running version is greater or equal (hence, 'ge') of the
specified triplet, so that the above piece of code becomes:

   if (pgagroal_version_ge(2,1,0))
     // version greater or equal 2.1.0

Close agroal#292
See agroal#253, agroal#289, agroal#290, agroal#293
fluca1978 added a commit to fluca1978/pgagroal that referenced this pull request Jul 28, 2022
Three new constants are introduced here:
- PGAGROAL_MAJOR_VERSION (number)
- PGAGROAL_MINOR_VERSION (number)
- PGAGROAL_PATCH_VERSION (number)
- PGAGROAL_VERSION       (string)

that represent, as integer literals and string composition,
the parts of the version number.
The values are copied from the variables in the `CmakeLists.txt` file
that creates the building flow, so changing the values in a single
place changes and propagates the changes all over the source code.

A few utility functions have been introduced to compose the three
constant into a unique number that can be used to compare the version
currently running, so that features and/or message can be targeted as
conditionals.

Introduced functions are:
- pgagroal_version_as_number() returns an unique sortable version
number. For example, version 1.5.0 is returned as 15000, version 1.6.2
as 16002, and so on;
- pgagroal_version_number() returns the currently running version
number, that is invokes pgagroal_version_as_number() with the
predefined constants.

The `pgagroal_version_as_number()` accepts individual values, while
`pgagroal_version_number()` provides the currently running version
number. The idea is that, thanks to both the functions, it is possible
to check for a feature that depends on a version in a way like the
following one:

   if (pgagroal_version_numer() >=
             pgagroal_version_as_number(2,1,0))
       // version is greater than 2.1.0 !

The utility function `pgagroal_version_ge()` does exactly the above:
it accepts the three parts of a version number and checks if the
currently running version is greater or equal (hence, 'ge') of the
specified triplet, so that the above piece of code becomes:

   if (pgagroal_version_ge(2,1,0))
     // version greater or equal 2.1.0

Close agroal#292
See agroal#253, agroal#289, agroal#290, agroal#293
@fluca1978
Copy link
Collaborator Author

Work discarded, see #294.

@fluca1978 fluca1978 closed this Jul 28, 2022
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.

Make the version number comparable
2 participants