Skip to content

Commit 6c1c7a2

Browse files
authored
Merge branch 'master' into fix-typo
2 parents be0f0f4 + b896c18 commit 6c1c7a2

File tree

18 files changed

+347
-20
lines changed

18 files changed

+347
-20
lines changed

base/poco/Net/include/Poco/Net/NameValueCollection.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ namespace Net
7979
/// Returns the value of the first name-value pair with the given name.
8080
/// If no value with the given name has been found, the defaultValue is returned.
8181

82+
const std::vector<std::reference_wrapper<const std::string>> getAll(const std::string & name) const;
83+
/// Returns all values of all name-value pairs with the given name.
84+
///
85+
/// Returns an empty vector if there are no name-value pairs with the given name.
86+
8287
bool has(const std::string & name) const;
8388
/// Returns true if there is at least one name-value pair
8489
/// with the given name.

base/poco/Net/src/NameValueCollection.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "Poco/Net/NameValueCollection.h"
1616
#include "Poco/Exception.h"
1717
#include <algorithm>
18+
#include <functional>
1819

1920

2021
using Poco::NotFoundException;
@@ -55,7 +56,7 @@ void NameValueCollection::swap(NameValueCollection& nvc)
5556
std::swap(_map, nvc._map);
5657
}
5758

58-
59+
5960
const std::string& NameValueCollection::operator [] (const std::string& name) const
6061
{
6162
ConstIterator it = _map.find(name);
@@ -65,8 +66,8 @@ const std::string& NameValueCollection::operator [] (const std::string& name) co
6566
throw NotFoundException(name);
6667
}
6768

68-
69-
void NameValueCollection::set(const std::string& name, const std::string& value)
69+
70+
void NameValueCollection::set(const std::string& name, const std::string& value)
7071
{
7172
Iterator it = _map.find(name);
7273
if (it != _map.end())
@@ -75,13 +76,13 @@ void NameValueCollection::set(const std::string& name, const std::string& value)
7576
_map.insert(HeaderMap::ValueType(name, value));
7677
}
7778

78-
79+
7980
void NameValueCollection::add(const std::string& name, const std::string& value)
8081
{
8182
_map.insert(HeaderMap::ValueType(name, value));
8283
}
8384

