ISSUES-4006 rename sign and version column

This commit is contained in:
zhang2014 2020-06-25 23:39:33 +08:00
parent 101a13b5c3
commit 3afffaf303
3 changed files with 63 additions and 2 deletions

View File

@ -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))

View 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);
}
}

View 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);
}