Skip to content

Fix multi-valued index #360

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

Closed
wants to merge 4 commits into from
Closed

Conversation

Dieken
Copy link

@Dieken Dieken commented Aug 21, 2021

These commits fixed four bugs in multi-valued index:

  1. multi-valued index isn't picked in view
  2. multi-valued index isn't picked in prepared statement
  3. multi-valued index isn't picked in member of(col) OR member of(col)
  4. MySQL wrongly gets "impossible condition" thus empty result set for WHERE func(...) AND func(...) where func is member of, json_contains or json_overlaps.

@Dieken
Copy link
Author

Dieken commented Aug 21, 2021

I sent a PR for the first fix some months ago but failed to fulfill the OCA, I wouldn't like to spend time on that again, you can just take those little patches as you will, they are licensed under GPL same with MySQL.

Any review to the patches are very appreciated.

@mysql-oca-bot
Copy link

Hi, thank you for submitting this pull request. In order to consider your code we need you to sign the Oracle Contribution Agreement (OCA). Please review the details and follow the instructions at https://oca.opensource.oracle.com/
Please make sure to include your MySQL bug system user (email) in the returned form.
Thanks

@Dieken Dieken force-pushed the fix-multi-valued-index branch 3 times, most recently from 7560481 to c93c00a Compare August 23, 2021 02:08
@Dieken
Copy link
Author

Dieken commented Aug 23, 2021

Bug report: https://bugs.mysql.com/bug.php?id=104700

The second commit fixes https://bugs.mysql.com/bug.php?id=104325 too.

Dieken added 4 commits August 23, 2021 23:15
REF_ITEM was not considered in Item::can_be_substituted_for_gc() and get_gc_for_expr(),
so optimizer failed to use multi-valued index in view.
Parameters in prepare statement are not constant literal but if they are
constant during statement execution the multi-valued index should be picked.

This also fixes Bug#104325.
…" expression

"json_contains" and "json_overlaps" already works but "member of" didn't work.
…occurs in AND clause

For a multi-valued index on json array field f=[1, 2], this statement wrongly
returned empty result set:

  SELECT * FROM f WHERE JSON_CONTAINS(f, 1) AND JSON_CONTAINS(f, 2);

The cause is `get_func_mm_tree()` converts two JSON_CONTAINS() to `f_idx = 1 AND f_idx = 2`
which is impossible for single value index but possible for multi-valued index.
@Dieken Dieken force-pushed the fix-multi-valued-index branch from c93c00a to 8bf7efe Compare August 23, 2021 15:18
@mysql-admin
Copy link

@Dieken:
Thanks for your effort, however we cannot take contributions without a signed OCA and a confirmation the code is submitted under the terms of the OCA.
Please submit one so we can process the above
Thanks
==Omer

@Dieken
Copy link
Author

Dieken commented Aug 23, 2021

@Dieken:
Thanks for your effort, however we cannot take contributions without a signed OCA and a confirmation the code is submitted under the terms of the OCA.
Please submit one so we can process the above
Thanks
==Omer

@mysql-admin I just signed a new OCA, it's still under review, could you accelerate that? I have no idea why my last signing in June was rejected.

@mysql-admin
Copy link

@Dieken : Thanks for submitting the OCA - we will process it shortly and then the bot will ask you to confirm the contributions are under the terms of the OCA
==Omer

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@Dieken
Copy link
Author

Dieken commented Aug 25, 2021

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=104721 for updates.
Thanks

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.

3 participants