Add `QueryAnalyzer` to have a single approach to hook all analyzers
What does this MR do and why?
This is used initially for !73839 (merged). !73839 (merged) is dependent on this MR so this MR needs to be merged first.
There appears to be a problem with how and where we hook all pg_query
validations.
There's a lot of reinventing a wheel many times, each one implementing things on its own.
This has been seen in:
- !73316 (diffs, comment 725070532)
- !71540 (closed)
- and
spec/support/database/prevent_cross_joins.rb
We want some of those to be run in production based on some criteria (percentage rollout?) which will create another set of duplication.
This tries to provide a central approach of QueryAnalyzer
that leverages pg_query
and can run many analyzers that just implement analyze, but might be configured in any way.
This effectively hooks a single subscriber that is no-op if no analyzer is enabled. The enabled flag is evaluated at runtime.
Example implementation of analyzer here: !71540 (diffs).
In current configuration this is not yet enabled in production, only dev/test. This would be next step after this MR gets merged.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.