eliminate unnecessary SHOW TABLES which breaks on Vitess #1182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
mycli currently makes two queries to the database to prep its auto-completion feature after connecting:
SHOW TABLES
select TABLE_NAME, COLUMN_NAME from information_schema.columns ...
The first is actually unnecessary, as the second also contains the table names.
Arguably the above is trivial and not worth changing, HOWEVER the above results in an error on Vitess:
Vitess is a distributed database layer for sharding MySQL.
Their
vtgate
component behaves as a drop-in replacement for MySQL.When a query is issued, it determines to which shard(s) it needs to proxy the query.
In the case of
SHOW TABLE
andinformation_schema.*
, it picks a shard at random on every query.Ideally, the schema should be identical across all Vitess shards, and certainly is for any user-created data on Vitess.
However, the maintainers have introduced an "Online DDL" feature which creates those
_vt_hold_...
tables for its own internal functions, which have a timestamp suffix that is slightly different between shards, hence the error above.Arguably, what I have described is a Vitess bug, and I am also following up with them to see what can be done.
However, in light of the above
SHOW TABLES
call being totally unnecessary, I think it increases the usability ofmycli
to just make the change so it doesn't error on Vitess, because it will then only issue one query, which will go to one shard, which will be consistent for the normal tables, and only error if a user attempts to autocomplete the Vitess internal tables, which one should not expect to work anyway, as they have different table names between shards.Note that the change I've done here is minimal wrt lines modified, yet it effectively undoes any performance benefit of using a generator. The generator feels a little unnecessary to me personally, but perhaps there once was someone with a mysql database with millions of columns. If you agree about eliminating
SHOW TABLES
, then we can iterate on this and make a different PR with a larger number of lines changed but preserving the generator.Checklist
let's discuss the change first, and if you agree on the implementation, i'll fill these out.
changelog.md
.AUTHORS
file (or it's already there).