diff --git a/README.md b/README.md
index ea9f365a3c6..bad00d8280f 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ ClickHouse® is an open-source column-oriented database management system that a
* [Tutorial](https://clickhouse.tech/docs/en/getting_started/tutorial/) shows how to set up and query small ClickHouse cluster.
* [Documentation](https://clickhouse.tech/docs/en/) provides more in-depth information.
* [YouTube channel](https://www.youtube.com/c/ClickHouseDB) has a lot of content about ClickHouse in video format.
-* [Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-nwwakmk4-xOJ6cdy0sJC3It8j348~IA) and [Telegram](https://telegram.me/clickhouse_en) allow to chat with ClickHouse users in real-time.
+* [Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-qfort0u8-TWqK4wIP0YSdoDE0btKa1w) and [Telegram](https://telegram.me/clickhouse_en) allow to chat with ClickHouse users in real-time.
* [Blog](https://clickhouse.yandex/blog/en/) contains various ClickHouse-related articles, as well as announcements and reports about events.
* [Code Browser](https://clickhouse.tech/codebrowser/html_report/ClickHouse/index.html) with syntax highlight and navigation.
* [Contacts](https://clickhouse.tech/#contacts) can help to get your questions answered if there are any.
diff --git a/contrib/grpc b/contrib/grpc
index 5b79aae85c5..60c986e15ca 160000
--- a/contrib/grpc
+++ b/contrib/grpc
@@ -1 +1 @@
-Subproject commit 5b79aae85c515e0df4abfb7b1e07975fdc7cecc1
+Subproject commit 60c986e15cae70aade721d26badabab1f822fdd6
diff --git a/docs/en/operations/external-authenticators/ldap.md b/docs/en/operations/external-authenticators/ldap.md
index 1b65ecc968b..805d45e1b38 100644
--- a/docs/en/operations/external-authenticators/ldap.md
+++ b/docs/en/operations/external-authenticators/ldap.md
@@ -17,6 +17,7 @@ To define LDAP server you must add `ldap_servers` section to the `config.xml`.
+
localhost
636
@@ -31,6 +32,18 @@ To define LDAP server you must add `ldap_servers` section to the `config.xml`.
/path/to/tls_ca_cert_dir
ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:AES256-GCM-SHA384
+
+
+
+ localhost
+ 389
+ EXAMPLE\{user_name}
+
+ CN=Users,DC=example,DC=com
+ (&(objectClass=user)(sAMAccountName={user_name}))
+
+ no
+
```
@@ -43,6 +56,15 @@ Note, that you can define multiple LDAP servers inside the `ldap_servers` sectio
- `port` — LDAP server port, default is `636` if `enable_tls` is set to `true`, `389` otherwise.
- `bind_dn` — Template used to construct the DN to bind to.
- The resulting DN will be constructed by replacing all `{user_name}` substrings of the template with the actual user name during each authentication attempt.
+- `user_dn_detection` - Section with LDAP search parameters for detecting the actual user DN of the bound user.
+ - This is mainly used in search filters for further role mapping when the server is Active Directory. The resulting user DN will be used when replacing `{user_dn}` substrings wherever they are allowed. By default, user DN is set equal to bind DN, but once search is performed, it will be updated with to the actual detected user DN value.
+ - `base_dn` - Template used to construct the base DN for the LDAP search.
+ - The resulting DN will be constructed by replacing all `{user_name}` and `{bind_dn}` substrings of the template with the actual user name and bind DN during the LDAP search.
+ - `scope` - Scope of the LDAP search.
+ - Accepted values are: `base`, `one_level`, `children`, `subtree` (the default).
+ - `search_filter` - Template used to construct the search filter for the LDAP search.
+ - The resulting filter will be constructed by replacing all `{user_name}`, `{bind_dn}`, and `{base_dn}` substrings of the template with the actual user name, bind DN, and base DN during the LDAP search.
+ - Note, that the special characters must be escaped properly in XML.
- `verification_cooldown` — A period of time, in seconds, after a successful bind attempt, during which the user will be assumed to be successfully authenticated for all consecutive requests without contacting the LDAP server.
- Specify `0` (the default) to disable caching and force contacting the LDAP server for each authentication request.
- `enable_tls` — A flag to trigger the use of the secure connection to the LDAP server.
@@ -107,7 +129,7 @@ Goes into `config.xml`.
-
+
my_ldap_server
@@ -122,6 +144,18 @@ Goes into `config.xml`.
clickhouse_
+
+
+
+ my_ad_server
+
+ CN=Users,DC=example,DC=com
+ CN
+ subtree
+ (&(objectClass=group)(member={user_dn}))
+ clickhouse_
+
+
```
@@ -137,13 +171,13 @@ Note that `my_ldap_server` referred in the `ldap` section inside the `user_direc
- When a user authenticates, while still bound to LDAP, an LDAP search is performed using `search_filter` and the name of the logged-in user. For each entry found during that search, the value of the specified attribute is extracted. For each attribute value that has the specified prefix, the prefix is removed, and the rest of the value becomes the name of a local role defined in ClickHouse, which is expected to be created beforehand by the [CREATE ROLE](../../sql-reference/statements/create/role.md#create-role-statement) statement.
- There can be multiple `role_mapping` sections defined inside the same `ldap` section. All of them will be applied.
- `base_dn` — Template used to construct the base DN for the LDAP search.
- - The resulting DN will be constructed by replacing all `{user_name}` and `{bind_dn}` substrings of the template with the actual user name and bind DN during each LDAP search.
+ - The resulting DN will be constructed by replacing all `{user_name}`, `{bind_dn}`, and `{user_dn}` substrings of the template with the actual user name, bind DN, and user DN during each LDAP search.
- `scope` — Scope of the LDAP search.
- Accepted values are: `base`, `one_level`, `children`, `subtree` (the default).
- `search_filter` — Template used to construct the search filter for the LDAP search.
- - The resulting filter will be constructed by replacing all `{user_name}`, `{bind_dn}` and `{base_dn}` substrings of the template with the actual user name, bind DN and base DN during each LDAP search.
+ - The resulting filter will be constructed by replacing all `{user_name}`, `{bind_dn}`, `{user_dn}`, and `{base_dn}` substrings of the template with the actual user name, bind DN, user DN, and base DN during each LDAP search.
- Note, that the special characters must be escaped properly in XML.
- - `attribute` — Attribute name whose values will be returned by the LDAP search.
+ - `attribute` — Attribute name whose values will be returned by the LDAP search. `cn`, by default.
- `prefix` — Prefix, that will be expected to be in front of each string in the original list of strings returned by the LDAP search. The prefix will be removed from the original strings and the resulting strings will be treated as local role names. Empty by default.
[Original article](https://clickhouse.tech/docs/en/operations/external-authenticators/ldap/)
diff --git a/docs/en/sql-reference/aggregate-functions/parametric-functions.md b/docs/en/sql-reference/aggregate-functions/parametric-functions.md
index b9d504241db..0edb1601023 100644
--- a/docs/en/sql-reference/aggregate-functions/parametric-functions.md
+++ b/docs/en/sql-reference/aggregate-functions/parametric-functions.md
@@ -253,7 +253,7 @@ windowFunnel(window, [mode, [mode, ... ]])(timestamp, cond1, cond2, ..., condN)
**Parameters**
-- `window` — Length of the sliding window, it is the time interval between first condition and last condition. The unit of `window` depends on the `timestamp` itself and varies. Determined using the expression `timestamp of cond1 <= timestamp of cond2 <= ... <= timestamp of condN <= timestamp of cond1 + window`.
+- `window` — Length of the sliding window, it is the time interval between the first and the last condition. The unit of `window` depends on the `timestamp` itself and varies. Determined using the expression `timestamp of cond1 <= timestamp of cond2 <= ... <= timestamp of condN <= timestamp of cond1 + window`.
- `mode` — It is an optional argument. One or more modes can be set.
- `'strict'` — If same condition holds for sequence of events then such non-unique events would be skipped.
- `'strict_order'` — Don't allow interventions of other events. E.g. in the case of `A->B->D->C`, it stops finding `A->B->C` at the `D` and the max event level is 2.
@@ -312,7 +312,7 @@ FROM
GROUP BY user_id
)
GROUP BY level
-ORDER BY level ASC
+ORDER BY level ASC;
```
Result:
diff --git a/docs/en/sql-reference/functions/ip-address-functions.md b/docs/en/sql-reference/functions/ip-address-functions.md
index 0b5dd7160b8..d37ef2e8f1a 100644
--- a/docs/en/sql-reference/functions/ip-address-functions.md
+++ b/docs/en/sql-reference/functions/ip-address-functions.md
@@ -422,7 +422,7 @@ Type: [UInt8](../../sql-reference/data-types/int-uint.md).
Query:
``` sql
-SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8')
+SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8');
```
Result:
@@ -436,7 +436,7 @@ Result:
Query:
``` sql
-SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16')
+SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16');
```
Result:
diff --git a/docs/en/sql-reference/functions/type-conversion-functions.md b/docs/en/sql-reference/functions/type-conversion-functions.md
index d8d13d81d97..661469e6901 100644
--- a/docs/en/sql-reference/functions/type-conversion-functions.md
+++ b/docs/en/sql-reference/functions/type-conversion-functions.md
@@ -373,7 +373,7 @@ This function accepts a number or date or date with time, and returns a FixedStr
## reinterpretAsUUID {#reinterpretasuuid}
-This function accepts 16 bytes string, and returns UUID containing bytes representing the corresponding value in network byte order (big-endian). If the string isn't long enough, the functions work as if the string is padded with the necessary number of null bytes to the end. If the string longer than 16 bytes, the extra bytes at the end are ignored.
+Accepts 16 bytes string and returns UUID containing bytes representing the corresponding value in network byte order (big-endian). If the string isn't long enough, the function works as if the string is padded with the necessary number of null bytes to the end. If the string longer than 16 bytes, the extra bytes at the end are ignored.
**Syntax**
@@ -429,7 +429,24 @@ Result:
## reinterpret(x, T) {#type_conversion_function-reinterpret}
-Use the same source in-memory bytes sequence for `x` value and reinterpret it to destination type
+Uses the same source in-memory bytes sequence for `x` value and reinterprets it to destination type.
+
+**Syntax**
+
+``` sql
+reinterpret(x, type)
+```
+
+**Arguments**
+
+- `x` — Any type.
+- `type` — Destination type. [String](../../sql-reference/data-types/string.md).
+
+**Returned value**
+
+- Destination type value.
+
+**Examples**
Query:
```sql
@@ -448,11 +465,27 @@ Result:
## CAST(x, T) {#type_conversion_function-cast}
-Converts input value `x` to the `T` data type. Unlike to `reinterpret` function use external representation of `x` value.
+Converts input value `x` to the `T` data type. Unlike to `reinterpret` function, type conversion is performed in a natural way.
The syntax `CAST(x AS t)` is also supported.
-Note, that if value `x` does not fit the bounds of type T, the function overflows. For example, CAST(-1, 'UInt8') returns 255.
+!!! note "Note"
+ If value `x` does not fit the bounds of type `T`, the function overflows. For example, `CAST(-1, 'UInt8')` returns `255`.
+
+**Syntax**
+
+``` sql
+CAST(x, T)
+```
+
+**Arguments**
+
+- `x` — Any type.
+- `T` — Destination type. [String](../../sql-reference/data-types/string.md).
+
+**Returned value**
+
+- Destination type value.
**Examples**
@@ -460,9 +493,9 @@ Query:
```sql
SELECT
- cast(toInt8(-1), 'UInt8') AS cast_int_to_uint,
- cast(toInt8(1), 'Float32') AS cast_int_to_float,
- cast('1', 'UInt32') AS cast_string_to_int
+ CAST(toInt8(-1), 'UInt8') AS cast_int_to_uint,
+ CAST(toInt8(1), 'Float32') AS cast_int_to_float,
+ CAST('1', 'UInt32') AS cast_string_to_int;
```
Result:
@@ -492,7 +525,7 @@ Result:
└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘
```
-Conversion to FixedString(N) only works for arguments of type String or FixedString(N).
+Conversion to FixedString(N) only works for arguments of type [String](../../sql-reference/data-types/string.md) or [FixedString](../../sql-reference/data-types/fixedstring.md).
Type conversion to [Nullable](../../sql-reference/data-types/nullable.md) and back is supported.
@@ -1038,7 +1071,7 @@ Result:
## parseDateTime64BestEffort {#parsedatetime64besteffort}
-Same as [parseDateTimeBestEffort](#parsedatetimebesteffort) function but also parse milliseconds and microseconds and return `DateTime64(3)` or `DateTime64(6)` data types.
+Same as [parseDateTimeBestEffort](#parsedatetimebesteffort) function but also parse milliseconds and microseconds and returns [DateTime](../../sql-reference/functions/type-conversion-functions.md#data_type-datetime) data type.
**Syntax**
@@ -1049,9 +1082,13 @@ parseDateTime64BestEffort(time_string [, precision [, time_zone]])
**Parameters**
- `time_string` — String containing a date or date with time to convert. [String](../../sql-reference/data-types/string.md).
-- `precision` — `3` for milliseconds, `6` for microseconds. Default `3`. Optional [UInt8](../../sql-reference/data-types/int-uint.md).
+- `precision` — Required precision. `3` — for milliseconds, `6` — for microseconds. Default — `3`. Optional. [UInt8](../../sql-reference/data-types/int-uint.md).
- `time_zone` — [Timezone](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone). The function parses `time_string` according to the timezone. Optional. [String](../../sql-reference/data-types/string.md).
+**Returned value**
+
+- `time_string` converted to the [DateTime](../../sql-reference/data-types/datetime.md) data type.
+
**Examples**
Query:
@@ -1064,7 +1101,7 @@ UNION ALL
SELECT parseDateTime64BestEffort('2021-01-01 01:01:00.12346',6) AS a, toTypeName(a) AS t
UNION ALL
SELECT parseDateTime64BestEffort('2021-01-01 01:01:00.12346',3,'Europe/Moscow') AS a, toTypeName(a) AS t
-FORMAT PrettyCompactMonoBlcok
+FORMAT PrettyCompactMonoBlock;
```
Result:
@@ -1131,12 +1168,14 @@ Result:
## toUnixTimestamp64Nano {#tounixtimestamp64nano}
-Converts a `DateTime64` to a `Int64` value with fixed sub-second precision.
-Input value is scaled up or down appropriately depending on it precision. Please note that output value is a timestamp in UTC, not in timezone of `DateTime64`.
+Converts a `DateTime64` to a `Int64` value with fixed sub-second precision. Input value is scaled up or down appropriately depending on it precision.
+
+!!! info "Note"
+ The output value is a timestamp in UTC, not in the timezone of `DateTime64`.
**Syntax**
-``` sql
+```sql
toUnixTimestamp64Milli(value)
```
@@ -1152,7 +1191,7 @@ toUnixTimestamp64Milli(value)
Query:
-``` sql
+```sql
WITH toDateTime64('2019-09-16 19:20:12.345678910', 6) AS dt64
SELECT toUnixTimestamp64Milli(dt64);
```
@@ -1298,4 +1337,3 @@ Result:
│ 2,"good" │
└───────────────────────────────────────────┘
```
-
diff --git a/docs/en/sql-reference/statements/grant.md b/docs/en/sql-reference/statements/grant.md
index 89f35b5f701..068eac1d083 100644
--- a/docs/en/sql-reference/statements/grant.md
+++ b/docs/en/sql-reference/statements/grant.md
@@ -316,7 +316,7 @@ Allows executing [CREATE](../../sql-reference/statements/create/index.md) and [A
Allows executing [DROP](../../sql-reference/statements/misc.md#drop) and [DETACH](../../sql-reference/statements/misc.md#detach) queries according to the following hierarchy of privileges:
-- `DROP`. Level:
+- `DROP`. Level: `GROUP`
- `DROP DATABASE`. Level: `DATABASE`
- `DROP TABLE`. Level: `TABLE`
- `DROP VIEW`. Level: `VIEW`
diff --git a/docs/ru/sql-reference/aggregate-functions/parametric-functions.md b/docs/ru/sql-reference/aggregate-functions/parametric-functions.md
index e5162b63b88..508c8de2a58 100644
--- a/docs/ru/sql-reference/aggregate-functions/parametric-functions.md
+++ b/docs/ru/sql-reference/aggregate-functions/parametric-functions.md
@@ -253,7 +253,7 @@ windowFunnel(window, [mode, [mode, ... ]])(timestamp, cond1, cond2, ..., condN)
**Параметры**
-- `window` — ширина скользящего окна по времени. Единица измерения зависит от `timestamp` и может варьироваться. Должно соблюдаться условие `timestamp события cond2 <= timestamp события cond1 + window`.
+- `window` — ширина скользящего окна по времени. Это время между первым и последним условием. Единица измерения зависит от `timestamp` и может варьироваться. Должно соблюдаться условие `timestamp события cond1 <= timestamp события cond2 <= ... <= timestamp события condN <= timestamp события cond1 + window`.
- `mode` — необязательный параметр. Может быть установленно несколько значений одновременно.
- `'strict'` — не учитывать подряд идущие повторяющиеся события.
- `'strict_order'` — запрещает посторонние события в искомой последовательности. Например, при поиске цепочки `A->B->C` в `A->B->D->C` поиск будет остановлен на `D` и функция вернет 2.
@@ -311,7 +311,7 @@ FROM
GROUP BY user_id
)
GROUP BY level
-ORDER BY level ASC
+ORDER BY level ASC;
```
## retention {#retention}
diff --git a/docs/ru/sql-reference/functions/ip-address-functions.md b/docs/ru/sql-reference/functions/ip-address-functions.md
index d7f6d2f7618..b02d45d7667 100644
--- a/docs/ru/sql-reference/functions/ip-address-functions.md
+++ b/docs/ru/sql-reference/functions/ip-address-functions.md
@@ -397,9 +397,9 @@ SELECT addr, isIPv6String(addr) FROM ( SELECT ['::', '1111::ffff', '::ffff:127.0
## isIPAddressInRange {#isipaddressinrange}
-Проверяет попадает ли IP адрес в интервал, заданный в [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing) нотации.
+Проверяет, попадает ли IP адрес в интервал, заданный в нотации [CIDR](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing).
-**Syntax**
+**Синтаксис**
``` sql
isIPAddressInRange(address, prefix)
@@ -409,7 +409,7 @@ isIPAddressInRange(address, prefix)
**Аргументы**
- `address` — IPv4 или IPv6 адрес. [String](../../sql-reference/data-types/string.md).
-- `prefix` — IPv4 или IPv6 подсеть, заданная в CIDR нотации. [String](../../sql-reference/data-types/string.md).
+- `prefix` — IPv4 или IPv6 подсеть, заданная в нотации CIDR. [String](../../sql-reference/data-types/string.md).
**Возвращаемое значение**
@@ -422,7 +422,7 @@ isIPAddressInRange(address, prefix)
Запрос:
``` sql
-SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8')
+SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8');
```
Результат:
@@ -436,7 +436,7 @@ SELECT isIPAddressInRange('127.0.0.1', '127.0.0.0/8')
Запрос:
``` sql
-SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16')
+SELECT isIPAddressInRange('127.0.0.1', 'ffff::/16');
```
Результат:
diff --git a/docs/ru/sql-reference/functions/type-conversion-functions.md b/docs/ru/sql-reference/functions/type-conversion-functions.md
index fc1dd15f8e3..2226c90525d 100644
--- a/docs/ru/sql-reference/functions/type-conversion-functions.md
+++ b/docs/ru/sql-reference/functions/type-conversion-functions.md
@@ -369,7 +369,7 @@ SELECT toFixedString('foo\0bar', 8) AS s, toStringCutToZero(s) AS s_cut;
## reinterpretAsUUID {#reinterpretasuuid}
-Функция принимает шестнадцатибайтную строку и интерпретирует ее байты в network order (big-endian). Если строка имеет недостаточную длину, то функция работает так, как будто строка дополнена необходимым количетсвом нулевых байт с конца. Если строка длиннее, чем шестнадцать байт, то игнорируются лишние байты с конца.
+Функция принимает строку из 16 байт и интерпретирует ее байты в порядок от старшего к младшему. Если строка имеет недостаточную длину, то функция работает так, как будто строка дополнена необходимым количеством нулевых байтов с конца. Если строка длиннее, чем 16 байтов, то лишние байты с конца игнорируются.
**Синтаксис**
@@ -425,9 +425,27 @@ SELECT uuid = uuid2;
## reinterpret(x, T) {#type_conversion_function-reinterpret}
-Использует туже самую исходную последовательность байт в памяти для значения `x` и переинтерпретирует ее как конечный тип данных
+Использует ту же самую исходную последовательность байтов в памяти для значения `x` и интерпретирует ее как конечный тип данных `T`.
+
+**Синтаксис**
+
+``` sql
+reinterpret(x, type)
+```
+
+**Аргументы**
+
+- `x` — любой тип данных.
+- `type` — конечный тип данных. [String](../../sql-reference/data-types/string.md).
+
+**Возвращаемое значение**
+
+- Значение конечного типа данных.
+
+**Примеры**
Запрос:
+
```sql
SELECT reinterpret(toInt8(-1), 'UInt8') as int_to_uint,
reinterpret(toInt8(1), 'Float32') as int_to_float,
@@ -448,7 +466,23 @@ SELECT reinterpret(toInt8(-1), 'UInt8') as int_to_uint,
Поддерживается также синтаксис `CAST(x AS t)`.
-Обратите внимание, что если значение `x` не может быть преобразовано к типу `T`, возникает переполнение. Например, `CAST(-1, 'UInt8')` возвращает 255.
+!!! warning "Предупреждение"
+ Если значение `x` не может быть преобразовано к типу `T`, возникает переполнение. Например, `CAST(-1, 'UInt8')` возвращает 255.
+
+**Синтаксис**
+
+``` sql
+CAST(x, T)
+```
+
+**Аргументы**
+
+- `x` — любой тип данных.
+- `T` — конечный тип данных. [String](../../sql-reference/data-types/string.md).
+
+**Возвращаемое значение**
+
+- Значение конечного типа данных.
**Примеры**
@@ -456,9 +490,9 @@ SELECT reinterpret(toInt8(-1), 'UInt8') as int_to_uint,
```sql
SELECT
- cast(toInt8(-1), 'UInt8') AS cast_int_to_uint,
- cast(toInt8(1), 'Float32') AS cast_int_to_float,
- cast('1', 'UInt32') AS cast_string_to_int
+ CAST(toInt8(-1), 'UInt8') AS cast_int_to_uint,
+ CAST(toInt8(1), 'Float32') AS cast_int_to_float,
+ CAST('1', 'UInt32') AS cast_string_to_int
```
Результат:
@@ -488,9 +522,9 @@ SELECT
└─────────────────────┴─────────────────────┴────────────┴─────────────────────┴───────────────────────────┘
```
-Преобразование в FixedString(N) работает только для аргументов типа String или FixedString(N).
+Преобразование в FixedString(N) работает только для аргументов типа [String](../../sql-reference/data-types/string.md) или [FixedString](../../sql-reference/data-types/fixedstring.md).
-Поддержано преобразование к типу [Nullable](../../sql-reference/functions/type-conversion-functions.md) и обратно.
+Поддерживается преобразование к типу [Nullable](../../sql-reference/functions/type-conversion-functions.md) и обратно.
**Примеры**
@@ -860,7 +894,7 @@ AS parseDateTimeBestEffortUS;
## parseDateTimeBestEffortOrZero {#parsedatetimebesteffortorzero}
## parseDateTime32BestEffortOrZero {#parsedatetime32besteffortorzero}
-Работает также как [parseDateTimeBestEffort](#parsedatetimebesteffort), но возвращает нулевую дату или нулевую дату и время когда получает формат даты который не может быть обработан.
+Работает аналогично функции [parseDateTimeBestEffort](#parsedatetimebesteffort), но возвращает нулевое значение, если формат даты не может быть обработан.
## parseDateTimeBestEffortUSOrNull {#parsedatetimebesteffortusornull}
@@ -1036,19 +1070,23 @@ SELECT parseDateTimeBestEffortUSOrZero('02.2021') AS parseDateTimeBestEffortUSOr
## parseDateTime64BestEffort {#parsedatetime64besteffort}
-Работает также как функция [parseDateTimeBestEffort](#parsedatetimebesteffort) но также понимамет милисекунды и микросекунды и возвращает `DateTime64(3)` или `DateTime64(6)` типы данных в зависимости от заданной точности.
+Работает аналогично функции [parseDateTimeBestEffort](#parsedatetimebesteffort), но также принимает миллисекунды и микросекунды. Возвращает тип данных [DateTime](../../sql-reference/functions/type-conversion-functions.md#data_type-datetime).
-**Syntax**
+**Синтаксис**
``` sql
parseDateTime64BestEffort(time_string [, precision [, time_zone]])
```
-**Parameters**
+**Аргументы**
-- `time_string` — String containing a date or date with time to convert. [String](../../sql-reference/data-types/string.md).
-- `precision` — `3` for milliseconds, `6` for microseconds. Default `3`. Optional [UInt8](../../sql-reference/data-types/int-uint.md).
-- `time_zone` — [Timezone](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone). The function parses `time_string` according to the timezone. Optional. [String](../../sql-reference/data-types/string.md).
+- `time_string` — строка, содержащая дату или дату со временем, которые нужно преобразовать. [String](../../sql-reference/data-types/string.md).
+- `precision` — требуемая точность: `3` — для миллисекунд, `6` — для микросекунд. По умолчанию — `3`. Необязательный. [UInt8](../../sql-reference/data-types/int-uint.md).
+- `time_zone` — [Timezone](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-timezone). Разбирает значение `time_string` в зависимости от часового пояса. Необязательный. [String](../../sql-reference/data-types/string.md).
+
+**Возвращаемое значение**
+
+- `time_string`, преобразованная в тип данных [DateTime](../../sql-reference/data-types/datetime.md).
**Примеры**
@@ -1062,7 +1100,7 @@ UNION ALL
SELECT parseDateTime64BestEffort('2021-01-01 01:01:00.12346',6) AS a, toTypeName(a) AS t
UNION ALL
SELECT parseDateTime64BestEffort('2021-01-01 01:01:00.12346',3,'Europe/Moscow') AS a, toTypeName(a) AS t
-FORMAT PrettyCompactMonoBlcok
+FORMAT PrettyCompactMonoBlock;
```
Результат:
@@ -1078,12 +1116,11 @@ FORMAT PrettyCompactMonoBlcok
## parseDateTime64BestEffortOrNull {#parsedatetime32besteffortornull}
-Работает также как функция [parseDateTime64BestEffort](#parsedatetime64besteffort) но возвращает `NULL` когда встречает формат даты который не может обработать.
+Работает аналогично функции [parseDateTime64BestEffort](#parsedatetime64besteffort), но возвращает `NULL`, если формат даты не может быть обработан.
## parseDateTime64BestEffortOrZero {#parsedatetime64besteffortorzero}
-Работает также как функция [parseDateTime64BestEffort](#parsedatetimebesteffort) но возвращает "нулевую" дату и время когда встречает формат даты который не может обработать.
-
+Работает аналогично функции [parseDateTime64BestEffort](#parsedatetimebesteffort), но возвращает нулевую дату и время, если формат даты не может быть обработан.
## toLowCardinality {#tolowcardinality}
@@ -1130,11 +1167,14 @@ SELECT toLowCardinality('1');
## toUnixTimestamp64Nano {#tounixtimestamp64nano}
Преобразует значение `DateTime64` в значение `Int64` с фиксированной точностью менее одной секунды.
-Входное значение округляется соответствующим образом вверх или вниз в зависимости от его точности. Обратите внимание, что возвращаемое значение - это временная метка в UTC, а не в часовом поясе `DateTime64`.
+Входное значение округляется соответствующим образом вверх или вниз в зависимости от его точности.
+
+!!! info "Примечание"
+ Возвращаемое значение — это временная метка в UTC, а не в часовом поясе `DateTime64`.
**Синтаксис**
-``` sql
+```sql
toUnixTimestamp64Milli(value)
```
@@ -1150,7 +1190,7 @@ toUnixTimestamp64Milli(value)
Запрос:
-``` sql
+```sql
WITH toDateTime64('2019-09-16 19:20:12.345678910', 6) AS dt64
SELECT toUnixTimestamp64Milli(dt64);
```
@@ -1296,4 +1336,3 @@ FROM numbers(3);
│ 2,"good" │
└───────────────────────────────────────────┘
```
-
diff --git a/docs/tools/README.md b/docs/tools/README.md
index 0a6c41d8089..4340561fa57 100644
--- a/docs/tools/README.md
+++ b/docs/tools/README.md
@@ -51,5 +51,5 @@ The easiest way to see the result is to use `--livereload=8888` argument of buil
At the moment there’s no easy way to do just that, but you can consider:
-- To hit the “Watch” button on top of GitHub web interface to know as early as possible, even during pull request. Alternative to this is `#github-activity` channel of [public ClickHouse Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-nwwakmk4-xOJ6cdy0sJC3It8j348~IA).
+- To hit the “Watch” button on top of GitHub web interface to know as early as possible, even during pull request. Alternative to this is `#github-activity` channel of [public ClickHouse Slack](https://join.slack.com/t/clickhousedb/shared_invite/zt-qfort0u8-TWqK4wIP0YSdoDE0btKa1w).
- Some search engines allow to subscribe on specific website changes via email and you can opt-in for that for https://clickhouse.tech.
diff --git a/docs/tools/website.py b/docs/tools/website.py
index 6927fbd87bb..f0346de5c94 100644
--- a/docs/tools/website.py
+++ b/docs/tools/website.py
@@ -155,10 +155,6 @@ def build_website(args):
os.path.join(args.src_dir, 'utils', 'list-versions', 'version_date.tsv'),
os.path.join(args.output_dir, 'data', 'version_date.tsv'))
- shutil.copy2(
- os.path.join(args.website_dir, 'js', 'embedd.min.js'),
- os.path.join(args.output_dir, 'js', 'embedd.min.js'))
-
for root, _, filenames in os.walk(args.output_dir):
for filename in filenames:
if filename == 'main.html':
diff --git a/docs/zh/engines/table-engines/integrations/odbc.md b/docs/zh/engines/table-engines/integrations/odbc.md
index 1264efeaa41..767c32cc438 100644
--- a/docs/zh/engines/table-engines/integrations/odbc.md
+++ b/docs/zh/engines/table-engines/integrations/odbc.md
@@ -7,11 +7,11 @@ toc_title: ODBC
# ODBC {#table-engine-odbc}
-允许ClickHouse通过以下方式连接到外部数据库 [ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity).
+允许ClickHouse通过[ODBC](https://en.wikipedia.org/wiki/Open_Database_Connectivity)方式连接到外部数据库.
-为了安全地实现ODBC连接,ClickHouse使用单独的程序 `clickhouse-odbc-bridge`. 如果直接从ODBC驱动程序加载 `clickhouse-server`,驱动程序问题可能会导致ClickHouse服务器崩溃。 ClickHouse自动启动 `clickhouse-odbc-bridge` 当它是必需的。 ODBC桥程序是从相同的软件包作为安装 `clickhouse-server`.
+为了安全地实现ODBC连接,ClickHouse使用了一个独立程序 `clickhouse-odbc-bridge`. 如果ODBC驱动程序是直接从 `clickhouse-server`中加载的,那么驱动问题可能会导致ClickHouse服务崩溃。 当有需要时,ClickHouse会自动启动 `clickhouse-odbc-bridge`。 ODBC桥梁程序与`clickhouse-server`来自相同的安装包.
-该引擎支持 [可为空](../../../sql-reference/data-types/nullable.md) 数据类型。
+该引擎支持 [可为空](../../../sql-reference/data-types/nullable.md) 的数据类型。
## 创建表 {#creating-a-table}
@@ -25,14 +25,14 @@ CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
ENGINE = ODBC(connection_settings, external_database, external_table)
```
-请参阅的详细说明 [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) 查询。
+详情请见 [CREATE TABLE](../../../sql-reference/statements/create.md#create-table-query) 查询。
表结构可以与源表结构不同:
- 列名应与源表中的列名相同,但您可以按任何顺序使用其中的一些列。
-- 列类型可能与源表中的列类型不同。 ClickHouse尝试 [投](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) ClickHouse数据类型的值。
+- 列类型可能与源表中的列类型不同。 ClickHouse尝试将数值[映射](../../../sql-reference/functions/type-conversion-functions.md#type_conversion_function-cast) 到ClickHouse的数据类型。
-**发动机参数**
+**引擎参数**
- `connection_settings` — Name of the section with connection settings in the `odbc.ini` 文件
- `external_database` — Name of a database in an external DBMS.
@@ -40,13 +40,13 @@ ENGINE = ODBC(connection_settings, external_database, external_table)
## 用法示例 {#usage-example}
-**通过ODBC从本地MySQL安装中检索数据**
+**通过ODBC从本地安装的MySQL中检索数据**
-此示例检查Ubuntu Linux18.04和MySQL服务器5.7。
+本示例针对Ubuntu Linux18.04和MySQL服务器5.7进行检查。
-确保安装了unixODBC和MySQL连接器。
+请确保安装了unixODBC和MySQL连接器。
-默认情况下(如果从软件包安装),ClickHouse以用户身份启动 `clickhouse`. 因此,您需要在MySQL服务器中创建和配置此用户。
+默认情况下(如果从软件包安装),ClickHouse以用户`clickhouse`的身份启动 . 因此,您需要在MySQL服务器中创建和配置此用户。
``` bash
$ sudo mysql
@@ -57,7 +57,7 @@ mysql> CREATE USER 'clickhouse'@'localhost' IDENTIFIED BY 'clickhouse';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'clickhouse'@'clickhouse' WITH GRANT OPTION;
```
-然后配置连接 `/etc/odbc.ini`.
+然后在`/etc/odbc.ini`中配置连接 .
``` bash
$ cat /etc/odbc.ini
@@ -70,7 +70,7 @@ USERNAME = clickhouse
PASSWORD = clickhouse
```
-您可以使用 `isql` unixodbc安装中的实用程序。
+您可以从安装的unixodbc中使用 `isql` 实用程序来检查连接情况。
``` bash
$ isql -v mysqlconn
diff --git a/docs/zh/operations/system-tables/data_type_families.md b/docs/zh/operations/system-tables/data_type_families.md
index 21eb4785e23..db08ff0371b 100644
--- a/docs/zh/operations/system-tables/data_type_families.md
+++ b/docs/zh/operations/system-tables/data_type_families.md
@@ -5,13 +5,13 @@ machine_translated_rev: 5decc73b5dc60054f19087d3690c4eb99446a6c3
# 系统。data_type_families {#system_tables-data_type_families}
-包含有关受支持的信息 [数据类型](../../sql-reference/data-types/).
+包含有关受支持的[数据类型](../../sql-reference/data-types/)的信息.
-列:
+列字段包括:
-- `name` ([字符串](../../sql-reference/data-types/string.md)) — Data type name.
-- `case_insensitive` ([UInt8](../../sql-reference/data-types/int-uint.md)) — Property that shows whether you can use a data type name in a query in case insensitive manner or not. For example, `Date` 和 `date` 都是有效的。
-- `alias_to` ([字符串](../../sql-reference/data-types/string.md)) — Data type name for which `name` 是个化名
+- `name` ([String](../../sql-reference/data-types/string.md)) — 数据类型的名称.
+- `case_insensitive` ([UInt8](../../sql-reference/data-types/int-uint.md)) — 该属性显示是否可以在查询中以不区分大小写的方式使用数据类型名称。例如 `Date` 和 `date` 都是有效的。
+- `alias_to` ([String](../../sql-reference/data-types/string.md)) — 名称为别名的数据类型名称。
**示例**
@@ -36,4 +36,4 @@ SELECT * FROM system.data_type_families WHERE alias_to = 'String'
**另请参阅**
-- [语法](../../sql-reference/syntax.md) — Information about supported syntax.
+- [Syntax](../../sql-reference/syntax.md) — 关于所支持的语法信息.
diff --git a/docs/zh/operations/system-tables/index.md b/docs/zh/operations/system-tables/index.md
index 56067bc5057..0e5778e3051 100644
--- a/docs/zh/operations/system-tables/index.md
+++ b/docs/zh/operations/system-tables/index.md
@@ -7,33 +7,33 @@ toc_title: "\u7CFB\u7EDF\u8868"
# 系统表 {#system-tables}
-## 导言 {#system-tables-introduction}
+## 引言 {#system-tables-introduction}
-系统表提供以下信息:
+系统表提供的信息如下:
-- 服务器状态、进程和环境。
+- 服务器的状态、进程以及环境。
- 服务器的内部进程。
系统表:
-- 坐落于 `system` 数据库。
-- 仅适用于读取数据。
-- 不能删除或更改,但可以分离。
+- 存储于 `system` 数据库。
+- 仅提供数据读取功能。
+- 不能被删除或更改,但可以对其进行分离(detach)操作。
-大多数系统表将数据存储在RAM中。 ClickHouse服务器在开始时创建此类系统表。
+大多数系统表将其数据存储在RAM中。 一个ClickHouse服务在刚启动时便会创建此类系统表。
-与其他系统表不同,系统日志表 [metric_log](../../operations/system-tables/metric_log.md#system_tables-metric_log), [query_log](../../operations/system-tables/query_log.md#system_tables-query_log), [query_thread_log](../../operations/system-tables/query_thread_log.md#system_tables-query_thread_log), [trace_log](../../operations/system-tables/trace_log.md#system_tables-trace_log), [part_log](../../operations/system-tables/part_log.md#system.part_log), crash_log and text_log 默认采用[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎并将其数据存储在存储文件系统中。 如果从文件系统中删除表,ClickHouse服务器会在下一次写入数据时再次创建空表。 如果系统表架构在新版本中发生更改,则ClickHouse会重命名当前表并创建一个新表。
+不同于其他系统表,系统日志表 [metric_log](../../operations/system-tables/metric_log.md#system_tables-metric_log), [query_log](../../operations/system-tables/query_log.md#system_tables-query_log), [query_thread_log](../../operations/system-tables/query_thread_log.md#system_tables-query_thread_log), [trace_log](../../operations/system-tables/trace_log.md#system_tables-trace_log), [part_log](../../operations/system-tables/part_log.md#system.part_log), crash_log and text_log 默认采用[MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) 引擎并将其数据存储在文件系统中。 如果人为的从文件系统中删除表,ClickHouse服务器会在下一次进行数据写入时再次创建空表。 如果系统表结构在新版本中发生更改,那么ClickHouse会重命名当前表并创建一个新表。
-用户可以通过在`/etc/clickhouse-server/config.d/`下创建与系统表同名的配置文件, 或者在`/etc/clickhouse-server/config.xml`中设置相应配置项,来自定义系统日志表的结构。可以自定义的配置项如下:
+用户可以通过在`/etc/clickhouse-server/config.d/`下创建与系统表同名的配置文件, 或者在`/etc/clickhouse-server/config.xml`中设置相应配置项,来自定义系统日志表的结构。可供自定义的配置项如下:
-- `database`: 系统日志表所在的数据库。这个选项目前已经废弃。所有的系统日表都位于`system`库中。
-- `table`: 系统日志表名。
+- `database`: 系统日志表所在的数据库。这个选项目前已经不推荐使用。所有的系统日表都位于`system`库中。
+- `table`: 接收数据写入的系统日志表。
- `partition_by`: 指定[PARTITION BY](../../engines/table-engines/mergetree-family/custom-partitioning-key.md)表达式。
- `ttl`: 指定系统日志表TTL选项。
-- `flush_interval_milliseconds`: 指定系统日志表数据落盘时间。
-- `engine`: 指定完整的表引擎定义。(以`ENGINE = `开始)。 这个选项与`partition_by`以及`ttl`冲突。如果两者一起设置,服务启动时会抛出异常并且退出。
+- `flush_interval_milliseconds`: 指定日志表数据刷新到磁盘的时间间隔。
+- `engine`: 指定完整的表引擎定义。(以`ENGINE = `开头)。 这个选项与`partition_by`以及`ttl`冲突。如果与两者一起设置,服务启动时会抛出异常并且退出。
-一个配置定义的例子如下:
+配置定义的示例如下:
```
@@ -50,20 +50,20 @@ toc_title: "\u7CFB\u7EDF\u8868"
```
-默认情况下,表增长是无限的。 要控制表的大小,可以使用 TTL 删除过期日志记录的设置。 你也可以使用分区功能 `MergeTree`-发动机表。
+默认情况下,表增长是无限的。可以通过TTL 删除过期日志记录的设置来控制表的大小。 你也可以使用分区功能 `MergeTree`-引擎表。
## 系统指标的来源 {#system-tables-sources-of-system-metrics}
用于收集ClickHouse服务器使用的系统指标:
- `CAP_NET_ADMIN` 能力。
-- [procfs](https://en.wikipedia.org/wiki/Procfs) (仅在Linux中)。
+- [procfs](https://en.wikipedia.org/wiki/Procfs) (仅限于Linux)。
**procfs**
-如果ClickHouse服务器没有 `CAP_NET_ADMIN` 能力,它试图回落到 `ProcfsMetricsProvider`. `ProcfsMetricsProvider` 允许收集每个查询系统指标(用于CPU和I/O)。
+如果ClickHouse服务器没有 `CAP_NET_ADMIN` 能力,那么它将试图退回到 `ProcfsMetricsProvider`. `ProcfsMetricsProvider` 允许收集每个查询系统指标(包括CPU和I/O)。
-如果系统上支持并启用procfs,ClickHouse server将收集这些指标:
+如果系统上支持并启用procfs,ClickHouse server将收集如下指标:
- `OSCPUVirtualTimeMicroseconds`
- `OSCPUWaitMicroseconds`
diff --git a/docs/zh/sql-reference/statements/create.md b/docs/zh/sql-reference/statements/create.md
index 639af0841dc..46e82bd1733 100644
--- a/docs/zh/sql-reference/statements/create.md
+++ b/docs/zh/sql-reference/statements/create.md
@@ -238,7 +238,7 @@ SELECT a, b, c FROM (SELECT ...)
当一个`SELECT`子句包含`DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT`时,请注意,这些仅会在插入数据时在每个单独的数据块上执行。例如,如果你在其中包含了`GROUP BY`,则只会在查询期间进行聚合,但聚合范围仅限于单个批的写入数据。数据不会进一步被聚合。但是当你使用一些其他数据聚合引擎时这是例外的,如:`SummingMergeTree`。
-目前对物化视图执行`ALTER`是不支持的,因此这可能是不方便的。如果物化视图是使用的`TO [db.]name`的方式进行构建的,你可以使用`DETACH`语句现将视图剥离,然后使用`ALTER`运行在目标表上,然后使用`ATTACH`将之前剥离的表重新加载进来。
+目前对物化视图执行`ALTER`是不支持的,因此这可能是不方便的。如果物化视图是使用的`TO [db.]name`的方式进行构建的,你可以使用`DETACH`语句先将视图剥离,然后使用`ALTER`运行在目标表上,然后使用`ATTACH`将之前剥离的表重新加载进来。
视图看起来和普通的表相同。例如,你可以通过`SHOW TABLES`查看到它们。
diff --git a/docs/zh/sql-reference/syntax.md b/docs/zh/sql-reference/syntax.md
index 8c331db1139..c05c5a1a7bf 100644
--- a/docs/zh/sql-reference/syntax.md
+++ b/docs/zh/sql-reference/syntax.md
@@ -14,7 +14,7 @@ INSERT INTO t VALUES (1, 'Hello, world'), (2, 'abc'), (3, 'def')
含`INSERT INTO t VALUES` 的部分由完整SQL解析器处理,包含数据的部分 `(1, 'Hello, world'), (2, 'abc'), (3, 'def')` 交给快速流式解析器解析。通过设置参数 [input_format_values_interpret_expressions](../operations/settings/settings.md#settings-input_format_values_interpret_expressions),你也可以对数据部分开启完整SQL解析器。当 `input_format_values_interpret_expressions = 1` 时,CH优先采用快速流式解析器来解析数据。如果失败,CH再尝试用完整SQL解析器来处理,就像处理SQL [expression](#syntax-expressions) 一样。
-数据可以采用任何格式。当CH接受到请求时,服务端先在内存中计算不超过 [max_query_size](../operations/settings/settings.md#settings-max_query_size) 字节的请求数据(默认1 mb),然后剩下部分交给快速流式解析器。
+数据可以采用任何格式。当CH接收到请求时,服务端先在内存中计算不超过 [max_query_size](../operations/settings/settings.md#settings-max_query_size) 字节的请求数据(默认1 mb),然后剩下部分交给快速流式解析器。
这将避免在处理大型的 `INSERT`语句时出现问题。
diff --git a/programs/server/config.xml b/programs/server/config.xml
index df8a5266c39..75647b10416 100644
--- a/programs/server/config.xml
+++ b/programs/server/config.xml
@@ -362,6 +362,20 @@
bind_dn - template used to construct the DN to bind to.
The resulting DN will be constructed by replacing all '{user_name}' substrings of the template with the actual
user name during each authentication attempt.
+ user_dn_detection - section with LDAP search parameters for detecting the actual user DN of the bound user.
+ This is mainly used in search filters for further role mapping when the server is Active Directory. The
+ resulting user DN will be used when replacing '{user_dn}' substrings wherever they are allowed. By default,
+ user DN is set equal to bind DN, but once search is performed, it will be updated with to the actual detected
+ user DN value.
+ base_dn - template used to construct the base DN for the LDAP search.
+ The resulting DN will be constructed by replacing all '{user_name}' and '{bind_dn}' substrings
+ of the template with the actual user name and bind DN during the LDAP search.
+ scope - scope of the LDAP search.
+ Accepted values are: 'base', 'one_level', 'children', 'subtree' (the default).
+ search_filter - template used to construct the search filter for the LDAP search.
+ The resulting filter will be constructed by replacing all '{user_name}', '{bind_dn}', and '{base_dn}'
+ substrings of the template with the actual user name, bind DN, and base DN during the LDAP search.
+ Note, that the special characters must be escaped properly in XML.
verification_cooldown - a period of time, in seconds, after a successful bind attempt, during which a user will be assumed
to be successfully authenticated for all consecutive requests without contacting the LDAP server.
Specify 0 (the default) to disable caching and force contacting the LDAP server for each authentication request.
@@ -393,6 +407,17 @@
/path/to/tls_ca_cert_dir
ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:AES256-GCM-SHA384
+ Example (typical Active Directory with configured user DN detection for further role mapping):
+
+ localhost
+ 389
+ EXAMPLE\{user_name}
+
+ CN=Users,DC=example,DC=com
+ (&(objectClass=user)(sAMAccountName={user_name}))
+
+ no
+
-->
@@ -444,15 +469,16 @@
There can be multiple 'role_mapping' sections defined inside the same 'ldap' section. All of them will be
applied.
base_dn - template used to construct the base DN for the LDAP search.
- The resulting DN will be constructed by replacing all '{user_name}' and '{bind_dn}' substrings
- of the template with the actual user name and bind DN during each LDAP search.
+ The resulting DN will be constructed by replacing all '{user_name}', '{bind_dn}', and '{user_dn}'
+ substrings of the template with the actual user name, bind DN, and user DN during each LDAP search.
scope - scope of the LDAP search.
Accepted values are: 'base', 'one_level', 'children', 'subtree' (the default).
search_filter - template used to construct the search filter for the LDAP search.
- The resulting filter will be constructed by replacing all '{user_name}', '{bind_dn}', and '{base_dn}'
- substrings of the template with the actual user name, bind DN, and base DN during each LDAP search.
+ The resulting filter will be constructed by replacing all '{user_name}', '{bind_dn}', '{user_dn}', and
+ '{base_dn}' substrings of the template with the actual user name, bind DN, user DN, and base DN during
+ each LDAP search.
Note, that the special characters must be escaped properly in XML.
- attribute - attribute name whose values will be returned by the LDAP search.
+ attribute - attribute name whose values will be returned by the LDAP search. 'cn', by default.
prefix - prefix, that will be expected to be in front of each string in the original list of strings returned by
the LDAP search. Prefix will be removed from the original strings and resulting strings will be treated
as local role names. Empty, by default.
@@ -471,6 +497,17 @@
clickhouse_
+ Example (typical Active Directory with role mapping that relies on the detected user DN):
+
+ my_ad_server
+
+ CN=Users,DC=example,DC=com
+ CN
+ subtree
+ (&(objectClass=group)(member={user_dn}))
+ clickhouse_
+
+
-->
diff --git a/src/Access/ContextAccess.cpp b/src/Access/ContextAccess.cpp
index 0bcaef1e441..90495a83dfc 100644
--- a/src/Access/ContextAccess.cpp
+++ b/src/Access/ContextAccess.cpp
@@ -143,11 +143,13 @@ ContextAccess::ContextAccess(const AccessControlManager & manager_, const Params
: manager(&manager_)
, params(params_)
{
+ std::lock_guard lock{mutex};
+
subscription_for_user_change = manager->subscribeForChanges(
*params.user_id, [this](const UUID &, const AccessEntityPtr & entity)
{
UserPtr changed_user = entity ? typeid_cast(entity) : nullptr;
- std::lock_guard lock{mutex};
+ std::lock_guard lock2{mutex};
setUser(changed_user);
});
@@ -189,7 +191,7 @@ void ContextAccess::setUser(const UserPtr & user_) const
current_roles_with_admin_option = user->granted_roles.findGrantedWithAdminOption(params.current_roles);
}
- subscription_for_roles_changes = {};
+ subscription_for_roles_changes.reset();
enabled_roles = manager->getEnabledRoles(current_roles, current_roles_with_admin_option);
subscription_for_roles_changes = enabled_roles->subscribeForChanges([this](const std::shared_ptr & roles_info_)
{
diff --git a/src/Access/ExternalAuthenticators.cpp b/src/Access/ExternalAuthenticators.cpp
index 0c4d2f417c9..d4100c4e520 100644
--- a/src/Access/ExternalAuthenticators.cpp
+++ b/src/Access/ExternalAuthenticators.cpp
@@ -20,13 +20,42 @@ namespace ErrorCodes
namespace
{
-auto parseLDAPServer(const Poco::Util::AbstractConfiguration & config, const String & name)
+void parseLDAPSearchParams(LDAPClient::SearchParams & params, const Poco::Util::AbstractConfiguration & config, const String & prefix)
+{
+ const bool has_base_dn = config.has(prefix + ".base_dn");
+ const bool has_search_filter = config.has(prefix + ".search_filter");
+ const bool has_attribute = config.has(prefix + ".attribute");
+ const bool has_scope = config.has(prefix + ".scope");
+
+ if (has_base_dn)
+ params.base_dn = config.getString(prefix + ".base_dn");
+
+ if (has_search_filter)
+ params.search_filter = config.getString(prefix + ".search_filter");
+
+ if (has_attribute)
+ params.attribute = config.getString(prefix + ".attribute");
+
+ if (has_scope)
+ {
+ auto scope = config.getString(prefix + ".scope");
+ boost::algorithm::to_lower(scope);
+
+ if (scope == "base") params.scope = LDAPClient::SearchParams::Scope::BASE;
+ else if (scope == "one_level") params.scope = LDAPClient::SearchParams::Scope::ONE_LEVEL;
+ else if (scope == "subtree") params.scope = LDAPClient::SearchParams::Scope::SUBTREE;
+ else if (scope == "children") params.scope = LDAPClient::SearchParams::Scope::CHILDREN;
+ else
+ throw Exception("Invalid value for 'scope' field of LDAP search parameters in '" + prefix +
+ "' section, must be one of 'base', 'one_level', 'subtree', or 'children'", ErrorCodes::BAD_ARGUMENTS);
+ }
+}
+
+void parseLDAPServer(LDAPClient::Params & params, const Poco::Util::AbstractConfiguration & config, const String & name)
{
if (name.empty())
throw Exception("LDAP server name cannot be empty", ErrorCodes::BAD_ARGUMENTS);
- LDAPClient::Params params;
-
const String ldap_server_config = "ldap_servers." + name;
const bool has_host = config.has(ldap_server_config + ".host");
@@ -34,6 +63,7 @@ auto parseLDAPServer(const Poco::Util::AbstractConfiguration & config, const Str
const bool has_bind_dn = config.has(ldap_server_config + ".bind_dn");
const bool has_auth_dn_prefix = config.has(ldap_server_config + ".auth_dn_prefix");
const bool has_auth_dn_suffix = config.has(ldap_server_config + ".auth_dn_suffix");
+ const bool has_user_dn_detection = config.has(ldap_server_config + ".user_dn_detection");
const bool has_verification_cooldown = config.has(ldap_server_config + ".verification_cooldown");
const bool has_enable_tls = config.has(ldap_server_config + ".enable_tls");
const bool has_tls_minimum_protocol_version = config.has(ldap_server_config + ".tls_minimum_protocol_version");
@@ -66,6 +96,17 @@ auto parseLDAPServer(const Poco::Util::AbstractConfiguration & config, const Str
params.bind_dn = auth_dn_prefix + "{user_name}" + auth_dn_suffix;
}
+ if (has_user_dn_detection)
+ {
+ if (!params.user_dn_detection)
+ {
+ params.user_dn_detection.emplace();
+ params.user_dn_detection->attribute = "dn";
+ }
+
+ parseLDAPSearchParams(*params.user_dn_detection, config, ldap_server_config + ".user_dn_detection");
+ }
+
if (has_verification_cooldown)
params.verification_cooldown = std::chrono::seconds{config.getUInt64(ldap_server_config + ".verification_cooldown")};
@@ -143,14 +184,10 @@ auto parseLDAPServer(const Poco::Util::AbstractConfiguration & config, const Str
}
else
params.port = (params.enable_tls == LDAPClient::Params::TLSEnable::YES ? 636 : 389);
-
- return params;
}
-auto parseKerberosParams(const Poco::Util::AbstractConfiguration & config)
+void parseKerberosParams(GSSAcceptorContext::Params & params, const Poco::Util::AbstractConfiguration & config)
{
- GSSAcceptorContext::Params params;
-
Poco::Util::AbstractConfiguration::Keys keys;
config.keys("kerberos", keys);
@@ -180,12 +217,20 @@ auto parseKerberosParams(const Poco::Util::AbstractConfiguration & config)
params.realm = config.getString("kerberos.realm", "");
params.principal = config.getString("kerberos.principal", "");
-
- return params;
}
}
+void parseLDAPRoleSearchParams(LDAPClient::RoleSearchParams & params, const Poco::Util::AbstractConfiguration & config, const String & prefix)
+{
+ parseLDAPSearchParams(params, config, prefix);
+
+ const bool has_prefix = config.has(prefix + ".prefix");
+
+ if (has_prefix)
+ params.prefix = config.getString(prefix + ".prefix");
+}
+
void ExternalAuthenticators::reset()
{
std::scoped_lock lock(mutex);
@@ -229,7 +274,8 @@ void ExternalAuthenticators::setConfiguration(const Poco::Util::AbstractConfigur
{
try
{
- ldap_client_params_blueprint.insert_or_assign(ldap_server_name, parseLDAPServer(config, ldap_server_name));
+ ldap_client_params_blueprint.erase(ldap_server_name);
+ parseLDAPServer(ldap_client_params_blueprint.emplace(ldap_server_name, LDAPClient::Params{}).first->second, config, ldap_server_name);
}
catch (...)
{
@@ -240,7 +286,7 @@ void ExternalAuthenticators::setConfiguration(const Poco::Util::AbstractConfigur
try
{
if (kerberos_keys_count > 0)
- kerberos_params = parseKerberosParams(config);
+ parseKerberosParams(kerberos_params.emplace(), config);
}
catch (...)
{
@@ -249,7 +295,7 @@ void ExternalAuthenticators::setConfiguration(const Poco::Util::AbstractConfigur
}
bool ExternalAuthenticators::checkLDAPCredentials(const String & server, const BasicCredentials & credentials,
- const LDAPClient::SearchParamsList * search_params, LDAPClient::SearchResultsList * search_results) const
+ const LDAPClient::RoleSearchParamsList * role_search_params, LDAPClient::SearchResultsList * role_search_results) const
{
std::optional params;
std::size_t params_hash = 0;
@@ -267,9 +313,9 @@ bool ExternalAuthenticators::checkLDAPCredentials(const String & server, const B
params->password = credentials.getPassword();
params->combineCoreHash(params_hash);
- if (search_params)
+ if (role_search_params)
{
- for (const auto & params_instance : *search_params)
+ for (const auto & params_instance : *role_search_params)
{
params_instance.combineHash(params_hash);
}
@@ -301,14 +347,14 @@ bool ExternalAuthenticators::checkLDAPCredentials(const String & server, const B
// Ensure that search_params are compatible.
(
- search_params == nullptr ?
- entry.last_successful_search_results.empty() :
- search_params->size() == entry.last_successful_search_results.size()
+ role_search_params == nullptr ?
+ entry.last_successful_role_search_results.empty() :
+ role_search_params->size() == entry.last_successful_role_search_results.size()
)
)
{
- if (search_results)
- *search_results = entry.last_successful_search_results;
+ if (role_search_results)
+ *role_search_results = entry.last_successful_role_search_results;
return true;
}
@@ -326,7 +372,7 @@ bool ExternalAuthenticators::checkLDAPCredentials(const String & server, const B
}
LDAPSimpleAuthClient client(params.value());
- const auto result = client.authenticate(search_params, search_results);
+ const auto result = client.authenticate(role_search_params, role_search_results);
const auto current_check_timestamp = std::chrono::steady_clock::now();
// Update the cache, but only if this is the latest check and the server is still configured in a compatible way.
@@ -345,9 +391,9 @@ bool ExternalAuthenticators::checkLDAPCredentials(const String & server, const B
std::size_t new_params_hash = 0;
new_params.combineCoreHash(new_params_hash);
- if (search_params)
+ if (role_search_params)
{
- for (const auto & params_instance : *search_params)
+ for (const auto & params_instance : *role_search_params)
{
params_instance.combineHash(new_params_hash);
}
@@ -363,17 +409,17 @@ bool ExternalAuthenticators::checkLDAPCredentials(const String & server, const B
entry.last_successful_params_hash = params_hash;
entry.last_successful_authentication_timestamp = current_check_timestamp;
- if (search_results)
- entry.last_successful_search_results = *search_results;
+ if (role_search_results)
+ entry.last_successful_role_search_results = *role_search_results;
else
- entry.last_successful_search_results.clear();
+ entry.last_successful_role_search_results.clear();
}
else if (
entry.last_successful_params_hash != params_hash ||
(
- search_params == nullptr ?
- !entry.last_successful_search_results.empty() :
- search_params->size() != entry.last_successful_search_results.size()
+ role_search_params == nullptr ?
+ !entry.last_successful_role_search_results.empty() :
+ role_search_params->size() != entry.last_successful_role_search_results.size()
)
)
{
diff --git a/src/Access/ExternalAuthenticators.h b/src/Access/ExternalAuthenticators.h
index c8feea7eada..24f1f7b6528 100644
--- a/src/Access/ExternalAuthenticators.h
+++ b/src/Access/ExternalAuthenticators.h
@@ -34,7 +34,7 @@ public:
// The name and readiness of the credentials must be verified before calling these.
bool checkLDAPCredentials(const String & server, const BasicCredentials & credentials,
- const LDAPClient::SearchParamsList * search_params = nullptr, LDAPClient::SearchResultsList * search_results = nullptr) const;
+ const LDAPClient::RoleSearchParamsList * role_search_params = nullptr, LDAPClient::SearchResultsList * role_search_results = nullptr) const;
bool checkKerberosCredentials(const String & realm, const GSSAcceptorContext & credentials) const;
GSSAcceptorContext::Params getKerberosParams() const;
@@ -44,7 +44,7 @@ private:
{
std::size_t last_successful_params_hash = 0;
std::chrono::steady_clock::time_point last_successful_authentication_timestamp;
- LDAPClient::SearchResultsList last_successful_search_results;
+ LDAPClient::SearchResultsList last_successful_role_search_results;
};
using LDAPCache = std::unordered_map; // user name -> cache entry
@@ -58,4 +58,6 @@ private:
std::optional kerberos_params;
};
+void parseLDAPRoleSearchParams(LDAPClient::RoleSearchParams & params, const Poco::Util::AbstractConfiguration & config, const String & prefix);
+
}
diff --git a/src/Access/LDAPAccessStorage.cpp b/src/Access/LDAPAccessStorage.cpp
index b47a9b3e041..c1d54e8c9aa 100644
--- a/src/Access/LDAPAccessStorage.cpp
+++ b/src/Access/LDAPAccessStorage.cpp
@@ -68,34 +68,15 @@ void LDAPAccessStorage::setConfiguration(AccessControlManager * access_control_m
common_roles_cfg.insert(role_names.begin(), role_names.end());
}
- LDAPClient::SearchParamsList role_search_params_cfg;
+ LDAPClient::RoleSearchParamsList role_search_params_cfg;
if (has_role_mapping)
{
Poco::Util::AbstractConfiguration::Keys all_keys;
config.keys(prefix, all_keys);
for (const auto & key : all_keys)
{
- if (key != "role_mapping" && key.find("role_mapping[") != 0)
- continue;
-
- const String rm_prefix = prefix_str + key;
- const String rm_prefix_str = rm_prefix + '.';
- role_search_params_cfg.emplace_back();
- auto & rm_params = role_search_params_cfg.back();
-
- rm_params.base_dn = config.getString(rm_prefix_str + "base_dn", "");
- rm_params.search_filter = config.getString(rm_prefix_str + "search_filter", "");
- rm_params.attribute = config.getString(rm_prefix_str + "attribute", "cn");
- rm_params.prefix = config.getString(rm_prefix_str + "prefix", "");
-
- auto scope = config.getString(rm_prefix_str + "scope", "subtree");
- boost::algorithm::to_lower(scope);
- if (scope == "base") rm_params.scope = LDAPClient::SearchParams::Scope::BASE;
- else if (scope == "one_level") rm_params.scope = LDAPClient::SearchParams::Scope::ONE_LEVEL;
- else if (scope == "subtree") rm_params.scope = LDAPClient::SearchParams::Scope::SUBTREE;
- else if (scope == "children") rm_params.scope = LDAPClient::SearchParams::Scope::CHILDREN;
- else
- throw Exception("Invalid value of 'scope' field in '" + key + "' section of LDAP user directory, must be one of 'base', 'one_level', 'subtree', or 'children'", ErrorCodes::BAD_ARGUMENTS);
+ if (key == "role_mapping" || key.find("role_mapping[") == 0)
+ parseLDAPRoleSearchParams(role_search_params_cfg.emplace_back(), config, prefix_str + key);
}
}
@@ -364,7 +345,7 @@ std::set LDAPAccessStorage::mapExternalRolesNoLock(const LDAPClient::Sea
bool LDAPAccessStorage::areLDAPCredentialsValidNoLock(const User & user, const Credentials & credentials,
- const ExternalAuthenticators & external_authenticators, LDAPClient::SearchResultsList & search_results) const
+ const ExternalAuthenticators & external_authenticators, LDAPClient::SearchResultsList & role_search_results) const
{
if (!credentials.isReady())
return false;
@@ -373,7 +354,7 @@ bool LDAPAccessStorage::areLDAPCredentialsValidNoLock(const User & user, const C
return false;
if (const auto * basic_credentials = dynamic_cast(&credentials))
- return external_authenticators.checkLDAPCredentials(ldap_server_name, *basic_credentials, &role_search_params, &search_results);
+ return external_authenticators.checkLDAPCredentials(ldap_server_name, *basic_credentials, &role_search_params, &role_search_results);
return false;
}
diff --git a/src/Access/LDAPAccessStorage.h b/src/Access/LDAPAccessStorage.h
index ea0ab47c225..33ac9f0a914 100644
--- a/src/Access/LDAPAccessStorage.h
+++ b/src/Access/LDAPAccessStorage.h
@@ -68,12 +68,12 @@ private:
void updateAssignedRolesNoLock(const UUID & id, const String & user_name, const LDAPClient::SearchResultsList & external_roles) const;
std::set mapExternalRolesNoLock(const LDAPClient::SearchResultsList & external_roles) const;
bool areLDAPCredentialsValidNoLock(const User & user, const Credentials & credentials,
- const ExternalAuthenticators & external_authenticators, LDAPClient::SearchResultsList & search_results) const;
+ const ExternalAuthenticators & external_authenticators, LDAPClient::SearchResultsList & role_search_results) const;
mutable std::recursive_mutex mutex;
AccessControlManager * access_control_manager = nullptr;
String ldap_server_name;
- LDAPClient::SearchParamsList role_search_params;
+ LDAPClient::RoleSearchParamsList role_search_params;
std::set common_role_names; // role name that should be granted to all users at all times
mutable std::map external_role_hashes; // user name -> LDAPClient::SearchResultsList hash (most recently retrieved and processed)
mutable std::map> users_per_roles; // role name -> user names (...it should be granted to; may but don't have to exist for common roles)
diff --git a/src/Access/LDAPClient.cpp b/src/Access/LDAPClient.cpp
index 5c4b7dd8d99..a8f9675774b 100644
--- a/src/Access/LDAPClient.cpp
+++ b/src/Access/LDAPClient.cpp
@@ -32,6 +32,11 @@ void LDAPClient::SearchParams::combineHash(std::size_t & seed) const
boost::hash_combine(seed, static_cast(scope));
boost::hash_combine(seed, search_filter);
boost::hash_combine(seed, attribute);
+}
+
+void LDAPClient::RoleSearchParams::combineHash(std::size_t & seed) const
+{
+ SearchParams::combineHash(seed);
boost::hash_combine(seed, prefix);
}
@@ -42,6 +47,9 @@ void LDAPClient::Params::combineCoreHash(std::size_t & seed) const
boost::hash_combine(seed, bind_dn);
boost::hash_combine(seed, user);
boost::hash_combine(seed, password);
+
+ if (user_dn_detection)
+ user_dn_detection->combineHash(seed);
}
LDAPClient::LDAPClient(const Params & params_)
@@ -286,18 +294,33 @@ void LDAPClient::openConnection()
if (params.enable_tls == LDAPClient::Params::TLSEnable::YES_STARTTLS)
diag(ldap_start_tls_s(handle, nullptr, nullptr));
+ final_user_name = escapeForLDAP(params.user);
+ final_bind_dn = replacePlaceholders(params.bind_dn, { {"{user_name}", final_user_name} });
+ final_user_dn = final_bind_dn; // The default value... may be updated right after a successful bind.
+
switch (params.sasl_mechanism)
{
case LDAPClient::Params::SASLMechanism::SIMPLE:
{
- const auto escaped_user_name = escapeForLDAP(params.user);
- const auto bind_dn = replacePlaceholders(params.bind_dn, { {"{user_name}", escaped_user_name} });
-
::berval cred;
cred.bv_val = const_cast(params.password.c_str());
cred.bv_len = params.password.size();
- diag(ldap_sasl_bind_s(handle, bind_dn.c_str(), LDAP_SASL_SIMPLE, &cred, nullptr, nullptr, nullptr));
+ diag(ldap_sasl_bind_s(handle, final_bind_dn.c_str(), LDAP_SASL_SIMPLE, &cred, nullptr, nullptr, nullptr));
+
+ // Once bound, run the user DN search query and update the default value, if asked.
+ if (params.user_dn_detection)
+ {
+ const auto user_dn_search_results = search(*params.user_dn_detection);
+
+ if (user_dn_search_results.empty())
+ throw Exception("Failed to detect user DN: empty search results", ErrorCodes::LDAP_ERROR);
+
+ if (user_dn_search_results.size() > 1)
+ throw Exception("Failed to detect user DN: more than one entry in the search results", ErrorCodes::LDAP_ERROR);
+
+ final_user_dn = *user_dn_search_results.begin();
+ }
break;
}
@@ -316,6 +339,9 @@ void LDAPClient::closeConnection() noexcept
ldap_unbind_ext_s(handle, nullptr, nullptr);
handle = nullptr;
+ final_user_name.clear();
+ final_bind_dn.clear();
+ final_user_dn.clear();
}
LDAPClient::SearchResults LDAPClient::search(const SearchParams & search_params)
@@ -333,10 +359,19 @@ LDAPClient::SearchResults LDAPClient::search(const SearchParams & search_params)
case SearchParams::Scope::CHILDREN: scope = LDAP_SCOPE_CHILDREN; break;
}
- const auto escaped_user_name = escapeForLDAP(params.user);
- const auto bind_dn = replacePlaceholders(params.bind_dn, { {"{user_name}", escaped_user_name} });
- const auto base_dn = replacePlaceholders(search_params.base_dn, { {"{user_name}", escaped_user_name}, {"{bind_dn}", bind_dn} });
- const auto search_filter = replacePlaceholders(search_params.search_filter, { {"{user_name}", escaped_user_name}, {"{bind_dn}", bind_dn}, {"{base_dn}", base_dn} });
+ const auto final_base_dn = replacePlaceholders(search_params.base_dn, {
+ {"{user_name}", final_user_name},
+ {"{bind_dn}", final_bind_dn},
+ {"{user_dn}", final_user_dn}
+ });
+
+ const auto final_search_filter = replacePlaceholders(search_params.search_filter, {
+ {"{user_name}", final_user_name},
+ {"{bind_dn}", final_bind_dn},
+ {"{user_dn}", final_user_dn},
+ {"{base_dn}", final_base_dn}
+ });
+
char * attrs[] = { const_cast(search_params.attribute.c_str()), nullptr };
::timeval timeout = { params.search_timeout.count(), 0 };
LDAPMessage* msgs = nullptr;
@@ -349,7 +384,7 @@ LDAPClient::SearchResults LDAPClient::search(const SearchParams & search_params)
}
});
- diag(ldap_search_ext_s(handle, base_dn.c_str(), scope, search_filter.c_str(), attrs, 0, nullptr, nullptr, &timeout, params.search_limit, &msgs));
+ diag(ldap_search_ext_s(handle, final_base_dn.c_str(), scope, final_search_filter.c_str(), attrs, 0, nullptr, nullptr, &timeout, params.search_limit, &msgs));
for (
auto * msg = ldap_first_message(handle, msgs);
@@ -361,6 +396,27 @@ LDAPClient::SearchResults LDAPClient::search(const SearchParams & search_params)
{
case LDAP_RES_SEARCH_ENTRY:
{
+ // Extract DN separately, if the requested attribute is DN.
+ if (boost::iequals("dn", search_params.attribute))
+ {
+ BerElement * ber = nullptr;
+
+ SCOPE_EXIT({
+ if (ber)
+ {
+ ber_free(ber, 0);
+ ber = nullptr;
+ }
+ });
+
+ ::berval bv;
+
+ diag(ldap_get_dn_ber(handle, msg, &ber, &bv));
+
+ if (bv.bv_val && bv.bv_len > 0)
+ result.emplace(bv.bv_val, bv.bv_len);
+ }
+
BerElement * ber = nullptr;
SCOPE_EXIT({
@@ -471,12 +527,12 @@ LDAPClient::SearchResults LDAPClient::search(const SearchParams & search_params)
return result;
}
-bool LDAPSimpleAuthClient::authenticate(const SearchParamsList * search_params, SearchResultsList * search_results)
+bool LDAPSimpleAuthClient::authenticate(const RoleSearchParamsList * role_search_params, SearchResultsList * role_search_results)
{
if (params.user.empty())
throw Exception("LDAP authentication of a user with empty name is not allowed", ErrorCodes::BAD_ARGUMENTS);
- if (!search_params != !search_results)
+ if (!role_search_params != !role_search_results)
throw Exception("Cannot return LDAP search results", ErrorCodes::BAD_ARGUMENTS);
// Silently reject authentication attempt if the password is empty as if it didn't match.
@@ -489,21 +545,21 @@ bool LDAPSimpleAuthClient::authenticate(const SearchParamsList * search_params,
openConnection();
// While connected, run search queries and save the results, if asked.
- if (search_params)
+ if (role_search_params)
{
- search_results->clear();
- search_results->reserve(search_params->size());
+ role_search_results->clear();
+ role_search_results->reserve(role_search_params->size());
try
{
- for (const auto & single_search_params : *search_params)
+ for (const auto & params_instance : *role_search_params)
{
- search_results->emplace_back(search(single_search_params));
+ role_search_results->emplace_back(search(params_instance));
}
}
catch (...)
{
- search_results->clear();
+ role_search_results->clear();
throw;
}
}
@@ -532,7 +588,7 @@ LDAPClient::SearchResults LDAPClient::search(const SearchParams &)
throw Exception("ClickHouse was built without LDAP support", ErrorCodes::FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME);
}
-bool LDAPSimpleAuthClient::authenticate(const SearchParamsList *, SearchResultsList *)
+bool LDAPSimpleAuthClient::authenticate(const RoleSearchParamsList *, SearchResultsList *)
{
throw Exception("ClickHouse was built without LDAP support", ErrorCodes::FEATURE_IS_NOT_ENABLED_AT_BUILD_TIME);
}
diff --git a/src/Access/LDAPClient.h b/src/Access/LDAPClient.h
index 4fc97bb957b..388e7ad0f0d 100644
--- a/src/Access/LDAPClient.h
+++ b/src/Access/LDAPClient.h
@@ -38,12 +38,20 @@ public:
Scope scope = Scope::SUBTREE;
String search_filter;
String attribute = "cn";
+
+ void combineHash(std::size_t & seed) const;
+ };
+
+ struct RoleSearchParams
+ : public SearchParams
+ {
String prefix;
void combineHash(std::size_t & seed) const;
};
- using SearchParamsList = std::vector;
+ using RoleSearchParamsList = std::vector;
+
using SearchResults = std::set;
using SearchResultsList = std::vector;
@@ -105,6 +113,8 @@ public:
String user;
String password;
+ std::optional user_dn_detection;
+
std::chrono::seconds verification_cooldown{0};
std::chrono::seconds operation_timeout{40};
@@ -134,6 +144,9 @@ protected:
#if USE_LDAP
LDAP * handle = nullptr;
#endif
+ String final_user_name;
+ String final_bind_dn;
+ String final_user_dn;
};
class LDAPSimpleAuthClient
@@ -141,7 +154,7 @@ class LDAPSimpleAuthClient
{
public:
using LDAPClient::LDAPClient;
- bool authenticate(const SearchParamsList * search_params, SearchResultsList * search_results);
+ bool authenticate(const RoleSearchParamsList * role_search_params, SearchResultsList * role_search_results);
};
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d22a69c211c..a0f36163d68 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -106,8 +106,8 @@ endif()
list (APPEND clickhouse_common_io_sources ${CONFIG_BUILD})
list (APPEND clickhouse_common_io_headers ${CONFIG_VERSION} ${CONFIG_COMMON})
-list (APPEND dbms_sources Functions/IFunction.cpp Functions/IFunctionOld.cpp Functions/FunctionFactory.cpp Functions/FunctionHelpers.cpp Functions/extractTimeZoneFromFunctionArguments.cpp Functions/replicate.cpp Functions/FunctionsLogical.cpp)
-list (APPEND dbms_headers Functions/IFunctionOld.h Functions/FunctionFactory.h Functions/FunctionHelpers.h Functions/extractTimeZoneFromFunctionArguments.h Functions/replicate.h Functions/FunctionsLogical.h)
+list (APPEND dbms_sources Functions/IFunction.cpp Functions/FunctionFactory.cpp Functions/FunctionHelpers.cpp Functions/extractTimeZoneFromFunctionArguments.cpp Functions/replicate.cpp Functions/FunctionsLogical.cpp)
+list (APPEND dbms_headers Functions/IFunction.h Functions/FunctionFactory.h Functions/FunctionHelpers.h Functions/extractTimeZoneFromFunctionArguments.h Functions/replicate.h Functions/FunctionsLogical.h)
list (APPEND dbms_sources
AggregateFunctions/AggregateFunctionFactory.cpp
diff --git a/src/Common/HashTable/LRUHashMap.h b/src/Common/HashTable/LRUHashMap.h
index 870fb219523..bdefee351b1 100644
--- a/src/Common/HashTable/LRUHashMap.h
+++ b/src/Common/HashTable/LRUHashMap.h
@@ -220,6 +220,12 @@ public:
return find(key) != nullptr;
}
+ Value & ALWAYS_INLINE operator[](const Key & key)
+ {
+ auto [it, _] = emplace(key);
+ return it->getMapped();
+ }
+
bool ALWAYS_INLINE erase(const Key & key)
{
auto key_hash = Base::hash(key);
diff --git a/src/Common/examples/CMakeLists.txt b/src/Common/examples/CMakeLists.txt
index 0395cb32438..c94ce580942 100644
--- a/src/Common/examples/CMakeLists.txt
+++ b/src/Common/examples/CMakeLists.txt
@@ -36,7 +36,7 @@ add_executable (arena_with_free_lists arena_with_free_lists.cpp)
target_link_libraries (arena_with_free_lists PRIVATE dbms)
add_executable (lru_hash_map_perf lru_hash_map_perf.cpp)
-target_link_libraries (lru_hash_map_perf PRIVATE clickhouse_common_io)
+target_link_libraries (lru_hash_map_perf PRIVATE dbms)
add_executable (thread_creation_latency thread_creation_latency.cpp)
target_link_libraries (thread_creation_latency PRIVATE clickhouse_common_io)
diff --git a/src/Common/examples/lru_hash_map_perf.cpp b/src/Common/examples/lru_hash_map_perf.cpp
index 14beff3f7da..c40548bea49 100644
--- a/src/Common/examples/lru_hash_map_perf.cpp
+++ b/src/Common/examples/lru_hash_map_perf.cpp
@@ -7,23 +7,26 @@
#include
#include
+#include
+#include
+
template
class LRUHashMapBasic
{
public:
using key_type = Key;
using value_type = Value;
- using list_type = std::list;
- using node = std::pair;
- using map_type = std::unordered_map>;
+ using list_type = std::list>;
+ using map_type = std::unordered_map;
- LRUHashMapBasic(size_t max_size_, bool preallocated)
+ LRUHashMapBasic(size_t max_size_, bool preallocated = false)
: hash_map(preallocated ? max_size_ : 32)
, max_size(max_size_)
{
}
- void insert(const Key &key, const Value &value)
+ template
+ std::pair emplace(const Key &key, Args &&... args)
{
auto it = hash_map.find(key);
@@ -33,40 +36,39 @@ public:
{
auto iterator_to_remove = list.begin();
- hash_map.erase(*iterator_to_remove);
+ auto & key_to_remove = iterator_to_remove->first;
+ hash_map.erase(key_to_remove);
+
list.erase(iterator_to_remove);
}
- list.push_back(key);
- hash_map[key] = std::make_pair(value, --list.end());
+
+ Value value(std::forward(args)...);
+ auto node = std::make_pair(key, std::move(value));
+
+ list.push_back(std::move(node));
+
+ auto inserted_iterator = --list.end();
+
+ hash_map[key] = inserted_iterator;
+
+ return std::make_pair(&inserted_iterator->second, true);
}
else
{
- auto & [value_to_update, iterator_in_list_to_update] = it->second;
+ auto & iterator_in_list_to_update = it->second;
list.splice(list.end(), list, iterator_in_list_to_update);
+ iterator_in_list_to_update = --list.end();
- iterator_in_list_to_update = list.end();
- value_to_update = value;
+ return std::make_pair(&iterator_in_list_to_update->second, false);
}
}
- value_type & get(const key_type &key)
+ value_type & operator[](const key_type & key)
{
- auto iterator_in_map = hash_map.find(key);
- assert(iterator_in_map != hash_map.end());
-
- auto & [value_to_return, iterator_in_list_to_update] = iterator_in_map->second;
-
- list.splice(list.end(), list, iterator_in_list_to_update);
- iterator_in_list_to_update = list.end();
-
- return value_to_return;
- }
-
- const value_type & get(const key_type & key) const
- {
- return const_cast *>(this)->get(key);
+ auto [it, _] = emplace(key);
+ return *it;
}
size_t getMaxSize() const
@@ -101,110 +103,45 @@ private:
size_t max_size;
};
-std::vector generateNumbersToInsert(size_t numbers_to_insert_size)
+template
+static void NO_INLINE test(const Key * data, size_t size, const std::string & name)
{
- std::vector numbers;
- numbers.reserve(numbers_to_insert_size);
-
- std::random_device rd;
- pcg64 gen(rd());
-
- UInt64 min = std::numeric_limits::min();
- UInt64 max = std::numeric_limits::max();
-
- auto distribution = std::uniform_int_distribution<>(min, max);
-
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
- {
- UInt64 number = distribution(gen);
- numbers.emplace_back(number);
- }
-
- return numbers;
-}
-
-void testInsertElementsIntoHashMap(size_t map_size, const std::vector & numbers_to_insert, bool preallocated)
-{
- size_t numbers_to_insert_size = numbers_to_insert.size();
- std::cout << "TestInsertElementsIntoHashMap preallocated map size: " << map_size << " numbers to insert size: " << numbers_to_insert_size;
- std::cout << std::endl;
-
- HashMap hash_map(preallocated ? map_size : 32);
-
+ size_t cache_size = size / 10;
+ Map cache(cache_size);
Stopwatch watch;
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
- hash_map.insert({ numbers_to_insert[i], numbers_to_insert[i] });
+ for (size_t i = 0; i < size; ++i)
+ ++cache[data[i]];
- std::cout << "Inserted in " << watch.elapsedMilliseconds() << " milliseconds" << std::endl;
+ watch.stop();
- UInt64 summ = 0;
-
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
- {
- auto * it = hash_map.find(numbers_to_insert[i]);
-
- if (it)
- summ += it->getMapped();
- }
-
- std::cout << "Calculated summ: " << summ << " in " << watch.elapsedMilliseconds() << " milliseconds" << std::endl;
+ std::cerr << name
+ << ":\nElapsed: " << watch.elapsedSeconds()
+ << " (" << size / watch.elapsedSeconds() << " elem/sec.)"
+ << ", map size: " << cache.size() << "\n";
}
-void testInsertElementsIntoStandardMap(size_t map_size, const std::vector & numbers_to_insert, bool preallocated)
+template
+static void NO_INLINE testForType(size_t method, size_t rows_size)
{
- size_t numbers_to_insert_size = numbers_to_insert.size();
- std::cout << "TestInsertElementsIntoStandardMap map size: " << map_size << " numbers to insert size: " << numbers_to_insert_size;
- std::cout << std::endl;
+ std::cerr << std::fixed << std::setprecision(3);
- std::unordered_map hash_map(preallocated ? map_size : 32);
+ std::vector data(rows_size);
- Stopwatch watch;
-
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
- hash_map.insert({ numbers_to_insert[i], numbers_to_insert[i] });
-
- std::cout << "Inserted in " << watch.elapsedMilliseconds() << " milliseconds" << std::endl;
-
- UInt64 summ = 0;
-
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
{
- auto it = hash_map.find(numbers_to_insert[i]);
-
- if (it != hash_map.end())
- summ += it->second;
+ DB::ReadBufferFromFileDescriptor in1(STDIN_FILENO);
+ DB::CompressedReadBuffer in2(in1);
+ in2.readStrict(reinterpret_cast(data.data()), sizeof(data[0]) * rows_size);
}
- std::cout << "Calculated summ: " << summ << " in " << watch.elapsedMilliseconds() << " milliseconds" << std::endl;
-}
-
-template
-UInt64 testInsertIntoEmptyCache(size_t map_size, const std::vector & numbers_to_insert, bool preallocated)
-{
- size_t numbers_to_insert_size = numbers_to_insert.size();
- std::cout << "Test testInsertPreallocated preallocated map size: " << map_size << " numbers to insert size: " << numbers_to_insert_size;
- std::cout << std::endl;
-
- LRUCache cache(map_size, preallocated);
- Stopwatch watch;
-
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
+ if (method == 0)
{
- cache.insert(numbers_to_insert[i], numbers_to_insert[i]);
+ test>(data.data(), data.size(), "CH HashMap");
+ }
+ else if (method == 1)
+ {
+ test>(data.data(), data.size(), "BasicLRU");
}
-
- std::cout << "Inserted in " << watch.elapsedMilliseconds() << " milliseconds" << std::endl;
-
- UInt64 summ = 0;
-
- for (size_t i = 0; i < numbers_to_insert_size; ++i)
- if (cache.contains(numbers_to_insert[i]))
- summ += cache.get(numbers_to_insert[i]);
-
- std::cout << "Calculated summ: " << summ << " in " << watch.elapsedMilliseconds() << " milliseconds" << std::endl;
-
- return summ;
}
int main(int argc, char ** argv)
@@ -212,33 +149,34 @@ int main(int argc, char ** argv)
(void)(argc);
(void)(argv);
- size_t hash_map_size = 1200000;
- size_t numbers_to_insert_size = 12000000;
- std::vector numbers = generateNumbersToInsert(numbers_to_insert_size);
+ if (argc < 4)
+ {
+ std::cerr << "Usage: program method column_type_name rows_count < input_column.bin \n";
+ return 1;
+ }
- std::cout << "Test insert into HashMap preallocated=0" << std::endl;
- testInsertElementsIntoHashMap(hash_map_size, numbers, true);
- std::cout << std::endl;
+ size_t method = std::stoull(argv[1]);
+ std::string type_name = std::string(argv[2]);
+ size_t n = std::stoull(argv[3]);
- std::cout << "Test insert into HashMap preallocated=1" << std::endl;
- testInsertElementsIntoHashMap(hash_map_size, numbers, true);
- std::cout << std::endl;
-
- std::cout << "Test LRUHashMap preallocated=0" << std::endl;
- testInsertIntoEmptyCache>(hash_map_size, numbers, false);
- std::cout << std::endl;
-
- std::cout << "Test LRUHashMap preallocated=1" << std::endl;
- testInsertIntoEmptyCache>(hash_map_size, numbers, true);
- std::cout << std::endl;
-
- std::cout << "Test LRUHashMapBasic preallocated=0" << std::endl;
- testInsertIntoEmptyCache>(hash_map_size, numbers, false);
- std::cout << std::endl;
-
- std::cout << "Test LRUHashMapBasic preallocated=1" << std::endl;
- testInsertIntoEmptyCache>(hash_map_size, numbers, true);
- std::cout << std::endl;
+ if (type_name == "UInt8")
+ testForType(method, n);
+ else if (type_name == "UInt16")
+ testForType(method, n);
+ else if (type_name == "UInt32")
+ testForType(method, n);
+ else if (type_name == "UInt64")
+ testForType(method, n);
+ else if (type_name == "Int8")
+ testForType(method, n);
+ else if (type_name == "Int16")
+ testForType(method, n);
+ else if (type_name == "Int32")
+ testForType(method, n);
+ else if (type_name == "Int64")
+ testForType(method, n);
+ else
+ std::cerr << "Unexpected type passed " << type_name << std::endl;
return 0;
}
diff --git a/src/Common/isLocalAddress.cpp b/src/Common/isLocalAddress.cpp
index 8da281e3051..cecff489a22 100644
--- a/src/Common/isLocalAddress.cpp
+++ b/src/Common/isLocalAddress.cpp
@@ -1,29 +1,84 @@
#include
+#include
#include
+#include
#include
-#include
-#include
+#include
+#include
#include
namespace DB
{
+namespace ErrorCodes
+{
+ extern const int SYSTEM_ERROR;
+}
+
+namespace
+{
+
+struct NetworkInterfaces
+{
+ ifaddrs * ifaddr;
+ NetworkInterfaces()
+ {
+ if (getifaddrs(&ifaddr) == -1)
+ {
+ throwFromErrno("Cannot getifaddrs", ErrorCodes::SYSTEM_ERROR);
+ }
+ }
+
+ bool hasAddress(const Poco::Net::IPAddress & address) const
+ {
+ ifaddrs * iface;
+ for (iface = ifaddr; iface != nullptr; iface = iface->ifa_next)
+ {
+ auto family = iface->ifa_addr->sa_family;
+ std::optional interface_address;
+ switch (family)
+ {
+ /// We interested only in IP-adresses
+ case AF_INET:
+ {
+ interface_address.emplace(*(iface->ifa_addr));
+ break;
+ }
+ case AF_INET6:
+ {
+ interface_address.emplace(&reinterpret_cast(iface->ifa_addr)->sin6_addr, sizeof(struct in6_addr));
+ break;
+ }
+ default:
+ continue;
+ }
+
+ /** Compare the addresses without taking into account `scope`.
+ * Theoretically, this may not be correct - depends on `route` setting
+ * - through which interface we will actually access the specified address.
+ */
+ if (interface_address->length() == address.length()
+ && 0 == memcmp(interface_address->addr(), address.addr(), address.length()))
+ return true;
+ }
+ return false;
+ }
+
+ ~NetworkInterfaces()
+ {
+ freeifaddrs(ifaddr);
+ }
+};
+
+}
+
+
bool isLocalAddress(const Poco::Net::IPAddress & address)
{
- static auto interfaces = Poco::Net::NetworkInterface::list();
-
- return interfaces.end() != std::find_if(interfaces.begin(), interfaces.end(),
- [&] (const Poco::Net::NetworkInterface & interface)
- {
- /** Compare the addresses without taking into account `scope`.
- * Theoretically, this may not be correct - depends on `route` setting
- * - through which interface we will actually access the specified address.
- */
- return interface.address().length() == address.length()
- && 0 == memcmp(interface.address().addr(), address.addr(), address.length());
- });
+ NetworkInterfaces interfaces;
+ return interfaces.hasAddress(address);
}
bool isLocalAddress(const Poco::Net::SocketAddress & address, UInt16 clickhouse_port)
diff --git a/src/Common/tests/gtest_local_address.cpp b/src/Common/tests/gtest_local_address.cpp
new file mode 100644
index 00000000000..504fba19713
--- /dev/null
+++ b/src/Common/tests/gtest_local_address.cpp
@@ -0,0 +1,19 @@
+#include
+#include
+#include
+#include
+#include
+
+
+TEST(LocalAddress, SmokeTest)
+{
+ auto cmd = DB::ShellCommand::executeDirect("/bin/hostname", {"-i"});
+ std::string address_str;
+ DB::readString(address_str, cmd->out);
+ cmd->wait();
+ std::cerr << "Got Address:" << address_str << std::endl;
+
+ Poco::Net::IPAddress address(address_str);
+
+ EXPECT_TRUE(DB::isLocalAddress(address));
+}
diff --git a/src/Compression/tests/gtest_compressionCodec.cpp b/src/Compression/tests/gtest_compressionCodec.cpp
index 20fe5476807..6ba2d3457ea 100644
--- a/src/Compression/tests/gtest_compressionCodec.cpp
+++ b/src/Compression/tests/gtest_compressionCodec.cpp
@@ -345,10 +345,12 @@ CodecTestSequence operator*(CodecTestSequence && left, T times)
std::ostream & operator<<(std::ostream & ostr, const Codec & codec)
{
- return ostr << "Codec{"
- << "name: " << codec.codec_statement
- << ", expected_compression_ratio: " << *codec.expected_compression_ratio
- << "}";
+ ostr << "Codec{"
+ << "name: " << codec.codec_statement;
+ if (codec.expected_compression_ratio)
+ return ostr << ", expected_compression_ratio: " << *codec.expected_compression_ratio << "}";
+ else
+ return ostr << "}";
}
std::ostream & operator<<(std::ostream & ostr, const CodecTestSequence & seq)
diff --git a/src/DataTypes/DataTypeDateTime64.h b/src/DataTypes/DataTypeDateTime64.h
index f51e0f5d047..ac0f49613a2 100644
--- a/src/DataTypes/DataTypeDateTime64.h
+++ b/src/DataTypes/DataTypeDateTime64.h
@@ -35,6 +35,8 @@ public:
bool canBePromoted() const override { return false; }
+ bool canBeUsedAsVersion() const override { return true; }
+
protected:
SerializationPtr doGetDefaultSerialization() const override;
};
diff --git a/src/DataTypes/DataTypeUUID.h b/src/DataTypes/DataTypeUUID.h
index 70104a03478..5ed7a912607 100644
--- a/src/DataTypes/DataTypeUUID.h
+++ b/src/DataTypes/DataTypeUUID.h
@@ -35,6 +35,7 @@ public:
bool textCanContainOnlyValidUTF8() const override { return true; }
bool isComparable() const override { return true; }
bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override { return true; }
+ bool isValueUnambiguouslyRepresentedInFixedSizeContiguousMemoryRegion() const override { return true; }
bool haveMaximumSizeOfValue() const override { return true; }
size_t getSizeOfValueInMemory() const override { return sizeof(UUID); }
bool isCategorial() const override { return true; }
diff --git a/src/DataTypes/IDataType.h b/src/DataTypes/IDataType.h
index 4602083f488..85526cd98de 100644
--- a/src/DataTypes/IDataType.h
+++ b/src/DataTypes/IDataType.h
@@ -177,7 +177,7 @@ public:
*/
virtual bool canBeComparedWithCollation() const { return false; }
- /** If the type is totally comparable (Ints, Date, DateTime, not nullable, not floats)
+ /** If the type is totally comparable (Ints, Date, DateTime, DateTime64, not nullable, not floats)
* and "simple" enough (not String, FixedString) to be used as version number
* (to select rows with maximum version).
*/
diff --git a/src/Databases/DatabaseLazy.cpp b/src/Databases/DatabaseLazy.cpp
index d498cb96062..80179de104a 100644
--- a/src/Databases/DatabaseLazy.cpp
+++ b/src/Databases/DatabaseLazy.cpp
@@ -203,7 +203,7 @@ void DatabaseLazy::shutdown()
for (const auto & kv : tables_snapshot)
{
if (kv.second.table)
- kv.second.table->shutdown();
+ kv.second.table->flushAndShutdown();
}
std::lock_guard lock(mutex);
diff --git a/src/Databases/DatabaseReplicated.cpp b/src/Databases/DatabaseReplicated.cpp
index b7214917ce8..d36fe45f748 100644
--- a/src/Databases/DatabaseReplicated.cpp
+++ b/src/Databases/DatabaseReplicated.cpp
@@ -529,7 +529,7 @@ void DatabaseReplicated::recoverLostReplica(const ZooKeeperPtr & current_zookeep
dropped_tables.push_back(tryGetTableUUID(table_name));
dropped_dictionaries += table->isDictionary();
- table->shutdown();
+ table->flushAndShutdown();
DatabaseAtomic::dropTable(getContext(), table_name, true);
}
else
diff --git a/src/Databases/DatabasesCommon.cpp b/src/Databases/DatabasesCommon.cpp
index 9329b0a4210..9d79a0dfe96 100644
--- a/src/Databases/DatabasesCommon.cpp
+++ b/src/Databases/DatabasesCommon.cpp
@@ -125,10 +125,15 @@ void DatabaseWithOwnTablesBase::shutdown()
tables_snapshot = tables;
}
+ for (const auto & kv : tables_snapshot)
+ {
+ kv.second->flush();
+ }
+
for (const auto & kv : tables_snapshot)
{
auto table_id = kv.second->getStorageID();
- kv.second->shutdown();
+ kv.second->flushAndShutdown();
if (table_id.hasUUID())
{
assert(getDatabaseName() == DatabaseCatalog::TEMPORARY_DATABASE || getUUID() != UUIDHelpers::Nil);
diff --git a/src/Databases/MySQL/DatabaseConnectionMySQL.cpp b/src/Databases/MySQL/DatabaseConnectionMySQL.cpp
index 59a575996ee..5cd59f8a7c8 100644
--- a/src/Databases/MySQL/DatabaseConnectionMySQL.cpp
+++ b/src/Databases/MySQL/DatabaseConnectionMySQL.cpp
@@ -316,7 +316,7 @@ void DatabaseConnectionMySQL::shutdown()
}
for (const auto & [table_name, modify_time_and_storage] : tables_snapshot)
- modify_time_and_storage.second->shutdown();
+ modify_time_and_storage.second->flushAndShutdown();
std::lock_guard lock(mutex);
local_tables_cache.clear();
@@ -343,7 +343,7 @@ void DatabaseConnectionMySQL::cleanOutdatedTables()
{
const auto table_lock = (*iterator)->lockExclusively(RWLockImpl::NO_QUERY, lock_acquire_timeout);
- (*iterator)->shutdown();
+ (*iterator)->flushAndShutdown();
(*iterator)->is_dropped = true;
iterator = outdated_tables.erase(iterator);
}
diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt
index ba876e02424..271deb0f42c 100644
--- a/src/Functions/CMakeLists.txt
+++ b/src/Functions/CMakeLists.txt
@@ -5,8 +5,8 @@ add_subdirectory(divide)
include("${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake")
add_headers_and_sources(clickhouse_functions .)
-list(REMOVE_ITEM clickhouse_functions_sources IFunctionOld.cpp FunctionFactory.cpp FunctionHelpers.cpp)
-list(REMOVE_ITEM clickhouse_functions_headers IFunctionOld.h FunctionFactory.h FunctionHelpers.h)
+list(REMOVE_ITEM clickhouse_functions_sources IFunction.cpp FunctionFactory.cpp FunctionHelpers.cpp)
+list(REMOVE_ITEM clickhouse_functions_headers IFunction.h FunctionFactory.h FunctionHelpers.h)
add_library(clickhouse_functions ${clickhouse_functions_sources})
diff --git a/src/Functions/CustomWeekTransforms.h b/src/Functions/CustomWeekTransforms.h
index f07f2777cec..d1a8e3a54fd 100644
--- a/src/Functions/CustomWeekTransforms.h
+++ b/src/Functions/CustomWeekTransforms.h
@@ -6,7 +6,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Functions/DateTimeTransforms.h b/src/Functions/DateTimeTransforms.h
index aa8f52b335e..03f35333150 100644
--- a/src/Functions/DateTimeTransforms.h
+++ b/src/Functions/DateTimeTransforms.h
@@ -7,7 +7,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionBinaryArithmetic.h b/src/Functions/FunctionBinaryArithmetic.h
index 0d90eece3e2..927b870891f 100644
--- a/src/Functions/FunctionBinaryArithmetic.h
+++ b/src/Functions/FunctionBinaryArithmetic.h
@@ -23,7 +23,7 @@
#include
#include
#include "Core/DecimalFunctions.h"
-#include "IFunctionOld.h"
+#include "IFunction.h"
#include "FunctionHelpers.h"
#include "IsOperation.h"
#include "DivisionUtils.h"
diff --git a/src/Functions/FunctionBitTestMany.h b/src/Functions/FunctionBitTestMany.h
index 6ed787d707e..567be37cda8 100644
--- a/src/Functions/FunctionBitTestMany.h
+++ b/src/Functions/FunctionBitTestMany.h
@@ -2,7 +2,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionCustomWeekToSomething.h b/src/Functions/FunctionCustomWeekToSomething.h
index c229764b8a4..0ef6a342218 100644
--- a/src/Functions/FunctionCustomWeekToSomething.h
+++ b/src/Functions/FunctionCustomWeekToSomething.h
@@ -3,7 +3,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Functions/FunctionDateOrDateTimeAddInterval.h b/src/Functions/FunctionDateOrDateTimeAddInterval.h
index d0b05c83eaa..14ab9f00452 100644
--- a/src/Functions/FunctionDateOrDateTimeAddInterval.h
+++ b/src/Functions/FunctionDateOrDateTimeAddInterval.h
@@ -7,7 +7,7 @@
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionDateOrDateTimeToSomething.h b/src/Functions/FunctionDateOrDateTimeToSomething.h
index ded6c157433..8b8f1b483c8 100644
--- a/src/Functions/FunctionDateOrDateTimeToSomething.h
+++ b/src/Functions/FunctionDateOrDateTimeToSomething.h
@@ -1,7 +1,7 @@
#pragma once
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionFQDN.cpp b/src/Functions/FunctionFQDN.cpp
index 439181862a7..304aad17d22 100644
--- a/src/Functions/FunctionFQDN.cpp
+++ b/src/Functions/FunctionFQDN.cpp
@@ -1,4 +1,4 @@
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionFactory.h b/src/Functions/FunctionFactory.h
index 966ee2df952..bac55dade16 100644
--- a/src/Functions/FunctionFactory.h
+++ b/src/Functions/FunctionFactory.h
@@ -3,7 +3,6 @@
#include
#include
#include
-#include
#include
#include
diff --git a/src/Functions/FunctionHelpers.cpp b/src/Functions/FunctionHelpers.cpp
index 8fc21fc0c57..dcdd0e521eb 100644
--- a/src/Functions/FunctionHelpers.cpp
+++ b/src/Functions/FunctionHelpers.cpp
@@ -1,5 +1,5 @@
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionIfBase.h b/src/Functions/FunctionIfBase.h
index 32f0f629287..17d02de2e27 100644
--- a/src/Functions/FunctionIfBase.h
+++ b/src/Functions/FunctionIfBase.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
#include
#if !defined(ARCADIA_BUILD)
diff --git a/src/Functions/FunctionMathBinaryFloat64.h b/src/Functions/FunctionMathBinaryFloat64.h
index 2f43981f751..8cc012d3ab2 100644
--- a/src/Functions/FunctionMathBinaryFloat64.h
+++ b/src/Functions/FunctionMathBinaryFloat64.h
@@ -6,7 +6,7 @@
#include
#include
#include
-#include
+#include
#include
#if !defined(ARCADIA_BUILD)
diff --git a/src/Functions/FunctionMathConstFloat64.h b/src/Functions/FunctionMathConstFloat64.h
index f983988a9ae..ab7d401e99e 100644
--- a/src/Functions/FunctionMathConstFloat64.h
+++ b/src/Functions/FunctionMathConstFloat64.h
@@ -2,7 +2,7 @@
#include
#include
-#include
+#include
namespace DB
diff --git a/src/Functions/FunctionMathUnary.h b/src/Functions/FunctionMathUnary.h
index 5f310e2d8f8..a637bbe3bd8 100644
--- a/src/Functions/FunctionMathUnary.h
+++ b/src/Functions/FunctionMathUnary.h
@@ -5,7 +5,7 @@
#include
#include
#include
-#include
+#include
#include
#if !defined(ARCADIA_BUILD)
diff --git a/src/Functions/FunctionNumericPredicate.h b/src/Functions/FunctionNumericPredicate.h
index d27739c28de..d5fa9f03aba 100644
--- a/src/Functions/FunctionNumericPredicate.h
+++ b/src/Functions/FunctionNumericPredicate.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionStartsEndsWith.h b/src/Functions/FunctionStartsEndsWith.h
index ead22ab15d1..65dbf393290 100644
--- a/src/Functions/FunctionStartsEndsWith.h
+++ b/src/Functions/FunctionStartsEndsWith.h
@@ -2,7 +2,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionStringOrArrayToT.h b/src/Functions/FunctionStringOrArrayToT.h
index 1e163b2ebef..158179fffe9 100644
--- a/src/Functions/FunctionStringOrArrayToT.h
+++ b/src/Functions/FunctionStringOrArrayToT.h
@@ -1,7 +1,7 @@
#pragma once
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionStringToString.h b/src/Functions/FunctionStringToString.h
index 50341ba149e..26480a83995 100644
--- a/src/Functions/FunctionStringToString.h
+++ b/src/Functions/FunctionStringToString.h
@@ -4,7 +4,7 @@
#include
#include
#include
-#include
+#include
#include
diff --git a/src/Functions/FunctionUnaryArithmetic.h b/src/Functions/FunctionUnaryArithmetic.h
index ee9cb914831..68fcfadfb84 100644
--- a/src/Functions/FunctionUnaryArithmetic.h
+++ b/src/Functions/FunctionUnaryArithmetic.h
@@ -7,7 +7,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionUnixTimestamp64.h b/src/Functions/FunctionUnixTimestamp64.h
index 969b31cd13b..a4357c148ac 100644
--- a/src/Functions/FunctionUnixTimestamp64.h
+++ b/src/Functions/FunctionUnixTimestamp64.h
@@ -1,7 +1,7 @@
#pragma once
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionsBitmap.h b/src/Functions/FunctionsBitmap.h
index 9bdcb2f81cb..bbdc53c3006 100644
--- a/src/Functions/FunctionsBitmap.h
+++ b/src/Functions/FunctionsBitmap.h
@@ -11,7 +11,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Functions/FunctionsCoding.h b/src/Functions/FunctionsCoding.h
index 512afc01674..01602cf1175 100644
--- a/src/Functions/FunctionsCoding.h
+++ b/src/Functions/FunctionsCoding.h
@@ -17,7 +17,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionsConsistentHashing.h b/src/Functions/FunctionsConsistentHashing.h
index 2448cee3f46..4c393f6ee01 100644
--- a/src/Functions/FunctionsConsistentHashing.h
+++ b/src/Functions/FunctionsConsistentHashing.h
@@ -4,7 +4,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Functions/FunctionsEmbeddedDictionaries.h b/src/Functions/FunctionsEmbeddedDictionaries.h
index aa32521ba6a..884f53125eb 100644
--- a/src/Functions/FunctionsEmbeddedDictionaries.h
+++ b/src/Functions/FunctionsEmbeddedDictionaries.h
@@ -9,7 +9,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionsExternalDictionaries.h b/src/Functions/FunctionsExternalDictionaries.h
index e2ee7dd31f3..6d9e4ce6768 100644
--- a/src/Functions/FunctionsExternalDictionaries.h
+++ b/src/Functions/FunctionsExternalDictionaries.h
@@ -27,7 +27,7 @@
#include
#include
-#include
+#include
#include
#include
diff --git a/src/Functions/FunctionsExternalModels.h b/src/Functions/FunctionsExternalModels.h
index f3e727cfcef..8f8b0e0c860 100644
--- a/src/Functions/FunctionsExternalModels.h
+++ b/src/Functions/FunctionsExternalModels.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
#include
namespace DB
diff --git a/src/Functions/FunctionsHashing.h b/src/Functions/FunctionsHashing.h
index efd9a46b1d8..690991759a3 100644
--- a/src/Functions/FunctionsHashing.h
+++ b/src/Functions/FunctionsHashing.h
@@ -39,7 +39,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionsJSON.h b/src/Functions/FunctionsJSON.h
index ebc828fb287..2b49d01de2c 100644
--- a/src/Functions/FunctionsJSON.h
+++ b/src/Functions/FunctionsJSON.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include
#include
#include
#include
diff --git a/src/Functions/FunctionsLogical.h b/src/Functions/FunctionsLogical.h
index 94bbafc5808..acc34a40d00 100644
--- a/src/Functions/FunctionsLogical.h
+++ b/src/Functions/FunctionsLogical.h
@@ -4,7 +4,7 @@
#include
#include
#include
-#include