mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #58390 from bharatnc/ncb/system-database-engines
add table system.database_engines
This commit is contained in:
commit
c29b5e351e
26
docs/en/operations/system-tables/database_engines.md
Normal file
26
docs/en/operations/system-tables/database_engines.md
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
slug: /en/operations/system-tables/database_engines
|
||||
---
|
||||
# database_engines
|
||||
|
||||
Contains the list of database engines supported by the server.
|
||||
|
||||
This table contains the following columns (the column type is shown in brackets):
|
||||
|
||||
- `name` (String) — The name of database engine.
|
||||
|
||||
Example:
|
||||
|
||||
``` sql
|
||||
SELECT *
|
||||
FROM system.database_engines
|
||||
WHERE name in ('Atomic', 'Lazy', 'Ordinary')
|
||||
```
|
||||
|
||||
``` text
|
||||
┌─name─────┐
|
||||
│ Ordinary │
|
||||
│ Atomic │
|
||||
│ Lazy │
|
||||
└──────────┘
|
||||
```
|
@ -155,6 +155,7 @@ namespace
|
||||
"formats",
|
||||
"privileges",
|
||||
"data_type_families",
|
||||
"database_engines",
|
||||
"table_engines",
|
||||
"table_functions",
|
||||
"aggregate_function_combinators",
|
||||
|
@ -77,6 +77,7 @@ static String getLoadSuggestionQuery(Int32 suggestion_limit, bool basic_suggesti
|
||||
};
|
||||
|
||||
add_column("name", "functions", false, {});
|
||||
add_column("name", "database_engines", false, {});
|
||||
add_column("name", "table_engines", false, {});
|
||||
add_column("name", "formats", false, {});
|
||||
add_column("name", "table_functions", false, {});
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
|
||||
void registerDatabase(const std::string & name, CreatorFn creator_fn);
|
||||
|
||||
const DatabaseEngines & getDatabaseEngines() const { return database_engines; }
|
||||
|
||||
private:
|
||||
DatabaseEngines database_engines;
|
||||
};
|
||||
|
25
src/Storages/System/StorageSystemDatabaseEngines.cpp
Normal file
25
src/Storages/System/StorageSystemDatabaseEngines.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <DataTypes/DataTypesNumber.h>
|
||||
#include <Databases/DatabaseFactory.h>
|
||||
#include <Storages/System/StorageSystemDatabaseEngines.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
NamesAndTypesList StorageSystemDatabaseEngines::getNamesAndTypes()
|
||||
{
|
||||
return {
|
||||
{"name", std::make_shared<DataTypeString>()},
|
||||
};
|
||||
}
|
||||
|
||||
void StorageSystemDatabaseEngines::fillData(MutableColumns & res_columns, ContextPtr, const SelectQueryInfo &) const
|
||||
{
|
||||
for (const auto & [engine, _] : DatabaseFactory::instance().getDatabaseEngines())
|
||||
{
|
||||
int i = 0;
|
||||
res_columns[i++]->insert(engine);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
22
src/Storages/System/StorageSystemDatabaseEngines.h
Normal file
22
src/Storages/System/StorageSystemDatabaseEngines.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <DataTypes/DataTypeString.h>
|
||||
#include <Storages/System/IStorageSystemOneBlock.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class StorageSystemDatabaseEngines final : public IStorageSystemOneBlock<StorageSystemDatabaseEngines>
|
||||
{
|
||||
protected:
|
||||
void fillData(MutableColumns & res_columns, ContextPtr context, const SelectQueryInfo & query_info) const override;
|
||||
|
||||
using IStorageSystemOneBlock::IStorageSystemOneBlock;
|
||||
|
||||
public:
|
||||
std::string getName() const override { return "SystemDatabaseEngines"; }
|
||||
|
||||
static NamesAndTypesList getNamesAndTypes();
|
||||
};
|
||||
|
||||
}
|
@ -45,6 +45,7 @@
|
||||
#include <Storages/System/StorageSystemSettings.h>
|
||||
#include <Storages/System/StorageSystemSettingsChanges.h>
|
||||
#include <Storages/System/StorageSystemMergeTreeSettings.h>
|
||||
#include <Storages/System/StorageSystemDatabaseEngines.h>
|
||||
#include <Storages/System/StorageSystemTableEngines.h>
|
||||
#include <Storages/System/StorageSystemTableFunctions.h>
|
||||
#include <Storages/System/StorageSystemTables.h>
|
||||
@ -132,6 +133,7 @@ void attachSystemTablesServer(ContextPtr context, IDatabase & system_database, b
|
||||
attach<StorageSystemAggregateFunctionCombinators>(context, system_database, "aggregate_function_combinators");
|
||||
attach<StorageSystemDataTypeFamilies>(context, system_database, "data_type_families");
|
||||
attach<StorageSystemCollations>(context, system_database, "collations");
|
||||
attach<StorageSystemDatabaseEngines>(context, system_database, "database_engines");
|
||||
attach<StorageSystemTableEngines>(context, system_database, "table_engines");
|
||||
attach<StorageSystemContributors>(context, system_database, "contributors");
|
||||
attach<StorageSystemUsers>(context, system_database, "users");
|
||||
|
@ -0,0 +1,3 @@
|
||||
Atomic
|
||||
Lazy
|
||||
Ordinary
|
@ -0,0 +1 @@
|
||||
SELECT * FROM system.database_engines WHERE name IN ('Atomic', 'Lazy', 'Ordinary') ORDER BY name;
|
Loading…
Reference in New Issue
Block a user