There's more...

There is one caveat to this functionality. It is not uncommon for databases to perform the write activity within a function body. For example:

CREATE FUNCTION test_insert() 
RETURNS VOID AS 
$$ 
  INSERT INTO foo SELECT generate_series(1, 100); 
$$ LANGUAGE SQL; 

By creating this function, we obfuscate the INSERT statement enough that pgpool won't recognize it. This means that pgpool will improperly send the query to a read-only server and produce an error. We can avoid this by using the black_function_list configuration setting. For example, if we add our new function to this setting, it resembles this:

black_function_list = 'currval,lastval,nextval,setval,test_insert' 

Now, pgpool will understand that queries that include a ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.