diff --git a/dbms/src/Functions/FunctionsJSON.cpp b/dbms/src/Functions/FunctionsJSON.cpp index d8c33945f52..819f97f07c7 100644 --- a/dbms/src/Functions/FunctionsJSON.cpp +++ b/dbms/src/Functions/FunctionsJSON.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include namespace DB diff --git a/dbms/src/Functions/FunctionsJSON.h b/dbms/src/Functions/FunctionsJSON.h index acf853b6c83..fa56b34bef0 100644 --- a/dbms/src/Functions/FunctionsJSON.h +++ b/dbms/src/Functions/FunctionsJSON.h @@ -130,38 +130,39 @@ public: { bool ok = parser.parse(reinterpret_cast(&chars[offsets[i - 1]]), offsets[i] - offsets[i - 1] - 1); - auto it = parser.getRoot(); - for (const auto j : ext::range(0, moves.size())) + if (ok) { - if (!ok) - break; + auto it = parser.getRoot(); /// Perform moves. - switch (moves[j].type) + for (size_t j = 0; (j != moves.size()) && ok; ++j) { - case MoveType::ConstIndex: - ok = moveIteratorToElementByIndex(it, moves[j].index); - break; - case MoveType::ConstKey: - ok = moveIteratorToElementByKey(it, moves[j].key); - break; - case MoveType::Index: + switch (moves[j].type) { - const Field field = (*block.getByPosition(arguments[j + 1]).column)[i]; - ok = moveIteratorToElementByIndex(it, field.get()); - break; - } - case MoveType::Key: - { - const Field field = (*block.getByPosition(arguments[j + 1]).column)[i]; - ok = moveIteratorToElementByKey(it, field.get().data()); - break; + case MoveType::ConstIndex: + ok = moveIteratorToElementByIndex(it, moves[j].index); + break; + case MoveType::ConstKey: + ok = moveIteratorToElementByKey(it, moves[j].key); + break; + case MoveType::Index: + { + const Field field = (*block.getByPosition(arguments[j + 1]).column)[i]; + ok = moveIteratorToElementByIndex(it, field.get()); + break; + } + case MoveType::Key: + { + const Field field = (*block.getByPosition(arguments[j + 1]).column)[i]; + ok = moveIteratorToElementByKey(it, field.get().data()); + break; + } } } - } - if (ok) - ok = impl.addValueToColumn(*to, it); + if (ok) + ok = impl.addValueToColumn(*to, it); + } /// We add default value (=null or zero) if something goes wrong, we don't throw exceptions in these JSON functions. if (!ok)