Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLASH-582: Fix table info json escape #285

Merged
merged 2 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbms/src/Storages/StorageMergeTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ void StorageMergeTree::alterInternal(

if (table_info)
{
auto literal = std::make_shared<ASTLiteral>(Field(table_info->get().serialize(true)));
auto literal = std::make_shared<ASTLiteral>(Field(table_info->get().serialize()));
typeid_cast<ASTExpressionList &>(*storage_ast.engine->arguments).children.back() = literal;
}
};
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/SchemaBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ String createTableStmt(const DBInfo & db_info, const TableInfo & table_info)
writeBackQuotedString(pks[i], stmt_buf);
}
writeString("), 8192, '", stmt_buf);
writeString(table_info.serialize(true), stmt_buf);
writeEscapedString(table_info.serialize(), stmt_buf);
writeString("')", stmt_buf);

return stmt;
Expand Down
15 changes: 3 additions & 12 deletions dbms/src/Storages/Transaction/TiDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ using DB::Decimal32;
using DB::Decimal64;
using DB::DecimalField;
using DB::Field;
using DB::WriteBufferFromOwnString;

ColumnInfo::ColumnInfo(Poco::JSON::Object::Ptr json) { deserialize(json); }

Expand Down Expand Up @@ -283,7 +282,8 @@ catch (const Poco::Exception & e)

TableInfo::TableInfo(const String & table_info_json) { deserialize(table_info_json); }

String TableInfo::serialize(bool escaped) const try
String TableInfo::serialize() const
try
{
std::stringstream buf;

Expand Down Expand Up @@ -324,16 +324,7 @@ String TableInfo::serialize(bool escaped) const try

json->stringify(buf);

if (!escaped)
{
return buf.str();
}
else
{
WriteBufferFromOwnString escaped_buf;
writeEscapedString(buf.str(), escaped_buf);
return escaped_buf.str();
}
return buf.str();
}
catch (const Poco::Exception & e)
{
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Storages/Transaction/TiDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ struct TableInfo

TableInfo(const String & table_info_json);

String serialize(bool escaped) const;
String serialize() const;

void deserialize(const String & json_str);

Expand Down
3 changes: 0 additions & 3 deletions dbms/src/Storages/Transaction/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ target_link_libraries (region_persister dbms)
add_executable (kvstore kvstore.cpp)
target_link_libraries (kvstore dbms)

add_executable (table_info table_info.cpp)
target_link_libraries (table_info dbms)

add_executable (region_test region.cpp)
target_link_libraries (region_test dbms)
119 changes: 0 additions & 119 deletions dbms/src/Storages/Transaction/tests/table_info.cpp

This file was deleted.