Skip to content

Inconsistent AST formatting with subscript operator and parenthesis #88495

@PedroTadim

Description

@PedroTadim

Describe the bug

The second case in #82834 was not yet fixed. It's another issue.

How to reproduce

Run:

SELECT (-NULL)[1];
/*
<Fatal> : Logical error: 'Inconsistent AST formatting: the query:
SELECT -(NULL)[1]
Was parsed and formatted back as:
SELECT -(NULL[1])'.
*/

Error message and/or stacktrace

Stack trace:

<Fatal> : Logical error: 'Inconsistent AST formatting: the query:
SELECT (-NULL)[1];
Formatted as:
SELECT -(NULL)[1]
Was parsed and formatted back as:
SELECT -(NULL[1])'.
<Fatal> : Stack trace (when copying this message, always include the lines below):

0. contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x0000000024107ff2
1. src/Common/Exception.cpp:129: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x0000000014a61ca9
2. src/Common/Exception.h:123: DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000d35830e
3. src/Common/Exception.h:58: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000d357d11
4. src/Common/Exception.h:141: DB::Exception::Exception<std::basic_string_view<char, std::char_traits<char>>&, String&, String&>(int, FormatStringHelperImpl<std::type_identity<std::basic_string_view<char, std::char_traits<char>>&>::type, std::type_identity<String&>::type, std::type_identity<String&>::type>, std::basic_string_view<char, std::char_traits<char>>&, String&, String&) @ 0x000000001aa8ed36
5. src/Interpreters/executeQuery.cpp:1148: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr<DB::ReadBuffer, std::default_delete<DB::ReadBuffer>>&, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::ImplicitTransactionControlExecutor>, std::function<void ()>) @ 0x000000001aa85032
6. src/Interpreters/executeQuery.cpp:1812: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x000000001aa7dcb2
7. src/Server/TCPHandler.cpp:743: DB::TCPHandler::runImpl() @ 0x000000001e3428ee
8. src/Server/TCPHandler.cpp:2754: DB::TCPHandler::run() @ 0x000000001e35c224
9. base/poco/Net/src/TCPServerConnection.cpp:40: Poco::Net::TCPServerConnection::start() @ 0x00000000241bea07
10. base/poco/Net/src/TCPServerDispatcher.cpp:115: Poco::Net::TCPServerDispatcher::run() @ 0x00000000241befe5
11. base/poco/Foundation/src/ThreadPool.cpp:205: Poco::PooledThread::run() @ 0x000000002415e17f
12. base/poco/Foundation/src/Thread_POSIX.cpp:341: Poco::ThreadImpl::runnableEntry(void*) @ 0x000000002415b851
13. start_thread @ 0x00000000000a27f1
14. __clone3 @ 0x0000000000133b5c

Metadata

Metadata

Labels

fuzzProblem found by one of the fuzzers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions