diff --git a/src/Parsers/ASTColumnDeclaration.h b/src/Parsers/ASTColumnDeclaration.h index 2008e4f99d1..45814551db8 100644 --- a/src/Parsers/ASTColumnDeclaration.h +++ b/src/Parsers/ASTColumnDeclaration.h @@ -16,7 +16,7 @@ public: std::optional null_modifier; String default_specifier; ASTPtr default_expression; - bool ephemeral_default; + bool ephemeral_default = false; ASTPtr comment; ASTPtr codec; ASTPtr ttl; diff --git a/src/Parsers/ASTDictionaryAttributeDeclaration.h b/src/Parsers/ASTDictionaryAttributeDeclaration.h index b6572e89d16..52103650684 100644 --- a/src/Parsers/ASTDictionaryAttributeDeclaration.h +++ b/src/Parsers/ASTDictionaryAttributeDeclaration.h @@ -19,13 +19,13 @@ public: /// Attribute expression ASTPtr expression; /// Is attribute mirrored to the parent identifier - bool hierarchical; + bool hierarchical = false; /// Is hierarchical attribute bidirectional - bool bidirectional; + bool bidirectional = false; /// Flag that shows whether the id->attribute image is injective - bool injective; + bool injective = false; /// MongoDB object ID - bool is_object_id; + bool is_object_id = false; String getID(char delim) const override { return "DictionaryAttributeDeclaration" + (delim + name); } diff --git a/src/Parsers/ASTOrderByElement.h b/src/Parsers/ASTOrderByElement.h index 4d07405c17a..468d2161dff 100644 --- a/src/Parsers/ASTOrderByElement.h +++ b/src/Parsers/ASTOrderByElement.h @@ -11,14 +11,14 @@ namespace DB class ASTOrderByElement : public IAST { public: - int direction; /// 1 for ASC, -1 for DESC - int nulls_direction; /// Same as direction for NULLS LAST, opposite for NULLS FIRST. - bool nulls_direction_was_explicitly_specified; + int direction = 0; /// 1 for ASC, -1 for DESC + int nulls_direction = 0; /// Same as direction for NULLS LAST, opposite for NULLS FIRST. + bool nulls_direction_was_explicitly_specified = false; /** Collation for locale-specific string comparison. If empty, then sorting done by bytes. */ ASTPtr collation; - bool with_fill; + bool with_fill = false; ASTPtr fill_from; ASTPtr fill_to; ASTPtr fill_step; diff --git a/src/Parsers/ASTQueryWithOutput.cpp b/src/Parsers/ASTQueryWithOutput.cpp index 9f771ab92e3..5f717715a69 100644 --- a/src/Parsers/ASTQueryWithOutput.cpp +++ b/src/Parsers/ASTQueryWithOutput.cpp @@ -35,6 +35,13 @@ void ASTQueryWithOutput::formatImpl(const FormatSettings & s, FormatState & stat { s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "INTO OUTFILE " << (s.hilite ? hilite_none : ""); out_file->formatImpl(s, state, frame); + + s.ostr << (s.hilite ? hilite_keyword : ""); + if (is_outfile_append) + s.ostr << " APPEND"; + if (is_into_outfile_with_stdout) + s.ostr << " AND STDOUT"; + s.ostr << (s.hilite ? hilite_none : ""); } if (format) diff --git a/src/Parsers/ASTQueryWithOutput.h b/src/Parsers/ASTQueryWithOutput.h index 09f08772468..7db021405e7 100644 --- a/src/Parsers/ASTQueryWithOutput.h +++ b/src/Parsers/ASTQueryWithOutput.h @@ -15,8 +15,8 @@ class ASTQueryWithOutput : public IAST { public: ASTPtr out_file; - bool is_into_outfile_with_stdout; - bool is_outfile_append; + bool is_into_outfile_with_stdout = false; + bool is_outfile_append = false; ASTPtr format; ASTPtr settings_ast; ASTPtr compression; diff --git a/src/Parsers/ASTWatchQuery.h b/src/Parsers/ASTWatchQuery.h index 29dadd71675..156fe6828bc 100644 --- a/src/Parsers/ASTWatchQuery.h +++ b/src/Parsers/ASTWatchQuery.h @@ -23,7 +23,7 @@ class ASTWatchQuery : public ASTQueryWithTableAndOutput public: ASTPtr limit_length; - bool is_watch_events; + bool is_watch_events = false; ASTWatchQuery() = default; String getID(char) const override { return "WatchQuery_" + getDatabase() + "_" + getTable(); } diff --git a/tests/queries/0_stateless/02767_into_outfile_extensions_msan.reference b/tests/queries/0_stateless/02767_into_outfile_extensions_msan.reference new file mode 100644 index 00000000000..0c8b489c2fd --- /dev/null +++ b/tests/queries/0_stateless/02767_into_outfile_extensions_msan.reference @@ -0,0 +1,2 @@ +Expression ((Projection + Before ORDER BY)) + ReadFromStorage (SystemNumbers) diff --git a/tests/queries/0_stateless/02767_into_outfile_extensions_msan.sh b/tests/queries/0_stateless/02767_into_outfile_extensions_msan.sh new file mode 100755 index 00000000000..d1e7312b150 --- /dev/null +++ b/tests/queries/0_stateless/02767_into_outfile_extensions_msan.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +out="explain1.$CLICKHOUSE_TEST_UNIQUE_NAME.out" +# only EXPLAIN triggers the problem under MSan +$CLICKHOUSE_CLIENT -q "explain select * from numbers(1) into outfile '$out'" +cat "$out" +rm -f "$out" diff --git a/tests/queries/0_stateless/02768_into_outfile_extensions_format.reference b/tests/queries/0_stateless/02768_into_outfile_extensions_format.reference new file mode 100644 index 00000000000..4ebc1da8865 --- /dev/null +++ b/tests/queries/0_stateless/02768_into_outfile_extensions_format.reference @@ -0,0 +1,20 @@ +SELECT * +FROM numbers(1) +INTO OUTFILE '/dev/null' +; + +SELECT * +FROM numbers(1) +INTO OUTFILE '/dev/null' AND STDOUT +; + +SELECT * +FROM numbers(1) +INTO OUTFILE '/dev/null' APPEND +; + +SELECT * +FROM numbers(1) +INTO OUTFILE '/dev/null' APPEND AND STDOUT +; + diff --git a/tests/queries/0_stateless/02768_into_outfile_extensions_format.sh b/tests/queries/0_stateless/02768_into_outfile_extensions_format.sh new file mode 100755 index 00000000000..756488076f9 --- /dev/null +++ b/tests/queries/0_stateless/02768_into_outfile_extensions_format.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CUR_DIR"/../shell_config.sh + +echo " +select * from numbers(1) into outfile '/dev/null'; +select * from numbers(1) into outfile '/dev/null' and stdout; +select * from numbers(1) into outfile '/dev/null' append; +select * from numbers(1) into outfile '/dev/null' append and stdout; +" | clickhouse-format -n