mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-22 01:30:51 +00:00
CLICKHOUSE-3791: Add system table collations
This commit is contained in:
parent
2915a58c8f
commit
fae9c33282
@ -87,3 +87,14 @@ const std::string & Collator::getLocale() const
|
||||
{
|
||||
return locale;
|
||||
}
|
||||
|
||||
std::vector<std::string> Collator::getAvailableCollations() {
|
||||
std::vector<std::string> result;
|
||||
#if USE_ICU
|
||||
size_t available_locales_count = ucol_countAvailable();
|
||||
for (size_t i = 0; i < available_locales_count; ++i) {
|
||||
result.push_back(ucol_getAvailable(i));
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
struct UCollator;
|
||||
@ -15,6 +16,8 @@ public:
|
||||
|
||||
const std::string & getLocale() const;
|
||||
|
||||
static std::vector<std::string> getAvailableCollations();
|
||||
|
||||
private:
|
||||
std::string locale;
|
||||
UCollator * collator;
|
||||
|
13
dbms/src/Storages/System/StorageSystemCollations.cpp
Normal file
13
dbms/src/Storages/System/StorageSystemCollations.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <Columns/Collator.h>
|
||||
#include <Storages/System/StorageSystemCollations.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
void StorageSystemCollations::fillData(MutableColumns & res_columns) const
|
||||
{
|
||||
for (const auto & collation : Collator::getAvailableCollations())
|
||||
{
|
||||
res_columns[0]->insert(collation);
|
||||
}
|
||||
}
|
||||
}
|
26
dbms/src/Storages/System/StorageSystemCollations.h
Normal file
26
dbms/src/Storages/System/StorageSystemCollations.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include <Storages/System/IStorageSystemWithStringColumns.h>
|
||||
#include <ext/shared_ptr_helper.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
class StorageSystemCollations : public ext::shared_ptr_helper<StorageSystemCollations>,
|
||||
public IStorageSystemWithStringColumns<StorageSystemCollations>
|
||||
{
|
||||
protected:
|
||||
void fillData(MutableColumns & res_columns) const override;
|
||||
|
||||
public:
|
||||
using IStorageSystemWithStringColumns::IStorageSystemWithStringColumns;
|
||||
|
||||
std::string getName() const override
|
||||
{
|
||||
return "SystemTableCollations";
|
||||
}
|
||||
|
||||
static std::vector<String> getColumnNames()
|
||||
{
|
||||
return {"name"};
|
||||
}
|
||||
};
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#include <Storages/System/StorageSystemAggregateFunctionCombinators.h>
|
||||
#include <Storages/System/StorageSystemAsynchronousMetrics.h>
|
||||
#include <Storages/System/StorageSystemBuildOptions.h>
|
||||
#include <Storages/System/StorageSystemCollations.h>
|
||||
#include <Storages/System/StorageSystemClusters.h>
|
||||
#include <Storages/System/StorageSystemColumns.h>
|
||||
#include <Storages/System/StorageSystemDatabases.h>
|
||||
@ -50,6 +51,7 @@ void attachSystemTablesLocal(IDatabase & system_database)
|
||||
system_database.attachTable("table_functions", StorageSystemTableFunctions::create("table_functions"));
|
||||
system_database.attachTable("aggregate_function_combinators", StorageSystemAggregateFunctionCombinators::create("aggregate_function_combinators"));
|
||||
system_database.attachTable("data_type_families", StorageSystemDataTypeFamilies::create("data_type_families"));
|
||||
system_database.attachTable("collations", StorageSystemCollations::create("collations"));
|
||||
}
|
||||
|
||||
void attachSystemTablesServer(IDatabase & system_database, bool has_zookeeper)
|
||||
|
Loading…
Reference in New Issue
Block a user