Skip to content

Commit

Permalink
Merge pull request #6417 from Veeupup/escape
Browse files Browse the repository at this point in the history
fix(query): escape `record_delimiter` when displaying
  • Loading branch information
mergify[bot] authored Jul 4, 2022
2 parents 28fee30 + e833db1 commit b768847
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ serfig = "0.0.2"
sha1 = "0.10.1"
sha2 = "0.10.2"
smallvec = { version = "1.8.0", features = ["write"] }
snailquote = "0.3.1"
strum = "0.24.1"
strum_macros = "0.24.0"
tempfile = { version = "3.3.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion query/src/sessions/session_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Settings {
default_value: DataValue::String("\n".as_bytes().to_vec()),
user_setting: UserSetting::create("record_delimiter", DataValue::String("\n".as_bytes().to_vec())),
level: ScopeLevel::Session,
desc: "Format record_delimiter, default value: \n",
desc: "Format record_delimiter, default value: \"\\n\"",
},
SettingValue {
default_value: DataValue::String(",".as_bytes().to_vec()),
Expand Down
5 changes: 3 additions & 2 deletions query/src/storages/system/settings_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use common_exception::Result;
use common_meta_app::schema::TableIdent;
use common_meta_app::schema::TableInfo;
use common_meta_app::schema::TableMeta;
use snailquote::escape;

use crate::sessions::QueryContext;
use crate::storages::system::table::SyncOneBlockSystemTable;
Expand Down Expand Up @@ -51,9 +52,9 @@ impl SyncSystemTable for SettingsTable {
// Name.
names.push(format!("{:?}", vals[0]));
// Value.
values.push(format!("{:?}", vals[1]));
values.push(escape(format!("{:?}", vals[1]).as_str()).to_string());
// Default Value.
defaults.push(format!("{:?}", vals[2]));
defaults.push(escape(format!("{:?}", vals[2]).as_str()).to_string());
// Scope level.
levels.push(format!("{:?}", vals[3]));
// Desc.
Expand Down
3 changes: 1 addition & 2 deletions query/tests/it/storages/system/settings_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ async fn test_settings_table() -> Result<()> {
"+--------------------------------+---------+---------+---------+----------------------------------------------------------------------------------------------------+--------+",
"| name | value | default | level | description | type |",
"+--------------------------------+---------+---------+---------+----------------------------------------------------------------------------------------------------+--------+",
"| | | | | | |",
"| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0 | UInt64 |",
"| compression | None | None | SESSION | Format compression, default value: None | String |",
"| empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1 | UInt64 |",
Expand All @@ -44,7 +43,7 @@ async fn test_settings_table() -> Result<()> {
"| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000 | UInt64 |",
"| max_block_size | 10000 | 10000 | SESSION | Maximum block size for reading | UInt64 |",
"| max_threads | 2 | 16 | SESSION | The maximum number of threads to execute the request. By default, it is determined automatically. | UInt64 |",
"| record_delimiter | | | SESSION | Format record_delimiter, default value: | String |",
"| record_delimiter | \"\\n\" | \"\\n\" | SESSION | Format record_delimiter, default value: \"\\n\" | String |",
"| skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0 | UInt64 |",
"| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 |",
"| timezone | UTC | UTC | SESSION | Timezone, default value: UTC, | String |",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ flight_client_timeout 60 60 SESSION Max duration the flight client request is al
group_by_two_level_threshold 10000 10000 SESSION The threshold of keys to open two-level aggregation, default value: 10000 UInt64
max_block_size 10000 10000 SESSION Maximum block size for reading UInt64
max_threads 11 16 SESSION The maximum number of threads to execute the request. By default, it is determined automatically. UInt64
record_delimiter \n \n SESSION Format record_delimiter, default value: \n String
record_delimiter "\\n" "\\n" SESSION Format record_delimiter, default value: "\\n" String
skip_header 0 0 SESSION Whether to skip the input header, default value: 0 UInt64
storage_read_buffer_size 1048576 1048576 SESSION The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. UInt64
timezone UTC UTC SESSION Timezone, default value: UTC, String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ flight_client_timeout 60 60 SESSION Max duration the flight client request is al
group_by_two_level_threshold 10000 10000 SESSION The threshold of keys to open two-level aggregation, default value: 10000 UInt64
max_block_size 10000 10000 SESSION Maximum block size for reading UInt64
max_threads 11 16 SESSION The maximum number of threads to execute the request. By default, it is determined automatically. UInt64
record_delimiter \n \n SESSION Format record_delimiter, default value: \n String
record_delimiter "\\n" "\\n" SESSION Format record_delimiter, default value: "\\n" String
skip_header 0 0 SESSION Whether to skip the input header, default value: 0 UInt64
storage_read_buffer_size 1048576 1048576 SESSION The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. UInt64
timezone UTC UTC SESSION Timezone, default value: UTC, String
Expand Down

0 comments on commit b768847

Please sign in to comment.