PostgreSQL SQLSTATE rule operation

Prev Next

As PostgreSQL error codes are reported alphanumerically, a new rule identifier has been added to allow targeting of these PostgreSQL SQLSTATE error codes in Database Activity Monitoring custom rules.

When creating custom rules, this new identifier appears in the rule dropdown as a selection choice. The new rule identifier operates as a string and can be used to check against SQL states including error codes returned from PostgreSQL query executions.

Use the new rule identifier, postgres_sqlstate, to create custom rules related to PostgreSQL SQLSTATE codes.

Rule identifier limitations

Monitoring a DBMS with Database Activity Monitoring is possible with memory monitoring and with network monitoring. The DBMS monitoring type determines what rule identifiers are available for use with that monitoring type.

Some rule identifiers such as error_code will work only over network monitoring, while some others like postgres_sqlstate will work only over memory monitoring. Creating rules with mixed network monitoring rule identifiers and memory monitoring rule identifiers are not supported and must be avoided.

Rule examples

An example of the unsupported rule, mixing memory and network rule identifiers, is:

  • error_code > 42 OR postgres_sqlstate LIKE '42%'

An alternative to this mixed rule would be two separate rules installed only on the DBMSs on which they can operate. The first rule would check for the error_code and be installed only on the DBMSs with network monitoring enabled. An example of this is:

  • error_code > 42

The second rule would check for the postgres_sqlstate and be installed only on the DBMSs with memory monitoring enabled. An example of this is:

  • postgres_sqlstate LIKE '42%'