| 118 | |
| 119 | template <bool nullptr_on_error> |
| 120 | DataTypePtr DataTypeFactory::getImpl(const String & full_name) const |
| 121 | { |
| 122 | /// Data type parser can be invoked from coroutines with small stack. |
| 123 | /// Value 315 is known to cause stack overflow in some test configurations (debug build, sanitizers) |
| 124 | /// let's make the threshold significantly lower. |
| 125 | /// It is impractical for user to have complex data types with this depth. |
| 126 | |
| 127 | #if defined(SANITIZER) || !defined(NDEBUG) |
| 128 | static constexpr size_t data_type_max_parse_depth = 150; |
| 129 | #else |
| 130 | static constexpr size_t data_type_max_parse_depth = 300; |
| 131 | #endif |
| 132 | |
| 133 | ParserDataType parser; |
| 134 | ASTPtr ast; |
| 135 | if constexpr (nullptr_on_error) |
| 136 | { |
| 137 | String out_err; |
| 138 | const char * start = full_name.data(); |
| 139 | ast = tryParseQuery(parser, start, start + full_name.size(), out_err, false, "data type", false, |
| 140 | DBMS_DEFAULT_MAX_QUERY_SIZE, data_type_max_parse_depth, DBMS_DEFAULT_MAX_PARSER_BACKTRACKS, true); |
| 141 | if (!ast) |
| 142 | return nullptr; |
| 143 | } |
| 144 | else |
| 145 | { |
| 146 | ast = parseQuery(parser, full_name.data(), full_name.data() + full_name.size(), "data type", false, data_type_max_parse_depth, DBMS_DEFAULT_MAX_PARSER_BACKTRACKS); |
| 147 | } |
| 148 | |
| 149 | return getImpl<nullptr_on_error>(ast); |
| 150 | } |
| 151 | |
| 152 | DataTypePtr DataTypeFactory::get(const ASTPtr & ast) const |
| 153 | { |
nothing calls this directly
no test coverage detected