postgresml / pgcat

PostgreSQL pooler with sharding, load balancing and failover support.
MIT License
3.13k stars 193 forks source link

#829: read/write splitting on CTE mutable statements #835

Closed jgoday closed 1 month ago

jgoday commented 1 month ago

Tries to fix #829.

Checks if a CTE query has some update/insert statements to infer primary server role (query_router::infer)

It defines a private 'query_is_mutable_statement' function to recursive check if a query contains some mutable expression (insert or update).

An additional test (test_split_cte_queries) is defined to check if a CTE query with an update statement is correctly assigned with a primary role