EPUB | CHM | PDF

TPSQLDatabase.Properties.ClientVersionAsInt

Top Previous Next

Returns the version of libpq PostgreSQL client library that is being used.

Syntax:

property ClientVersionAsInt: integer;

Description:

The result of this property can be used to determine, at run time, if specific functionality is available in the currently loaded version of libpq. The property can be used, for example, to determine which connection options are available or if the hex bytea output added in PostgreSQL 9.0 is supported.

The number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 9.1 will be returned as 90100, and version 9.1.2 will be returned as 90102 (leading zeroes are not shown).

If no library loaded yet then property returns InvalidOID value, which is 0.

Example:

This example checks if server supports tablespaces:

procedure TForm1.Button2Click(Sender: TObject);
begin
  if PSQLDatabase1.ClientVersionAsInt >= 090000 then // v.8.0.0 or greater
   ShowMessage('hex bytea output supported')
  else
   if PSQLDatabase1.ClientVersionAsInt = InvalidOID then 
   LoadPSQLLibrary();
end;