Merge pull request #35886 from azat/format-insert-infile-fix

Fix formatting of INSERT INFILE queries (missing quotes)
This commit is contained in:
Alexey Milovidov 2022-04-05 00:47:54 +03:00 committed by GitHub
commit 9d5c13c71d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 4 deletions

View File

@ -81,9 +81,17 @@ void ASTInsertQuery::formatImpl(const FormatSettings & settings, FormatState & s
if (infile)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << " FROM INFILE " << (settings.hilite ? hilite_none : "") << infile->as<ASTLiteral &>().value.safeGet<std::string>();
settings.ostr
<< (settings.hilite ? hilite_keyword : "")
<< " FROM INFILE "
<< (settings.hilite ? hilite_none : "")
<< quoteString(infile->as<ASTLiteral &>().value.safeGet<std::string>());
if (compression)
settings.ostr << (settings.hilite ? hilite_keyword : "") << " COMPRESSION " << (settings.hilite ? hilite_none : "") << compression->as<ASTLiteral &>().value.safeGet<std::string>();
settings.ostr
<< (settings.hilite ? hilite_keyword : "")
<< " COMPRESSION "
<< (settings.hilite ? hilite_none : "")
<< quoteString(compression->as<ASTLiteral &>().value.safeGet<std::string>());
}
if (select)

View File

@ -1,5 +1,5 @@
INSERT INTO test FROM INFILE data.file SELECT x
INSERT INTO test FROM INFILE \'data.file\' SELECT x
FROM input(\'x UInt32\')
INSERT INTO test FROM INFILE data.file WITH number AS x
INSERT INTO test FROM INFILE \'data.file\' WITH number AS x
SELECT number
FROM input(\'number UInt32\')

View File

@ -0,0 +1,3 @@
-- { echo }
EXPLAIN SYNTAX INSERT INTO foo FROM INFILE '/dev/null' COMPRESSION 'gz';
INSERT INTO foo FROM INFILE \'/dev/null\' COMPRESSION \'gz\'

View File

@ -0,0 +1,2 @@
-- { echo }
EXPLAIN SYNTAX INSERT INTO foo FROM INFILE '/dev/null' COMPRESSION 'gz';

View File

@ -0,0 +1,3 @@
-- { echo }
EXPLAIN SYNTAX INSERT INTO foo FROM INFILE '/dev/null';
INSERT INTO foo FROM INFILE \'/dev/null\'

View File

@ -0,0 +1,2 @@
-- { echo }
EXPLAIN SYNTAX INSERT INTO foo FROM INFILE '/dev/null';