Skip to content

test: make inheritance search test config-independent - #422

Merged
tjgreen42 merged 2 commits into
mainfrom
tjgreen42/inheritance-test-config-independent
Aug 12, 2026
Merged

test: make inheritance search test config-independent#422
tjgreen42 merged 2 commits into
mainfrom
tjgreen42/inheritance-test-config-independent

Conversation

@tjgreen42

Copy link
Copy Markdown
Collaborator

What

Make the inheritance regression test independent of the server's default_text_search_config.

Why

Test 1 checks "searching on child table works" with core text search:

WHERE content @@ to_tsquery('english', 'postgresql & inheritance');

Here @@ resolves to ts_match_tq(text, tsquery) — a sequential scan that stems the text side using the database default_text_search_config, while the tsquery side is explicitly english (stems inheritanceinherit). On any server whose default config is not english — notably PostgreSQL's compiled-in boot default pg_catalog.simpleinheritance is not stemmed to inherit, 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's text_config (english), so the result no longer depends on default_text_search_config — and it actually exercises pg_textsearch.

Testing

make installcheck — verified the inheritance test passes under both default_text_search_config = 'pg_catalog.simple' and 'pg_catalog.english', and the full suite (71 tests) passes.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@tjgreen42
tjgreen42 force-pushed the tjgreen42/inheritance-test-config-independent branch from 0c763b0 to d3eb540 Compare June 24, 2026 00:02
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@tjgreen42
tjgreen42 merged commit 68dca31 into main Aug 12, 2026
13 checks passed
@tjgreen42
tjgreen42 deleted the tjgreen42/inheritance-test-config-independent branch August 12, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant