mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
Daemon: check TRT schema [closes #309]
This commit is contained in:
committed by
Aleksey Midenkov
parent
0b2c308888
commit
08099bc05a
@@ -100,6 +100,8 @@
|
|||||||
|
|
||||||
#include "rpl_handler.h"
|
#include "rpl_handler.h"
|
||||||
|
|
||||||
|
#include "transaction.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_PRCTL_H
|
#ifdef HAVE_SYS_PRCTL_H
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -6024,6 +6026,26 @@ int mysqld_main(int argc, char **argv)
|
|||||||
if (Events::init((THD*) 0, opt_noacl || opt_bootstrap))
|
if (Events::init((THD*) 0, opt_noacl || opt_bootstrap))
|
||||||
unireg_abort(1);
|
unireg_abort(1);
|
||||||
|
|
||||||
|
if (!opt_bootstrap)
|
||||||
|
{
|
||||||
|
THD *thd = new THD(0);
|
||||||
|
thd->thread_stack= (char*) &thd;
|
||||||
|
thd->store_globals();
|
||||||
|
|
||||||
|
{
|
||||||
|
TR_table trt(thd);
|
||||||
|
if (trt.check())
|
||||||
|
{
|
||||||
|
sql_print_error("%s schema is incorrect", trt.table_name);
|
||||||
|
delete thd;
|
||||||
|
unireg_abort(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trans_commit_stmt(thd);
|
||||||
|
delete thd;
|
||||||
|
}
|
||||||
|
|
||||||
if (WSREP_ON)
|
if (WSREP_ON)
|
||||||
{
|
{
|
||||||
if (opt_bootstrap)
|
if (opt_bootstrap)
|
||||||
|
55
sql/table.cc
55
sql/table.cc
@@ -8684,6 +8684,61 @@ bool TR_table::query_sees(bool &result, ulonglong trx_id1, ulonglong trx_id0,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TR_table::check() const
|
||||||
|
{
|
||||||
|
// InnoDB may not be loaded
|
||||||
|
if (!ha_resolve_by_legacy_type(thd, DB_TYPE_INNODB))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!table)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->file->ht->db_type != DB_TYPE_INNODB)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->s->fields != 5)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->field[FLD_TRX_ID]->type() != MYSQL_TYPE_LONGLONG)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->field[FLD_COMMIT_ID]->type() != MYSQL_TYPE_LONGLONG)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->field[FLD_BEGIN_TS]->type() != MYSQL_TYPE_TIMESTAMP)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->field[FLD_COMMIT_TS]->type() != MYSQL_TYPE_TIMESTAMP)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (table->field[FLD_ISO_LEVEL]->type() != MYSQL_TYPE_STRING ||
|
||||||
|
!(table->field[FLD_ISO_LEVEL]->flags & ENUM_FLAG))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Field_enum *iso_level= static_cast<Field_enum *>(table->field[FLD_ISO_LEVEL]);
|
||||||
|
st_typelib *typelib= iso_level->typelib;
|
||||||
|
|
||||||
|
if (typelib->count != 4)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (strcmp(typelib->type_names[0], "READ-UNCOMMITTED") ||
|
||||||
|
strcmp(typelib->type_names[1], "READ-COMMITTED") ||
|
||||||
|
strcmp(typelib->type_names[2], "REPEATABLE-READ") ||
|
||||||
|
strcmp(typelib->type_names[3], "SERIALIZABLE"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!table->key_info || !table->key_info->key_part)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (strcmp(table->key_info->key_part->field->field_name.str,
|
||||||
|
"transaction_id"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void vers_select_conds_t::resolve_units(bool timestamps_only)
|
void vers_select_conds_t::resolve_units(bool timestamps_only)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(type != FOR_SYSTEM_TIME_UNSPECIFIED);
|
DBUG_ASSERT(type != FOR_SYSTEM_TIME_UNSPECIFIED);
|
||||||
|
@@ -2979,6 +2979,7 @@ public:
|
|||||||
DBUG_ASSERT(iso_level <= ISO_SERIALIZABLE);
|
DBUG_ASSERT(iso_level <= ISO_SERIALIZABLE);
|
||||||
store(FLD_ISO_LEVEL, iso_level + 1);
|
store(FLD_ISO_LEVEL, iso_level + 1);
|
||||||
}
|
}
|
||||||
|
bool check() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MYSQL_CLIENT */
|
#endif /* MYSQL_CLIENT */
|
||||||
|
Reference in New Issue
Block a user