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

[CBRD-24600] Problem with creating the same index with different names #4020

Merged
merged 4 commits into from
Jan 5, 2023

Conversation

ctshim
Copy link
Contributor

@ctshim ctshim commented Dec 28, 2022

http://jira.cubrid.org/browse/CBRD-24600

  • fix classobj_check_index_compatibility() and classobj_find_constraint_by_attrs()

The classobj_find_constraint_by_attrs() function is the role of checking whether an index with the same configuration already exists.
The cause of the problem was that the function did not include function index information in the check target of the same configuration.
classobj_check_index_compatibility() was checking if the function index information was the same.

For example, all three indexes below use column val.
create index idx_a on tbl(val);
create index idx_b on tbl(abs(val));
create index idx_c on tbl(val);

case1) If you attempt to create idx_c after creating it in the order of idx_a and idx_b
The classobj_find_constrain_by_attrs() function returns idx_a.
In classobj_check_index_compatibility(), idx_c and idx_a are determined to have the same configuration and do not generate idx_c.

case2) If you attempt to create idx_c after creating it in the order of idx_b and idx_a
The classobj_find_constrain_by_attrs() function returns idx_b.
In classobj_check_index_compatibility(), idx_c and idx_b are determined to have different configurations and will generate idx_c.

So, here's the correction:

  1. classobj_find_constrain_by_attrs() has been changed to find the same function index information as well as filter conditions.
  2. classobj_check_index_compatibility() removes checks that are no longer needed.
  3. Additionally, I changed the logic to a switch statement so that you can see it intuitively.

@ctshim ctshim self-assigned this Dec 28, 2022
Comment on lines -4129 to +4141
{
if (filter_predicate)
{
if (!cons->filter_predicate)
{
continue;
}
if (i != len)
{
continue;
}

if (!filter_predicate->pred_string || !cons->filter_predicate->pred_string)
{
continue;
}
if (filter_predicate)
{
Copy link
Member

Choose a reason for hiding this comment

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

Checking cons->filter_predicate seems to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to the conditions added to the 4105 line,
If filter_predicate is not NULL, cons->filter_predicate is also determined to be NULL.

(filter_predicate && !cons->filter_predicate) || (!filter_predicate && cons->filter_predicate)

@ctshim ctshim merged commit ba545ef into CUBRID:develop Jan 5, 2023
ctshim added a commit to ctshim/cubrid that referenced this pull request Jan 16, 2023
CUBRID#4020)

http://jira.cubrid.org/browse/CBRD-24600

* fix classobj_check_index_compatibility() and classobj_find_constraint_by_attrs()
* with function index
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.

6 participants