PostgreSQL 11 Administration Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it…

Unfortunately, there isn't a single function or parameter that works on each variant of PostgreSQL and at the same time is able to answer that question. The closest you can get is the version() function that is used in the next recipe, What version is the server?, which returns a textual description of the version you are running, including (but not limited to) the version number.

In some cases, this is enough, but otherwise, you have to determine the specific version from other clues, such as the following:

  • The version number for stable releases of community PostgreSQL is either X.Y (with X=10 or above) or X.Y.Z (up to X=9). An extra number usually indicates that you are running a variant of PostgreSQL.
  • The presence of certain objects that are available only on a specific variant, for instance an extension. More details on how to work with extensions can be found in the Listing extensions in this database recipe in this chapter.