[MDEV-31788] Factor out code repeat in functions calling spider_check_and_init_casual_read() Created: 2023-07-28 Updated: 2023-11-28 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Spider |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2 |
| Type: | Task | Priority: | Major |
| Reporter: | Yuchen Pei | Assignee: | Yuchen Pei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Epic Link: | Spider Refactoring | ||||||||||||
| Description |
|
The following ha_spider methods inside ha_spider.cc call spider_check_and_init_casual_read() ft_read_internal multi_range_read_next_first Near the callsite is about 80 lines of repeated code. Part of the repeated region is also a common pattern found in other spider files and functions. They need to be factored out. See the attached gif for an IDE demo, as well as attached .cc files with these functions extracted out (at 11.0 941f91edbc3d3a0a184b9bfc58d5e4042c4b65f1). |
| Comments |
| Comment by Yuchen Pei [ 2023-07-28 ] | ||||||||||||||||||||||||
|
The cleanup is a bit more involved than I expected which is why I opened this ticket separately from We can just factor out the portion in the gif, but it is not a "logical" block by it self, but rather a block before a for loop, and the if branch inside the for loop. There are (often minor) differences in the else branches, which may not be real differences, but require a bit more effort to the cleanup properly. For example, I suspect the following are not real differences, and just redundancy in data structure
I suspect share->use_sql_dbton_ids[roop_count] and conn->dbton_id are always the same value. Another issues is the pattern in calls to spider_ping_table_mon_from_table(), and the patterns like the following in setup and teardown of queries
They come in variants (sometimes missing the set / clear file pos part, sometimes without assigning to conn->need_mon) and is scattered all around the codebase, and need a proper cleanup based on understanding (see also my previous attempt in |