From 4f0b3539c5ea8ecdf3bd2d5dfdffeabc2efc4784 Mon Sep 17 00:00:00 2001 From: Wojciech Mitros Date: Wed, 15 Feb 2023 09:20:12 +0100 Subject: [PATCH] cql3: add type_parser::parse() method taking user_types_metadata In a future patch, we don't have access to a `user_types_storage` while we want to parse a type, but we do have access to a `user_types_metadata`, which is enough to parse the type. We add a variant of the `type_parser::parse()` that takes a `user_types_metadata` instead of a `user_types_storage` to be able to parse a type also in the described context. --- db/cql_type_parser.cc | 8 ++++++-- db/cql_type_parser.hh | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/db/cql_type_parser.cc b/db/cql_type_parser.cc index 4677375904..738e9dd523 100644 --- a/db/cql_type_parser.cc +++ b/db/cql_type_parser.cc @@ -24,7 +24,7 @@ static ::shared_ptr parse_raw(const sstring& str) { }); } -data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str, const data_dictionary::user_types_storage& uts) { +data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str, const data_dictionary::user_types_metadata& utm) { static const thread_local std::unordered_map native_types = []{ std::unordered_map res; for (auto& nt : cql3::cql3_type::values()) { @@ -39,7 +39,11 @@ data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str } auto raw = parse_raw(str); - return raw->prepare_internal(keyspace, uts.get(keyspace)).get_type(); + return raw->prepare_internal(keyspace, utm).get_type(); +} + +data_type db::cql_type_parser::parse(const sstring& keyspace, const sstring& str, const data_dictionary::user_types_storage& uts) { + return parse(keyspace, str, uts.get(keyspace)); } class db::cql_type_parser::raw_builder::impl { diff --git a/db/cql_type_parser.hh b/db/cql_type_parser.hh index f71eb60fcd..310c634182 100644 --- a/db/cql_type_parser.hh +++ b/db/cql_type_parser.hh @@ -22,11 +22,13 @@ class types_metadata; namespace data_dictionary { class keyspace_metadata; class user_types_storage; +class user_types_metadata; } namespace db { namespace cql_type_parser { +data_type parse(const sstring& keyspace, const sstring& type, const data_dictionary::user_types_metadata& utm); data_type parse(const sstring& keyspace, const sstring& type, const data_dictionary::user_types_storage& uts); class raw_builder {