diff --git a/notifier/query_exclusion.rb b/notifier/query_exclusion.rb index 004ba2aa81e46e73c4388e9575d291245bbef2d8..81977dd3d65b72698c32b6d95060c1d73373e65f 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 19561499baa7531d5492c2352bdadea4b476090e..8bdb8711b5d5f9673033bf4966a10cc35e9a189f 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;"