84-
85+
8586
const std::string& NameValueCollection::get(const std::string& name) const
8687
{
8788
ConstIterator it = _map.find(name);
@@ -101,6 +102,15 @@ const std::string& NameValueCollection::get(const std::string& name, const std::
101102
return defaultValue;
102103
}
103104

105+
const std::vector<std::reference_wrapper<const std::string>> NameValueCollection::getAll(const std::string& name) const
106+
{
107+
std::vector<std::reference_wrapper<const std::string>> values;
108+
for (ConstIterator it = _map.find(name); it != _map.end(); it++)
109+
if (it->first == name)
110+
values.push_back(it->second);
111+
return values;
112+
}
113+
104114

105115
bool NameValueCollection::has(const std::string& name) const
106116
{
@@ -113,19 +123,19 @@ NameValueCollection::ConstIterator NameValueCollection::find(const std::string&
113123
return _map.find(name);
114124
}
115125

116-
126+
117127
NameValueCollection::ConstIterator NameValueCollection::begin() const
118128
{
119129
return _map.begin();
120130
}
121131

122-
132+
123133
NameValueCollection::ConstIterator NameValueCollection::end() const
124134
{
125135
return _map.end();
126136
}
127137

128-
138+
129139
bool NameValueCollection::empty() const
130140
{
131141
return _map.empty();

docs/en/interfaces/http.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,37 @@ $ curl -sS 'http://localhost:8123/?max_result_bytes=4000000&buffer_size=3000000&
325325

326326
Use buffering to avoid situations where a query processing error occurred after the response code and HTTP headers were sent to the client. In this situation, an error message is written at the end of the response body, and on the client-side, the error can only be detected at the parsing stage.
327327

328+
## Setting a role with query parameters {#setting-role-with-query-parameters}
329+
330+
In certain scenarios, it might be required to set the granted role first, before executing the statement itself.
331+
However, it is not possible to send `SET ROLE` and the statement together, as multi-statements are not allowed:
332+
333+
```
334+
curl -sS "http://localhost:8123" --data-binary "SET ROLE my_role;SELECT * FROM my_table;"
335+
```
336+
337+
Which will result in an error:
338+
339+
```
340+
Code: 62. DB::Exception: Syntax error (Multi-statements are not allowed)
341+
```
342+
343+
To overcome this limitation, you could use the `role` query parameter instead:
344+
345+
```
346+
curl -sS "http://localhost:8123?role=my_role" --data-binary "SELECT * FROM my_table;"
347+
```
348+
349+
This will be an equivalent of executing `SET ROLE my_role` before the statement.
350+
351+
Additionally, it is possible to specify multiple `role` query parameters:
352+
353+
```
354+
curl -sS "http://localhost:8123?role=my_role&role=my_other_role" --data-binary "SELECT * FROM my_table;"
355+
```
356+
357+
In this case, `?role=my_role&role=my_other_role` works similarly to executing `SET ROLE my_role, my_other_role` before the statement.
358+
328359
## HTTP response codes caveats {#http_response_codes_caveats}
329360

330361
Because of limitation of HTTP protocol, HTTP 200 response code does not guarantee that a query was successful.

docs/en/operations/settings/settings.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5480,3 +5480,11 @@ Default value: 'false'.
54805480
## allow_suspicious_primary_key {#allow_suspicious_primary_key}
54815481

54825482
Allow suspicious `PRIMARY KEY`/`ORDER BY` for MergeTree (i.e. SimpleAggregateFunction).
5483+
5484+
## mysql_datatypes_support_level
5485+
5486+
Defines how MySQL types are converted to corresponding ClickHouse types. A comma separated list in any combination of `decimal`, `datetime64`, `date2Date32` or `date2String`.
5487+
- `decimal`: convert `NUMERIC` and `DECIMAL` types to `Decimal` when precision allows it.
5488+
- `datetime64`: convert `DATETIME` and `TIMESTAMP` types to `DateTime64` instead of `DateTime` when precision is not `0`.
5489+
- `date2Date32`: convert `DATE` to `Date32` instead of `Date`. Takes precedence over `date2String`.
5490+
- `date2String`: convert `DATE` to `String` instead of `Date`. Overridden by `datetime64`.

docs/en/sql-reference/functions/rounding-functions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ Alias: `truncate`.
3636

3737
**Parameters**
3838

39-
- `input`: A float type [Float](/docs/en/sql-reference/data-types/float.md).
40-
- `precision`: A decimal type [Decimal](/docs/en/sql-reference/data-types/decimal.md).
39+
- `input`: A numeric type ([Float](/docs/en/sql-reference/data-types/float.md), [Decimal](/docs/en/sql-reference/data-types/decimal.md) or [Integer](/docs/en/sql-reference/data-types/int-uint.md)).
40+
- `precision`: An [Integer](/docs/en/sql-reference/data-types/int-uint.md) type.
4141

4242
**Returned value**
4343

44-
- A [Float64](/docs/en/sql-reference/data-types/float.md) value.
44+
- A data type of `input`.
4545

4646
**Example**
4747

docs/en/sql-reference/functions/string-replace-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ translateUTF8(s, from, to)
208208

209209
**Returned value**
210210

211-
- `s`: A string type [String](/docs/en/sql-reference/data-types/string.md).
211+
- A [String](/docs/en/sql-reference/data-types/string.md) data type value.
212212

213213
**Examples**
214214

docs/ru/sql-reference/functions/rounding-functions.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,42 @@ N может быть отрицательным.
2424
Возвращает наименьшее круглое число, которое больше или равно, чем x.
2525
В остальном, аналогично функции floor, см. выше.
2626

27+
## trunc(x\[, N\]), truncate(x\[, N\])
28+
29+
Возвращает круглое число с наибольшим абсолютным значением, абсолютное значение которого меньше или равно значению `x`. Во всех остальных отношениях она аналогична функции 'floor' (см. выше).
30+
31+
**Синтаксис**
32+
33+
```sql
34+
trunc(input, precision)
35+
```
36+
37+
Alias: `truncate`.
38+
39+
**Параметры**
40+
41+
- `input` - число для округления. Может быть в любом чисельном формате ([Float](/docs/en/sql-reference/data-types/float.md), [Decimal](/docs/en/sql-reference/data-types/decimal.md) или [Integer](/docs/en/sql-reference/data-types/int-uint.md)).
42+
- `precision` - точность округления, [целочисельный](/docs/en/sql-reference/data-types/int-uint.md) тип.
43+
44+
**Возвращаемое значение**
45+
46+
- Тип даных в `input`.
47+
48+
**Пример**
49+
50+
Query:
51+
52+
```sql
53+
SELECT trunc(123.499, 1) as res;
54+
```
55+
56+
```response
57+
┌───res─┐
58+
│ 123.4 │
59+
└───────┘
60+
```
61+
62+
2763
## round(x\[, N\]) {#rounding_functions-round}
2864

2965
Округляет значение до указанного десятичного разряда.

docs/zh/sql-reference/functions/rounding-functions.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@ slug: /zh/sql-reference/functions/rounding-functions
1919

2020
返回大于或等于’x’的最小舍入数。在其他方面,它与’floor’功能相同(见上文)。
2121

22+
## trunc(x\[, N\]), truncate(x\[, N\])
23+
24+
返回绝对值小于或等于 `x` 的绝对值最大的整数。在其他方面,它与 "floor "函数相同(见上文)。
25+
26+
**语法**
27+
28+
```SQL
29+
trunc(input, precision)
30+
```
31+
32+
别名:`truncate`
33+
34+
**参数***
35+
36+
- `输入` 数值类型([Float](/docs/en/sql-reference/data-types/float.md)[Decimal](/docs/en/sql-reference/data-types/decimal.md)[Integer](/docs/en/sql-reference/data-types/int-uint.md))。
37+
- `精度` 一个 [Integer](/docs/en/sql-reference/data-types/int-uint.md) 类型。
38+
39+
**返回值**
40+
41+
- 输入 "的数据类型。
42+
43+
**示例
44+
45+
查询:
46+
47+
``` SQL
48+
SELECT trunc(123.499, 1) as res;
49+
```
50+
51+
```responce
52+
┌──res─┐
53+
│ 123.4 │
54+
└───────┘
55+
```
56+
2257
## 圆形(x\[,N\]) {#rounding_functions-round}
2358

2459
将值取整到指定的小数位数。

src/Analyzer/Passes/QueryAnalysisPass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7164,7 +7164,9 @@ void QueryAnalyzer::resolveTableFunction(QueryTreeNodePtr & table_function_node,
71647164
auto parametrized_view_storage = scope_context->getQueryContext()->buildParametrizedViewStorage(function_ast, database_name, table_name);
71657165
if (parametrized_view_storage)
71667166
{
7167-
table_function_node = std::make_shared<TableNode>(parametrized_view_storage, scope_context);
7167+
auto fake_table_node = std::make_shared<TableNode>(parametrized_view_storage, scope_context);
7168+
fake_table_node->setAlias(table_function_node->getAlias());
7169+
table_function_node = fake_table_node;
71687170
return;
71697171
}
71707172

src/Core/Settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ class IColumn;
636636
M(Bool, allow_experimental_database_materialized_mysql, false, "Allow to create database with Engine=MaterializedMySQL(...).", 0) \
637637
M(Bool, allow_experimental_database_materialized_postgresql, false, "Allow to create database with Engine=MaterializedPostgreSQL(...).", 0) \
638638
M(Bool, system_events_show_zero_values, false, "When querying system.events or system.metrics tables, include all metrics, even with zero values.", 0) \
639-
M(MySQLDataTypesSupport, mysql_datatypes_support_level, MySQLDataTypesSupportList{}, "Which MySQL types should be converted to corresponding ClickHouse types (rather than being represented as String). Can be empty or any combination of 'decimal', 'datetime64', 'date2Date32' or 'date2String'. When empty MySQL's DECIMAL and DATETIME/TIMESTAMP with non-zero precision are seen as String on ClickHouse's side.", 0) \
639+
M(MySQLDataTypesSupport, mysql_datatypes_support_level, MySQLDataTypesSupportList{}, "Defines how MySQL types are converted to corresponding ClickHouse types. A comma separated list in any combination of 'decimal', 'datetime64', 'date2Date32' or 'date2String'. decimal: convert NUMERIC and DECIMAL types to Decimal when precision allows it. datetime64: convert DATETIME and TIMESTAMP types to DateTime64 instead of DateTime when precision is not 0. date2Date32: convert DATE to Date32 instead of Date. Takes precedence over date2String. date2String: convert DATE to String instead of Date. Overridden by datetime64.", 0) \
640640
M(Bool, optimize_trivial_insert_select, true, "Optimize trivial 'INSERT INTO table SELECT ... FROM TABLES' query", 0) \
641641
M(Bool, allow_non_metadata_alters, true, "Allow to execute alters which affects not only tables metadata, but also data on disk", 0) \
642642
M(Bool, enable_global_with_statement, true, "Propagate WITH statements to UNION queries and all subqueries", 0) \
@@ -795,6 +795,7 @@ class IColumn;
795795
M(Bool, throw_on_error_from_cache_on_write_operations, false, "Ignore error from cache when caching on write operations (INSERT, merges)", 0) \
796796
M(UInt64, filesystem_cache_segments_batch_size, 20, "Limit on size of a single batch of file segments that a read buffer can request from cache. Too low value will lead to excessive requests to cache, too large may slow down eviction from cache", 0) \
797797
M(UInt64, filesystem_cache_reserve_space_wait_lock_timeout_milliseconds, 1000, "Wait time to lock cache for sapce reservation in filesystem cache", 0) \
798+
M(UInt64, temporary_data_in_cache_reserve_space_wait_lock_timeout_milliseconds, (10 * 60 * 1000), "Wait time to lock cache for sapce reservation for temporary data in filesystem cache", 0) \
798799
\
799800
M(Bool, use_page_cache_for_disks_without_file_cache, false, "Use userspace page cache for remote disks that don't have filesystem cache enabled.", 0) \
800801
M(Bool, read_from_page_cache_if_exists_otherwise_bypass_cache, false, "Use userspace page cache in passive mode, similar to read_from_filesystem_cache_if_exists_otherwise_bypass_cache.", 0) \

0 commit comments

Comments
 (0)