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

Don't use type conversion with String query parameters #48577

Merged
merged 3 commits into from
Apr 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Interpreters/ReplaceQueryParameterVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <Columns/IColumn.h>
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/IDataType.h>
#include <DataTypes/DataTypeString.h>
#include <Formats/FormatSettings.h>
#include <IO/ReadBufferFromString.h>
#include <Interpreters/IdentifierSemantic.h>
Expand Down Expand Up @@ -102,7 +103,13 @@ void ReplaceQueryParameterVisitor::visitQueryParameter(ASTPtr & ast)
else
literal = temp_column[0];

ast = addTypeConversionToAST(std::make_shared<ASTLiteral>(literal), type_name);
/// If it's a String, substitute it in the form of a string literal without CAST
/// to enable substitutions in simple queries that don't support expressions
/// (such as CREATE USER).
if (typeid_cast<const DataTypeString *>(data_type.get()))
evillique marked this conversation as resolved.
Show resolved Hide resolved
ast = std::make_shared<ASTLiteral>(literal);
else
ast = addTypeConversionToAST(std::make_shared<ASTLiteral>(literal), type_name);

/// Keep the original alias.
ast->setAlias(alias);
Expand Down