[Bug] Report some errors after using new user-defined access methods
- Dominant language
- C
- Stars
- 1.4k
- Forks
- 247
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 39
Description
### Cloudberry Database version
Any version
### What happened
After add new like-intrenal index access method ( as like-btree, like-hash..), there are several problems as below.
- If you create a new op class by new access method and you create a table in partition key that include new defined op class, you will get a error. For example:
`CREATE FUNCTION my_int4_sort(int4,int4) RETURNS int LANGUAGE sql`
` AS $$ SELECT CASE WHEN $1 = $2 THEN 0 WHEN $1 > $2 THEN 1 ELSE -1 END; $$;`
`CREATE OPERATOR CLASS test_int4_ops FOR TYPE int4 USING usbtree AS`
`OPERATOR 1 < (int4,int4), OPERATOR 2 <= (int4,int4),`
` OPERATOR 3 = (int4,int4), OPERATOR 4 >= (int4,int4),`
`OPERATOR 5 > (int4,int4), FUNCTION 1 my_int4_sort(int4,int4);`
`CREATE TABLE partkey_t (a int4) PARTITION BY RANGE (a test_int4_ops);`
Because cbdb core will find a op class by BTREE_AM_OID when using partition key and not identify new defined opclass.
- When use onconflict clause , it still has the problem. For example:
`create table insertconflicttest(key int4, fruit text);`
`create unique index op_index_key on insertconflicttest(key, fruit text_pattern_ops);`
`insert into insertconflicttest values(0, 'Crowberry') on conflict (key, fruit text_pattern_ops) do nothing;`
In onconflict clause, it will find text_pattern_ops opclass by BTREE_AM_OID and compare result and existing index info. So it report a error that unmatched.
### What you think should happen instead
Core idea is add a new hook that catch correct opclasses. For example, you can get all opclasses of BTREE_AM_OID firstly, if you can find target , you can find other opclasses in like-btree index access method(maybe user-defined).
### How to reproduce
Please refer exmaples as above.
### Operating System
Linux
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes, I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://cloudberrydb.org/community/coc).
Contributor guide
Research direction
Start by running the partition-key and ON CONFLICT SQL reproductions from the issue and trace how each case looks up operator classes using BTREE_AM_OID. The issue names no source files or tests, so first locate those lookup paths in the database core. Done means both examples recognize the matching user-defined access-method operator class without reporting an unmatched or otherwise erroneous result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, postgresql, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100