packages feed

sydtest-persistent-postgresql 0.5.2.0 → 0.5.3.0

raw patch · 4 files changed

+509/−1 lines, 4 files

Files

CHANGELOG.md view
@@ -1,5 +1,17 @@ # Changelog +## [0.5.3.0] - 2026-11-13++### Added++* `Test.Syd.Persistent.Postgresql.RedundantIndices.shouldHaveNoRedundantIndices`,+  to assert that a schema has no index that another index covers: a second+  index on the same columns, or an index on the leading columns of a longer+  one such as a unique constraint. Every write maintains such an index while+  the planner gains nothing from it, and `CREATE INDEX IF NOT EXISTS` cannot+  notice one because it matches on the name. The failure lists the definition+  of every redundant index and of the indices that cover it.+ ## [0.5.2.0] - 2026-09-26  ### Fixed
+ src/Test/Syd/Persistent/Postgresql/RedundantIndices.hs view
@@ -0,0 +1,130 @@+{-# LANGUAGE OverloadedStrings #-}++-- | Assert that a schema has no index that another index makes unnecessary.+--+-- 'CREATE INDEX IF NOT EXISTS' matches on the name, so nothing in PostgreSQL+-- stops a schema from growing an index that another one already covers: a+-- second index on the same columns under another name, or an index on the+-- leading columns of a unique constraint.+-- Every write to the table then maintains both, and the planner gains nothing.+module Test.Syd.Persistent.Postgresql.RedundantIndices+  ( shouldHaveNoRedundantIndices,+  )+where++import Data.List.NonEmpty (NonEmpty (..))+import qualified Data.List.NonEmpty as NE+import Data.Text (Text)+import qualified Data.Text as Text+import Database.Persist.Sql (Single (..), SqlPersistT, rawSql)+import Test.Syd++-- | Fail with the definition of every index that another index on the same+-- table covers, and the definitions of the indices that cover it, outside of+-- PostgreSQL's own schemas.+--+-- An index is covered when the other index has the same access method, the+-- same partial predicate and the same expressions, and its key starts with+-- the whole key of the covered one, column for column, with the same+-- operator class, collation and ordering.+-- Only a btree is searched by a leading part of its key, so for any other+-- access method the keys have to be the same.+-- The covering index also has to contain every column the covered one+-- carries in INCLUDE, or the covered one could answer index-only scans the+-- covering one cannot.+--+-- A unique index enforces something a non-unique one does not, so it is only+-- covered by a unique index on the same key that enforces at least as much:+-- immediately rather than deferred, and with NULLs not distinct if it has+-- them so.+-- An index that backs an exclusion constraint is never reported, because it+-- cannot be dropped without the constraint.+--+-- Two indices that cover each other are both reported, because either one can+-- go.+--+-- A later version may recognise more kinds of redundant index, so a schema+-- that passes this today can fail it after an upgrade.+shouldHaveNoRedundantIndices :: (MonadIO m) => SqlPersistT m ()+shouldHaveNoRedundantIndices = do+  coverings <- redundantIndexCoverings+  case NE.groupWith fst coverings of+    [] -> pure ()+    redundancies ->+      liftIO $+        expectationFailure $+          unlines $+            "Found indices that other indices cover:"+              : concatMap renderRedundancy redundancies++renderRedundancy :: NonEmpty (Text, Text) -> [String]+renderRedundancy coveringsOfOneIndex@((redundant, _) :| _) =+  ""+    : Text.unpack redundant+    : map+      (\(_, covering) -> unwords ["  is covered by", Text.unpack covering])+      (NE.toList coveringsOfOneIndex)++-- | The definition of every redundant index, paired with the definition of+-- each index that covers it, ordered by the first and then the second.+redundantIndexCoverings :: (MonadIO m) => SqlPersistT m [(Text, Text)]+redundantIndexCoverings = do+  rows <-+    rawSql+      "WITH described AS ( \+      \  SELECT x.indexrelid, \+      \         x.indrelid, \+      \         x.indisunique, \+      \         x.indimmediate, \+      \         x.indnullsnotdistinct, \+      \         x.indisvalid, \+      \         c.relam, \+      \         coalesce(pg_get_expr(x.indpred, x.indrelid), '') AS predicate, \+      \         coalesce(pg_get_expr(x.indexprs, x.indrelid), '') AS expressions, \+      \         ( SELECT array_agg(format('%s/%s/%s/%s', k.attnum, k.opclass, k.collation_oid, k.sort_option) ORDER BY k.ord) \+      \           FROM unnest(x.indkey::int2[], x.indclass::oid[], x.indcollation::oid[], x.indoption::int2[]) \+      \                WITH ORDINALITY AS k(attnum, opclass, collation_oid, sort_option, ord) \+      \           WHERE k.ord <= x.indnkeyatts \+      \         ) AS keys, \+      \         ( SELECT coalesce(array_agg(k.attnum), '{}') \+      \           FROM unnest(x.indkey::int2[]) WITH ORDINALITY AS k(attnum, ord) \+      \           WHERE k.ord > x.indnkeyatts \+      \         ) AS included, \+      \         x.indkey::int2[] AS columns \+      \  FROM pg_index x \+      \  JOIN pg_class c ON c.oid = x.indexrelid \+      \  JOIN pg_namespace n ON n.oid = c.relnamespace \+      \  WHERE n.nspname <> 'information_schema' \+      \    AND n.nspname NOT LIKE 'pg\\_%' \+      \) \+      \SELECT pg_get_indexdef(redundant.indexrelid), \+      \       pg_get_indexdef(covering.indexrelid) \+      \FROM described redundant \+      \JOIN described covering \+      \  ON covering.indrelid = redundant.indrelid \+      \ AND covering.indexrelid <> redundant.indexrelid \+      \ AND covering.indisvalid \+      \ AND covering.relam = redundant.relam \+      \ AND covering.predicate = redundant.predicate \+      \ AND covering.expressions = redundant.expressions \+      \ AND cardinality(redundant.keys) <= cardinality(covering.keys) \+      \ AND covering.keys[1:cardinality(redundant.keys)] = redundant.keys \+      \ AND redundant.included <@ covering.columns \+      \WHERE ( cardinality(redundant.keys) = cardinality(covering.keys) \+      \        OR redundant.relam = (SELECT oid FROM pg_am WHERE amname = 'btree') \+      \      ) \+      \  AND ( NOT redundant.indisunique \+      \        OR ( covering.indisunique \+      \             AND cardinality(redundant.keys) = cardinality(covering.keys) \+      \             AND (covering.indimmediate OR NOT redundant.indimmediate) \+      \             AND (covering.indnullsnotdistinct OR NOT redundant.indnullsnotdistinct) \+      \           ) \+      \      ) \+      \  AND NOT EXISTS ( \+      \        SELECT 1 FROM pg_constraint con \+      \        WHERE con.conindid = redundant.indexrelid \+      \          AND con.contype = 'x' \+      \      ) \+      \ORDER BY 1, 2"+      []+  pure $ map (\(Single redundant, Single covering) -> (redundant, covering)) rows
sydtest-persistent-postgresql.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           sydtest-persistent-postgresql-version:        0.5.2.0+version:        0.5.3.0 synopsis:       An persistent-postgresql companion library for sydtest category:       Testing homepage:       https://github.com/NorfairKing/sydtest#readme@@ -33,6 +33,7 @@ library   exposed-modules:       Test.Syd.Persistent.Postgresql+      Test.Syd.Persistent.Postgresql.RedundantIndices   other-modules:       Paths_sydtest_persistent_postgresql   hs-source-dirs:@@ -43,6 +44,7 @@     , filepath     , monad-logger     , mtl+    , persistent     , persistent-postgresql     , postgres-options     , postgresql-simple@@ -61,6 +63,7 @@   main-is: Spec.hs   other-modules:       Test.Syd.Persistent.Example+      Test.Syd.Persistent.Postgresql.RedundantIndicesSpec       Test.Syd.Persistent.Postgresql.StandbySpec       Test.Syd.Persistent.PostgresqlSpec       Paths_sydtest_persistent_postgresql
+ test/Test/Syd/Persistent/Postgresql/RedundantIndicesSpec.hs view
@@ -0,0 +1,363 @@+{-# LANGUAGE OverloadedStrings #-}++module Test.Syd.Persistent.Postgresql.RedundantIndicesSpec (spec) where++import Database.Persist.Sql+import Test.Syd+import Test.Syd.Persistent.Postgresql+import Test.Syd.Persistent.Postgresql.RedundantIndices++spec :: Spec+spec = persistPostgresqlSpec (pure ()) $+  describe "shouldHaveNoRedundantIndices" $ do+    it "passes on an empty database" $ \pool ->+      runPostgresqlTest pool shouldHaveNoRedundantIndices++    it "passes for a primary key and an index on another column" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (id int PRIMARY KEY, a int)" []+        rawExecute "CREATE INDEX t_a ON t (a)" []+        shouldHaveNoRedundantIndices++    it "reports both of two indices on the same columns" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int)" []+        rawExecute "CREATE INDEX t_a_b_1 ON t (a, b)" []+        rawExecute "CREATE INDEX t_a_b_2 ON t (a, b)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a_b_1 ON public.t USING btree (a, b)",+                                  "  is covered by CREATE INDEX t_a_b_2 ON public.t USING btree (a, b)",+                                  "",+                                  "CREATE INDEX t_a_b_2 ON public.t USING btree (a, b)",+                                  "  is covered by CREATE INDEX t_a_b_1 ON public.t USING btree (a, b)"+                                ]+                            )+                      )++    it "reports an index on the leading column of a unique constraint" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int, CONSTRAINT t_unique UNIQUE (a, b))" []+        rawExecute "CREATE INDEX t_a ON t (a)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING btree (a)",+                                  "  is covered by CREATE UNIQUE INDEX t_unique ON public.t USING btree (a, b)"+                                ]+                            )+                      )++    it "reports an index on the leading columns of another index" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int, c int)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        rawExecute "CREATE INDEX t_a_b_c ON t (a, b, c)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a_b ON public.t USING btree (a, b)",+                                  "  is covered by CREATE INDEX t_a_b_c ON public.t USING btree (a, b, c)"+                                ]+                            )+                      )++    it "reports an index once with every index that covers it" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int, c int)" []+        rawExecute "CREATE INDEX t_a ON t (a)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        rawExecute "CREATE INDEX t_a_c ON t (a, c)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING btree (a)",+                                  "  is covered by CREATE INDEX t_a_b ON public.t USING btree (a, b)",+                                  "  is covered by CREATE INDEX t_a_c ON public.t USING btree (a, c)"+                                ]+                            )+                      )++    it "passes for an index on the trailing column of another index" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int)" []+        rawExecute "CREATE INDEX t_b ON t (b)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        shouldHaveNoRedundantIndices++    it "passes for indices on the same columns of different tables" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int)" []+        rawExecute "CREATE TABLE u (a int)" []+        rawExecute "CREATE INDEX t_a ON t (a)" []+        rawExecute "CREATE INDEX u_a ON u (a)" []+        shouldHaveNoRedundantIndices++    it "passes for a unique index on the leading column of a longer one" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int)" []+        rawExecute "CREATE UNIQUE INDEX t_a ON t (a)" []+        rawExecute "CREATE UNIQUE INDEX t_a_b ON t (a, b)" []+        shouldHaveNoRedundantIndices++    it "reports a non-unique index on the same columns as a unique one" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int)" []+        rawExecute "CREATE INDEX t_a ON t (a)" []+        rawExecute "CREATE UNIQUE INDEX t_a_unique ON t (a)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING btree (a)",+                                  "  is covered by CREATE UNIQUE INDEX t_a_unique ON public.t USING btree (a)"+                                ]+                            )+                      )++    it "reports a unique index on the same columns as a unique constraint" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, CONSTRAINT t_unique UNIQUE (a))" []+        rawExecute "CREATE UNIQUE INDEX t_a ON t (a)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE UNIQUE INDEX t_a ON public.t USING btree (a)",+                                  "  is covered by CREATE UNIQUE INDEX t_unique ON public.t USING btree (a)",+                                  "",+                                  "CREATE UNIQUE INDEX t_unique ON public.t USING btree (a)",+                                  "  is covered by CREATE UNIQUE INDEX t_a ON public.t USING btree (a)"+                                ]+                            )+                      )++    it "reports a deferred unique constraint only as covered by an immediate one" $ \pool -> do+      runPostgresqlTest pool $+        rawExecute "CREATE TABLE t (a int, CONSTRAINT t_deferred UNIQUE (a) DEFERRABLE, CONSTRAINT t_immediate UNIQUE (a))" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE UNIQUE INDEX t_deferred ON public.t USING btree (a)",+                                  "  is covered by CREATE UNIQUE INDEX t_immediate ON public.t USING btree (a)"+                                ]+                            )+                      )++    it "reports a unique index with distinct NULLs only as covered by one without" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int)" []+        rawExecute "CREATE UNIQUE INDEX t_distinct ON t (a)" []+        rawExecute "CREATE UNIQUE INDEX t_not_distinct ON t (a) NULLS NOT DISTINCT" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE UNIQUE INDEX t_distinct ON public.t USING btree (a)",+                                  "  is covered by CREATE UNIQUE INDEX t_not_distinct ON public.t USING btree (a) NULLS NOT DISTINCT"+                                ]+                            )+                      )++    it "reports a partial index covered by one with the same predicate" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int)" []+        rawExecute "CREATE INDEX t_a ON t (a) WHERE b IS NULL" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b) WHERE b IS NULL" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING btree (a) WHERE (b IS NULL)",+                                  "  is covered by CREATE INDEX t_a_b ON public.t USING btree (a, b) WHERE (b IS NULL)"+                                ]+                            )+                      )++    it "passes for indices with different predicates" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int)" []+        rawExecute "CREATE INDEX t_a ON t (a) WHERE b IS NULL" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        shouldHaveNoRedundantIndices++    it "reports both of two indices on the same expression" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a text)" []+        rawExecute "CREATE INDEX t_lower_1 ON t (lower(a))" []+        rawExecute "CREATE INDEX t_lower_2 ON t (lower(a))" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_lower_1 ON public.t USING btree (lower(a))",+                                  "  is covered by CREATE INDEX t_lower_2 ON public.t USING btree (lower(a))",+                                  "",+                                  "CREATE INDEX t_lower_2 ON public.t USING btree (lower(a))",+                                  "  is covered by CREATE INDEX t_lower_1 ON public.t USING btree (lower(a))"+                                ]+                            )+                      )++    it "passes for an index on a column and one on an expression over it" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a text)" []+        rawExecute "CREATE INDEX t_a ON t (a)" []+        rawExecute "CREATE INDEX t_lower ON t (lower(a))" []+        shouldHaveNoRedundantIndices++    it "passes for indices with different operator classes" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a text, b int)" []+        rawExecute "CREATE INDEX t_a ON t (a text_pattern_ops)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        shouldHaveNoRedundantIndices++    it "passes for indices with different collations" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a text, b int)" []+        rawExecute "CREATE INDEX t_a ON t (a COLLATE \"C\")" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        shouldHaveNoRedundantIndices++    it "passes for indices with different orderings" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int, c int)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b DESC)" []+        rawExecute "CREATE INDEX t_a_b_c ON t (a, b, c)" []+        shouldHaveNoRedundantIndices++    it "reports both of two hash indices on the same column" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int)" []+        rawExecute "CREATE INDEX t_a_1 ON t USING hash (a)" []+        rawExecute "CREATE INDEX t_a_2 ON t USING hash (a)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a_1 ON public.t USING hash (a)",+                                  "  is covered by CREATE INDEX t_a_2 ON public.t USING hash (a)",+                                  "",+                                  "CREATE INDEX t_a_2 ON public.t USING hash (a)",+                                  "  is covered by CREATE INDEX t_a_1 ON public.t USING hash (a)"+                                ]+                            )+                      )++    it "passes for indices with different access methods" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int)" []+        rawExecute "CREATE INDEX t_a_hash ON t USING hash (a)" []+        rawExecute "CREATE INDEX t_a_btree ON t (a)" []+        shouldHaveNoRedundantIndices++    it "passes for a leading part of the key of an index that is not a btree" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a box, b box)" []+        rawExecute "CREATE INDEX t_a ON t USING gist (a)" []+        rawExecute "CREATE INDEX t_a_b ON t USING gist (a, b)" []+        shouldHaveNoRedundantIndices++    it "passes for an index that includes a column the longer one lacks" $ \pool ->+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int, c int)" []+        rawExecute "CREATE INDEX t_a ON t (a) INCLUDE (c)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        shouldHaveNoRedundantIndices++    it "reports an index whose included column the longer one carries" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int, c int)" []+        rawExecute "CREATE INDEX t_a ON t (a) INCLUDE (c)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b) INCLUDE (c)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING btree (a) INCLUDE (c)",+                                  "  is covered by CREATE INDEX t_a_b ON public.t USING btree (a, b) INCLUDE (c)"+                                ]+                            )+                      )++    it "does not count an included column as part of the key" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a int, b int)" []+        rawExecute "CREATE INDEX t_a_b ON t (a, b)" []+        rawExecute "CREATE INDEX t_a ON t (a) INCLUDE (b)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING btree (a) INCLUDE (b)",+                                  "  is covered by CREATE INDEX t_a_b ON public.t USING btree (a, b)"+                                ]+                            )+                      )++    it "does not report the index of an exclusion constraint" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE TABLE t (a box, CONSTRAINT t_exclusion EXCLUDE USING gist (a WITH &&))" []+        rawExecute "CREATE INDEX t_a ON t USING gist (a)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON public.t USING gist (a)",+                                  "  is covered by CREATE INDEX t_exclusion ON public.t USING gist (a)"+                                ]+                            )+                      )++    it "reports indices outside of the public schema" $ \pool -> do+      runPostgresqlTest pool $ do+        rawExecute "CREATE SCHEMA other" []+        rawExecute "CREATE TABLE other.t (a int, b int)" []+        rawExecute "CREATE INDEX t_a ON other.t (a)" []+        rawExecute "CREATE INDEX t_a_b ON other.t (a, b)" []+      runPostgresqlTest pool shouldHaveNoRedundantIndices+        `shouldThrow` ( ==+                          ExpectationFailed+                            ( unlines+                                [ "Found indices that other indices cover:",+                                  "",+                                  "CREATE INDEX t_a ON other.t USING btree (a)",+                                  "  is covered by CREATE INDEX t_a_b ON other.t USING btree (a, b)"+                                ]+                            )+                      )