Skip to content

Add `QueryAnalyzer` to have a single approach to hook all analyzers

Kamil Trzciński requested to merge implement-query-analyzers into master

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:

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.

Edited by Dylan Griffith

Merge request reports