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
4af3cb82
Commit
4af3cb82
authored
Apr 05, 2017
by
kevg
Committed by
Aleksey Midenkov
May 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IB: MIN/MAX trx_id by querying VTQ with commit ts [closes #168]
parent
994cdf1b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
2 deletions
+57
-2
storage/innobase/vers/vers0vtq.cc
storage/innobase/vers/vers0vtq.cc
+57
-2
No files found.
storage/innobase/vers/vers0vtq.cc
View file @
4af3cb82
...
...
@@ -201,6 +201,14 @@ operator== (const timeval &a, const timeval &b)
return
a
.
tv_sec
==
b
.
tv_sec
&&
a
.
tv_usec
==
b
.
tv_usec
;
}
static
inline
bool
operator
!=
(
const
timeval
&
a
,
const
timeval
&
b
)
{
return
!
(
a
==
b
);
}
static
inline
bool
...
...
@@ -217,6 +225,52 @@ operator< (const timeval &a, const timeval &b)
return
b
>
a
;
}
static
trx_id_t
read_trx_id
(
const
rec_t
*
rec
)
{
ulong
len
=
0
;
const
rec_t
*
field
=
rec_get_nth_field_old
(
rec
,
1
,
&
len
);
DBUG_ASSERT
(
len
==
8
);
return
mach_read_from_8
(
field
);
}
/** Find a row with given commit_ts but MAX()/MIN() trx_id
@param[in] mtr mini-transaction handler
@param[in, out] pcur btree cursor which may be changed by this function
@param[in] backwards search direction
@param[in] commit_ts target timestamp for records
@param[in] rec record buffer for pcur
*/
static
void
find_best_match
(
mtr_t
&
mtr
,
btr_pcur_t
&
pcur
,
bool
backwards
,
timeval
commit_ts
,
const
rec_t
*
rec
)
{
btr_pcur_t
best
;
btr_pcur_init
(
&
best
);
btr_pcur_copy_stored_position
(
&
best
,
&
pcur
);
trx_id_t
best_trx_id
=
read_trx_id
(
rec
);
while
(
true
)
{
if
(
backwards
?
!
btr_pcur_move_to_prev_user_rec
(
&
pcur
,
&
mtr
)
:
!
btr_pcur_move_to_next_user_rec
(
&
pcur
,
&
mtr
))
break
;
timeval
tv
;
rec
=
btr_pcur_get_rec
(
&
pcur
);
rec_get_timeval
(
rec
,
0
,
tv
);
if
(
tv
!=
commit_ts
)
break
;
trx_id_t
trx_id
=
read_trx_id
(
rec
);
if
(
backwards
?
trx_id
<
best_trx_id
:
trx_id
>
best_trx_id
)
{
best_trx_id
=
trx_id
;
btr_pcur_copy_stored_position
(
&
best
,
&
pcur
);
}
}
btr_pcur_copy_stored_position
(
&
pcur
,
&
best
);
btr_pcur_free
(
&
best
);
}
/** Query VTQ by COMMIT_TS.
@param[in] thd MySQL thread
...
...
@@ -298,9 +352,10 @@ vtq_query_commit_ts(
rec
=
btr_pcur_get_rec
(
&
pcur
);
rec_get_timeval
(
rec
,
0
,
rec_ts
);
if
(
rec_ts
.
tv_sec
==
commit_ts
.
tv_sec
&&
rec_ts
.
tv_usec
==
commit_ts
.
tv_usec
)
if
(
rec_ts
==
commit_ts
)
{
find_best_match
(
mtr
,
pcur
,
backwards
,
commit_ts
,
rec
);
goto
found
;
}
}
else
{
rec_ts
=
commit_ts
;
}
...
...
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