mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #50216 from azat/fix-asts
Fix UB for INTO OUTFILE extensions (APPEND / AND STDOUT) and WATCH EVENTS
This commit is contained in:
commit
27617fb590
@ -16,7 +16,7 @@ public:
|
||||
std::optional<bool> null_modifier;
|
||||
String default_specifier;
|
||||
ASTPtr default_expression;
|
||||
bool ephemeral_default;
|
||||
bool ephemeral_default = false;
|
||||
ASTPtr comment;
|
||||
ASTPtr codec;
|
||||
ASTPtr ttl;
|
||||
|
@ -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); }
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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(); }
|
||||
|
@ -0,0 +1,2 @@
|
||||
Expression ((Projection + Before ORDER BY))
|
||||
ReadFromStorage (SystemNumbers)
|
11
tests/queries/0_stateless/02767_into_outfile_extensions_msan.sh
Executable file
11
tests/queries/0_stateless/02767_into_outfile_extensions_msan.sh
Executable file
@ -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"
|
@ -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
|
||||
;
|
||||
|
12
tests/queries/0_stateless/02768_into_outfile_extensions_format.sh
Executable file
12
tests/queries/0_stateless/02768_into_outfile_extensions_format.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user