Skip to content

Commit

Permalink
AST fuzzer: Print data of INSERT VALUES
Browse files Browse the repository at this point in the history
  • Loading branch information
Algunenano committed Nov 22, 2022
1 parent 8776b2f commit ad95846
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 19 additions & 2 deletions programs/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@

#include <IO/ReadBufferFromString.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <IO/WriteBufferFromOStream.h>
#include <IO/UseSSL.h>
#include <IO/WriteBufferFromOStream.h>
#include <IO/WriteHelpers.h>
#include <IO/copyData.h>

#include <Parsers/ASTCreateQuery.h>
#include <Parsers/ASTDropQuery.h>
Expand All @@ -39,6 +40,8 @@
#include <Parsers/ASTInsertQuery.h>
#include <Parsers/ASTSelectQuery.h>

#include <Processors/Transforms/getSourceFromASTInsertQuery.h>

#include <Interpreters/InterpreterSetQuery.h>

#include <Functions/registerFunctions.h>
Expand Down Expand Up @@ -829,6 +832,20 @@ bool Client::processWithFuzzing(const String & full_query)
WriteBufferFromOStream ast_buf(std::cout, 4096);
formatAST(*query, ast_buf, false /*highlight*/);
ast_buf.next();
if (const auto * insert = query->as<ASTInsertQuery>())
{
/// For inserts with data it's really useful to have the data itself available in the logs, as formatAST doesn't print it
if (insert->hasInlinedData())
{
String bytes;
{
auto read_buf = getReadBufferFromASTInsertQuery(query);
WriteBufferFromString write_buf(bytes);
copyData(*read_buf, write_buf);
}
std::cout << std::endl << bytes;
}
}
std::cout << std::endl << std::endl;

try
Expand Down
1 change: 0 additions & 1 deletion tests/queries/0_stateless/02482_value_block_parsing.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# Tags: long

CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
Expand Down

0 comments on commit ad95846

Please sign in to comment.