Переглянути джерело

* improved table cleanup of mariadb driver

master
bergmann 7 роки тому
джерело
коміт
c9f2ae8177
1 змінених файлів з 11 додано та 13 видалено
  1. +11
    -13
      src/cpphibernate/driver/mariadb/schema/table.cpp

+ 11
- 13
src/cpphibernate/driver/mariadb/schema/table.cpp Переглянути файл

@@ -1297,7 +1297,7 @@ std::string table_t::execute_create_update(
/* delete non referenced elements */ /* delete non referenced elements */
if (context.is_update) if (context.is_update)
{ {
ref_table.execute_foreign_many_delete(context);
ref_table.destroy_cleanup(context, true, true);
} }
} }


@@ -1519,6 +1519,8 @@ std::string table_t::build_delete_query(const std::string* where) const


void table_t::execute_foreign_many_delete(const base_context& context) const void table_t::execute_foreign_many_delete(const base_context& context) const
{ {
if (foreign_key_fields.empty())
return;
auto& connection = context.connection; auto& connection = context.connection;
auto& statement = get_statement_foreign_many_delete(); auto& statement = get_statement_foreign_many_delete();
cpphibernate_debug_log("execute DELETE old foreign many query: " << statement.query(connection)); cpphibernate_debug_log("execute DELETE old foreign many query: " << statement.query(connection));
@@ -1668,28 +1670,24 @@ void table_t::destroy_exec(const destroy_context& context) const
cpphibernate_debug_log("execute DELETE query: " << statement.query(connection)); cpphibernate_debug_log("execute DELETE query: " << statement.query(connection));
connection.execute(statement); connection.execute(statement);


destroy_cleanup(context, false, true);
}

void table_t::destroy_cleanup(const base_context& context, bool check_derived, bool check_base) const
{
for (auto ptr : foreign_table_many_fields)
for (auto& ptr : foreign_table_many_fields)
{ {
assert(ptr); assert(ptr);
assert(ptr->referenced_table); assert(ptr->referenced_table);

auto& ref_table = *ptr->referenced_table; auto& ref_table = *ptr->referenced_table;

ref_table.execute_foreign_many_delete(context);
ref_table.destroy_cleanup(context, true, true);
} }
}

void table_t::destroy_cleanup(const base_context& context, bool check_derived, bool check_base) const
{
execute_foreign_many_delete(context);


for (auto ptr : foreign_table_fields)
for (auto ptr : foreign_table_many_fields)
{ {
assert(ptr); assert(ptr);
assert(ptr->referenced_table); assert(ptr->referenced_table);

auto& ref_table = *ptr->referenced_table; auto& ref_table = *ptr->referenced_table;

ref_table.destroy_cleanup(context, true, true); ref_table.destroy_cleanup(context, true, true);
} }




Завантаження…
Відмінити
Зберегти