MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getCreateTableQueryImpl

Method getCreateTableQueryImpl

src/Databases/SQLite/DatabaseSQLite.cpp:185–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185ASTPtr DatabaseSQLite::getCreateTableQueryImpl(const String & table_name, ContextPtr local_context, bool throw_on_error) const
186{
187 StoragePtr storage;
188 {
189 std::lock_guard lock(mutex);
190 storage = fetchTable(table_name, local_context, false);
191 }
192 if (!storage)
193 {
194 if (throw_on_error)
195 throw Exception(ErrorCodes::UNKNOWN_TABLE, "SQLite table {}.{} does not exist",
196 getDatabaseName(), table_name);
197 return nullptr;
198 }
199 auto table_storage_define = database_engine_define->clone();
200 ASTStorage * ast_storage = table_storage_define->as<ASTStorage>();
201 ast_storage->engine->setKind(ASTFunction::Kind::TABLE_ENGINE);
202 auto storage_engine_arguments = ast_storage->engine->arguments;
203 auto table_id = storage->getStorageID();
204 /// Add table_name to engine arguments
205 storage_engine_arguments->children.insert(storage_engine_arguments->children.begin() + 1, make_intrusive<ASTLiteral>(table_id.table_name));
206
207 const Settings & settings = getContext()->getSettingsRef();
208
209 auto create_table_query = DB::getCreateQueryFromStorage(
210 storage,
211 table_storage_define,
212 true,
213 static_cast<uint32_t>(settings[Setting::max_parser_depth]),
214 static_cast<uint32_t>(settings[Setting::max_parser_backtracks]),
215 throw_on_error,
216 getContext());
217
218 return create_table_query;
219}
220
221void registerDatabaseSQLite(DatabaseFactory & factory);
222void registerDatabaseSQLite(DatabaseFactory & factory)

Callers

nothing calls this directly

Calls 8

ExceptionClass · 0.50
getContextFunction · 0.50
cloneMethod · 0.45
setKindMethod · 0.45
getStorageIDMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected