Skip to content

Commit c173bd3

Browse files
committed
ISSUES-4006 try fix build & test failure
1 parent 6b452cf commit c173bd3

18 files changed

+250
-247
lines changed

src/Common/tests/CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ target_link_libraries (symbol_index PRIVATE clickhouse_common_io)
7474
add_executable (chaos_sanitizer chaos_sanitizer.cpp)
7575
target_link_libraries (chaos_sanitizer PRIVATE clickhouse_common_io)
7676

77-
add_executable (memory_statistics_os_perf memory_statistics_os_perf.cpp)
78-
target_link_libraries (memory_statistics_os_perf PRIVATE clickhouse_common_io)
77+
if (OS_LINUX)
78+
add_executable (memory_statistics_os_perf memory_statistics_os_perf.cpp)
79+
target_link_libraries (memory_statistics_os_perf PRIVATE clickhouse_common_io)
80+
endif()
7981

8082
add_executable (procfs_metrics_provider_perf procfs_metrics_provider_perf.cpp)
8183
target_link_libraries (procfs_metrics_provider_perf PRIVATE clickhouse_common_io)

src/Core/MySQLReplication.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ namespace MySQLReplication
398398
}
399399
case MYSQL_TYPE_TIMESTAMP: {
400400
UInt32 val = 0;
401+
401402
payload.readStrict(reinterpret_cast<char *>(&val), 4);
402403
row.push_back(Field{val});
403404
break;

src/DataTypes/DataTypesNumber.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ static DataTypePtr createNumericDataType(const ASTPtr & arguments)
3535

3636
void registerDataTypeNumbers(DataTypeFactory & factory)
3737
{
38-
factory.registerSimpleDataType("UInt8", [] { return DataTypePtr(std::make_shared<DataTypeUInt8>()); });
39-
factory.registerSimpleDataType("UInt16", [] { return DataTypePtr(std::make_shared<DataTypeUInt16>()); });
40-
factory.registerSimpleDataType("UInt32", [] { return DataTypePtr(std::make_shared<DataTypeUInt32>()); });
41-
factory.registerSimpleDataType("UInt64", [] { return DataTypePtr(std::make_shared<DataTypeUInt64>()); });
38+
factory.registerDataType("UInt8", createNumericDataType<UInt8>);
39+
factory.registerDataType("UInt16", createNumericDataType<UInt16>);
40+
factory.registerDataType("UInt32", createNumericDataType<UInt32>);
41+
factory.registerDataType("UInt64", createNumericDataType<UInt64>);
4242

4343
factory.registerDataType("Int8", createNumericDataType<Int8>);
4444
factory.registerDataType("Int16", createNumericDataType<Int16>);

src/Databases/MySQL/MaterializeMetadata.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void MaterializeMetadata::transaction(const MySQLReplication::Position & positio
155155
out.close();
156156
}
157157

158-
commitMetadata(fun, persistent_tmp_path, persistent_path);
158+
commitMetadata(std::move(fun), persistent_tmp_path, persistent_path);
159159
}
160160

161161
MaterializeMetadata::MaterializeMetadata(

src/Databases/MySQL/MaterializeMySQLSyncThread.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ static void writeFieldsToColumn(
377377
if (field.isNull())
378378
{
379379
column_to.insertDefault();
380-
null_map_column->insertDefault();
380+
null_map_column->insertValue(1);
381381
return false;
382382
}
383383

@@ -391,7 +391,8 @@ static void writeFieldsToColumn(
391391
{
392392
for (size_t index = 0; index < rows_data.size(); ++index)
393393
{
394-
const Field & value = DB::get<const Tuple &>(rows_data[index])[column_index];
394+
const Tuple & row_data = DB::get<const Tuple &>(rows_data[index]);
395+
const Field & value = row_data[column_index];
395396

396397
if (write_data_to_null_map(value, index))
397398
casted_column->insertValue(static_cast<decltype(to_type)>(value.template get<decltype(from_type)>()));
@@ -420,7 +421,8 @@ static void writeFieldsToColumn(
420421
{
421422
for (size_t index = 0; index < rows_data.size(); ++index)
422423
{
423-
const Field & value = DB::get<const Tuple &>(rows_data[index])[column_index];
424+
const Tuple & row_data = DB::get<const Tuple &>(rows_data[index]);
425+
const Field & value = row_data[column_index];
424426

425427
if (write_data_to_null_map(value, index))
426428
{
@@ -441,7 +443,8 @@ static void writeFieldsToColumn(
441443
{
442444
for (size_t index = 0; index < rows_data.size(); ++index)
443445
{
444-
const Field & value = DB::get<const Tuple &>(rows_data[index])[column_index];
446+
const Tuple & row_data = DB::get<const Tuple &>(rows_data[index]);
447+
const Field & value = row_data[column_index];
445448

446449
if (write_data_to_null_map(value, index))
447450
{
@@ -454,7 +457,8 @@ static void writeFieldsToColumn(
454457
{
455458
for (size_t index = 0; index < rows_data.size(); ++index)
456459
{
457-
const Field & value = DB::get<const Tuple &>(rows_data[index])[column_index];
460+
const Tuple & row_data = DB::get<const Tuple &>(rows_data[index]);
461+
const Field & value = row_data[column_index];
458462

459463
if (write_data_to_null_map(value, index))
460464
{
@@ -600,7 +604,7 @@ void MaterializeMySQLSyncThread::Buffers::add(size_t block_rows, size_t block_by
600604
max_block_bytes = std::max(block_bytes, max_block_bytes);
601605
}
602606

603-
bool MaterializeMySQLSyncThread::Buffers::checkThresholds(size_t check_block_rows, size_t check_block_bytes, size_t check_total_rows, size_t check_total_bytes)
607+
bool MaterializeMySQLSyncThread::Buffers::checkThresholds(size_t check_block_rows, size_t check_block_bytes, size_t check_total_rows, size_t check_total_bytes) const
604608
{
605609
return max_block_rows >= check_block_rows || max_block_bytes >= check_block_bytes || total_blocks_rows >= check_total_rows
606610
|| total_blocks_bytes >= check_total_bytes;

src/Databases/MySQL/MaterializeMySQLSyncThread.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class MaterializeMySQLSyncThread
6868

6969
void add(size_t block_rows, size_t block_bytes, size_t written_rows, size_t written_bytes);
7070

71-
bool checkThresholds(size_t check_block_rows, size_t check_block_bytes, size_t check_total_rows, size_t check_total_bytes);
71+
bool checkThresholds(size_t check_block_rows, size_t check_block_bytes, size_t check_total_rows, size_t check_total_bytes) const;
7272

7373
BufferAndSortingColumnsPtr getTableDataBuffer(const String & table, const Context & context);
7474
};

src/Interpreters/MySQL/InterpretersMySQLDDLQuery.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static inline NamesAndTypesList getColumnsList(ASTExpressionList * columns_defin
6464

6565
if (is_unsigned)
6666
{
67-
auto data_type_function = data_type->as<ASTFunction>();
67+
auto * data_type_function = data_type->as<ASTFunction>();
6868

6969
if (data_type_function)
7070
{

src/Parsers/MySQL/ASTAlterCommand.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -29,40 +29,15 @@ ASTPtr ASTAlterCommand::clone() const
2929
res->set(res->additional_columns, additional_columns->clone());
3030

3131
if (order_by_columns)
32-
res->set(res->order_by_columns, additional_columns->clone());
32+
res->set(res->order_by_columns, order_by_columns->clone());
3333

3434
if (properties)
3535
res->set(res->properties, properties->clone());
3636

3737
return res;
3838
}
3939

40-
bool ParserAlterCommand::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
41-
{
42-
ParserKeyword k_add("ADD");
43-
ParserKeyword k_drop("DROP");
44-
ParserKeyword k_alter("ALTER");
45-
ParserKeyword k_rename("RENAME");
46-
ParserKeyword k_modify("MODIFY");
47-
ParserKeyword k_change("CHANGE");
48-
49-
if (k_add.ignore(pos, expected))
50-
return parseAddCommand(pos, node, expected);
51-
else if (k_drop.ignore(pos, expected))
52-
return parseDropCommand(pos, node, expected);
53-
else if (k_alter.ignore(pos, expected))
54-
return parseAlterCommand(pos, node, expected);
55-
else if (k_rename.ignore(pos, expected))
56-
return parseRenameCommand(pos, node, expected);
57-
else if (k_modify.ignore(pos, expected))
58-
return parseModifyCommand(pos, node, expected);
59-
else if (k_change.ignore(pos, expected))
60-
return parseModifyCommand(pos, node, expected, true);
61-
else
62-
return parseOtherCommand(pos, node, expected);
63-
}
64-
65-
bool ParserAlterCommand::parseAddCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
40+
static inline bool parseAddCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
6641
{
6742
ASTPtr declare_index;
6843
ASTPtr additional_columns;
@@ -120,7 +95,7 @@ bool ParserAlterCommand::parseAddCommand(IParser::Pos & pos, ASTPtr & node, Expe
12095
return true;
12196
}
12297

123-
bool ParserAlterCommand::parseDropCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
98+
static inline bool parseDropCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
12499
{
125100
ASTPtr name;
126101
ParserIdentifier identifier_p;
@@ -173,7 +148,7 @@ bool ParserAlterCommand::parseDropCommand(IParser::Pos & pos, ASTPtr & node, Exp
173148
return true;
174149
}
175150

176-
bool ParserAlterCommand::parseAlterCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
151+
static inline bool parseAlterCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
177152
{
178153
ASTPtr name;
179154

@@ -241,7 +216,7 @@ bool ParserAlterCommand::parseAlterCommand(IParser::Pos & pos, ASTPtr & node, Ex
241216
return true;
242217
}
243218

244-
bool ParserAlterCommand::parseRenameCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
219+
static inline bool parseRenameCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
245220
{
246221
ASTPtr old_name;
247222
ASTPtr new_name;
@@ -296,7 +271,7 @@ bool ParserAlterCommand::parseRenameCommand(IParser::Pos & pos, ASTPtr & node, E
296271
return true;
297272
}
298273

299-
bool ParserAlterCommand::parseOtherCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
274+
static inline bool parseOtherCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected)
300275
{
301276
auto alter_command = std::make_shared<ASTAlterCommand>();
302277

@@ -346,7 +321,7 @@ bool ParserAlterCommand::parseOtherCommand(IParser::Pos & pos, ASTPtr & node, Ex
346321
return true;
347322
}
348323

349-
bool ParserAlterCommand::parseModifyCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected, bool exists_old_column_name)
324+
static inline bool parseModifyCommand(IParser::Pos & pos, ASTPtr & node, Expected & expected, bool exists_old_column_name = false)
350325
{
351326
ASTPtr old_column_name;
352327
auto alter_command = std::make_shared<ASTAlterCommand>();
@@ -381,6 +356,31 @@ bool ParserAlterCommand::parseModifyCommand(IParser::Pos & pos, ASTPtr & node, E
381356

382357
return true;
383358
}
359+
360+
bool ParserAlterCommand::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
361+
{
362+
ParserKeyword k_add("ADD");
363+
ParserKeyword k_drop("DROP");
364+
ParserKeyword k_alter("ALTER");
365+
ParserKeyword k_rename("RENAME");
366+
ParserKeyword k_modify("MODIFY");
367+
ParserKeyword k_change("CHANGE");
368+
369+
if (k_add.ignore(pos, expected))
370+
return parseAddCommand(pos, node, expected);
371+
else if (k_drop.ignore(pos, expected))
372+
return parseDropCommand(pos, node, expected);
373+
else if (k_alter.ignore(pos, expected))
374+
return parseAlterCommand(pos, node, expected);
375+
else if (k_rename.ignore(pos, expected))
376+
return parseRenameCommand(pos, node, expected);
377+
else if (k_modify.ignore(pos, expected))
378+
return parseModifyCommand(pos, node, expected);
379+
else if (k_change.ignore(pos, expected))
380+
return parseModifyCommand(pos, node, expected, true);
381+
else
382+
return parseOtherCommand(pos, node, expected);
383+
}
384384
}
385385

386386
}

src/Parsers/MySQL/ASTAlterCommand.h

+5-17
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ class ASTAlterCommand : public IAST
4343
Type type = NO_TYPE;
4444

4545
/// For ADD INDEX
46-
ASTDeclareIndex * index_decl;
46+
ASTDeclareIndex * index_decl = nullptr;
4747

4848
/// For modify default expression
49-
IAST * default_expression;
49+
IAST * default_expression = nullptr;
5050

5151
/// For ADD COLUMN
52-
ASTExpressionList * additional_columns;
52+
ASTExpressionList * additional_columns = nullptr;
5353
/// For ORDER BY
54-
ASTExpressionList * order_by_columns;
54+
ASTExpressionList * order_by_columns = nullptr;
5555

5656
bool first = false;
5757
bool index_visible = false;
@@ -63,7 +63,7 @@ class ASTAlterCommand : public IAST
6363
String column_name;
6464
String constraint_name;
6565

66-
IAST * properties;
66+
IAST * properties = nullptr;
6767

6868
ASTPtr clone() const override;
6969

@@ -76,18 +76,6 @@ class ParserAlterCommand : public IParserBase
7676
const char * getName() const override { return "alter command"; }
7777

7878
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
79-
80-
bool parseAddCommand(Pos & pos, ASTPtr & node, Expected & expected);
81-
82-
bool parseDropCommand(Pos & pos, ASTPtr & node, Expected & expected);
83-
84-
bool parseAlterCommand(Pos & pos, ASTPtr & node, Expected & expected);
85-
86-
bool parseRenameCommand(Pos & pos, ASTPtr & node, Expected & expected);
87-
88-
bool parseModifyCommand(Pos & pos, ASTPtr & node, Expected & expected, bool exists_old_column_name = false);
89-
90-
bool parseOtherCommand(Pos & pos, ASTPtr & node, Expected & expected);
9179
};
9280

9381
}

src/Parsers/MySQL/ASTDeclareColumn.cpp

+33-31
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,39 @@ ASTPtr ASTDeclareColumn::clone() const
3434
return res;
3535
}
3636

37+
static inline bool parseColumnDeclareOptions(IParser::Pos & pos, ASTPtr & node, Expected & expected)
38+
{
39+
ParserDeclareOptions p_non_generate_options{
40+
{
41+
OptionDescribe("ZEROFILL", "zero_fill", std::make_unique<ParserAlwaysTrue>()),
42+
OptionDescribe("SIGNED", "is_unsigned", std::make_unique<ParserAlwaysFalse>()),
43+
OptionDescribe("UNSIGNED", "is_unsigned", std::make_unique<ParserAlwaysTrue>()),
44+
OptionDescribe("NULL", "is_null", std::make_unique<ParserAlwaysTrue>()),
45+
OptionDescribe("NOT NULL", "is_null", std::make_unique<ParserAlwaysFalse>()),
46+
OptionDescribe("DEFAULT", "default", std::make_unique<ParserExpression>()),
47+
OptionDescribe("ON UPDATE", "on_update", std::make_unique<ParserExpression>()),
48+
OptionDescribe("AUTO_INCREMENT", "auto_increment", std::make_unique<ParserAlwaysTrue>()),
49+
OptionDescribe("UNIQUE", "unique_key", std::make_unique<ParserAlwaysTrue>()),
50+
OptionDescribe("UNIQUE KEY", "unique_key", std::make_unique<ParserAlwaysTrue>()),
51+
OptionDescribe("KEY", "primary_key", std::make_unique<ParserAlwaysTrue>()),
52+
OptionDescribe("PRIMARY KEY", "primary_key", std::make_unique<ParserAlwaysTrue>()),
53+
OptionDescribe("COMMENT", "comment", std::make_unique<ParserStringLiteral>()),
54+
OptionDescribe("CHARACTER SET", "charset_name", std::make_unique<ParserCharsetName>()),
55+
OptionDescribe("COLLATE", "collate", std::make_unique<ParserCharsetName>()),
56+
OptionDescribe("COLUMN_FORMAT", "column_format", std::make_unique<ParserIdentifier>()),
57+
OptionDescribe("STORAGE", "storage", std::make_unique<ParserIdentifier>()),
58+
OptionDescribe("AS", "generated", std::make_unique<ParserExpression>()),
59+
OptionDescribe("GENERATED ALWAYS AS", "generated", std::make_unique<ParserExpression>()),
60+
OptionDescribe("STORED", "is_stored", std::make_unique<ParserAlwaysTrue>()),
61+
OptionDescribe("VIRTUAL", "is_stored", std::make_unique<ParserAlwaysFalse>()),
62+
OptionDescribe("", "reference", std::make_unique<ParserDeclareReference>()),
63+
OptionDescribe("", "constraint", std::make_unique<ParserDeclareConstraint>()),
64+
}
65+
};
66+
67+
return p_non_generate_options.parse(pos, node, expected);
68+
}
69+
3770
bool ParserDeclareColumn::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
3871
{
3972
ASTPtr column_name;
@@ -65,37 +98,6 @@ bool ParserDeclareColumn::parseImpl(Pos & pos, ASTPtr & node, Expected & expecte
6598
node = declare_column;
6699
return true;
67100
}
68-
bool ParserDeclareColumn::parseColumnDeclareOptions(IParser::Pos & pos, ASTPtr & node, Expected & expected)
69-
{
70-
ParserDeclareOptions p_non_generate_options{
71-
{
72-
OptionDescribe("ZEROFILL", "zero_fill", std::make_unique<ParserAlwaysTrue>()),
73-
OptionDescribe("SIGNED", "is_unsigned", std::make_unique<ParserAlwaysFalse>()),
74-
OptionDescribe("UNSIGNED", "is_unsigned", std::make_unique<ParserAlwaysTrue>()),
75-
OptionDescribe("NULL", "is_null", std::make_unique<ParserAlwaysTrue>()),
76-
OptionDescribe("NOT NULL", "is_null", std::make_unique<ParserAlwaysFalse>()),
77-
OptionDescribe("DEFAULT", "default", std::make_unique<ParserExpression>()),
78-
OptionDescribe("AUTO_INCREMENT", "auto_increment", std::make_unique<ParserAlwaysTrue>()),
79-
OptionDescribe("UNIQUE", "unique_key", std::make_unique<ParserAlwaysTrue>()),
80-
OptionDescribe("UNIQUE KEY", "unique_key", std::make_unique<ParserAlwaysTrue>()),
81-
OptionDescribe("KEY", "primary_key", std::make_unique<ParserAlwaysTrue>()),
82-
OptionDescribe("PRIMARY KEY", "primary_key", std::make_unique<ParserAlwaysTrue>()),
83-
OptionDescribe("COMMENT", "comment", std::make_unique<ParserStringLiteral>()),
84-
OptionDescribe("CHARACTER SET", "charset_name", std::make_unique<ParserCharsetName>()),
85-
OptionDescribe("COLLATE", "collate", std::make_unique<ParserCharsetName>()),
86-
OptionDescribe("COLUMN_FORMAT", "column_format", std::make_unique<ParserIdentifier>()),
87-
OptionDescribe("STORAGE", "storage", std::make_unique<ParserIdentifier>()),
88-
OptionDescribe("AS", "generated", std::make_unique<ParserExpression>()),
89-
OptionDescribe("GENERATED ALWAYS AS", "generated", std::make_unique<ParserExpression>()),
90-
OptionDescribe("STORED", "is_stored", std::make_unique<ParserAlwaysTrue>()),
91-
OptionDescribe("VIRTUAL", "is_stored", std::make_unique<ParserAlwaysFalse>()),
92-
OptionDescribe("", "reference", std::make_unique<ParserDeclareReference>()),
93-
OptionDescribe("", "constraint", std::make_unique<ParserDeclareConstraint>()),
94-
}
95-
};
96-
97-
return p_non_generate_options.parse(pos, node, expected);
98-
}
99101

100102
}
101103

src/Parsers/MySQL/ASTDeclareColumn.h

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ class ParserDeclareColumn : public IParserBase
2727
const char * getName() const override { return "index declaration"; }
2828

2929
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
30-
31-
bool parseColumnDeclareOptions(Pos & pos, ASTPtr & node, Expected & expected);
3230
};
3331

3432

0 commit comments

Comments
 (0)