def internal_test_reindex(self, name, sql): c = self.db.cursor() # Create index c.execute(sql) oid1 = get_rel_oid(c, name) stmt1 = fetch_single_val(c, "SELECT pg_get_indexdef(%s, 0, false)", [oid1]) # Recreate index pgtool.pg_reindex(self.db, name) oid2 = get_rel_oid(c, name) stmt2 = fetch_single_val(c, "SELECT pg_get_indexdef(%s, 0, false)", [oid2]) self.assertTrue(oid2 > 0) # New oid must be allocated for the new index self.assertNotEqual(oid1, oid2) # But index expressions must remain equal self.assertEqual(stmt1, stmt2)
def get_rel_oid(c, relname): return fetch_single_val(c, "SELECT %s::regclass::int", [relname])