SELECT * FROM system.build_options [#METR-24175] (#398)

* start [#METR-24175]

* missing

* wip

* add spaces

* wip

* wip

* fix

* fix

* missing

* style fix
This commit is contained in:
proller 2017-01-26 01:24:36 +03:00 committed by alexey-milovidov
parent 70e641f58a
commit e715ddd72a
10 changed files with 166 additions and 19 deletions

View File

@ -113,14 +113,14 @@ endif ()
set (CMAKE_BUILD_COLOR_MAKEFILE ON)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} -std=gnu++1y ${PLATFORM_EXTRA_CXX_FLAG} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMPILER_FLAGS}")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_FLAGS} -O3")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_FLAGS} -O0 -g3 -ggdb3 -fno-inline")
#set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMPILER_FLAGS}")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_FLAGS} -O3")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_FLAGS} -O0 -g3 -ggdb3 -fno-inline")
#set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline")
if (NOT APPLE AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM MATCHES "FreeBSD"))
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
@ -183,6 +183,12 @@ if (ENABLE_LIBTCMALLOC)
include (cmake/find_gperftools.cmake)
endif ()
set(FULL_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
set(FULL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
message (STATUS "C_FLAGS = ${FULL_C_FLAGS}")
message (STATUS "CXX_FLAGS = ${FULL_CXX_FLAGS}")
message (STATUS "LINK_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")
# Directory for Yandex specific files
set (CLICKHOUSE_PRIVATE_DIR ${ClickHouse_SOURCE_DIR}/private/)
if (EXISTS ${CLICKHOUSE_PRIVATE_DIR})
@ -194,8 +200,4 @@ add_subdirectory (libs)
add_subdirectory (utils)
add_subdirectory (dbms)
message (STATUS "C_FLAGS = ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
message (STATUS "CXX_FLAGS = ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
message (STATUS "LINK_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")
include (cmake/print_include_directories.cmake)

View File

@ -0,0 +1,43 @@
#pragma once
#include <ext/shared_ptr_helper.hpp>
#include <DB/Storages/IStorage.h>
namespace DB
{
class Context;
/** System table "build_options" with many params used for clickhouse building
*/
class StorageSystemBuildOptions : private ext::shared_ptr_helper<StorageSystemBuildOptions>, public IStorage
{
friend class ext::shared_ptr_helper<StorageSystemBuildOptions>;
public:
static StoragePtr create(const std::string & name_);
std::string getName() const override { return "SystemBuildOptions"; }
std::string getTableName() const override { return name; }
const NamesAndTypesList & getColumnsListImpl() const override { return columns; }
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const Context & context,
const Settings & settings,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
unsigned threads = 1) override;
private:
const std::string name;
NamesAndTypesList columns;
StorageSystemBuildOptions(const std::string & name_);
};
}

View File

@ -10,7 +10,7 @@ namespace DB
class Context;
/** Реализует системную таблицу settings, которая позволяет получить информацию о текущих настройках.
/** implements system table "settings", which allows to get information about the current settings.
*/
class StorageSystemSettings : private ext::shared_ptr_helper<StorageSystemSettings>, public IStorage
{

View File

@ -16,6 +16,7 @@
#include <DB/Storages/System/StorageSystemDictionaries.h>
#include <DB/Storages/System/StorageSystemColumns.h>
#include <DB/Storages/System/StorageSystemFunctions.h>
#include <DB/Storages/System/StorageSystemBuildOptions.h>
#include <DB/Interpreters/Context.h>
#include <DB/Interpreters/ProcessList.h>
@ -410,6 +411,7 @@ void LocalServer::attachSystemTables()
system_database->attachTable("functions", StorageSystemFunctions::create("functions"));
system_database->attachTable("events", StorageSystemEvents::create("events"));
system_database->attachTable("settings", StorageSystemSettings::create("settings"));
system_database->attachTable("build_options", StorageSystemBuildOptions::create("build_options"));
}

View File

@ -41,6 +41,7 @@
#include <DB/Storages/System/StorageSystemClusters.h>
#include <DB/Storages/System/StorageSystemMetrics.h>
#include <DB/Storages/System/StorageSystemAsynchronousMetrics.h>
#include <DB/Storages/System/StorageSystemBuildOptions.h>
#include <DB/Storages/StorageReplicatedMergeTree.h>
#include <DB/Storages/MergeTree/ReshardingWorker.h>
#include <DB/Databases/DatabaseOrdinary.h>
@ -367,6 +368,7 @@ int Server::main(const std::vector<std::string> & args)
system_database->attachTable("columns", StorageSystemColumns::create("columns"));
system_database->attachTable("functions", StorageSystemFunctions::create("functions"));
system_database->attachTable("clusters", StorageSystemClusters::create("clusters", *global_context));
system_database->attachTable("build_options", StorageSystemBuildOptions::create("build_options"));
if (has_zookeeper)
system_database->attachTable("zookeeper", StorageSystemZooKeeper::create("zookeeper"));

View File

@ -0,0 +1,58 @@
#include <DB/Columns/ColumnString.h>
#include <DB/DataTypes/DataTypeString.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataStreams/OneBlockInputStream.h>
#include <DB/Interpreters/Settings.h>
#include <DB/Storages/System/StorageSystemBuildOptions.h>
#include <common/config_build.h>
namespace DB
{
StorageSystemBuildOptions::StorageSystemBuildOptions(const std::string & name_)
: name(name_)
, columns{
{ "name", std::make_shared<DataTypeString>() },
{ "value", std::make_shared<DataTypeString>() },
}
{
}
StoragePtr StorageSystemBuildOptions::create(const std::string & name_)
{
return make_shared(name_);
}
BlockInputStreams StorageSystemBuildOptions::read(
const Names & column_names,
ASTPtr query,
const Context & context,
const Settings & settings,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,
const unsigned threads)
{
check(column_names);
processed_stage = QueryProcessingStage::FetchColumns;
ColumnWithTypeAndName col_name{std::make_shared<ColumnString>(), std::make_shared<DataTypeString>(), "name"};
ColumnWithTypeAndName col_value{std::make_shared<ColumnString>(), std::make_shared<DataTypeString>(), "value"};
for (const auto & option : auto_config_build)
{
col_name.column->insert(String(option.first));
col_value.column->insert(String(option.second));
}
Block block{
col_name,
col_value,
};
return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(block));
}
}

View File

@ -0,0 +1,5 @@
BUILD_DATE
BUILD_TYPE
CXX_COMPILER
CXX_FLAGS
LINK_FLAGS

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
clickhouse-client --query="SELECT * FROM system.build_options" | perl -lnE 'print $1 if /(BUILD_DATE|BUILD_TYPE|CXX_COMPILER|CXX_FLAGS|LINK_FLAGS)\s+\S+/';

View File

@ -1,5 +1,6 @@
SET(CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_version.h)
SET(CONFIG_COMMON ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_common.h)
set (CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_version.h)
set (CONFIG_COMMON ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_common.h)
set (CONFIG_BUILD ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_build.h)
include_directories (include)
include_directories (BEFORE ${CMAKE_SOURCE_DIR}/contrib/libcctz/include)
@ -12,19 +13,25 @@ if (APPLE)
else ()
set (APPLE_SIERRA_OR_NEWER 0)
endif ()
endif()
endif ()
include(cmake/version.cmake)
message(STATUS "Will build ${VERSION_FULL}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_common.h.in ${CONFIG_COMMON})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_version.h.in ${CONFIG_VERSION})
include (cmake/version.cmake)
message (STATUS "Will build ${VERSION_FULL}")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_common.h.in ${CONFIG_COMMON})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_version.h.in ${CONFIG_VERSION})
get_property (BUILD_COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
get_property (BUILD_INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
string (TIMESTAMP BUILD_DATE UTC)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_build.h.in ${CONFIG_BUILD})
if (APPLE)
add_library (apple_rt
src/apple_rt.cpp
include/common/apple_rt.h
)
endif()
endif ()
add_library (common
src/DateLUT.cpp

View File

@ -0,0 +1,25 @@
#pragma once
// .h autogenerated by cmake !
#include <utility>
#include <array>
const std::array<std::pair<const char *, const char *>, 16> auto_config_build { {
{"BUILD_DATE", "@BUILD_DATE@"},
{"CMAKE_VERSION", "@CMAKE_VERSION@"},
{"SYSTEM_NAME", "@CMAKE_SYSTEM_NAME@"},
{"SYSTEM_VERSION", "@CMAKE_SYSTEM_VERSION@"},
{"BUILD_TYPE", "@CMAKE_BUILD_TYPE@"},
{"SYSTEM_PROCESSOR", "@CMAKE_SYSTEM_PROCESSOR@"},
{"LIBRARY_ARCHITECTURE", "@CMAKE_LIBRARY_ARCHITECTURE@"},
{"C_COMPILER", "@CMAKE_C_COMPILER@"},
{"C_COMPILE_FEATURES", "@CMAKE_C_COMPILE_FEATURES@"},
{"CXX_COMPILER", "@CMAKE_CXX_COMPILER@"},
{"CXX_COMPILE_FEATURES", "@CMAKE_CXX_COMPILE_FEATURES@"},
{"C_FLAGS", "@FULL_C_FLAGS@"},
{"CXX_FLAGS", "@FULL_CXX_FLAGS@"},
{"LINK_FLAGS", "@CMAKE_EXE_LINKER_FLAGS@"},
{"BUILD_COMPILE_DEFINITIONS", "@BUILD_COMPILE_DEFINITIONS@"},
{"BUILD_INCLUDE_DIRECTORIES", "@BUILD_INCLUDE_DIRECTORIES@"},
} };