Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db_verify::getIndex(): Support index_col_name optional parts #5055

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

Deltik
Copy link
Member

@Deltik Deltik commented Aug 2, 2023

Motivation and Context

Fixes: #5054

Description

Update the regex in db_verify::getIndex() to support the optional parts of index_col_name

How Has This Been Tested?

Automated test method: db_verifyTest::testGetIndexOptionalLengthAndSortOrder()

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist

@CaMer0n
Copy link
Member

CaMer0n commented Aug 17, 2023

Thank you for this @Deltik !
Would you also like to add a test for it in db_VerifyTest::testGetIndex() before I merge the pull-request?

@Deltik
Copy link
Member Author

Deltik commented Aug 17, 2023

Yep, I'll add a test now, @CaMer0n

In the MariaDB `CREATE TABLE` [`index_definition`](https://mariadb.com/kb/en/create-table/#index-definitions),
 the `index_col_name` could have an optional length and a sort order:

```
index_definition:
    {INDEX|KEY} [index_name] [index_type] (index_col_name,...) [index_option] ...
  {{{|}}} {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...) [index_option] ...
  {{{|}}} [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...) [index_option] ...
  {{{|}}} [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...) [index_option] ...
  {{{|}}} [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...) reference_definition

index_col_name:
    col_name [(length)] [ASC | DESC]

index_type:
    USING {BTREE | HASH | RTREE}

index_option:
    [ KEY_BLOCK_SIZE [=] value
  {{{|}}} index_type
  {{{|}}} WITH PARSER parser_name
  {{{|}}} COMMENT 'string'
  {{{|}}} CLUSTERING={YES| NO} ]
  [ IGNORED | NOT IGNORED ]

reference_definition:
    REFERENCES tbl_name (index_col_name,...)
      [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
      [ON DELETE reference_option]
      [ON UPDATE reference_option]

reference_option:
    RESTRICT | CASCADE | SET NULL | NO ACTION
```

`db_verify::getIndex()` didn't handle this possibility, leading to a
database validity check failure despite the index actually existing.

Fixes: e107inc#5054
@Deltik
Copy link
Member Author

Deltik commented Aug 17, 2023

@codeclimate
Copy link

codeclimate bot commented Aug 17, 2023

Code Climate has analyzed commit b623868 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (80% is the threshold).

This pull request will bring the total coverage in the repository to 34.5% (0.0% change).

View more on Code Climate.

@CaMer0n
Copy link
Member

CaMer0n commented Aug 17, 2023

Thank you!! 👍

@CaMer0n CaMer0n merged commit 068bf05 into e107inc:master Aug 17, 2023
99 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants