Add database engine of MySQL type#5599
Conversation
Co-authored-by: zhang2014 <[email protected]> Co-authored-by: TCeason <[email protected]>
968f51d to
6ccef4d
Compare
2416a81 to
d8a14f5
Compare
|
There was no way to determine from the returned log whether the error was related to the modification, and I need some help. BTW, is there more information with the other two pending tests? |
|
Now everything is green. |
| { | ||
| std::stringstream ostr; | ||
| formatAST(*engine_define, ostr, false, false); | ||
| throw Exception("Unknown database engine: " + ostr.str(), ErrorCodes::UNKNOWN_DATABASE_ENGINE); |
There was a problem hiding this comment.
You can make error message more descriptive, like "Database engine XYZ cannot have arguments".
PS. And parameters, primary_key, order_by, sample_by, settings should not ever be in CREATE DATABASE statement.
| @@ -0,0 +1,22 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
The file name is too generic. You can name it convertMySQLDataType.
dbms/src/Common/dataTypeTransform.h
Outdated
| namespace DB | ||
| { | ||
|
|
||
| ASTPtr getDataTypeAST(const DataTypePtr & data_type); |
There was a problem hiding this comment.
Non-descriptive function name.
Missing comments.
There was a problem hiding this comment.
(the method name was Ok before, because it was hidden inside single cpp file)
|
|
||
| else if (engine_name == "MySQL") | ||
| { | ||
| ASTFunction * engine = engine_define->engine; |
dbms/src/Databases/DatabaseFactory.h
Outdated
|
|
||
| #include <Common/ThreadPool.h> | ||
| #include <Databases/IDatabase.h> | ||
| #include <Parsers/ASTCreateQuery.h> |
There was a problem hiding this comment.
It's not necessarily to include header, because you can use forward declaration.
dbms/src/Databases/DatabaseMySQL.cpp
Outdated
| } | ||
| } | ||
|
|
||
| cond.wait_for(lock, cleaner_sleep_time, quit_requested); |
There was a problem hiding this comment.
You can move it in a while condition, making quit_requested lambda unneeded.
There was a problem hiding this comment.
This might make the code less readable ?
There was a problem hiding this comment.
But now it looks redundant.
dbms/src/Databases/DatabaseMySQL.cpp
Outdated
|
|
||
| static constexpr const std::chrono::seconds cleaner_sleep_time{30}; | ||
|
|
||
| String toQueryStringWithQuote(const std::vector<String> "e_list) |
There was a problem hiding this comment.
Style (whitespace around &)
| * It doesn't make any manipulations with filesystem. | ||
| * All tables are created by calling code after real-time pull-out structure from remote MySQL | ||
| */ | ||
| class DatabaseMySQL : public IDatabase |
There was a problem hiding this comment.
BTW, how it was working without cache?
There was a problem hiding this comment.
The current way of working is not very efficient. Currently, a simple query(no join, no subquery) will call the tryGetStorage method five or six times.
The MySQL database engine attempts to query MySQL system tables every time tryGetStorage is called. This will exist the following scenarios:
- exist in cache & no exist in mysql :
Move tables to outdated list for asynchronous drop. - no exist in cache & exist in mysql :
Create tables and add to cache. - exist in cache & exist in mysql, but table structure are updated:
Execute both cases simultaneously
There was a problem hiding this comment.
I'm not sure what would happen if you returned different storage to the same query. Maybe we should write a test ?
There was a problem hiding this comment.
Ok, the cache is reasonable.
dbms/src/Databases/DatabasesCommon.h
Outdated
| bool isTableExist( | ||
| const Context & context, | ||
| const String & table_name) const override; | ||
| const String & table_name) override; |
There was a problem hiding this comment.
I don't like removing const from methods... maybe it is better to make cache mutable.
| } | ||
|
|
||
| if (columns.empty()) | ||
| throw Exception("MySQL table " + database_name + "." + table_name + " doesn't exist..", ErrorCodes::UNKNOWN_TABLE); |
| } | ||
|
|
||
| if (columns.empty()) | ||
| throw Exception("MySQL table " + database_name + "." + table_name + " doesn't exist..", ErrorCodes::UNKNOWN_TABLE); |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Almost Ok, just a few questions remain.
3c65409 to
162d05b
Compare
162d05b to
ec8d735
Compare
| } | ||
|
|
||
| if (columns.empty()) | ||
| throw Exception("MySQL table `" + database_name + "`.`" + table_name + "` doesn't exist.", ErrorCodes::UNKNOWN_TABLE); |
There was a problem hiding this comment.
But there is a function named backQuoteIfNeed that will also do proper escaping.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Category:
Detailed description (optional):
It doesn't make any manipulations with filesystem.
All tables are created by calling code after real-time pull-out structure from remote MySQL