From 9e87968e2f843feb644a68f790d5c5c6f7515e94 Mon Sep 17 00:00:00 2001 From: Pavel Shutsin Date: Mon, 28 Nov 2022 15:19:03 +0100 Subject: [PATCH] Add select postgres partition query to exclusion list --- notifier/query_exclusion.rb | 3 ++- notifier/spec/query_exclusion_spec.rb | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/notifier/query_exclusion.rb b/notifier/query_exclusion.rb index 004ba2aa..81977dd3 100644 --- a/notifier/query_exclusion.rb +++ b/notifier/query_exclusion.rb @@ -16,7 +16,8 @@ class QueryExclusion "SELECT current_database()", "SELECT $1", "SELECT current_schema", - "SELECT \"postgres_async_indexes\".* FROM \"postgres_async_indexes\" WHERE \"postgres_async_indexes\".\"name\" = $1 LIMIT $2" + "SELECT \"postgres_async_indexes\".* FROM \"postgres_async_indexes\" WHERE \"postgres_async_indexes\".\"name\" = $1 LIMIT $2", + "SELECT $1 AS one FROM \"postgres_partitions\" WHERE (identifier = concat(current_schema(), $2, $3)) LIMIT $4" ].map { |q| PgQuery.parse(q).deparse.downcase }.freeze # rubocop:enable Layout/LineLength diff --git a/notifier/spec/query_exclusion_spec.rb b/notifier/spec/query_exclusion_spec.rb index 19561499..8bdb8711 100644 --- a/notifier/spec/query_exclusion_spec.rb +++ b/notifier/spec/query_exclusion_spec.rb @@ -34,6 +34,13 @@ RSpec.describe QueryExclusion do expect(described_class.exclude?(query)).to be true end + it 'is true if query table is postgres_partitions' do + query = + "SELECT $1 AS one FROM \"postgres_partitions\" WHERE (identifier = concat(current_schema(), $2, $3)) LIMIT $4" + + expect(described_class.exclude?(query)).to be true + end + it 'is false for other queries' do query = "SELECT * from user;" -- GitLab