Commit graph

17 commits

Author SHA1 Message Date
Julien Rouhaud
c93081f35e Add support for hypothetical hash indexes.
Only support such indexes for PostgreSQL 10+, as they were previously not crash
safe.
2021-03-07 19:41:21 +08:00
Julien Rouhaud
8eb71b0dda Make new regression tests for INCLUDE stable.
The regression tests included the oid of the hypothetical index.  Since the
hypothetical Oid generator was introduced, the sequence of generated Oids is
somewhat stable for a given PostgreSQL major version, but is defenitely not
across multiple major versions.

(cherry picked from commit 203a0200464e7bbe55bc386eca6cb0c938bb48c1)
2021-02-28 17:07:53 +08:00
Julien Rouhaud
f49d369bd6 Display hypothetical indexes on dropped tables in hypopg_list_indexes.
We could try to automatically remove such indexes by registering a relcache
callback, but this seems like an unlikely corner case so it doesn't seems worth
spending effort for that, accurately displaying the list of stored hypothetical
indexes should be enough.
2021-02-07 22:14:33 +08:00
Julien Rouhaud
3e3339b4b8 Check if access methods support an INCLUDE clause.
Trying to create an hypothetical index with an INCLUDE clause on pg10- will
obviously fail with a syntax error.

Also add regression test for the INCLUDE clause on btree indexes.
2021-02-04 00:21:53 +08:00
Julien Rouhaud
2bd376d6bd Change the Oid generator.
To avoid locking on pg_class (required to safely call GetNewOidWithIndex or
similar) and to be usable on a standby node, use the oids unused in the
FirstBootstrapObjectId / FirstNormalObjectId range rather than real oids.  For
performance, always start with the biggest oid lesser than FirstNormalObjectId.
This way the loop to find an unused oid will only happens once a single backend
has created more than ~2.5k hypothetical indexes.

For people needing to have thousands of hypothetical indexes at the same time,
we also allow to use the initial implementation that relies on real oids, which
comes with all the limitations mentioned above, with the new
hypopg.use_real_oids GUC.
2021-01-22 19:56:06 +08:00
Julien Rouhaud
3131560b85 Change hypopg_list_indexes() to a view.
And while at schema-qualify relation names used in that view.
2021-01-22 18:55:48 +08:00
Julien Rouhaud
48ed9e4f17 Be more permissive in brin regression tests.
Upstream postgres will probably soon push some changes that will change the
semantics of explain_get_index_name_hook_type.  The returned index name will
automatically be properly quoted if needed, while it was previously the
extension's duty to take care of that, which hypopg failed to do.  See
discussion at https://postgr.es/m/flat/16502-57bd1c9f913ed1d1%40postgresql.org
for more details.

To avoid build failure when the change is committed, change brin regression
test to match an hypothetical index name whether is quoted or not, similarly to
how it's done in all other regression tests.
2020-06-22 15:55:28 +02:00
Julien Rouhaud
205482a733 Add support for hypothetical index on partitioned tables. 2020-06-13 09:42:37 +02:00
Julien Rouhaud
046ba10488 Warn about broken hypothetical BRIN indexes in some minor versions.
Hypothetical BRIN indexes are broken in some minor versions of pg10, pg11 and
pg12.  Detect those versions and warn users with a useful error message
recommending to update their minor versions of postgres.

Also add regression tests to make sure that support BRIN hypothetical indexes
doesn't get broken again.
2020-02-22 14:56:01 +01:00
Julien Rouhaud
73d82eee94 Make tests more portable.
The estimated index size depends on the architecture, so just make
sure the code path is tested, without really caring of what the
estimated size is.  Thanks to Christoph Berg for the report.
2018-03-27 19:48:41 +02:00
Julien Rouhaud
79220f2c71 Fix NULL ordering for SORTBY_DESC case. Thanks to Andrew Kane for the
report and test case.
2017-09-05 06:45:31 +02:00
Julien Rouhaud
d2cfd7898f Add a hypopg_get_indexdef(oid) function 2016-11-16 23:49:27 +01:00
Julien Rouhaud
c05e2da4f7 Add support for hypothetical indexes on expression.
The estimation (size and cardinality) will probably always be very poor, the
postgres infrastructure get accurate informations by analyzing a real
index.  One consequence is that almost only Bitmap Index Scan will be
chosen by the planner.

Some simple and frequent expressions are explicitely handled (for now md5(),
lower() and uppser()), but it only impacts the estimated size, not the
selectivity.
2016-11-15 15:31:09 +01:00
Julien Rouhaud
022ac3396e Add regression test for expression indexes.
This has already been broken twice, make sure it won't happen again.
2016-06-07 20:10:04 +02:00
Julien Rouhaud
079a4f7610 Test hypopg.enabled GUC 2015-09-14 17:49:33 +02:00
Julien Rouhaud
1f211190fd Add some more tests 2015-09-03 19:02:32 +02:00
Julien Rouhaud
3bf0e6d118 Add some basic regression test. 2015-07-11 10:28:34 +02:00