2014-02-17 23:56:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/Timespan.h>
|
2018-03-11 00:15:26 +00:00
|
|
|
#include <DataStreams/SizeLimits.h>
|
2018-06-10 19:22:49 +00:00
|
|
|
#include <Formats/FormatSettings.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/CompressedStream.h>
|
2018-06-05 19:46:49 +00:00
|
|
|
#include <Core/Types.h>
|
2015-10-12 07:05:54 +00:00
|
|
|
|
2014-02-17 23:56:45 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
class Field;
|
|
|
|
class ReadBuffer;
|
|
|
|
class WriteBuffer;
|
2016-01-11 21:46:36 +00:00
|
|
|
|
2014-02-17 23:56:45 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** One setting for any type.
|
|
|
|
* Stores a value within itself, as well as a flag - whether the value was changed.
|
|
|
|
* This is done so that you can send to the remote servers only changed settings (or explicitly specified in the config) values.
|
|
|
|
* That is, if the configuration was not specified in the config and was not dynamically changed, it is not sent to the remote server,
|
|
|
|
* and the remote server will use its default value.
|
2014-02-17 23:56:45 +00:00
|
|
|
*/
|
|
|
|
|
2016-02-12 02:26:04 +00:00
|
|
|
template <typename IntType>
|
|
|
|
struct SettingInt
|
2014-02-17 23:56:45 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
IntType value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingInt(IntType x = 0) : value(x) {}
|
|
|
|
|
|
|
|
operator IntType() const { return value; }
|
|
|
|
SettingInt & operator= (IntType x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
/// Serialize to a test string.
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
/// Serialize to binary stream suitable for transfer over network.
|
|
|
|
void write(WriteBuffer & buf) const;
|
|
|
|
|
|
|
|
void set(IntType x);
|
|
|
|
|
|
|
|
/// Read from SQL literal.
|
|
|
|
void set(const Field & x);
|
|
|
|
|
|
|
|
/// Read from text string.
|
|
|
|
void set(const String & x);
|
|
|
|
|
|
|
|
/// Read from binary stream.
|
|
|
|
void set(ReadBuffer & buf);
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
2016-02-12 02:26:04 +00:00
|
|
|
using SettingUInt64 = SettingInt<UInt64>;
|
|
|
|
using SettingInt64 = SettingInt<Int64>;
|
|
|
|
using SettingBool = SettingUInt64;
|
2014-02-17 23:56:45 +00:00
|
|
|
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/** Unlike SettingUInt64, supports the value of 'auto' - the number of processor cores without taking into account SMT.
|
|
|
|
* A value of 0 is also treated as auto.
|
|
|
|
* When serializing, `auto` is written in the same way as 0.
|
2015-02-22 10:50:36 +00:00
|
|
|
*/
|
|
|
|
struct SettingMaxThreads
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
UInt64 value;
|
|
|
|
bool is_auto;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingMaxThreads(UInt64 x = 0) : value(x ? x : getAutoValue()), is_auto(x == 0) {}
|
|
|
|
|
|
|
|
operator UInt64() const { return value; }
|
|
|
|
SettingMaxThreads & operator= (UInt64 x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(UInt64 x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
|
|
|
|
|
|
|
void setAuto();
|
|
|
|
UInt64 getAutoValue() const;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// Executed once for all time. Executed from one thread.
|
2018-06-05 19:46:49 +00:00
|
|
|
UInt64 getAutoValueImpl() const;
|
2015-02-22 10:50:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-02-17 23:56:45 +00:00
|
|
|
struct SettingSeconds
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Timespan value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingSeconds(UInt64 seconds = 0) : value(seconds, 0) {}
|
|
|
|
|
|
|
|
operator Poco::Timespan() const { return value; }
|
2017-09-08 02:37:02 +00:00
|
|
|
SettingSeconds & operator= (const Poco::Timespan & x) { set(x); return *this; }
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
Poco::Timespan::TimeDiff totalSeconds() const { return value.totalSeconds(); }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(const Poco::Timespan & x);
|
|
|
|
|
|
|
|
void set(UInt64 x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct SettingMilliseconds
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
Poco::Timespan value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingMilliseconds(UInt64 milliseconds = 0) : value(milliseconds * 1000) {}
|
|
|
|
|
|
|
|
operator Poco::Timespan() const { return value; }
|
2017-09-08 02:29:47 +00:00
|
|
|
SettingMilliseconds & operator= (const Poco::Timespan & x) { set(x); return *this; }
|
2017-04-01 07:20:54 +00:00
|
|
|
|
|
|
|
Poco::Timespan::TimeDiff totalMilliseconds() const { return value.totalMilliseconds(); }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(const Poco::Timespan & x);
|
|
|
|
void set(UInt64 x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
void write(WriteBuffer & buf) const;
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct SettingFloat
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
float value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingFloat(float x = 0) : value(x) {}
|
|
|
|
|
|
|
|
operator float() const { return value; }
|
|
|
|
SettingFloat & operator= (float x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(float x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum class LoadBalancing
|
|
|
|
{
|
2017-06-02 21:37:28 +00:00
|
|
|
/// among replicas with a minimum number of errors selected randomly
|
2017-04-01 07:20:54 +00:00
|
|
|
RANDOM = 0,
|
2017-06-02 21:37:28 +00:00
|
|
|
/// a replica is selected among the replicas with the minimum number of errors
|
|
|
|
/// with the minimum number of distinguished characters in the replica name and local hostname
|
2017-04-01 07:20:54 +00:00
|
|
|
NEAREST_HOSTNAME,
|
2017-06-02 21:37:28 +00:00
|
|
|
/// replicas are walked through strictly in order; the number of errors does not matter
|
2017-04-01 07:20:54 +00:00
|
|
|
IN_ORDER,
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SettingLoadBalancing
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
LoadBalancing value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingLoadBalancing(LoadBalancing x) : value(x) {}
|
|
|
|
|
|
|
|
operator LoadBalancing() const { return value; }
|
|
|
|
SettingLoadBalancing & operator= (LoadBalancing x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
static LoadBalancing getLoadBalancing(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(LoadBalancing x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-08-29 15:15:42 +00:00
|
|
|
enum class JoinStrictness
|
|
|
|
{
|
|
|
|
Unspecified = 0, /// Query JOIN without strictness will throw Exception.
|
|
|
|
ALL, /// Query JOIN without strictness -> ALL JOIN ...
|
|
|
|
ANY, /// Query JOIN without strictness -> ANY JOIN ...
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct SettingJoinStrictness
|
|
|
|
{
|
|
|
|
JoinStrictness value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingJoinStrictness(JoinStrictness x) : value(x) {}
|
|
|
|
|
|
|
|
operator JoinStrictness() const { return value; }
|
|
|
|
SettingJoinStrictness & operator= (JoinStrictness x) { set(x); return *this; }
|
|
|
|
|
|
|
|
static JoinStrictness getJoinStrictness(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(JoinStrictness x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// Which rows should be included in TOTALS.
|
2014-02-18 09:02:35 +00:00
|
|
|
enum class TotalsMode
|
|
|
|
{
|
2017-06-02 21:37:28 +00:00
|
|
|
BEFORE_HAVING = 0, /// Count HAVING for all read rows;
|
|
|
|
/// including those not in max_rows_to_group_by
|
|
|
|
/// and have not passed HAVING after grouping.
|
|
|
|
AFTER_HAVING_INCLUSIVE = 1, /// Count on all rows except those that have not passed HAVING;
|
|
|
|
/// that is, to include in TOTALS all the rows that did not pass max_rows_to_group_by.
|
|
|
|
AFTER_HAVING_EXCLUSIVE = 2, /// Include only the rows that passed and max_rows_to_group_by, and HAVING.
|
|
|
|
AFTER_HAVING_AUTO = 3, /// Automatically select between INCLUSIVE and EXCLUSIVE,
|
2014-02-18 09:02:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SettingTotalsMode
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
TotalsMode value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingTotalsMode(TotalsMode x) : value(x) {}
|
|
|
|
|
|
|
|
operator TotalsMode() const { return value; }
|
|
|
|
SettingTotalsMode & operator= (TotalsMode x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
static TotalsMode getTotalsMode(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(TotalsMode x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2014-02-18 09:02:35 +00:00
|
|
|
};
|
|
|
|
|
2014-02-17 23:56:45 +00:00
|
|
|
|
|
|
|
template <bool enable_mode_any>
|
|
|
|
struct SettingOverflowMode
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
OverflowMode value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingOverflowMode(OverflowMode x = OverflowMode::THROW) : value(x) {}
|
|
|
|
|
|
|
|
operator OverflowMode() const { return value; }
|
|
|
|
SettingOverflowMode & operator= (OverflowMode x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
static OverflowMode getOverflowModeForGroupBy(const String & s);
|
|
|
|
static OverflowMode getOverflowMode(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(OverflowMode x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2014-02-17 23:56:45 +00:00
|
|
|
};
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
|
2015-05-21 16:05:02 +00:00
|
|
|
struct SettingCompressionMethod
|
2015-05-21 09:38:02 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
CompressionMethod value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingCompressionMethod(CompressionMethod x = CompressionMethod::LZ4) : value(x) {}
|
|
|
|
|
|
|
|
operator CompressionMethod() const { return value; }
|
|
|
|
SettingCompressionMethod & operator= (CompressionMethod x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
static CompressionMethod getCompressionMethod(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(CompressionMethod x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2015-05-21 09:38:02 +00:00
|
|
|
};
|
2015-09-04 21:39:10 +00:00
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
|
2017-06-02 21:37:28 +00:00
|
|
|
/// The setting for executing distributed subqueries inside IN or JOIN sections.
|
2015-09-18 13:36:10 +00:00
|
|
|
enum class DistributedProductMode
|
|
|
|
{
|
2017-06-02 21:37:28 +00:00
|
|
|
DENY = 0, /// Disable
|
|
|
|
LOCAL, /// Convert to local query
|
|
|
|
GLOBAL, /// Convert to global query
|
|
|
|
ALLOW /// Enable
|
2015-09-18 13:36:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SettingDistributedProductMode
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
DistributedProductMode value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingDistributedProductMode(DistributedProductMode x) : value(x) {}
|
|
|
|
|
|
|
|
operator DistributedProductMode() const { return value; }
|
|
|
|
SettingDistributedProductMode & operator= (DistributedProductMode x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
static DistributedProductMode getDistributedProductMode(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(DistributedProductMode x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
void write(WriteBuffer & buf) const;
|
2015-09-18 13:36:10 +00:00
|
|
|
};
|
|
|
|
|
2016-07-10 15:52:35 +00:00
|
|
|
|
|
|
|
struct SettingString
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
String value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingString(const String & x = String{}) : value(x) {}
|
|
|
|
|
|
|
|
operator String() const { return value; }
|
|
|
|
SettingString & operator= (const String & x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(const String & x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2016-07-10 15:52:35 +00:00
|
|
|
};
|
|
|
|
|
2018-04-27 20:12:26 +00:00
|
|
|
|
2018-04-21 23:38:01 +00:00
|
|
|
struct SettingChar
|
|
|
|
{
|
|
|
|
private:
|
2018-06-05 19:46:49 +00:00
|
|
|
void checkStringIsACharacter(const String & x) const;
|
|
|
|
|
2018-04-21 23:38:01 +00:00
|
|
|
public:
|
|
|
|
char value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingChar(char x = '\0') : value(x) {}
|
|
|
|
|
|
|
|
operator char() const { return value; }
|
|
|
|
SettingChar & operator= (char x) { set(x); return *this; }
|
|
|
|
|
2018-06-05 19:46:49 +00:00
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(char x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
void write(WriteBuffer & buf) const;
|
2018-04-21 23:38:01 +00:00
|
|
|
};
|
2018-06-05 19:46:49 +00:00
|
|
|
|
2018-06-08 03:15:33 +00:00
|
|
|
|
|
|
|
struct SettingDateTimeInputFormat
|
|
|
|
{
|
|
|
|
using Value = FormatSettings::DateTimeInputFormat;
|
|
|
|
|
|
|
|
Value value;
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
SettingDateTimeInputFormat(Value x) : value(x) {}
|
|
|
|
|
|
|
|
operator Value() const { return value; }
|
|
|
|
SettingDateTimeInputFormat & operator= (Value x) { set(x); return *this; }
|
|
|
|
|
|
|
|
static Value getValue(const String & s);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
|
|
|
|
void set(Value x);
|
|
|
|
void set(const Field & x);
|
|
|
|
void set(const String & x);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
void write(WriteBuffer & buf) const;
|
|
|
|
};
|
|
|
|
|
2018-12-18 21:18:54 +00:00
|
|
|
|
|
|
|
class SettingLogsLevel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
String value;
|
|
|
|
bool changed = false;
|
|
|
|
static const std::vector<String> log_levels;
|
|
|
|
|
|
|
|
SettingLogsLevel(const String & level);
|
|
|
|
operator String() const { return value; }
|
|
|
|
void set(const String & level);
|
|
|
|
void set(const Field & level);
|
|
|
|
void set(ReadBuffer & buf);
|
|
|
|
|
|
|
|
String toString() const;
|
|
|
|
void write(WriteBuffer & buf) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-17 23:56:45 +00:00
|
|
|
}
|