|
16 | 16 | exit 1 |
17 | 17 | fi |
18 | 18 |
|
19 | | - |
20 | 19 | target_dir=$(dirname "$(dirname "$(realpath "$0")")") |
21 | 20 | SCRIPT_NAME=$(basename "$0") |
| 21 | +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
22 | 22 | tmp_dir="$target_dir/tmp" |
23 | 23 |
|
24 | 24 | mkdir -p "$tmp_dir" || exit 1 |
|
41 | 41 |
|
42 | 42 | echo "Downloaded to: $script_path" |
43 | 43 | echo "[$SCRIPT_NAME] Auto-generating settings" |
44 | | - |
45 | | -# Autogenerate Format settings |
46 | 44 | chmod +x "$script_path" || { echo "Error: Failed to set execute permission"; exit 1; } |
47 | | - |
48 | 45 | root=$(dirname "$(dirname "$(realpath "$tmp_dir")")") |
49 | 46 |
|
50 | | -./clickhouse -q " |
51 | | -WITH |
52 | | -'FormatFactorySettings.h' AS cpp_file, |
53 | | -settings_from_cpp AS |
54 | | -( |
55 | | - SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name |
56 | | - FROM file(cpp_file, LineAsString) |
57 | | - WHERE match(line, '^\\s*DECLARE\\(') |
58 | | -), |
59 | | -main_content AS |
60 | | -( |
61 | | - SELECT format('## {} {}\\n{}\\n\\nType: \`{}\`\\n\\nDefault: \`{}\`\\n\\n{}\\n\\n', |
62 | | - name, '{#'||name||'}', multiIf(tier == 'Experimental', '<ExperimentalBadge/>', tier == 'Beta', '<BetaBadge/>', ''), type, default, trim(BOTH '\\n' FROM description)) |
63 | | - FROM system.settings WHERE name IN settings_from_cpp |
64 | | - ORDER BY name |
65 | | -), |
66 | | -'--- |
67 | | -title: ''Format Settings'' |
68 | | -sidebar_label: ''Format Settings'' |
69 | | -slug: /operations/settings/formats |
70 | | -toc_max_heading_level: 2 |
71 | | -description: ''Settings which control input and output formats.'' |
72 | | ---- |
73 | | -
|
74 | | -import ExperimentalBadge from \'@theme/badges/ExperimentalBadge\'; |
75 | | -import BetaBadge from \'@theme/badges/BetaBadge\'; |
76 | | -
|
77 | | -<!-- Autogenerated --> |
78 | | -These settings are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/FormatFactorySettings.h). |
79 | | -
|
80 | | -' AS prefix |
81 | | -SELECT prefix || (SELECT groupConcat(*) FROM main_content) |
82 | | -INTO OUTFILE 'settings-formats.md' TRUNCATE FORMAT LineAsString |
83 | | -" > /dev/null || { echo "Failed to Autogenerate Format settings"; exit 1; } |
84 | | - |
85 | | -# Autogenerate settings |
86 | | -./clickhouse -q " |
87 | | -WITH |
88 | | -'Settings.cpp' AS cpp_file, |
89 | | -settings_from_cpp AS |
90 | | -( |
91 | | - SELECT extract(line, 'DECLARE\\(\\w+, (\\w+),') AS name |
92 | | - FROM file(cpp_file, LineAsString) |
93 | | - WHERE match(line, '^\\s*DECLARE\\(') |
94 | | -), |
95 | | -main_content AS |
96 | | -( |
97 | | - SELECT format('## {} {}\\n{}\\n{}\\n\\nType: {}\\n\\nDefault value: {}\\n\\n{}\\n\\n', |
98 | | - name, '{#'||name||'}', multiIf(tier == 'Experimental', '<ExperimentalBadge/>', tier == 'Beta', '<BetaBadge/>', ''), if(description LIKE '%Only has an effect in ClickHouse Cloud%', '\\n<CloudAvailableBadge/>', ''), type, default, replaceOne(trim(BOTH '\\n' FROM description), ' and [MaterializedMySQL](../../engines/database-engines/materialized-mysql.md)','')) |
99 | | - FROM system.settings WHERE name IN settings_from_cpp |
100 | | - ORDER BY name |
101 | | -), |
102 | | -'--- |
103 | | -title: ''Session Settings'' |
104 | | -sidebar_label: ''Session Settings'' |
105 | | -slug: /operations/settings/settings |
106 | | -toc_max_heading_level: 2 |
107 | | -description: ''Settings which are found in the ``system.settings`` table.'' |
108 | | ---- |
109 | | -
|
110 | | -import ExperimentalBadge from \'@theme/badges/ExperimentalBadge\'; |
111 | | -import BetaBadge from \'@theme/badges/BetaBadge\'; |
112 | | -import CloudAvailableBadge from \'@theme/badges/CloudAvailableBadge\'; |
113 | | -
|
114 | | -<!-- Autogenerated --> |
115 | | -All below settings are also available in table [system.settings](/docs/operations/system-tables/settings). These settings are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp). |
116 | | -
|
117 | | -' AS prefix |
118 | | -SELECT prefix || (SELECT groupConcat(*) FROM main_content) |
119 | | -INTO OUTFILE 'settings.md' TRUNCATE FORMAT LineAsString |
120 | | -" > /dev/null || { echo "Failed to Autogenerate Core settings"; exit 1; } |
121 | | - |
122 | | -# Auto generate global server settings |
123 | | -./clickhouse -q " |
124 | | -WITH |
125 | | - server_settings_outside_source AS |
126 | | - ( |
127 | | - SELECT |
128 | | - arrayJoin(extractAllGroups(raw_blob, '## (\\w+)(?:\\s[^\n]+)?\n\\s+((?:[^#]|#[^#]|##[^ ])+)')) AS g, |
129 | | - g[1] AS name, |
130 | | - replaceRegexpAll(replaceRegexpAll(g[2], '\n(Type|Default( value)?): [^\n]+\n', ''), '^\n+|\n+$', '') AS doc |
131 | | - FROM file('_server_settings_outside_source.md', RawBLOB) |
132 | | - ), |
133 | | - server_settings_in_source AS |
134 | | - ( |
135 | | - SELECT |
136 | | - name, |
137 | | - replaceRegexpAll(description, '(?m)^[ \t]+', '') AS description, |
138 | | - type, |
139 | | - default |
140 | | - FROM system.server_settings |
141 | | - ), |
142 | | - combined_server_settings AS |
143 | | - ( |
144 | | - SELECT |
145 | | - name, |
146 | | - description, |
147 | | - type, |
148 | | - default |
149 | | - FROM server_settings_in_source |
150 | | - UNION ALL |
151 | | - SELECT |
152 | | - name, |
153 | | - doc AS description, |
154 | | - '' AS type, |
155 | | - '' AS default |
156 | | - FROM server_settings_outside_source |
157 | | - ), |
158 | | - formatted_settings AS |
159 | | - ( |
160 | | - SELECT |
161 | | - format( |
162 | | - '## {} {}\n\n{}{}{}\n\n', |
163 | | - name, |
164 | | - lcase('{#'||name||'}'), |
165 | | - if(type != '', concat('Type: \`', type, '\`\n\n'), ''), |
166 | | - if(default != '', concat('Default: \`', default, '\`\n\n'), ''), |
167 | | - description |
168 | | - ) AS formatted_text |
169 | | - FROM combined_server_settings |
170 | | - ORDER BY name ASC |
171 | | - ), |
172 | | - prefix_text AS |
173 | | - ( |
174 | | - SELECT |
175 | | - '--- |
176 | | -description: ''This section contains descriptions of server settings i.e settings |
177 | | - which cannot be changed at the session or query level.'' |
178 | | -keywords: [''global server settings''] |
179 | | -sidebar_label: ''Server Settings'' |
180 | | -sidebar_position: 57 |
181 | | -slug: /operations/server-configuration-parameters/settings |
182 | | -title: ''Server Settings'' |
183 | | ---- |
184 | | -
|
185 | | -import Tabs from ''@theme/Tabs''; |
186 | | -import TabItem from ''@theme/TabItem''; |
187 | | -import SystemLogParameters from ''@site/docs/operations/server-configuration-parameters/_snippets/_system-log-parameters.md'' |
188 | | -
|
189 | | -# Server Settings |
190 | | -
|
191 | | -This section contains descriptions of server settings. These are settings which |
192 | | -cannot be changed at the session or query level. |
193 | | -
|
194 | | -For more information on configuration files in ClickHouse see [""Configuration Files""](/operations/configuration-files). |
195 | | -
|
196 | | -Other settings are described in the ""[Settings](/operations/settings/overview)"" section. |
197 | | -Before studying the settings, we recommend reading the [Configuration files](/operations/configuration-files) |
198 | | -section and note the use of substitutions (the `incl` and `optional` attributes). |
199 | | -
|
200 | | -' AS prefix_content |
201 | | - ) |
202 | | -SELECT |
203 | | - arrayStringConcat([ |
204 | | - (SELECT prefix_content FROM prefix_text), |
205 | | - arrayStringConcat(groupArray(formatted_text), '') |
206 | | - ], '') |
207 | | -FROM formatted_settings |
208 | | -INTO OUTFILE 'server_settings.md' |
209 | | -TRUNCATE FORMAT LineAsString" > /dev/null || { echo "Failed to Autogenerate Format settings"; exit 1; } |
| 47 | +# Autogenerate settings for all .sql files in directory |
| 48 | +for SQL_FILE in "$SCRIPT_DIR"/*.sql; do |
| 49 | + if [ -f "$SQL_FILE" ]; then |
| 50 | + ./clickhouse --queries-file "$SQL_FILE" > /dev/null || { echo "Failed to generate some settings"; exit 1; } |
| 51 | + fi |
| 52 | +done |
210 | 53 |
|
| 54 | +# move across files to where they need to be |
211 | 55 | mv settings-formats.md "$root/docs/operations/settings" || { echo "Failed to move generated settings-format.md"; exit 1; } |
212 | 56 | mv settings.md "$root/docs/operations/settings" || { echo "Failed to move generated settings.md"; exit 1; } |
213 | 57 | mv server_settings.md "$root/docs/operations/server-configuration-parameters/settings.md" || { echo "Failed to move generated server_settings.md"; exit 1; } |
|
0 commit comments