Prefixed index creation (functional index on substring) has no test coverage

Created on 8 December 2023, about 1 year ago
Updated 29 December 2023, 12 months ago

Problem/Motivation

While working on πŸ“Œ Adding GIN and GIST indexes to PostgreSQL databases RTBC I discovered rarely-used syntax for creating an index on a table that allows for indexing on a substring'ed prefix. Support by drivers is optional and it appears the only core DB driver which does so is Postgres. While this works, there is no test coverage.

Steps to reproduce

Not a bug, just no test coverage. The new default test coverage in DriverSpecificSchemaTestBase::assertPrefixedColumnIndex() passes on drivers which do not support this syntax (e.g., MySQL) and fails on pgsql. A Postgres-specific test method override is included in the MR.

Proposed resolution

Interestingly, at least in the case of Postgres this also reveals that pgsql module's implementation of Schema::introspectIndexSchema() won't capture these types of indexes. I messed around with variations on the existing SQL in that method and it seems that functional indexes are just a different beast. As that method's docblock says it will return a list of columns that are indexed, I think it's OK to keep things as they are in that method and not get too cute about trying to also figure out which columns contribute to a functional index.

Remaining tasks

User interface changes

API changes

None.

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
DatabaseΒ  β†’

Last updated 2 days ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @bradjones1
  • Merge request !5742Add test coverage for prefixed indexes β†’ (Open) created by bradjones1
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

    The test-only CI run skips because it's configured for MySQL...but the only "actual" test class changed here is pgsql. Raised a question in Slack. Don't think that should necessarily hold this up, however.

  • πŸ‡ΊπŸ‡ΈUnited States bradjones1 Digital Nomad Life

    Test-only changes here aren't going to be helpful because we're adding test coverage, not demonstrating a bug... πŸ™ƒ

    I think this should be ready for review. Some initial test failures but they look to be unrelated/related to new performance testing.

  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Additional test coverage is always a plus.

    See you ran tests for all the different database types and no failures.

    The comments read fine to me.

  • Status changed to Needs work 12 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    I'm triaging RTBC issues β†’ .

    I agree with @smustgrave that additional test coverage is always welcome.

    I read the IS, the comments and the MR. I didn't see any unanswered questions. I then tried to apply the diff but it no longer applies.

    While reading the MR I was having trouble with the different terms applied to this type of index being tested. It seems that functional, alternative and prefix are being used for the same thing. While I could be wrong it does suggest that consisting in the wording and the method names would help. I also think adding a link to this 'rarely used syntax' would be beneficial.

    Setting back to NW for the above.

Production build 0.71.5 2024