Result set filter - Postgres

A result set filter gets invoked whenever a result set is being sent by the database server. Result set filters can modify the result set, hide or add rows, modify specific values, etc... The only limitations are typically that you do not want to confuse the database client, which expects data to look a certain way.

Each packet represents a row in a result set.

Parameters

  • User pattern : optional. If specified, only execute the filter if the current database user matches the specified user(s). If the given value starts with regex: then the rest of the value is compiled as a Java regular expression. For instance: regex:(jdoe)|(anewman)

  • Schema pattern : optional. If specified, only execute the filter if the result set contains at least one column from a table in the specified schema(s). If the given value starts with regex: then the rest of the value is compiled as a Java regular expression. For instance: regex:(accounting)|(acct_\p{Alnum}+)

  • Table pattern : optional. If specified, only execute the filter if the result set contains at least one column from the specified table(s). If the given value starts with regex: then the rest of the value is compiled as a Java regular expression. For instance: regex:(customers)|(cust_[0-9]+)

  • Column pattern : optional. If specified, a semicolon-separated list of <name>=<value> pairs, where name is the name of a column, and value is a string representation of a value. For instance: country=US;state=MN;county=Hennepin

  • columnsAndOr : defaults to and. If Column pattern was specified, and there is more than one <name>=<value> pair, specify whether these should be and'ed or or'ed.

  • Query pattern : optional. If specified, specify which SQL query should be active for this filter to be executed. If the given value starts with regex: then the rest of the value is compiled as a Java regular expression. For instance: regex:^select.+from (customers)|(cust_[0-9]+).*

  • action : what to do if the row matches. The default is code, which executes the JavaScript code, the other option is hide, in which case the row will be ignored and not passed on to the database client.

Context

The usual context.packet variable will always be a DataRow packet.