mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 12:44:42 +00:00
ISSUES-4006 rename sign and version column
This commit is contained in:
parent
101a13b5c3
commit
3afffaf303
@ -142,8 +142,8 @@ String toCreateQuery(const MySQLTableStruct & table_struct, const Context & cont
|
||||
+ " cannot be materialized, because there is no primary keys.", ErrorCodes::NOT_IMPLEMENTED);
|
||||
|
||||
WriteBufferFromOwnString out;
|
||||
String sign = getUniqueColumnName(table_struct.columns_name_and_type, "__sign");
|
||||
String version = getUniqueColumnName(table_struct.columns_name_and_type, "__version");
|
||||
String sign = getUniqueColumnName(table_struct.columns_name_and_type, "_sign");
|
||||
String version = getUniqueColumnName(table_struct.columns_name_and_type, "_version");
|
||||
out << "CREATE TABLE " << (table_struct.if_not_exists ? "IF NOT EXISTS" : "")
|
||||
<< backQuoteIfNeed(table_struct.database_name) + "." << backQuoteIfNeed(table_struct.table_name)
|
||||
<< "(" << queryToString(InterpreterCreateQuery::formatColumns(table_struct.columns_name_and_type))
|
||||
|
37
src/Parsers/MySQL/tryParseMySQLQuery.cpp
Normal file
37
src/Parsers/MySQL/tryParseMySQLQuery.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <Parsers/MySQL/tryParseMySQLQuery.h>
|
||||
|
||||
#include <Parsers/ParserDropQuery.h>
|
||||
#include <Parsers/ParserRenameQuery.h>
|
||||
#include <Parsers/MySQL/ASTCreateQuery.h>
|
||||
|
||||
#include <Parsers/parseQuery.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace MySQLParser
|
||||
{
|
||||
|
||||
bool ParserQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
ParserDropQuery p_drop_query;
|
||||
ParserRenameQuery p_rename_query;
|
||||
ParserCreateQuery p_create_query;
|
||||
/// TODO: alter table
|
||||
|
||||
return p_create_query.parse(pos, node, expected) || p_drop_query.parse(pos, node, expected)
|
||||
|| p_rename_query.parse(pos, node, expected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ASTPtr tryParseMySQLQuery(const std::string & query, size_t max_query_size, size_t max_parser_depth)
|
||||
{
|
||||
std::string error_message;
|
||||
const char * pos = query.data();
|
||||
MySQLParser::ParserQuery p_query;
|
||||
return tryParseQuery(p_query, pos, query.data() + query.size(), error_message, false, "", false, max_query_size, max_parser_depth);
|
||||
}
|
||||
|
||||
}
|
||||
|
24
src/Parsers/MySQL/tryParseMySQLQuery.h
Normal file
24
src/Parsers/MySQL/tryParseMySQLQuery.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <Parsers/IAST.h>
|
||||
#include <Parsers/IParserBase.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace MySQLParser
|
||||
{
|
||||
|
||||
class ParserQuery : public IParserBase
|
||||
{
|
||||
protected:
|
||||
const char * getName() const override { return "MySQL Query"; }
|
||||
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ASTPtr tryParseMySQLQuery(const std::string & query, size_t max_query_size, size_t max_parser_depth);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user