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
7252e44b
Commit
7252e44b
authored
Mar 01, 2005
by
marko@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
After review fixes. Fix bugs in TRUNCATE.
parent
d184e93a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
13 deletions
+71
-13
innobase/dict/dict0crea.c
innobase/dict/dict0crea.c
+36
-7
innobase/include/dict0crea.h
innobase/include/dict0crea.h
+5
-2
innobase/include/page0page.ic
innobase/include/page0page.ic
+3
-0
innobase/log/log0recv.c
innobase/log/log0recv.c
+0
-2
innobase/row/row0mysql.c
innobase/row/row0mysql.c
+25
-2
sql/ha_innodb.cc
sql/ha_innodb.cc
+2
-0
No files found.
innobase/dict/dict0crea.c
View file @
7252e44b
...
@@ -729,14 +729,17 @@ dict_drop_index_tree(
...
@@ -729,14 +729,17 @@ dict_drop_index_tree(
/***********************************************************************
/***********************************************************************
Truncates the index tree associated with a row in SYS_INDEXES table. */
Truncates the index tree associated with a row in SYS_INDEXES table. */
void
ulint
dict_truncate_index_tree
(
dict_truncate_index_tree
(
/*=====================*/
/*=====================*/
/* out: new root page number, or
FIL_NULL on failure */
dict_table_t
*
table
,
/* in: the table the index belongs to */
dict_table_t
*
table
,
/* in: the table the index belongs to */
rec_t
*
rec
,
/* in: record in the clustered index of
rec_t
*
rec
,
/* in: record in the clustered index of
SYS_INDEXES table */
SYS_INDEXES table */
mtr_t
*
mtr
)
/* in: mtr having the latch
mtr_t
*
mtr
)
/* in: mtr having the latch
on the record page */
on the record page. The mtr may be
committed and restarted in this call. */
{
{
ulint
root_page_no
;
ulint
root_page_no
;
ulint
space
;
ulint
space
;
...
@@ -761,7 +764,10 @@ dict_truncate_index_tree(
...
@@ -761,7 +764,10 @@ dict_truncate_index_tree(
if
(
root_page_no
==
FIL_NULL
)
{
if
(
root_page_no
==
FIL_NULL
)
{
/* The tree has been freed. */
/* The tree has been freed. */
return
;
ut_print_timestamp
(
stderr
);
fprintf
(
stderr
,
" InnoDB: Trying to TRUNCATE"
" a missing index of table %s!
\n
"
,
table
->
name
);
return
(
FIL_NULL
);
}
}
ptr
=
rec_get_nth_field_old
(
rec
,
ptr
=
rec_get_nth_field_old
(
rec
,
...
@@ -775,7 +781,10 @@ dict_truncate_index_tree(
...
@@ -775,7 +781,10 @@ dict_truncate_index_tree(
/* It is a single table tablespace and the .ibd file is
/* It is a single table tablespace and the .ibd file is
missing: do nothing */
missing: do nothing */
return
;
ut_print_timestamp
(
stderr
);
fprintf
(
stderr
,
" InnoDB: Trying to TRUNCATE"
" a missing .ibd file of table %s!
\n
"
,
table
->
name
);
return
(
FIL_NULL
);
}
}
ptr
=
rec_get_nth_field_old
(
rec
,
ptr
=
rec_get_nth_field_old
(
rec
,
...
@@ -801,6 +810,20 @@ dict_truncate_index_tree(
...
@@ -801,6 +810,20 @@ dict_truncate_index_tree(
space
,
root_page_no
,
RW_X_LATCH
,
mtr
));
space
,
root_page_no
,
RW_X_LATCH
,
mtr
));
btr_free_root
(
space
,
root_page_no
,
mtr
);
btr_free_root
(
space
,
root_page_no
,
mtr
);
/* We will temporarily write FIL_NULL to the PAGE_NO field
in SYS_INDEXES, so that the database will not get into an
inconsistent state in case it crashes between the mtr_commit()
below and the following mtr_commit() call. */
page_rec_write_index_page_no
(
rec
,
DICT_SYS_INDEXES_PAGE_NO_FIELD
,
FIL_NULL
,
mtr
);
/* We will need to commit the mini-transaction in order to avoid
deadlocks in the btr_create() call, because otherwise we would
be freeing and allocating pages in the same mini-transaction. */
mtr_commit
(
mtr
);
/* mtr_commit() will invalidate rec. */
rec
=
NULL
;
mtr_start
(
mtr
);
/* Find the index corresponding to this SYS_INDEXES record. */
/* Find the index corresponding to this SYS_INDEXES record. */
for
(
index
=
UT_LIST_GET_FIRST
(
table
->
indexes
);
for
(
index
=
UT_LIST_GET_FIRST
(
table
->
indexes
);
...
@@ -814,11 +837,17 @@ dict_truncate_index_tree(
...
@@ -814,11 +837,17 @@ dict_truncate_index_tree(
root_page_no
=
btr_create
(
type
,
space
,
index_id
,
comp
,
mtr
);
root_page_no
=
btr_create
(
type
,
space
,
index_id
,
comp
,
mtr
);
if
(
index
)
{
if
(
index
)
{
index
->
tree
->
page
=
root_page_no
;
index
->
tree
->
page
=
root_page_no
;
}
else
{
ut_print_timestamp
(
stderr
);
fprintf
(
stderr
,
" InnoDB: Index %lu %lu of table %s is missing
\n
"
"InnoDB: from the data dictionary during TRUNCATE!
\n
"
,
ut_dulint_get_high
(
index_id
),
ut_dulint_get_low
(
index_id
),
table
->
name
);
}
}
page_rec_write_index_page_no
(
rec
,
return
(
root_page_no
);
DICT_SYS_INDEXES_PAGE_NO_FIELD
,
root_page_no
,
mtr
);
}
}
/*************************************************************************
/*************************************************************************
...
...
innobase/include/dict0crea.h
View file @
7252e44b
...
@@ -56,14 +56,17 @@ dict_create_index_step(
...
@@ -56,14 +56,17 @@ dict_create_index_step(
/***********************************************************************
/***********************************************************************
Truncates the index tree associated with a row in SYS_INDEXES table. */
Truncates the index tree associated with a row in SYS_INDEXES table. */
void
ulint
dict_truncate_index_tree
(
dict_truncate_index_tree
(
/*=====================*/
/*=====================*/
/* out: new root page number, or
FIL_NULL on failure */
dict_table_t
*
table
,
/* in: the table the index belongs to */
dict_table_t
*
table
,
/* in: the table the index belongs to */
rec_t
*
rec
,
/* in: record in the clustered index of
rec_t
*
rec
,
/* in: record in the clustered index of
SYS_INDEXES table */
SYS_INDEXES table */
mtr_t
*
mtr
);
/* in: mtr having the latch
mtr_t
*
mtr
);
/* in: mtr having the latch
on the record page */
on the record page. The mtr may be
committed and restarted in this call. */
/***********************************************************************
/***********************************************************************
Drops the index tree associated with a row in SYS_INDEXES table. */
Drops the index tree associated with a row in SYS_INDEXES table. */
...
...
innobase/include/page0page.ic
View file @
7252e44b
...
@@ -788,12 +788,15 @@ page_mem_free(
...
@@ -788,12 +788,15 @@ page_mem_free(
page_rec_set_next(rec, free);
page_rec_set_next(rec, free);
page_header_set_ptr(page, PAGE_FREE, rec);
page_header_set_ptr(page, PAGE_FREE, rec);
#if 0 /* It's better not to destroy the user's data. */
/* Clear the data bytes of the deleted record in order to improve
/* Clear the data bytes of the deleted record in order to improve
the compression ratio of the page and to make it easier to read
the compression ratio of the page and to make it easier to read
page dumps in corruption reports. The extra bytes of the record
page dumps in corruption reports. The extra bytes of the record
cannot be cleared, because page_mem_alloc() needs them in order
cannot be cleared, because page_mem_alloc() needs them in order
to determine the size of the deleted record. */
to determine the size of the deleted record. */
memset(rec, 0, rec_offs_data_size(offsets));
memset(rec, 0, rec_offs_data_size(offsets));
#endif
garbage = page_header_get_field(page, PAGE_GARBAGE);
garbage = page_header_get_field(page, PAGE_GARBAGE);
...
...
innobase/log/log0recv.c
View file @
7252e44b
...
@@ -1435,7 +1435,6 @@ recv_apply_hashed_log_recs(
...
@@ -1435,7 +1435,6 @@ recv_apply_hashed_log_recs(
mutex_exit
(
&
(
recv_sys
->
mutex
));
mutex_exit
(
&
(
recv_sys
->
mutex
));
}
}
#ifdef UNIV_HOTBACKUP
/* This page is allocated from the buffer pool and used in the function
/* This page is allocated from the buffer pool and used in the function
below */
below */
static
page_t
*
recv_backup_application_page
=
NULL
;
static
page_t
*
recv_backup_application_page
=
NULL
;
...
@@ -1560,7 +1559,6 @@ recv_apply_log_recs_for_backup(void)
...
@@ -1560,7 +1559,6 @@ recv_apply_log_recs_for_backup(void)
recv_sys_empty_hash
();
recv_sys_empty_hash
();
}
}
#endif
/* UNIV_HOTBACKUP */
#ifdef notdefined
#ifdef notdefined
/***********************************************************************
/***********************************************************************
...
...
innobase/row/row0mysql.c
View file @
7252e44b
...
@@ -2615,6 +2615,7 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */
...
@@ -2615,6 +2615,7 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */
rec_t
*
rec
;
rec_t
*
rec
;
const
byte
*
field
;
const
byte
*
field
;
ulint
len
;
ulint
len
;
ulint
root_page_no
;
if
(
!
btr_pcur_is_on_user_rec
(
&
pcur
,
&
mtr
))
{
if
(
!
btr_pcur_is_on_user_rec
(
&
pcur
,
&
mtr
))
{
/* The end of SYS_INDEXES has been reached. */
/* The end of SYS_INDEXES has been reached. */
...
@@ -2633,11 +2634,33 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */
...
@@ -2633,11 +2634,33 @@ do not allow the TRUNCATE. We also reserve the data dictionary latch. */
if
(
rec_get_deleted_flag
(
rec
,
FALSE
))
{
if
(
rec_get_deleted_flag
(
rec
,
FALSE
))
{
/* The index has been dropped. */
/* The index has been dropped. */
continue
;
goto
next_rec
;
}
}
dict_truncate_index_tree
(
table
,
rec
,
&
mtr
);
btr_pcur_store_position
(
&
pcur
,
&
mtr
);
/* This call may commit and restart mtr. */
root_page_no
=
dict_truncate_index_tree
(
table
,
rec
,
&
mtr
);
btr_pcur_restore_position
(
BTR_MODIFY_LEAF
,
&
pcur
,
&
mtr
);
rec
=
btr_pcur_get_rec
(
&
pcur
);
if
(
root_page_no
!=
FIL_NULL
)
{
page_rec_write_index_page_no
(
rec
,
DICT_SYS_INDEXES_PAGE_NO_FIELD
,
root_page_no
,
&
mtr
);
/* We will need to commit and restart the
mini-transaction in order to avoid deadlocks.
The dict_truncate_index_tree() call has allocated
a page in this mini-transaction, and the rest of
this loop could latch another index page. */
mtr_commit
(
&
mtr
);
mtr_start
(
&
mtr
);
btr_pcur_restore_position
(
BTR_MODIFY_LEAF
,
&
pcur
,
&
mtr
);
}
next_rec:
btr_pcur_move_to_next_user_rec
(
&
pcur
,
&
mtr
);
btr_pcur_move_to_next_user_rec
(
&
pcur
,
&
mtr
);
}
}
...
...
sql/ha_innodb.cc
View file @
7252e44b
...
@@ -4250,6 +4250,8 @@ ha_innobase::delete_all_rows(void)
...
@@ -4250,6 +4250,8 @@ ha_innobase::delete_all_rows(void)
/* Truncate the table in InnoDB */
/* Truncate the table in InnoDB */
trx
->
active_trans
=
1
;
error
=
row_truncate_table_for_mysql
(
prebuilt
->
table
,
trx
);
error
=
row_truncate_table_for_mysql
(
prebuilt
->
table
,
trx
);
if
(
error
==
DB_ERROR
)
{
if
(
error
==
DB_ERROR
)
{
/* Cannot truncate; resort to ha_innobase::delete_row() */
/* Cannot truncate; resort to ha_innobase::delete_row() */
...
...
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