Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5994b687
Commit
5994b687
authored
Nov 21, 2017
by
Aleksey Midenkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Daemon: TRT check doesn't abort [fixes #335]
Added schema check logging messages.
parent
0b40a981
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
89 additions
and
24 deletions
+89
-24
sql/handler.cc
sql/handler.cc
+1
-1
sql/mysqld.cc
sql/mysqld.cc
+24
-13
sql/mysqld.h
sql/mysqld.h
+1
-0
sql/sql_table.cc
sql/sql_table.cc
+1
-1
sql/table.cc
sql/table.cc
+59
-8
sql/table.h
sql/table.h
+2
-0
sql/vtmd.cc
sql/vtmd.cc
+1
-1
No files found.
sql/handler.cc
View file @
5994b687
...
...
@@ -1416,7 +1416,7 @@ int ha_commit_trans(THD *thd, bool all)
if
(
rw_trans
||
thd
->
lex
->
sql_command
==
SQLCOM_ALTER_TABLE
)
{
if
(
opt
_transaction_registry
&&
thd
->
vers_update_trt
)
if
(
use
_transaction_registry
&&
thd
->
vers_update_trt
)
{
TR_table
trt
(
thd
,
true
);
if
(
trt
.
update
())
...
...
sql/mysqld.cc
View file @
5994b687
...
...
@@ -535,6 +535,7 @@ ulong feature_files_opened_with_delayed_keys= 0, feature_check_constraint= 0;
ulonglong
denied_connections
;
my_decimal
decimal_zero
;
my_bool
opt_transaction_registry
=
1
;
my_bool
use_transaction_registry
=
1
;
/*
Maximum length of parameter value which can be set through
...
...
@@ -6027,25 +6028,35 @@ int mysqld_main(int argc, char **argv)
if
(
Events
::
init
((
THD
*
)
0
,
opt_noacl
||
opt_bootstrap
))
unireg_abort
(
1
);
if
(
!
opt_bootstrap
&&
opt_transaction_registry
)
if
(
opt_transaction_registry
)
{
use_transaction_registry
=
true
;
if
(
opt_bootstrap
)
{
use_transaction_registry
=
false
;
}
else
{
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
);
use_transaction_registry
=
false
;
}
}
trans_commit_stmt
(
thd
);
delete
thd
;
}
}
else
use_transaction_registry
=
false
;
if
(
opt_transaction_registry
&&
!
use_transaction_registry
)
sql_print_information
(
"Disabled transaction registry."
);
if
(
WSREP_ON
)
{
...
...
sql/mysqld.h
View file @
5994b687
...
...
@@ -313,6 +313,7 @@ extern ulong encryption_algorithm;
extern
const
char
*
encryption_algorithm_names
[];
extern
const
char
*
quoted_string
;
extern
my_bool
opt_transaction_registry
;
extern
my_bool
use_transaction_registry
;
#ifdef HAVE_PSI_INTERFACE
#ifdef HAVE_MMAP
...
...
sql/sql_table.cc
View file @
5994b687
...
...
@@ -7432,7 +7432,7 @@ static bool mysql_inplace_alter_table(THD *thd,
TR_table
trt
(
thd
,
true
);
if
(
thd
->
vers_update_trt
&&
trt
!=
*
table_list
)
{
if
(
opt
_transaction_registry
&&
trt
.
update
())
if
(
use
_transaction_registry
&&
trt
.
update
())
return
true
;
}
...
...
sql/table.cc
View file @
5994b687
...
...
@@ -8699,57 +8699,108 @@ bool TR_table::query_sees(bool &result, ulonglong trx_id1, ulonglong trx_id0,
return
false
;
}
void
TR_table
::
warn_schema_incorrect
(
const
char
*
reason
)
{
if
(
MYSQL_VERSION_ID
==
table
->
s
->
mysql_version
)
{
sql_print_error
(
"`%s.%s` schema is incorrect: %s."
,
db
,
table_name
,
reason
);
}
else
{
sql_print_error
(
"`%s.%s` schema is incorrect: %s. Created with MariaDB %d, "
"now running %d."
,
db
,
table_name
,
reason
,
MYSQL_VERSION_ID
,
static_cast
<
int
>
(
table
->
s
->
mysql_version
));
}
}
bool
TR_table
::
check
()
{
// InnoDB may not be loaded
if
(
!
ha_resolve_by_legacy_type
(
thd
,
DB_TYPE_INNODB
))
return
false
;
{
sql_print_information
(
"`%s.%s` requires InnoDB storage engine."
,
db
,
table_name
);
return
true
;
}
if
(
open
())
{
sql_print_warning
(
"`%s.%s` does not exist (open failed)."
,
db
,
table_name
);
return
true
;
}
if
(
table
->
file
->
ht
->
db_type
!=
DB_TYPE_INNODB
)
{
warn_schema_incorrect
(
"Wrong table engine (expected InnoDB)"
);
return
true
;
}
#define WARN_SCHEMA(...) \
char reason[128]; \
snprintf(reason, 128, __VA_ARGS__); \
warn_schema_incorrect(reason);
if
(
table
->
s
->
fields
!=
5
)
if
(
table
->
s
->
fields
!=
FIELD_COUNT
)
{
WARN_SCHEMA
(
"Wrong field count (expected %d)"
,
FIELD_COUNT
);
return
true
;
}
if
(
table
->
field
[
FLD_TRX_ID
]
->
type
()
!=
MYSQL_TYPE_LONGLONG
)
{
WARN_SCHEMA
(
"Wrong field %d type (expected BIGINT UNSIGNED)"
,
FLD_TRX_ID
);
return
true
;
}
if
(
table
->
field
[
FLD_COMMIT_ID
]
->
type
()
!=
MYSQL_TYPE_LONGLONG
)
{
WARN_SCHEMA
(
"Wrong field %d type (expected BIGINT UNSIGNED)"
,
FLD_COMMIT_ID
);
return
true
;
}
if
(
table
->
field
[
FLD_BEGIN_TS
]
->
type
()
!=
MYSQL_TYPE_TIMESTAMP
)
{
WARN_SCHEMA
(
"Wrong field %d type (expected TIMESTAMP(6))"
,
FLD_BEGIN_TS
);
return
true
;
}
if
(
table
->
field
[
FLD_COMMIT_TS
]
->
type
()
!=
MYSQL_TYPE_TIMESTAMP
)
{
WARN_SCHEMA
(
"Wrong field %d type (expected TIMESTAMP(6))"
,
FLD_COMMIT_TS
);
return
true
;
}
if
(
table
->
field
[
FLD_ISO_LEVEL
]
->
type
()
!=
MYSQL_TYPE_STRING
||
!
(
table
->
field
[
FLD_ISO_LEVEL
]
->
flags
&
ENUM_FLAG
))
{
wrong_enum:
WARN_SCHEMA
(
"Wrong field %d type (expected ENUM('READ-UNCOMMITTED', "
"'READ-COMMITTED', 'REPEATABLE-READ', 'SERIALIZABLE'))"
,
FLD_ISO_LEVEL
);
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
;
goto
wrong_enum
;
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
;
goto
wrong_enum
;
}
if
(
!
table
->
key_info
||
!
table
->
key_info
->
key_part
)
return
true
;
goto
wrong_pk
;
if
(
strcmp
(
table
->
key_info
->
key_part
->
field
->
field_name
.
str
,
"transaction_id"
))
if
(
strcmp
(
table
->
key_info
->
key_part
->
field
->
field_name
.
str
,
"transaction_id"
))
{
wrong_pk:
WARN_SCHEMA
(
"Wrong PRIMARY KEY (expected `transaction_id`)"
);
return
true
;
}
return
false
;
}
...
...
sql/table.h
View file @
5994b687
...
...
@@ -2967,6 +2967,8 @@ class TR_table: public TABLE_LIST
DBUG_ASSERT
(
iso_level
<=
ISO_SERIALIZABLE
);
store
(
FLD_ISO_LEVEL
,
iso_level
+
1
);
}
void
warn_schema_incorrect
(
const
char
*
reason
);
bool
check
();
public:
...
...
sql/vtmd.cc
View file @
5994b687
...
...
@@ -255,7 +255,7 @@ VTMD_table::update(THD *thd, const char* archive_name)
}
quit:
if
(
!
result
&&
opt
_transaction_registry
)
if
(
!
result
&&
use
_transaction_registry
)
{
DBUG_ASSERT
(
thd
->
vers_update_trt
);
TR_table
trt
(
thd
,
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment