mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 04:52:10 +00:00
drop table immediately
fix style update
This commit is contained in:
parent
f8f22f9a51
commit
6c4b0f2d37
@ -140,6 +140,11 @@ void DatabaseAtomic::dropTable(ContextPtr local_context, const String & table_na
|
||||
if (table->storesDataOnDisk())
|
||||
tryRemoveSymlink(table_name);
|
||||
|
||||
if (table->dropTableImmediately())
|
||||
{
|
||||
table->drop();
|
||||
}
|
||||
|
||||
/// Notify DatabaseCatalog that table was dropped. It will remove table data in background.
|
||||
/// Cleanup is performed outside of database to allow easily DROP DATABASE without waiting for cleanup to complete.
|
||||
DatabaseCatalog::instance().enqueueDroppedTableCleanup(table->getStorageID(), table, table_metadata_path_drop, no_delay);
|
||||
|
@ -898,7 +898,7 @@ void DatabaseCatalog::dropTableDataTask()
|
||||
|
||||
void DatabaseCatalog::dropTableFinally(const TableMarkedAsDropped & table)
|
||||
{
|
||||
if (table.table)
|
||||
if (table.table && !table.table->dropTableImmediately())
|
||||
{
|
||||
table.table->drop();
|
||||
}
|
||||
|
@ -11,12 +11,7 @@
|
||||
|
||||
namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
const auto MAX_FAILED_POLL_ATTEMPTS = 10;
|
||||
static constexpr auto MAX_FAILED_POLL_ATTEMPTS = 10;
|
||||
|
||||
FileLogSource::FileLogSource(
|
||||
StorageFileLog & storage_,
|
||||
|
@ -39,7 +39,8 @@ namespace ErrorCodes
|
||||
extern const int CANNOT_GET_FILE_STAT;
|
||||
extern const int NOT_REGULAR_FILE;
|
||||
extern const int READ_META_FILE_FAILED;
|
||||
extern const int FILE_STREAM_ERROR;
|
||||
extern const int FILE_STREAM_ERROR;
|
||||
extern const int LOGICAL_ERROR;
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
|
||||
void drop() override;
|
||||
|
||||
bool dropTableImmediately() const override { return true; }
|
||||
|
||||
const auto & getFormatName() const { return format_name; }
|
||||
|
||||
enum class FileStatus
|
||||
|
@ -578,6 +578,8 @@ public:
|
||||
/// Does not takes underlying Storage (if any) into account.
|
||||
virtual std::optional<UInt64> lifetimeBytes() const { return {}; }
|
||||
|
||||
virtual bool dropTableImmediately() const { return false; }
|
||||
|
||||
private:
|
||||
/// Lock required for alter queries (lockForAlter). Always taken for write
|
||||
/// (actually can be replaced with std::mutex, but for consistency we use
|
||||
|
@ -46,8 +46,8 @@ rm ${user_files_path}/logs/d.txt
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;"
|
||||
|
||||
${CLICKHOUSE_CLIENT} --query "detach table t;"
|
||||
${CLICKHOUSE_CLIENT} --query "attach table t;"
|
||||
${CLICKHOUSE_CLIENT} --query "detach table file_log;"
|
||||
${CLICKHOUSE_CLIENT} --query "attach table file_log;"
|
||||
|
||||
# should no records return
|
||||
${CLICKHOUSE_CLIENT} --query "select *, _file_name, _offset from file_log order by _file_name, _offset;"
|
||||
|
Loading…
Reference in New Issue
Block a user