test: make inheritance search test config-independent - #422
Conversation
There was a problem hiding this comment.
LGTM — straightforward test-only change that makes the inheritance test config-independent and actually exercises the bm25 index.
Extended reasoning...
Overview
This PR modifies a single regression test (test/sql/inheritance.sql and its expected output) to replace a core text-search @@ predicate (which depends on the server's default_text_search_config) with a bm25 <@> ordering query against the child's bm25 index. Both files change in a consistent way: the SQL query and its expected output.
Security risks
None. This is purely a test file change with no impact on production code, auth, data handling, or external interfaces.
Level of scrutiny
Low. The change touches no extension C/SQL implementation code, only the regression test suite. The motivation in the PR description is technically accurate: to_tsquery('english', ...) only stems the query side under the english config, while the @@ operator stems the document side under default_text_search_config, so the test was fragile on servers with the default pg_catalog.simple config.
Other factors
The replacement query uses <@> with to_bm25query('postgresql inheritance', 'child1_bm25_idx'), which exercises pg_textsearch's own code path (an improvement over the previous test). The expected output correctly reflects the single LIMIT 1 result. Bug hunting found no issues.
The "search on child table works" check used core text search
`content @@ to_tsquery('english', ...)`, which runs as a sequential scan
via ts_match_tq and stems the text side with the session's
default_text_search_config. On servers where that GUC is not 'english'
(PostgreSQL's compiled boot default is 'pg_catalog.simple'), 'inheritance'
is not stemmed to 'inherit', so the query returns 0 rows instead of 1 and
the test fails. It also never exercised the bm25 index.
Replace it with a bm25 search via the <@> operator against the child's
bm25 index, which uses the index's text_config ('english') and therefore
does not depend on default_text_search_config.
0c763b0 to
d3eb540
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
What
Make the
inheritanceregression test independent of the server'sdefault_text_search_config.Why
Test 1 checks "searching on child table works" with core text search:
Here
@@resolves tots_match_tq(text, tsquery)— a sequential scan that stems the text side using the databasedefault_text_search_config, while the tsquery side is explicitlyenglish(stemsinheritance→inherit). On any server whose default config is not english — notably PostgreSQL's compiled-in boot defaultpg_catalog.simple—inheritanceis not stemmed toinherit, the match returns 0 rows instead of 1, and the test fails. The line also never exercised the bm25 index, so it wasn't really testing pg_textsearch.What changed
Replace it with a bm25 search using the
<@>operator against the child's bm25 index (child1_bm25_idx). bm25 parses the query with the index'stext_config(english), so the result no longer depends ondefault_text_search_config— and it actually exercises pg_textsearch.Testing
make installcheck— verified theinheritancetest passes under bothdefault_text_search_config = 'pg_catalog.simple'and'pg_catalog.english', and the full suite (71 tests) passes.