diff --git a/expected/hypopg.out b/expected/hypopg.out index 5e98da8..f3af1bd 100644 --- a/expected/hypopg.out +++ b/expected/hypopg.out @@ -105,6 +105,26 @@ ORDER BY indexrelid; 4120 kB (3 rows) +-- locally disable hypoopg +SET hypopg.enabled to false; +-- no hypothetical index should be used +SELECT COUNT(*) FROM do_explain('SELECT * FROM hypo WHERE id = 1') e +WHERE e ~ 'Index.*<\d+>btree_hypo.*'; + count +------- + 0 +(1 row) + +-- locally re-enable hypoopg +SET hypopg.enabled to true; +-- hypothetical index should be used +SELECT COUNT(*) FROM do_explain('SELECT * FROM hypo WHERE id = 1') e +WHERE e ~ 'Index.*<\d+>btree_hypo.*'; + count +------- + 1 +(1 row) + -- Remove one hypothetical index SELECT hypopg_drop_index(indexrelid) FROM hypopg() ORDER BY indexrelid LIMIT 1; hypopg_drop_index diff --git a/test/sql/hypopg.sql b/test/sql/hypopg.sql index b28cd5b..39a5426 100644 --- a/test/sql/hypopg.sql +++ b/test/sql/hypopg.sql @@ -70,6 +70,20 @@ SELECT pg_size_pretty(hypopg_relation_size(indexrelid)) FROM hypopg() ORDER BY indexrelid; +-- locally disable hypoopg +SET hypopg.enabled to false; + +-- no hypothetical index should be used +SELECT COUNT(*) FROM do_explain('SELECT * FROM hypo WHERE id = 1') e +WHERE e ~ 'Index.*<\d+>btree_hypo.*'; + +-- locally re-enable hypoopg +SET hypopg.enabled to true; + +-- hypothetical index should be used +SELECT COUNT(*) FROM do_explain('SELECT * FROM hypo WHERE id = 1') e +WHERE e ~ 'Index.*<\d+>btree_hypo.*'; + -- Remove one hypothetical index SELECT hypopg_drop_index(indexrelid) FROM hypopg() ORDER BY indexrelid LIMIT 1;