| 303 | |
| 304 | |
| 305 | Sequence_share *ha_seq::get_share() |
| 306 | { |
| 307 | Sequence_share *tmp_share; |
| 308 | lock_shared_ha_data(); |
| 309 | if (!(tmp_share= static_cast<Sequence_share*>(get_ha_share_ptr()))) |
| 310 | { |
| 311 | bool reverse; |
| 312 | ulonglong from, to, step; |
| 313 | |
| 314 | parse_table_name(table_share->table_name.str, |
| 315 | table_share->table_name.length, &from, &to, &step); |
| 316 | |
| 317 | if ((reverse = from > to)) |
| 318 | { |
| 319 | if (step > from - to) |
| 320 | to = from; |
| 321 | else |
| 322 | swap_variables(ulonglong, from, to); |
| 323 | /* |
| 324 | when keyread is allowed, optimizer will always prefer an index to a |
| 325 | table scan for our tables, and we'll never see the range reversed. |
| 326 | */ |
| 327 | table_share->keys_for_keyread.clear_all(); |
| 328 | } |
| 329 | |
| 330 | to= (to - from) / step * step + step + from; |
| 331 | |
| 332 | tmp_share= new Sequence_share(Lex_ident_table(table_share->normalized_path), |
| 333 | from, to, step, reverse); |
| 334 | |
| 335 | if (!tmp_share) |
| 336 | goto err; |
| 337 | set_ha_share_ptr(static_cast<Handler_share*>(tmp_share)); |
| 338 | } |
| 339 | err: |
| 340 | unlock_shared_ha_data(); |
| 341 | return tmp_share; |
| 342 | } |
| 343 | |
| 344 | |
| 345 | static int discover_table(handlerton *hton, THD *thd, TABLE_SHARE *share) |
nothing calls this directly
no test coverage detected