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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
e90a57aa
Commit
e90a57aa
authored
Mar 21, 2002
by
heikki@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Many files:
Merge InnoDB-3.23.50
parent
254df5fd
Changes
40
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
2553 additions
and
652 deletions
+2553
-652
innobase/btr/btr0btr.c
innobase/btr/btr0btr.c
+13
-0
innobase/btr/btr0cur.c
innobase/btr/btr0cur.c
+1
-1
innobase/btr/btr0sea.c
innobase/btr/btr0sea.c
+1
-1
innobase/buf/buf0buf.c
innobase/buf/buf0buf.c
+64
-18
innobase/buf/buf0flu.c
innobase/buf/buf0flu.c
+30
-17
innobase/dict/dict0dict.c
innobase/dict/dict0dict.c
+185
-14
innobase/dict/dict0load.c
innobase/dict/dict0load.c
+10
-1
innobase/fil/fil0fil.c
innobase/fil/fil0fil.c
+75
-5
innobase/fsp/fsp0fsp.c
innobase/fsp/fsp0fsp.c
+171
-10
innobase/include/buf0flu.h
innobase/include/buf0flu.h
+10
-0
innobase/include/dict0dict.h
innobase/include/dict0dict.h
+19
-2
innobase/include/fil0fil.h
innobase/include/fil0fil.h
+19
-2
innobase/include/fsp0fsp.h
innobase/include/fsp0fsp.h
+11
-0
innobase/include/log0log.h
innobase/include/log0log.h
+46
-1
innobase/include/log0recv.h
innobase/include/log0recv.h
+79
-3
innobase/include/mem0mem.h
innobase/include/mem0mem.h
+2
-2
innobase/include/os0file.h
innobase/include/os0file.h
+30
-0
innobase/include/row0mysql.h
innobase/include/row0mysql.h
+7
-7
innobase/include/srv0srv.h
innobase/include/srv0srv.h
+20
-1
innobase/include/srv0start.h
innobase/include/srv0start.h
+50
-0
innobase/include/trx0sys.h
innobase/include/trx0sys.h
+9
-0
innobase/include/ut0byte.h
innobase/include/ut0byte.h
+9
-0
innobase/include/ut0rnd.h
innobase/include/ut0rnd.h
+1
-1
innobase/include/ut0ut.h
innobase/include/ut0ut.h
+19
-0
innobase/log/log0log.c
innobase/log/log0log.c
+154
-7
innobase/log/log0recv.c
innobase/log/log0recv.c
+485
-125
innobase/mem/mem0mem.c
innobase/mem/mem0mem.c
+3
-2
innobase/os/os0file.c
innobase/os/os0file.c
+232
-63
innobase/rem/rem0cmp.c
innobase/rem/rem0cmp.c
+2
-1
innobase/row/row0ins.c
innobase/row/row0ins.c
+30
-1
innobase/row/row0mysql.c
innobase/row/row0mysql.c
+69
-11
innobase/row/row0sel.c
innobase/row/row0sel.c
+21
-5
innobase/row/row0upd.c
innobase/row/row0upd.c
+1
-1
innobase/srv/srv0srv.c
innobase/srv/srv0srv.c
+30
-4
innobase/srv/srv0start.c
innobase/srv/srv0start.c
+351
-23
innobase/trx/trx0sys.c
innobase/trx/trx0sys.c
+36
-0
innobase/ut/ut0mem.c
innobase/ut/ut0mem.c
+1
-0
innobase/ut/ut0ut.c
innobase/ut/ut0ut.c
+63
-14
sql/ha_innobase.cc
sql/ha_innobase.cc
+192
-308
sql/ha_innobase.h
sql/ha_innobase.h
+2
-1
No files found.
innobase/btr/btr0btr.c
View file @
e90a57aa
...
@@ -570,6 +570,19 @@ btr_page_get_father_for_rec(
...
@@ -570,6 +570,19 @@ btr_page_get_father_for_rec(
node_ptr
=
btr_cur_get_rec
(
&
cursor
);
node_ptr
=
btr_cur_get_rec
(
&
cursor
);
if
(
btr_node_ptr_get_child_page_no
(
node_ptr
)
!=
buf_frame_get_page_no
(
page
))
{
fprintf
(
stderr
,
"InnoDB: Corruption of an index tree: table %s, index %s,
\n
"
"InnoDB: father ptr page no %lu, child page no %lu
\n
"
,
(
UT_LIST_GET_FIRST
(
tree
->
tree_indexes
))
->
table_name
,
(
UT_LIST_GET_FIRST
(
tree
->
tree_indexes
))
->
name
,
btr_node_ptr_get_child_page_no
(
node_ptr
),
buf_frame_get_page_no
(
page
));
page_rec_print
(
page_rec_get_next
(
page_get_infimum_rec
(
page
)));
page_rec_print
(
node_ptr
);
}
ut_a
(
btr_node_ptr_get_child_page_no
(
node_ptr
)
==
ut_a
(
btr_node_ptr_get_child_page_no
(
node_ptr
)
==
buf_frame_get_page_no
(
page
));
buf_frame_get_page_no
(
page
));
mem_heap_free
(
heap
);
mem_heap_free
(
heap
);
...
...
innobase/btr/btr0cur.c
View file @
e90a57aa
innobase/btr/btr0sea.c
View file @
e90a57aa
...
@@ -743,7 +743,7 @@ btr_search_guess_on_hash(
...
@@ -743,7 +743,7 @@ btr_search_guess_on_hash(
#ifdef notdefined
#ifdef notdefined
/* These lines of code can be used in a debug version to check
/* These lines of code can be used in a debug version to check
correctness of the searched cursor position: */
the
correctness of the searched cursor position: */
info
->
last_hash_succ
=
FALSE
;
info
->
last_hash_succ
=
FALSE
;
...
...
innobase/buf/buf0buf.c
View file @
e90a57aa
...
@@ -220,6 +220,10 @@ buf_calc_page_checksum(
...
@@ -220,6 +220,10 @@ buf_calc_page_checksum(
{
{
ulint
checksum
;
ulint
checksum
;
/* Since the fields FIL_PAGE_FILE_FLUSH_LSN and ..._ARCH_LOG_NO
are written outside the buffer pool to the first pages of data
files, we have to skip them in page checksum calculation */
checksum
=
ut_fold_binary
(
page
,
FIL_PAGE_FILE_FLUSH_LSN
);
checksum
=
ut_fold_binary
(
page
,
FIL_PAGE_FILE_FLUSH_LSN
);
+
ut_fold_binary
(
page
+
FIL_PAGE_DATA
,
+
ut_fold_binary
(
page
+
FIL_PAGE_DATA
,
UNIV_PAGE_SIZE
-
FIL_PAGE_DATA
UNIV_PAGE_SIZE
-
FIL_PAGE_DATA
...
@@ -279,8 +283,9 @@ buf_page_print(
...
@@ -279,8 +283,9 @@ buf_page_print(
ut_sprintf_buf
(
buf
,
read_buf
,
UNIV_PAGE_SIZE
);
ut_sprintf_buf
(
buf
,
read_buf
,
UNIV_PAGE_SIZE
);
ut_print_timestamp
(
stderr
);
fprintf
(
stderr
,
fprintf
(
stderr
,
"InnoDB: Page dump in ascii and hex (%lu bytes):
\n
%s"
,
"
InnoDB: Page dump in ascii and hex (%lu bytes):
\n
%s"
,
UNIV_PAGE_SIZE
,
buf
);
UNIV_PAGE_SIZE
,
buf
);
fprintf
(
stderr
,
"InnoDB: End of page dump
\n
"
);
fprintf
(
stderr
,
"InnoDB: End of page dump
\n
"
);
...
@@ -288,7 +293,8 @@ buf_page_print(
...
@@ -288,7 +293,8 @@ buf_page_print(
checksum
=
buf_calc_page_checksum
(
read_buf
);
checksum
=
buf_calc_page_checksum
(
read_buf
);
fprintf
(
stderr
,
"InnoDB: Page checksum %lu stored checksum %lu
\n
"
,
ut_print_timestamp
(
stderr
);
fprintf
(
stderr
,
" InnoDB: Page checksum %lu stored checksum %lu
\n
"
,
checksum
,
mach_read_from_4
(
read_buf
checksum
,
mach_read_from_4
(
read_buf
+
UNIV_PAGE_SIZE
+
UNIV_PAGE_SIZE
-
FIL_PAGE_END_LSN
));
-
FIL_PAGE_END_LSN
));
...
@@ -1358,21 +1364,51 @@ buf_page_io_complete(
...
@@ -1358,21 +1364,51 @@ buf_page_io_complete(
/*=================*/
/*=================*/
buf_block_t
*
block
)
/* in: pointer to the block in question */
buf_block_t
*
block
)
/* in: pointer to the block in question */
{
{
dulint
id
;
dict_index_t
*
index
;
dict_index_t
*
index
;
dulint
id
;
ulint
io_type
;
ulint
io_type
;
ulint
read_page_no
;
ut_ad
(
block
);
ut_ad
(
block
);
io_type
=
block
->
io_fix
;
io_type
=
block
->
io_fix
;
if
(
io_type
==
BUF_IO_READ
)
{
if
(
io_type
==
BUF_IO_READ
)
{
/* If this page is not uninitialized and not in the
doublewrite buffer, then the page number should be the
same as in block */
read_page_no
=
mach_read_from_4
((
block
->
frame
)
+
FIL_PAGE_OFFSET
);
if
(
read_page_no
!=
0
&&
!
trx_doublewrite_page_inside
(
read_page_no
)
&&
read_page_no
!=
block
->
offset
)
{
fprintf
(
stderr
,
"InnoDB: Error: page n:o stored in the page read in is %lu, should be %lu!
\n
"
,
read_page_no
,
block
->
offset
);
}
#ifdef notdefined
if
(
block
->
offset
!=
0
&&
read_page_no
==
0
)
{
/* Check that the page is really uninited */
for
(
i
=
0
;
i
<
UNIV_PAGE_SIZE
;
i
++
)
{
if
(
*
((
block
->
frame
)
+
i
)
!=
'\0'
)
{
fprintf
(
stderr
,
"InnoDB: Error: page n:o in the page read in is 0, but page %lu is inited!
\n
"
,
block
->
offset
);
break
;
}
}
}
#endif
/* From version 3.23.38 up we store the page checksum
/* From version 3.23.38 up we store the page checksum
to the 4
upper
bytes of the page end lsn field */
to the 4
first
bytes of the page end lsn field */
if
(
buf_page_is_corrupted
(
block
->
frame
))
{
if
(
buf_page_is_corrupted
(
block
->
frame
))
{
fprintf
(
stderr
,
fprintf
(
stderr
,
"InnoDB: Database page corruption
or a failed
\n
"
"InnoDB: Database page corruption on disk
or a failed
\n
"
"InnoDB: file read of page %lu.
\n
"
,
block
->
offset
);
"InnoDB: file read of page %lu.
\n
"
,
block
->
offset
);
fprintf
(
stderr
,
fprintf
(
stderr
,
...
@@ -1381,7 +1417,7 @@ buf_page_io_complete(
...
@@ -1381,7 +1417,7 @@ buf_page_io_complete(
buf_page_print
(
block
->
frame
);
buf_page_print
(
block
->
frame
);
fprintf
(
stderr
,
fprintf
(
stderr
,
"InnoDB: Database page corruption
or a failed
\n
"
"InnoDB: Database page corruption on disk
or a failed
\n
"
"InnoDB: file read of page %lu.
\n
"
,
block
->
offset
);
"InnoDB: file read of page %lu.
\n
"
,
block
->
offset
);
fprintf
(
stderr
,
fprintf
(
stderr
,
"InnoDB: You may have to recover from a backup.
\n
"
);
"InnoDB: You may have to recover from a backup.
\n
"
);
...
@@ -1389,16 +1425,26 @@ buf_page_io_complete(
...
@@ -1389,16 +1425,26 @@ buf_page_io_complete(
"InnoDB: It is also possible that your operating
\n
"
"InnoDB: It is also possible that your operating
\n
"
"InnoDB: system has corrupted its own file cache
\n
"
"InnoDB: system has corrupted its own file cache
\n
"
"InnoDB: and rebooting your computer removes the
\n
"
"InnoDB: and rebooting your computer removes the
\n
"
"InnoDB: error.
\n
"
);
"InnoDB: error.
\n
"
"InnoDB: If the corrupt page is an index page
\n
"
"InnoDB: you can also try to fix the corruption
\n
"
"InnoDB: by dumping, dropping, and reimporting
\n
"
"InnoDB: the corrupt table. You can use CHECK
\n
"
"InnoDB: TABLE to scan your table for corruption.
\n
"
"InnoDB: Look also at section 6.1 of
\n
"
"InnoDB: http://www.innodb.com/ibman.html about
\n
"
"InnoDB: forcing recovery.
\n
"
);
if
(
srv_force_recovery
<
SRV_FORCE_IGNORE_CORRUPT
)
{
if
(
srv_force_recovery
<
SRV_FORCE_IGNORE_CORRUPT
)
{
fprintf
(
stderr
,
"InnoDB: Ending processing because of a corrupt database page.
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
}
}
if
(
recv_recovery_is_on
())
{
if
(
recv_recovery_is_on
())
{
recv_recover_page
(
TRUE
,
block
->
frame
,
block
->
spac
e
,
recv_recover_page
(
FALSE
,
TRUE
,
block
->
fram
e
,
block
->
offset
);
block
->
space
,
block
->
offset
);
}
}
if
(
!
recv_no_ibuf_operations
)
{
if
(
!
recv_no_ibuf_operations
)
{
...
...
innobase/buf/buf0flu.c
View file @
e90a57aa
...
@@ -327,6 +327,34 @@ try_again:
...
@@ -327,6 +327,34 @@ try_again:
mutex_exit
(
&
(
trx_doublewrite
->
mutex
));
mutex_exit
(
&
(
trx_doublewrite
->
mutex
));
}
}
/************************************************************************
Initializes a page for writing to the tablespace. */
void
buf_flush_init_for_writing
(
/*=======================*/
byte
*
page
,
/* in: page */
dulint
newest_lsn
,
/* in: newest modification lsn to the page */
ulint
space
,
/* in: space id */
ulint
page_no
)
/* in: page number */
{
/* Write the newest modification lsn to the page */
mach_write_to_8
(
page
+
FIL_PAGE_LSN
,
newest_lsn
);
mach_write_to_8
(
page
+
UNIV_PAGE_SIZE
-
FIL_PAGE_END_LSN
,
newest_lsn
);
/* Write to the page the space id and page number */
mach_write_to_4
(
page
+
FIL_PAGE_SPACE
,
space
);
mach_write_to_4
(
page
+
FIL_PAGE_OFFSET
,
page_no
);
/* We overwrite the first 4 bytes of the end lsn field to store
a page checksum */
mach_write_to_4
(
page
+
UNIV_PAGE_SIZE
-
FIL_PAGE_END_LSN
,
buf_calc_page_checksum
(
page
));
}
/************************************************************************
/************************************************************************
Does an asynchronous write of a buffer page. NOTE: in simulated aio and
Does an asynchronous write of a buffer page. NOTE: in simulated aio and
also when the doublewrite buffer is used, we must call
also when the doublewrite buffer is used, we must call
...
@@ -349,23 +377,8 @@ buf_flush_write_block_low(
...
@@ -349,23 +377,8 @@ buf_flush_write_block_low(
/* Force the log to the disk before writing the modified block */
/* Force the log to the disk before writing the modified block */
log_flush_up_to
(
block
->
newest_modification
,
LOG_WAIT_ALL_GROUPS
);
log_flush_up_to
(
block
->
newest_modification
,
LOG_WAIT_ALL_GROUPS
);
#endif
#endif
/* Write the newest modification lsn to the page */
buf_flush_init_for_writing
(
block
->
frame
,
block
->
newest_modification
,
mach_write_to_8
(
block
->
frame
+
FIL_PAGE_LSN
,
block
->
space
,
block
->
offset
);
block
->
newest_modification
);
mach_write_to_8
(
block
->
frame
+
UNIV_PAGE_SIZE
-
FIL_PAGE_END_LSN
,
block
->
newest_modification
);
/* Write to the page the space id and page number */
mach_write_to_4
(
block
->
frame
+
FIL_PAGE_SPACE
,
block
->
space
);
mach_write_to_4
(
block
->
frame
+
FIL_PAGE_OFFSET
,
block
->
offset
);
/* We overwrite the first 4 bytes of the end lsn field to store
a page checksum */
mach_write_to_4
(
block
->
frame
+
UNIV_PAGE_SIZE
-
FIL_PAGE_END_LSN
,
buf_calc_page_checksum
(
block
->
frame
));
if
(
!
trx_doublewrite
)
{
if
(
!
trx_doublewrite
)
{
fil_io
(
OS_FILE_WRITE
|
OS_AIO_SIMULATED_WAKE_LATER
,
fil_io
(
OS_FILE_WRITE
|
OS_AIO_SIMULATED_WAKE_LATER
,
FALSE
,
block
->
space
,
block
->
offset
,
0
,
UNIV_PAGE_SIZE
,
FALSE
,
block
->
space
,
block
->
offset
,
0
,
UNIV_PAGE_SIZE
,
...
...
innobase/dict/dict0dict.c
View file @
e90a57aa
...
@@ -281,7 +281,8 @@ dict_table_autoinc_initialize(
...
@@ -281,7 +281,8 @@ dict_table_autoinc_initialize(
}
}
/************************************************************************
/************************************************************************
Gets the next autoinc value, 0 if not yet initialized. */
Gets the next autoinc value, 0 if not yet initialized. If initialized,
increments the counter by 1. */
ib_longlong
ib_longlong
dict_table_autoinc_get
(
dict_table_autoinc_get
(
...
@@ -306,6 +307,32 @@ dict_table_autoinc_get(
...
@@ -306,6 +307,32 @@ dict_table_autoinc_get(
return
(
value
);
return
(
value
);
}
}
/************************************************************************
Reads the autoinc counter value, 0 if not yet initialized. Does not
increment the counter. */
ib_longlong
dict_table_autoinc_read
(
/*====================*/
/* out: value of the counter */
dict_table_t
*
table
)
/* in: table */
{
ib_longlong
value
;
mutex_enter
(
&
(
table
->
autoinc_mutex
));
if
(
!
table
->
autoinc_inited
)
{
value
=
0
;
}
else
{
value
=
table
->
autoinc
;
}
mutex_exit
(
&
(
table
->
autoinc_mutex
));
return
(
value
);
}
/************************************************************************
/************************************************************************
Updates the autoinc counter if the value supplied is bigger than the
Updates the autoinc counter if the value supplied is bigger than the
current value. If not inited, does nothing. */
current value. If not inited, does nothing. */
...
@@ -644,7 +671,10 @@ dict_table_rename_in_cache(
...
@@ -644,7 +671,10 @@ dict_table_rename_in_cache(
/*=======================*/
/*=======================*/
/* out: TRUE if success */
/* out: TRUE if success */
dict_table_t
*
table
,
/* in: table */
dict_table_t
*
table
,
/* in: table */
char
*
new_name
)
/* in: new name */
char
*
new_name
,
/* in: new name */
ibool
rename_also_foreigns
)
/* in: in ALTER TABLE we want
to preserve the original table name
in constraints which reference it */
{
{
dict_foreign_t
*
foreign
;
dict_foreign_t
*
foreign
;
dict_index_t
*
index
;
dict_index_t
*
index
;
...
@@ -702,6 +732,41 @@ dict_table_rename_in_cache(
...
@@ -702,6 +732,41 @@ dict_table_rename_in_cache(
index
=
dict_table_get_next_index
(
index
);
index
=
dict_table_get_next_index
(
index
);
}
}
if
(
!
rename_also_foreigns
)
{
/* In ALTER TABLE we think of the rename table operation
in the direction table -> temporary table (#sql...)
as dropping the table with the old name and creating
a new with the new name. Thus we kind of drop the
constraints from the dictionary cache here. The foreign key
constraints will be inherited to the new table from the
system tables through a call of dict_load_foreigns. */
/* Remove the foreign constraints from the cache */
foreign
=
UT_LIST_GET_LAST
(
table
->
foreign_list
);
while
(
foreign
!=
NULL
)
{
dict_foreign_remove_from_cache
(
foreign
);
foreign
=
UT_LIST_GET_LAST
(
table
->
foreign_list
);
}
/* Reset table field in referencing constraints */
foreign
=
UT_LIST_GET_FIRST
(
table
->
referenced_list
);
while
(
foreign
!=
NULL
)
{
foreign
->
referenced_table
=
NULL
;
foreign
->
referenced_index
=
NULL
;
foreign
=
UT_LIST_GET_NEXT
(
referenced_list
,
foreign
);
}
/* Make the list of referencing constraints empty */
UT_LIST_INIT
(
table
->
referenced_list
);
return
(
TRUE
);
}
/* Update the table name fields in foreign constraints */
/* Update the table name fields in foreign constraints */
foreign
=
UT_LIST_GET_FIRST
(
table
->
foreign_list
);
foreign
=
UT_LIST_GET_FIRST
(
table
->
foreign_list
);
...
@@ -768,8 +833,6 @@ dict_table_remove_from_cache(
...
@@ -768,8 +833,6 @@ dict_table_remove_from_cache(
foreign
=
UT_LIST_GET_LAST
(
table
->
foreign_list
);
foreign
=
UT_LIST_GET_LAST
(
table
->
foreign_list
);
while
(
foreign
!=
NULL
)
{
while
(
foreign
!=
NULL
)
{
ut_a
(
0
==
ut_strcmp
(
foreign
->
foreign_table_name
,
table
->
name
));
dict_foreign_remove_from_cache
(
foreign
);
dict_foreign_remove_from_cache
(
foreign
);
foreign
=
UT_LIST_GET_LAST
(
table
->
foreign_list
);
foreign
=
UT_LIST_GET_LAST
(
table
->
foreign_list
);
}
}
...
@@ -779,8 +842,6 @@ dict_table_remove_from_cache(
...
@@ -779,8 +842,6 @@ dict_table_remove_from_cache(
foreign
=
UT_LIST_GET_FIRST
(
table
->
referenced_list
);
foreign
=
UT_LIST_GET_FIRST
(
table
->
referenced_list
);
while
(
foreign
!=
NULL
)
{
while
(
foreign
!=
NULL
)
{
ut_a
(
0
==
ut_strcmp
(
foreign
->
referenced_table_name
,
table
->
name
));
foreign
->
referenced_table
=
NULL
;
foreign
->
referenced_table
=
NULL
;
foreign
->
referenced_index
=
NULL
;
foreign
->
referenced_index
=
NULL
;
...
@@ -1630,6 +1691,7 @@ dict_foreign_add_to_cache(
...
@@ -1630,6 +1691,7 @@ dict_foreign_add_to_cache(
dict_table_t
*
ref_table
;
dict_table_t
*
ref_table
;
dict_foreign_t
*
for_in_cache
=
NULL
;
dict_foreign_t
*
for_in_cache
=
NULL
;
dict_index_t
*
index
;
dict_index_t
*
index
;
ibool
added_to_referenced_list
=
FALSE
;
ut_ad
(
mutex_own
(
&
(
dict_sys
->
mutex
)));
ut_ad
(
mutex_own
(
&
(
dict_sys
->
mutex
)));
...
@@ -1673,6 +1735,7 @@ dict_foreign_add_to_cache(
...
@@ -1673,6 +1735,7 @@ dict_foreign_add_to_cache(
UT_LIST_ADD_LAST
(
referenced_list
,
UT_LIST_ADD_LAST
(
referenced_list
,
ref_table
->
referenced_list
,
ref_table
->
referenced_list
,
for_in_cache
);
for_in_cache
);
added_to_referenced_list
=
TRUE
;
}
}
if
(
for_in_cache
->
foreign_table
==
NULL
&&
for_table
)
{
if
(
for_in_cache
->
foreign_table
==
NULL
&&
for_table
)
{
...
@@ -1683,6 +1746,12 @@ dict_foreign_add_to_cache(
...
@@ -1683,6 +1746,12 @@ dict_foreign_add_to_cache(
if
(
index
==
NULL
)
{
if
(
index
==
NULL
)
{
if
(
for_in_cache
==
foreign
)
{
if
(
for_in_cache
==
foreign
)
{
if
(
added_to_referenced_list
)
{
UT_LIST_REMOVE
(
referenced_list
,
ref_table
->
referenced_list
,
for_in_cache
);
}
mem_heap_free
(
foreign
->
heap
);
mem_heap_free
(
foreign
->
heap
);
}
}
...
@@ -1802,9 +1871,14 @@ dict_scan_col(
...
@@ -1802,9 +1871,14 @@ dict_scan_col(
return
(
ptr
);
return
(
ptr
);
}
}
if
(
*
ptr
==
'`'
)
{
ptr
++
;
}
old_ptr
=
ptr
;
old_ptr
=
ptr
;
while
(
!
isspace
(
*
ptr
)
&&
*
ptr
!=
','
&&
*
ptr
!=
')'
)
{
while
(
!
isspace
(
*
ptr
)
&&
*
ptr
!=
','
&&
*
ptr
!=
')'
&&
*
ptr
!=
'`'
)
{
ptr
++
;
ptr
++
;
}
}
...
@@ -1825,6 +1899,10 @@ dict_scan_col(
...
@@ -1825,6 +1899,10 @@ dict_scan_col(
}
}
}
}
if
(
*
ptr
==
'`'
)
{
ptr
++
;
}
return
(
ptr
);
return
(
ptr
);
}
}
...
@@ -1855,9 +1933,13 @@ dict_scan_table_name(
...
@@ -1855,9 +1933,13 @@ dict_scan_table_name(
return
(
ptr
);
return
(
ptr
);
}
}
if
(
*
ptr
==
'`'
)
{
ptr
++
;
}
old_ptr
=
ptr
;
old_ptr
=
ptr
;
while
(
!
isspace
(
*
ptr
)
&&
*
ptr
!=
'('
)
{
while
(
!
isspace
(
*
ptr
)
&&
*
ptr
!=
'('
&&
*
ptr
!=
'`'
)
{
if
(
*
ptr
==
'.'
)
{
if
(
*
ptr
==
'.'
)
{
dot_ptr
=
ptr
;
dot_ptr
=
ptr
;
}
}
...
@@ -1898,6 +1980,10 @@ dict_scan_table_name(
...
@@ -1898,6 +1980,10 @@ dict_scan_table_name(
*
table
=
dict_table_get_low
(
second_table_name
);
*
table
=
dict_table_get_low
(
second_table_name
);
if
(
*
ptr
==
'`'
)
{
ptr
++
;
}
return
(
ptr
);
return
(
ptr
);
}
}
...
@@ -1940,8 +2026,8 @@ dict_create_foreign_constraints(
...
@@ -1940,8 +2026,8 @@ dict_create_foreign_constraints(
/*============================*/
/*============================*/
/* out: error code or DB_SUCCESS */
/* out: error code or DB_SUCCESS */
trx_t
*
trx
,
/* in: transaction */
trx_t
*
trx
,
/* in: transaction */
char
*
sql_string
,
/* in: table create
statement where
char
*
sql_string
,
/* in: table create
or ALTER TABLE
foreign keys are declared like:
statement where
foreign keys are declared like:
FOREIGN KEY (a, b) REFERENCES table2(c, d),
FOREIGN KEY (a, b) REFERENCES table2(c, d),
table2 can be written also with the database
table2 can be written also with the database
name before it: test.table2; the default
name before it: test.table2; the default
...
@@ -1967,10 +2053,11 @@ dict_create_foreign_constraints(
...
@@ -1967,10 +2053,11 @@ dict_create_foreign_constraints(
if
(
table
==
NULL
)
{
if
(
table
==
NULL
)
{
return
(
DB_ERROR
);
return
(
DB_ERROR
);
}
}
loop:
loop:
ptr
=
dict_scan_to
(
ptr
,
"FOREIGN"
);
ptr
=
dict_scan_to
(
ptr
,
"FOREIGN"
);
if
(
*
ptr
==
'\0'
||
dict_bracket_count
(
sql_string
,
ptr
)
!=
1
)
{
if
(
*
ptr
==
'\0'
)
{
/* The following call adds the foreign key constraints
/* The following call adds the foreign key constraints
to the data dictionary system tables on disk */
to the data dictionary system tables on disk */
...
@@ -2883,12 +2970,89 @@ dict_field_print_low(
...
@@ -2883,12 +2970,89 @@ dict_field_print_low(
printf
(
" %s"
,
field
->
name
);
printf
(
" %s"
,
field
->
name
);
}
}
/**************************************************************************
Sprintfs to a string info on foreign keys of a table in a format suitable
for CREATE TABLE. */
static
void
dict_print_info_on_foreign_keys_in_create_format
(
/*=============================================*/
char
*
buf
,
/* in: auxiliary buffer of 10000 chars */
char
*
str
,
/* in/out: pointer to a string */
ulint
len
,
/* in: space in str available for info */
dict_table_t
*
table
)
/* in: table */
{
dict_foreign_t
*
foreign
;
ulint
i
;
char
*
buf2
;
buf2
=
buf
;
mutex_enter
(
&
(
dict_sys
->
mutex
));
foreign
=
UT_LIST_GET_FIRST
(
table
->
foreign_list
);
if
(
foreign
==
NULL
)
{
mutex_exit
(
&
(
dict_sys
->
mutex
));
return
;
}
while
(
foreign
!=
NULL
)
{
buf2
+=
sprintf
(
buf2
,
",
\n
FOREIGN KEY ("
);
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
buf2
+=
sprintf
(
buf2
,
"`%s`"
,
foreign
->
foreign_col_names
[
i
]);
if
(
i
+
1
<
foreign
->
n_fields
)
{
buf2
+=
sprintf
(
buf2
,
", "
);
}
}
buf2
+=
sprintf
(
buf2
,
") REFERENCES `%s` ("
,
foreign
->
referenced_table_name
);
/* Change the '/' in the table name to '.' */
for
(
i
=
ut_strlen
(
buf
);
i
>
0
;
i
--
)
{
if
(
buf
[
i
]
==
'/'
)
{
buf
[
i
]
=
'.'
;
break
;
}
}
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
buf2
+=
sprintf
(
buf2
,
"`%s`"
,
foreign
->
referenced_col_names
[
i
]);
if
(
i
+
1
<
foreign
->
n_fields
)
{
buf2
+=
sprintf
(
buf2
,
", "
);
}
}
buf2
+=
sprintf
(
buf2
,
")"
);
foreign
=
UT_LIST_GET_NEXT
(
foreign_list
,
foreign
);
}
mutex_exit
(
&
(
dict_sys
->
mutex
));
buf
[
len
-
1
]
=
'\0'
;
ut_memcpy
(
str
,
buf
,
len
);
}
/**************************************************************************
/**************************************************************************
Sprintfs to a string info on foreign keys of a table. */
Sprintfs to a string info on foreign keys of a table. */
void
void
dict_print_info_on_foreign_keys
(
dict_print_info_on_foreign_keys
(
/*============================*/
/*============================*/
ibool
create_table_format
,
/* in: if TRUE then print in
a format suitable to be inserted into
a CREATE TABLE, otherwise in the format
of SHOW TABLE STATUS */
char
*
str
,
/* in/out: pointer to a string */
char
*
str
,
/* in/out: pointer to a string */
ulint
len
,
/* in: space in str available for info */
ulint
len
,
/* in: space in str available for info */
dict_table_t
*
table
)
/* in: table */
dict_table_t
*
table
)
/* in: table */
...
@@ -2898,6 +3062,12 @@ dict_print_info_on_foreign_keys(
...
@@ -2898,6 +3062,12 @@ dict_print_info_on_foreign_keys(
char
*
buf2
;
char
*
buf2
;
char
buf
[
10000
];
char
buf
[
10000
];
if
(
create_table_format
)
{
dict_print_info_on_foreign_keys_in_create_format
(
buf
,
str
,
len
,
table
);
return
;
}
buf2
=
buf
;
buf2
=
buf
;
mutex_enter
(
&
(
dict_sys
->
mutex
));
mutex_enter
(
&
(
dict_sys
->
mutex
));
...
@@ -2916,6 +3086,7 @@ dict_print_info_on_foreign_keys(
...
@@ -2916,6 +3086,7 @@ dict_print_info_on_foreign_keys(
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
buf2
+=
sprintf
(
buf2
,
"%s"
,
buf2
+=
sprintf
(
buf2
,
"%s"
,
foreign
->
foreign_col_names
[
i
]);
foreign
->
foreign_col_names
[
i
]);
if
(
i
+
1
<
foreign
->
n_fields
)
{
if
(
i
+
1
<
foreign
->
n_fields
)
{
buf2
+=
sprintf
(
buf2
,
" "
);
buf2
+=
sprintf
(
buf2
,
" "
);
}
}
...
...
innobase/dict/dict0load.c
View file @
e90a57aa
...
@@ -688,8 +688,17 @@ dict_load_indexes(
...
@@ -688,8 +688,17 @@ dict_load_indexes(
dict_load_fields
(
table
,
index
,
heap
);
dict_load_fields
(
table
,
index
,
heap
);
if
(
index
->
type
&
DICT_CLUSTERED
==
0
&&
NULL
==
dict_table_get_first_index
(
table
))
{
fprintf
(
stderr
,
"InnoDB: Error: trying to load index %s for table %s
\n
"
"InnoDB: but the first index was not clustered
\n
"
,
index
->
name
,
table
->
name
);
}
else
{
dict_index_add_to_cache
(
table
,
index
);
dict_index_add_to_cache
(
table
,
index
);
}
}
}
btr_pcur_move_to_next_user_rec
(
&
pcur
,
&
mtr
);
btr_pcur_move_to_next_user_rec
(
&
pcur
,
&
mtr
);
}
}
...
...
innobase/fil/fil0fil.c
View file @
e90a57aa
...
@@ -89,8 +89,8 @@ struct fil_node_struct {
...
@@ -89,8 +89,8 @@ struct fil_node_struct {
char
*
name
;
/* the file name or path */
char
*
name
;
/* the file name or path */
ibool
open
;
/* TRUE if file open */
ibool
open
;
/* TRUE if file open */
os_file_t
handle
;
/* OS handle to the file, if file open */
os_file_t
handle
;
/* OS handle to the file, if file open */
ulint
size
;
/* size of the file in database
block
s
ulint
size
;
/* size of the file in database
page
s
(where the possible last incomplete
block
(where the possible last incomplete
megabyte
is ignored) */
is ignored) */
ulint
n_pending
;
ulint
n_pending
;
/* count of pending i/o-ops on this file */
/* count of pending i/o-ops on this file */
...
@@ -945,6 +945,76 @@ fil_node_complete_io(
...
@@ -945,6 +945,76 @@ fil_node_complete_io(
}
}
}
}
/**************************************************************************
Tries to extend a data file by the number of pages given. Any fractions of a
megabyte are ignored. */
ibool
fil_extend_last_data_file
(
/*======================*/
/* out: TRUE if success, also if we run
out of disk space we may return TRUE */
ulint
*
actual_increase
,
/* out: number of pages we were able to
extend, here the orginal size of the file and
the resulting size of the file are rounded
downwards to a full megabyte, and the
difference expressed in pages is returned */
ulint
size_increase
)
/* in: try to extend this many pages */
{
fil_node_t
*
node
;
fil_space_t
*
space
;
fil_system_t
*
system
=
fil_system
;
byte
*
buf
;
ibool
success
;
ulint
i
;
mutex_enter
(
&
(
system
->
mutex
));
HASH_SEARCH
(
hash
,
system
->
spaces
,
0
,
space
,
space
->
id
==
0
);
ut_a
(
space
);
node
=
UT_LIST_GET_LAST
(
space
->
chain
);
fil_node_prepare_for_io
(
node
,
system
,
space
);
buf
=
mem_alloc
(
1024
*
1024
);
memset
(
buf
,
'\0'
,
1024
*
1024
);
for
(
i
=
0
;
i
<
size_increase
/
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
i
++
)
{
success
=
os_file_write
(
node
->
name
,
node
->
handle
,
buf
,
(
node
->
size
<<
UNIV_PAGE_SIZE_SHIFT
)
&
0xFFFFFFFF
,
node
->
size
>>
(
32
-
UNIV_PAGE_SIZE_SHIFT
),
1024
*
1024
);
if
(
!
success
)
{
break
;
}
node
->
size
+=
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
space
->
size
+=
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
os_has_said_disk_full
=
FALSE
;
}
mem_free
(
buf
);
fil_node_complete_io
(
node
,
system
,
OS_FILE_WRITE
);
mutex_exit
(
&
(
system
->
mutex
));
*
actual_increase
=
i
*
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
fil_flush
(
0
);
srv_data_file_sizes
[
srv_n_data_files
-
1
]
+=
*
actual_increase
;
return
(
TRUE
);
}
/************************************************************************
/************************************************************************
Reads or writes data. This operation is asynchronous (aio). */
Reads or writes data. This operation is asynchronous (aio). */
...
@@ -966,9 +1036,9 @@ fil_io(
...
@@ -966,9 +1036,9 @@ fil_io(
ulint
byte_offset
,
/* in: remainder of offset in bytes; in
ulint
byte_offset
,
/* in: remainder of offset in bytes; in
aio this must be divisible by the OS block
aio this must be divisible by the OS block
size */
size */
ulint
len
,
/* in: how many bytes to read
; this must
ulint
len
,
/* in: how many bytes to read
or write; this
not cross a file boundary; in aio this must
must not cross a file boundary; in aio this
be a block size multiple */
must
be a block size multiple */
void
*
buf
,
/* in/out: buffer where to store read data
void
*
buf
,
/* in/out: buffer where to store read data
or from where to write; in aio this must be
or from where to write; in aio this must be
appropriately aligned */
appropriately aligned */
...
...
innobase/fsp/fsp0fsp.c
View file @
e90a57aa
...
@@ -50,7 +50,7 @@ descriptor page, but used only in the first. */
...
@@ -50,7 +50,7 @@ descriptor page, but used only in the first. */
#define FSP_FREE_LIMIT 12
/* Minimum page number for which the
#define FSP_FREE_LIMIT 12
/* Minimum page number for which the
free list has not been initialized:
free list has not been initialized:
the pages >= this limit are, by
the pages >= this limit are, by
definition free */
definition
,
free */
#define FSP_LOWEST_NO_WRITE 16
/* The lowest page offset for which
#define FSP_LOWEST_NO_WRITE 16
/* The lowest page offset for which
the page has not been written to disk
the page has not been written to disk
(if it has been written, we know that
(if it has been written, we know that
...
@@ -898,6 +898,106 @@ fsp_header_inc_size(
...
@@ -898,6 +898,106 @@ fsp_header_inc_size(
mlog_write_ulint
(
header
+
FSP_SIZE
,
size
+
size_inc
,
MLOG_4BYTES
,
mtr
);
mlog_write_ulint
(
header
+
FSP_SIZE
,
size
+
size_inc
,
MLOG_4BYTES
,
mtr
);
}
}
/**************************************************************************
Gets the current free limit of a tablespace. The free limit means the
place of the first page which has never been put to the the free list
for allocation. The space above that address is initialized to zero.
Sets also the global variable log_fsp_current_free_limit. */
ulint
fsp_header_get_free_limit
(
/*======================*/
/* out: free limit in megabytes */
ulint
space
)
/* in: space id */
{
fsp_header_t
*
header
;
ulint
limit
;
mtr_t
mtr
;
ut_a
(
space
==
0
);
/* We have only one log_fsp_current_... variable */
mtr_start
(
&
mtr
);
mtr_x_lock
(
fil_space_get_latch
(
space
),
&
mtr
);
header
=
fsp_get_space_header
(
space
,
&
mtr
);
limit
=
mtr_read_ulint
(
header
+
FSP_FREE_LIMIT
,
MLOG_4BYTES
,
&
mtr
);
limit
=
limit
/
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
log_fsp_current_free_limit_set_and_checkpoint
(
limit
);
mtr_commit
(
&
mtr
);
return
(
limit
);
}
/***************************************************************************
Tries to extend the last data file file if it is defined as auto-extending. */
static
ibool
fsp_try_extend_last_file
(
/*=====================*/
/* out: FALSE if not auto-extending */
ulint
*
actual_increase
,
/* out: actual increase in pages */
ulint
space
,
/* in: space */
fsp_header_t
*
header
,
/* in: space header */
mtr_t
*
mtr
)
/* in: mtr */
{
ulint
size
;
ulint
size_increase
;
ibool
success
;
ut_a
(
space
==
0
);
*
actual_increase
=
0
;
if
(
!
srv_auto_extend_last_data_file
)
{
return
(
FALSE
);
}
size
=
mtr_read_ulint
(
header
+
FSP_SIZE
,
MLOG_4BYTES
,
mtr
);
if
(
srv_last_file_size_max
!=
0
)
{
if
(
srv_last_file_size_max
<
srv_data_file_sizes
[
srv_n_data_files
-
1
])
{
fprintf
(
stderr
,
"InnoDB: Error: Last data file size is %lu, max size allowed %lu
\n
"
,
srv_data_file_sizes
[
srv_n_data_files
-
1
],
srv_last_file_size_max
);
}
size_increase
=
srv_last_file_size_max
-
srv_data_file_sizes
[
srv_n_data_files
-
1
];
if
(
size_increase
>
SRV_AUTO_EXTEND_INCREMENT
)
{
size_increase
=
SRV_AUTO_EXTEND_INCREMENT
;
}
}
else
{
size_increase
=
SRV_AUTO_EXTEND_INCREMENT
;
}
if
(
size_increase
==
0
)
{
return
(
TRUE
);
}
/* Extend the data file. If we are not able to extend
the full requested length, the function tells us
the number of full megabytes (but the unit is pages!)
we were able to extend. */
success
=
fil_extend_last_data_file
(
actual_increase
,
size_increase
);
if
(
success
)
{
mlog_write_ulint
(
header
+
FSP_SIZE
,
size
+
*
actual_increase
,
MLOG_4BYTES
,
mtr
);
}
return
(
TRUE
);
}
/**************************************************************************
/**************************************************************************
Puts new extents to the free list if there are free extents above the free
Puts new extents to the free list if there are free extents above the free
limit. If an extent happens to contain an extent descriptor page, the extent
limit. If an extent happens to contain an extent descriptor page, the extent
...
@@ -917,8 +1017,9 @@ fsp_fill_free_list(
...
@@ -917,8 +1017,9 @@ fsp_fill_free_list(
ulint
frag_n_used
;
ulint
frag_n_used
;
page_t
*
descr_page
;
page_t
*
descr_page
;
page_t
*
ibuf_page
;
page_t
*
ibuf_page
;
mtr_t
ibuf_mtr
;
ulint
actual_increase
;
ulint
i
;
ulint
i
;
mtr_t
ibuf_mtr
;
ut_ad
(
header
&&
mtr
);
ut_ad
(
header
&&
mtr
);
...
@@ -926,12 +1027,28 @@ fsp_fill_free_list(
...
@@ -926,12 +1027,28 @@ fsp_fill_free_list(
size
=
mtr_read_ulint
(
header
+
FSP_SIZE
,
MLOG_4BYTES
,
mtr
);
size
=
mtr_read_ulint
(
header
+
FSP_SIZE
,
MLOG_4BYTES
,
mtr
);
limit
=
mtr_read_ulint
(
header
+
FSP_FREE_LIMIT
,
MLOG_4BYTES
,
mtr
);
limit
=
mtr_read_ulint
(
header
+
FSP_FREE_LIMIT
,
MLOG_4BYTES
,
mtr
);
if
(
srv_auto_extend_last_data_file
&&
size
<
limit
+
FSP_EXTENT_SIZE
*
FSP_FREE_ADD
)
{
/* Try to increase the last data file size */
fsp_try_extend_last_file
(
&
actual_increase
,
space
,
header
,
mtr
);
size
=
mtr_read_ulint
(
header
+
FSP_SIZE
,
MLOG_4BYTES
,
mtr
);
}
i
=
limit
;
i
=
limit
;
while
((
i
+
FSP_EXTENT_SIZE
<=
size
)
&&
(
count
<
FSP_FREE_ADD
))
{
while
((
i
+
FSP_EXTENT_SIZE
<=
size
)
&&
(
count
<
FSP_FREE_ADD
))
{
mlog_write_ulint
(
header
+
FSP_FREE_LIMIT
,
i
+
FSP_EXTENT_SIZE
,
mlog_write_ulint
(
header
+
FSP_FREE_LIMIT
,
i
+
FSP_EXTENT_SIZE
,
MLOG_4BYTES
,
mtr
);
MLOG_4BYTES
,
mtr
);
/* Update the free limit info in the log system and make
a checkpoint */
log_fsp_current_free_limit_set_and_checkpoint
(
(
i
+
FSP_EXTENT_SIZE
)
/
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
));
if
(
0
==
i
%
XDES_DESCRIBED_PER_PAGE
)
{
if
(
0
==
i
%
XDES_DESCRIBED_PER_PAGE
)
{
/* We are going to initialize a new descriptor page
/* We are going to initialize a new descriptor page
...
@@ -1172,6 +1289,7 @@ fsp_free_page(
...
@@ -1172,6 +1289,7 @@ fsp_free_page(
xdes_t
*
descr
;
xdes_t
*
descr
;
ulint
state
;
ulint
state
;
ulint
frag_n_used
;
ulint
frag_n_used
;
char
buf
[
1000
];
ut_ad
(
mtr
);
ut_ad
(
mtr
);
...
@@ -1183,10 +1301,38 @@ fsp_free_page(
...
@@ -1183,10 +1301,38 @@ fsp_free_page(
state
=
xdes_get_state
(
descr
,
mtr
);
state
=
xdes_get_state
(
descr
,
mtr
);
ut_a
((
state
==
XDES_FREE_FRAG
)
||
(
state
==
XDES_FULL_FRAG
));
if
(
state
!=
XDES_FREE_FRAG
&&
state
!=
XDES_FULL_FRAG
)
{
fprintf
(
stderr
,
"InnoDB: Error: File space extent descriptor of page %lu has state %lu
\n
"
,
page
,
state
);
ut_sprintf_buf
(
buf
,
((
byte
*
)
descr
)
-
50
,
200
);
ut_a
(
xdes_get_bit
(
descr
,
XDES_FREE_BIT
,
page
%
FSP_EXTENT_SIZE
,
mtr
)
fprintf
(
stderr
,
"InnoDB: Dump of descriptor: %s
\n
"
,
buf
);
==
FALSE
);
if
(
state
==
XDES_FREE
)
{
/* We put here some fault tolerance: if the page
is already free, return without doing anything! */
return
;
}
ut_a
(
0
);
}
if
(
xdes_get_bit
(
descr
,
XDES_FREE_BIT
,
page
%
FSP_EXTENT_SIZE
,
mtr
)
==
TRUE
)
{
fprintf
(
stderr
,
"InnoDB: Error: File space extent descriptor of page %lu says it is free
\n
"
,
page
);
ut_sprintf_buf
(
buf
,
((
byte
*
)
descr
)
-
50
,
200
);
fprintf
(
stderr
,
"InnoDB: Dump of descriptor: %s
\n
"
,
buf
);
/* We put here some fault tolerance: if the page
is already free, return without doing anything! */
return
;
}
xdes_set_bit
(
descr
,
XDES_FREE_BIT
,
page
%
FSP_EXTENT_SIZE
,
TRUE
,
mtr
);
xdes_set_bit
(
descr
,
XDES_FREE_BIT
,
page
%
FSP_EXTENT_SIZE
,
TRUE
,
mtr
);
xdes_set_bit
(
descr
,
XDES_CLEAN_BIT
,
page
%
FSP_EXTENT_SIZE
,
TRUE
,
mtr
);
xdes_set_bit
(
descr
,
XDES_CLEAN_BIT
,
page
%
FSP_EXTENT_SIZE
,
TRUE
,
mtr
);
...
@@ -2243,13 +2389,15 @@ fsp_reserve_free_extents(
...
@@ -2243,13 +2389,15 @@ fsp_reserve_free_extents(
mtr_t
*
mtr
)
/* in: mtr */
mtr_t
*
mtr
)
/* in: mtr */
{
{
fsp_header_t
*
space_header
;
fsp_header_t
*
space_header
;
rw_lock_t
*
latch
;
ulint
n_free_list_ext
;
ulint
n_free_list_ext
;
ulint
free_limit
;
ulint
free_limit
;
ulint
size
;
ulint
size
;
ulint
n_free
;
ulint
n_free
;
ulint
n_free_up
;
ulint
n_free_up
;
ulint
reserve
;
ulint
reserve
;
rw_lock_t
*
latch
;
ibool
success
;
ulint
n_pages_added
;
ut_ad
(
mtr
);
ut_ad
(
mtr
);
ut_ad
(
!
mutex_own
(
&
kernel_mutex
)
ut_ad
(
!
mutex_own
(
&
kernel_mutex
)
...
@@ -2260,7 +2408,7 @@ fsp_reserve_free_extents(
...
@@ -2260,7 +2408,7 @@ fsp_reserve_free_extents(
mtr_x_lock
(
latch
,
mtr
);
mtr_x_lock
(
latch
,
mtr
);
space_header
=
fsp_get_space_header
(
space
,
mtr
);
space_header
=
fsp_get_space_header
(
space
,
mtr
);
try_again:
size
=
mtr_read_ulint
(
space_header
+
FSP_SIZE
,
MLOG_4BYTES
,
mtr
);
size
=
mtr_read_ulint
(
space_header
+
FSP_SIZE
,
MLOG_4BYTES
,
mtr
);
n_free_list_ext
=
flst_get_len
(
space_header
+
FSP_FREE
,
mtr
);
n_free_list_ext
=
flst_get_len
(
space_header
+
FSP_FREE
,
mtr
);
...
@@ -2291,7 +2439,7 @@ fsp_reserve_free_extents(
...
@@ -2291,7 +2439,7 @@ fsp_reserve_free_extents(
if
(
n_free
<=
reserve
+
n_ext
)
{
if
(
n_free
<=
reserve
+
n_ext
)
{
return
(
FALSE
)
;
goto
try_to_extend
;
}
}
}
else
if
(
alloc_type
==
FSP_UNDO
)
{
}
else
if
(
alloc_type
==
FSP_UNDO
)
{
/* We reserve 1 % of the space size to cleaning operations */
/* We reserve 1 % of the space size to cleaning operations */
...
@@ -2300,13 +2448,26 @@ fsp_reserve_free_extents(
...
@@ -2300,13 +2448,26 @@ fsp_reserve_free_extents(
if
(
n_free
<=
reserve
+
n_ext
)
{
if
(
n_free
<=
reserve
+
n_ext
)
{
return
(
FALSE
)
;
goto
try_to_extend
;
}
}
}
else
{
}
else
{
ut_a
(
alloc_type
==
FSP_CLEANING
);
ut_a
(
alloc_type
==
FSP_CLEANING
);
}
}
return
(
fil_space_reserve_free_extents
(
space
,
n_free
,
n_ext
));
success
=
fil_space_reserve_free_extents
(
space
,
n_free
,
n_ext
);
if
(
success
)
{
return
(
TRUE
);
}
try_to_extend:
success
=
fsp_try_extend_last_file
(
&
n_pages_added
,
space
,
space_header
,
mtr
);
if
(
success
&&
n_pages_added
>
0
)
{
goto
try_again
;
}
return
(
FALSE
);
}
}
/**************************************************************************
/**************************************************************************
...
...
innobase/include/buf0flu.h
View file @
e90a57aa
...
@@ -28,6 +28,16 @@ a margin of replaceable pages there. */
...
@@ -28,6 +28,16 @@ a margin of replaceable pages there. */
void
void
buf_flush_free_margin
(
void
);
buf_flush_free_margin
(
void
);
/*=======================*/
/*=======================*/
/************************************************************************
Initializes a page for writing to the tablespace. */
void
buf_flush_init_for_writing
(
/*=======================*/
byte
*
page
,
/* in: page */
dulint
newest_lsn
,
/* in: newest modification lsn to the page */
ulint
space
,
/* in: space id */
ulint
page_no
);
/* in: page number */
/***********************************************************************
/***********************************************************************
This utility flushes dirty blocks from the end of the LRU list or flush_list.
This utility flushes dirty blocks from the end of the LRU list or flush_list.
NOTE 1: in the case of an LRU flush the calling thread may own latches to
NOTE 1: in the case of an LRU flush the calling thread may own latches to
...
...
innobase/include/dict0dict.h
View file @
e90a57aa
...
@@ -105,7 +105,8 @@ dict_table_autoinc_initialize(
...
@@ -105,7 +105,8 @@ dict_table_autoinc_initialize(
dict_table_t
*
table
,
/* in: table */
dict_table_t
*
table
,
/* in: table */
ib_longlong
value
);
/* in: value which was assigned to a row */
ib_longlong
value
);
/* in: value which was assigned to a row */
/************************************************************************
/************************************************************************
Gets the next autoinc value, 0 if not yet initialized. */
Gets the next autoinc value, 0 if not yet initialized. If initialized,
increments the counter by 1. */
ib_longlong
ib_longlong
dict_table_autoinc_get
(
dict_table_autoinc_get
(
...
@@ -113,6 +114,15 @@ dict_table_autoinc_get(
...
@@ -113,6 +114,15 @@ dict_table_autoinc_get(
/* out: value for a new row, or 0 */
/* out: value for a new row, or 0 */
dict_table_t
*
table
);
/* in: table */
dict_table_t
*
table
);
/* in: table */
/************************************************************************
/************************************************************************
Reads the autoinc counter value, 0 if not yet initialized. Does not
increment the counter. */
ib_longlong
dict_table_autoinc_read
(
/*====================*/
/* out: value of the counter */
dict_table_t
*
table
);
/* in: table */
/************************************************************************
Updates the autoinc counter if the value supplied is bigger than the
Updates the autoinc counter if the value supplied is bigger than the
current value. If not inited, does nothing. */
current value. If not inited, does nothing. */
...
@@ -143,7 +153,10 @@ dict_table_rename_in_cache(
...
@@ -143,7 +153,10 @@ dict_table_rename_in_cache(
/*=======================*/
/*=======================*/
/* out: TRUE if success */
/* out: TRUE if success */
dict_table_t
*
table
,
/* in: table */
dict_table_t
*
table
,
/* in: table */
char
*
new_name
);
/* in: new name */
char
*
new_name
,
/* in: new name */
ibool
rename_also_foreigns
);
/* in: in ALTER TABLE we want
to preserve the original table name
in constraints which reference it */
/**************************************************************************
/**************************************************************************
Adds a foreign key constraint object to the dictionary cache. May free
Adds a foreign key constraint object to the dictionary cache. May free
the object if there already is an object with the same identifier in.
the object if there already is an object with the same identifier in.
...
@@ -284,6 +297,10 @@ Sprintfs to a string info on foreign keys of a table. */
...
@@ -284,6 +297,10 @@ Sprintfs to a string info on foreign keys of a table. */
void
void
dict_print_info_on_foreign_keys
(
dict_print_info_on_foreign_keys
(
/*============================*/
/*============================*/
ibool
create_table_format
,
/* in: if TRUE then print in
a format suitable to be inserted into
a CREATE TABLE, otherwise in the format
of SHOW TABLE STATUS */
char
*
str
,
/* in/out: pointer to a string */
char
*
str
,
/* in/out: pointer to a string */
ulint
len
,
/* in: space in str available for info */
ulint
len
,
/* in: space in str available for info */
dict_table_t
*
table
);
/* in: table */
dict_table_t
*
table
);
/* in: table */
...
...
innobase/include/fil0fil.h
View file @
e90a57aa
...
@@ -64,8 +64,10 @@ extern fil_addr_t fil_addr_null;
...
@@ -64,8 +64,10 @@ extern fil_addr_t fil_addr_null;
#define FIL_PAGE_DATA 38
/* start of the data on the page */
#define FIL_PAGE_DATA 38
/* start of the data on the page */
/* File page trailer */
/* File page trailer */
#define FIL_PAGE_END_LSN 8
/* this should be same as
#define FIL_PAGE_END_LSN 8
/* the low 4 bytes of this are used
FIL_PAGE_LSN */
to store the page checksum, the
last 4 bytes should be identical
to the last 4 bytes of FIL_PAGE_LSN */
#define FIL_PAGE_DATA_END 8
#define FIL_PAGE_DATA_END 8
/* File page types */
/* File page types */
...
@@ -134,6 +136,21 @@ fil_space_truncate_start(
...
@@ -134,6 +136,21 @@ fil_space_truncate_start(
ulint
trunc_len
);
/* in: truncate by this much; it is an error
ulint
trunc_len
);
/* in: truncate by this much; it is an error
if this does not equal to the combined size of
if this does not equal to the combined size of
some initial files in the space */
some initial files in the space */
/**************************************************************************
Tries to extend a data file by the number of pages given. Any fractions of a
megabyte are ignored. */
ibool
fil_extend_last_data_file
(
/*======================*/
/* out: TRUE if success, also if we run
out of disk space we may return TRUE */
ulint
*
actual_increase
,
/* out: number of pages we were able to
extend, here the orginal size of the file and
the resulting size of the file are rounded
downwards to a full megabyte, and the
difference expressed in pages is returned */
ulint
size_increase
);
/* in: try to extend this many pages */
/***********************************************************************
/***********************************************************************
Frees a space object from a file system. Closes the files in the chain
Frees a space object from a file system. Closes the files in the chain
but does not delete them. */
but does not delete them. */
...
...
innobase/include/fsp0fsp.h
View file @
e90a57aa
...
@@ -46,6 +46,17 @@ void
...
@@ -46,6 +46,17 @@ void
fsp_init
(
void
);
fsp_init
(
void
);
/*==========*/
/*==========*/
/**************************************************************************
/**************************************************************************
Gets the current free limit of a tablespace. The free limit means the
place of the first page which has never been put to the the free list
for allocation. The space above that address is initialized to zero.
Sets also the global variable log_fsp_current_free_limit. */
ulint
fsp_header_get_free_limit
(
/*======================*/
/* out: free limit in megabytes */
ulint
space
);
/* in: space id */
/**************************************************************************
Initializes the space header of a new created space. */
Initializes the space header of a new created space. */
void
void
...
...
innobase/include/log0log.h
View file @
e90a57aa
...
@@ -26,6 +26,32 @@ extern ibool log_debug_writes;
...
@@ -26,6 +26,32 @@ extern ibool log_debug_writes;
#define LOG_WAIT_ALL_GROUPS 93
#define LOG_WAIT_ALL_GROUPS 93
#define LOG_MAX_N_GROUPS 32
#define LOG_MAX_N_GROUPS 32
/********************************************************************
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
so that we know that the limit has been written to a log checkpoint field
on disk. */
void
log_fsp_current_free_limit_set_and_checkpoint
(
/*==========================================*/
ulint
limit
);
/* in: limit to set */
/***********************************************************************
Calculates where in log files we find a specified lsn. */
ulint
log_calc_where_lsn_is
(
/*==================*/
/* out: log file number */
ib_longlong
*
log_file_offset
,
/* out: offset in that file
(including the header) */
dulint
first_header_lsn
,
/* in: first log file start
lsn */
dulint
lsn
,
/* in: lsn whose position to
determine */
ulint
n_log_files
,
/* in: total number of log
files */
ib_longlong
log_file_size
);
/* in: log file size
(including the header) */
/****************************************************************
/****************************************************************
Writes to the log the string given. The log must be released with
Writes to the log the string given. The log must be released with
log_release. */
log_release. */
...
@@ -225,6 +251,16 @@ Writes checkpoint info to groups. */
...
@@ -225,6 +251,16 @@ Writes checkpoint info to groups. */
void
void
log_groups_write_checkpoint_info
(
void
);
log_groups_write_checkpoint_info
(
void
);
/*==================================*/
/*==================================*/
/**********************************************************
Writes info to a buffer of a log group when log files are created in
backup restoration. */
void
log_reset_first_header_and_checkpoint
(
/*==================================*/
byte
*
hdr_buf
,
/* in: buffer which will be written to the start
of the first log file */
dulint
lsn
);
/* in: lsn of the start of the first log file */
/************************************************************************
/************************************************************************
Starts an archiving operation. */
Starts an archiving operation. */
...
@@ -507,7 +543,16 @@ extern log_t* log_sys;
...
@@ -507,7 +543,16 @@ extern log_t* log_sys;
+ LOG_MAX_N_GROUPS * 8)
+ LOG_MAX_N_GROUPS * 8)
#define LOG_CHECKPOINT_CHECKSUM_1 LOG_CHECKPOINT_ARRAY_END
#define LOG_CHECKPOINT_CHECKSUM_1 LOG_CHECKPOINT_ARRAY_END
#define LOG_CHECKPOINT_CHECKSUM_2 (4 + LOG_CHECKPOINT_ARRAY_END)
#define LOG_CHECKPOINT_CHECKSUM_2 (4 + LOG_CHECKPOINT_ARRAY_END)
#define LOG_CHECKPOINT_SIZE (8 + LOG_CHECKPOINT_ARRAY_END)
#define LOG_CHECKPOINT_FSP_FREE_LIMIT (8 + LOG_CHECKPOINT_ARRAY_END)
/* current fsp free limit in the
tablespace, in units of one megabyte */
#define LOG_CHECKPOINT_FSP_MAGIC_N (12 + LOG_CHECKPOINT_ARRAY_END)
/* this magic number tells if the
checkpoint contains the above field:
the field was added to InnoDB-3.23.50 */
#define LOG_CHECKPOINT_SIZE (16 + LOG_CHECKPOINT_ARRAY_END)
#define LOG_CHECKPOINT_FSP_MAGIC_N_VAL 1441231243
/* Offsets of a log file header */
/* Offsets of a log file header */
#define LOG_GROUP_ID 0
/* log group number */
#define LOG_GROUP_ID 0
/* log group number */
...
...
innobase/include/log0recv.h
View file @
e90a57aa
...
@@ -15,6 +15,39 @@ Created 9/20/1997 Heikki Tuuri
...
@@ -15,6 +15,39 @@ Created 9/20/1997 Heikki Tuuri
#include "hash0hash.h"
#include "hash0hash.h"
#include "log0log.h"
#include "log0log.h"
/***********************************************************************
Reads the checkpoint info needed in hot backup. */
ibool
recv_read_cp_info_for_backup
(
/*=========================*/
/* out: TRUE if success */
byte
*
hdr
,
/* in: buffer containing the log group header */
dulint
*
lsn
,
/* out: checkpoint lsn */
ulint
*
offset
,
/* out: checkpoint offset in the log group */
ulint
*
fsp_limit
,
/* out: fsp limit, 1000000000 if the database
is running with < version 3.23.50 of InnoDB */
dulint
*
cp_no
,
/* out: checkpoint number */
dulint
*
first_header_lsn
);
/* out: lsn of of the start of the first log file */
/***********************************************************************
Scans the log segment and n_bytes_scanned is set to the length of valid
log scanned. */
void
recv_scan_log_seg_for_backup
(
/*=========================*/
byte
*
buf
,
/* in: buffer containing log data */
ulint
buf_len
,
/* in: data length in that buffer */
dulint
*
scanned_lsn
,
/* in/out: lsn of buffer start,
we return scanned lsn */
ulint
*
scanned_checkpoint_no
,
/* in/out: 4 lowest bytes of the
highest scanned checkpoint number so
far */
ulint
*
n_bytes_scanned
);
/* out: how much we were able to
scan, smaller than buf_len if log
data ended here */
/***********************************************************************
/***********************************************************************
Returns TRUE if recovery is currently running. */
Returns TRUE if recovery is currently running. */
UNIV_INLINE
UNIV_INLINE
...
@@ -35,6 +68,10 @@ read in, or also for a page already in the buffer pool. */
...
@@ -35,6 +68,10 @@ read in, or also for a page already in the buffer pool. */
void
void
recv_recover_page
(
recv_recover_page
(
/*==============*/
/*==============*/
ibool
recover_backup
,
/* in: TRUE if we are recovering a backup
page: then we do not acquire any latches
since the page was read in outside the
buffer pool */
ibool
just_read_in
,
/* in: TRUE if the i/o-handler calls this for
ibool
just_read_in
,
/* in: TRUE if the i/o-handler calls this for
a freshly read page */
a freshly read page */
page_t
*
page
,
/* in: buffer page */
page_t
*
page
,
/* in: buffer page */
...
@@ -69,8 +106,15 @@ recv_scan_log_recs(
...
@@ -69,8 +106,15 @@ recv_scan_log_recs(
/*===============*/
/*===============*/
/* out: TRUE if limit_lsn has been reached, or
/* out: TRUE if limit_lsn has been reached, or
not able to scan any more in this log group */
not able to scan any more in this log group */
ibool
apply_automatically
,
/* in: TRUE if we want this function to
apply log records automatically when the
hash table becomes full; in the hot backup tool
the tool does the applying, not this
function */
ulint
available_memory
,
/* in: we let the hash table of recs to grow
to this size, at the maximum */
ibool
store_to_hash
,
/* in: TRUE if the records should be stored
ibool
store_to_hash
,
/* in: TRUE if the records should be stored
to the hash table; this is set FALSE if just
to the hash table; this is set
to
FALSE if just
debug checking is needed */
debug checking is needed */
byte
*
buf
,
/* in: buffer containing a log segment or
byte
*
buf
,
/* in: buffer containing a log segment or
garbage */
garbage */
...
@@ -92,6 +136,16 @@ recv_reset_logs(
...
@@ -92,6 +136,16 @@ recv_reset_logs(
ibool
new_logs_created
);
/* in: TRUE if resetting logs is done
ibool
new_logs_created
);
/* in: TRUE if resetting logs is done
at the log creation; FALSE if it is done
at the log creation; FALSE if it is done
after archive recovery */
after archive recovery */
/**********************************************************
Creates new log files after a backup has been restored. */
void
recv_reset_log_files_for_backup
(
/*============================*/
char
*
log_dir
,
/* in: log file directory path */
ulint
n_log_files
,
/* in: number of log files */
ulint
log_file_size
,
/* in: log file size */
dulint
lsn
);
/* in: new start lsn */
/************************************************************
/************************************************************
Creates the recovery system. */
Creates the recovery system. */
...
@@ -102,8 +156,11 @@ recv_sys_create(void);
...
@@ -102,8 +156,11 @@ recv_sys_create(void);
Inits the recovery system for a recovery operation. */
Inits the recovery system for a recovery operation. */
void
void
recv_sys_init
(
void
);
recv_sys_init
(
/*===============*/
/*==========*/
ibool
recover_from_backup
,
/* in: TRUE if this is called
to recover from a hot backup */
ulint
available_memory
);
/* in: available memory in bytes */
/***********************************************************************
/***********************************************************************
Empties the hash table of stored log records, applying them to appropriate
Empties the hash table of stored log records, applying them to appropriate
pages. */
pages. */
...
@@ -118,6 +175,17 @@ recv_apply_hashed_log_recs(
...
@@ -118,6 +175,17 @@ recv_apply_hashed_log_recs(
disk and invalidated in buffer pool: this
disk and invalidated in buffer pool: this
alternative means that no new log records
alternative means that no new log records
can be generated during the application */
can be generated during the application */
/***********************************************************************
Applies log records in the hash table to a backup. */
void
recv_apply_log_recs_for_backup
(
/*===========================*/
ulint
n_data_files
,
/* in: number of data files */
char
**
data_files
,
/* in: array containing the paths to the
data files */
ulint
*
file_sizes
);
/* in: sizes of the data files in database
pages */
/************************************************************
/************************************************************
Recovers from archived log files, and also from log files, if they exist. */
Recovers from archived log files, and also from log files, if they exist. */
...
@@ -260,6 +328,14 @@ extern ibool recv_recovery_on;
...
@@ -260,6 +328,14 @@ extern ibool recv_recovery_on;
extern
ibool
recv_no_ibuf_operations
;
extern
ibool
recv_no_ibuf_operations
;
extern
ibool
recv_needed_recovery
;
extern
ibool
recv_needed_recovery
;
/* Size of the parsing buffer; it must accommodate RECV_SCAN_SIZE many
times! */
#define RECV_PARSING_BUF_SIZE (2 * 1024 * 1024)
/* Size of block reads when the log groups are scanned forward to do a
roll-forward */
#define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE)
/* States of recv_addr_struct */
/* States of recv_addr_struct */
#define RECV_NOT_PROCESSED 71
#define RECV_NOT_PROCESSED 71
#define RECV_BEING_READ 72
#define RECV_BEING_READ 72
...
...
innobase/include/mem0mem.h
View file @
e90a57aa
...
@@ -41,11 +41,11 @@ page buffer pool; the latter method is used for very big heaps */
...
@@ -41,11 +41,11 @@ page buffer pool; the latter method is used for very big heaps */
/* The following start size is used for the first block in the memory heap if
/* The following start size is used for the first block in the memory heap if
the size is not specified, i.e., 0 is given as the parameter in the call of
the size is not specified, i.e., 0 is given as the parameter in the call of
create. The standard size is the maximum size of the blocks used for
create. The standard size is the maximum
(payload)
size of the blocks used for
allocations of small buffers. */
allocations of small buffers. */
#define MEM_BLOCK_START_SIZE 64
#define MEM_BLOCK_START_SIZE 64
#define MEM_BLOCK_STANDARD_SIZE 8
192
#define MEM_BLOCK_STANDARD_SIZE 8
000
/* If a memory heap is allowed to grow into the buffer pool, the following
/* If a memory heap is allowed to grow into the buffer pool, the following
is the maximum size for a single allocated buffer: */
is the maximum size for a single allocated buffer: */
...
...
innobase/include/os0file.h
View file @
e90a57aa
...
@@ -11,6 +11,12 @@ Created 10/21/1995 Heikki Tuuri
...
@@ -11,6 +11,12 @@ Created 10/21/1995 Heikki Tuuri
#include "univ.i"
#include "univ.i"
/* If the following is set to TRUE, we do not call os_file_flush in every
os_file_write */
extern
ibool
os_do_not_call_flush_at_each_write
;
extern
ibool
os_has_said_disk_full
;
#ifdef __WIN__
#ifdef __WIN__
/* We define always WIN_ASYNC_IO, and check at run-time whether
/* We define always WIN_ASYNC_IO, and check at run-time whether
...
@@ -55,6 +61,9 @@ log. */
...
@@ -55,6 +61,9 @@ log. */
#define OS_FILE_CREATE 52
#define OS_FILE_CREATE 52
#define OS_FILE_OVERWRITE 53
#define OS_FILE_OVERWRITE 53
#define OS_FILE_READ_ONLY 333
#define OS_FILE_READ_WRITE 444
/* Options for file_create */
/* Options for file_create */
#define OS_FILE_AIO 61
#define OS_FILE_AIO 61
#define OS_FILE_NORMAL 62
#define OS_FILE_NORMAL 62
...
@@ -118,6 +127,27 @@ os_get_os_version(void);
...
@@ -118,6 +127,27 @@ os_get_os_version(void);
/*===================*/
/*===================*/
/* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */
/* out: OS_WIN95, OS_WIN31, OS_WINNT (2000 == NT) */
/********************************************************************
/********************************************************************
Creates the seek mutexes used in positioned reads and writes. */
void
os_io_init_simple
(
void
);
/*===================*/
/********************************************************************
A simple function to open or create a file. */
os_file_t
os_file_create_simple
(
/*==================*/
/* out, own: handle to the file, not defined if error,
error number can be retrieved with os_get_last_error */
char
*
name
,
/* in: name of the file or path as a null-terminated
string */
ulint
create_mode
,
/* in: OS_FILE_OPEN if an existing file is opened
(if does not exist, error), or OS_FILE_CREATE if a new
file is created (if exists, error) */
ulint
access_type
,
/* in: OS_FILE_READ_ONLY or OS_FILE_READ_WRITE */
ibool
*
success
);
/* out: TRUE if succeed, FALSE if error */
/********************************************************************
Opens an existing file or creates a new. */
Opens an existing file or creates a new. */
os_file_t
os_file_t
...
...
innobase/include/row0mysql.h
View file @
e90a57aa
...
@@ -402,13 +402,13 @@ struct row_prebuilt_struct {
...
@@ -402,13 +402,13 @@ struct row_prebuilt_struct {
byte
*
ins_upd_rec_buff
;
/* buffer for storing data converted
byte
*
ins_upd_rec_buff
;
/* buffer for storing data converted
to the Innobase format from the MySQL
to the Innobase format from the MySQL
format */
format */
ibool
in_update_remember_po
s
;
ibool
hint_no_need_to_fetch_extra_col
s
;
/*
if an update is processed, then if
/*
normally this is TRUE, but
this flag is set to TRUE, it means
MySQL will set this to FALSE
that the stored cursor position in
if we might be required to fetch also
SELECT is the right position also
other columns than mentioned in the
for the update: we can just restore
query: the clustered index column(s),
the cursor and save CPU time
*/
or an auto-increment column
*/
upd_node_t
*
upd_node
;
/* Innobase SQL update node used
upd_node_t
*
upd_node
;
/* Innobase SQL update node used
to perform updates and deletes */
to perform updates and deletes */
que_fork_t
*
ins_graph
;
/* Innobase SQL query graph used
que_fork_t
*
ins_graph
;
/* Innobase SQL query graph used
...
...
innobase/include/srv0srv.h
View file @
e90a57aa
...
@@ -24,10 +24,13 @@ extern char srv_fatal_errbuf[];
...
@@ -24,10 +24,13 @@ extern char srv_fatal_errbuf[];
thread starts running */
thread starts running */
extern
os_event_t
srv_lock_timeout_thread_event
;
extern
os_event_t
srv_lock_timeout_thread_event
;
/* If the last data file is auto-extended, we add this many pages to it
at a time */
#define SRV_AUTO_EXTEND_INCREMENT (8 * ((1024 * 1024) / UNIV_PAGE_SIZE))
/* Server parameters which are read from the initfile */
/* Server parameters which are read from the initfile */
extern
char
*
srv_data_home
;
extern
char
*
srv_data_home
;
extern
char
*
srv_logs_home
;
extern
char
*
srv_arch_dir
;
extern
char
*
srv_arch_dir
;
extern
ulint
srv_n_data_files
;
extern
ulint
srv_n_data_files
;
...
@@ -35,6 +38,9 @@ extern char** srv_data_file_names;
...
@@ -35,6 +38,9 @@ extern char** srv_data_file_names;
extern
ulint
*
srv_data_file_sizes
;
extern
ulint
*
srv_data_file_sizes
;
extern
ulint
*
srv_data_file_is_raw_partition
;
extern
ulint
*
srv_data_file_is_raw_partition
;
extern
ibool
srv_auto_extend_last_data_file
;
extern
ulint
srv_last_file_size_max
;
extern
ibool
srv_created_new_raw
;
extern
ibool
srv_created_new_raw
;
#define SRV_NEW_RAW 1
#define SRV_NEW_RAW 1
...
@@ -185,6 +191,19 @@ srv_boot(void);
...
@@ -185,6 +191,19 @@ srv_boot(void);
/*==========*/
/*==========*/
/* out: DB_SUCCESS or error code */
/* out: DB_SUCCESS or error code */
/*************************************************************************
/*************************************************************************
Initializes the server. */
void
srv_init
(
void
);
/*==========*/
/*************************************************************************
Initializes the synchronization primitives, memory system, and the thread
local storage. */
void
srv_general_init
(
void
);
/*==================*/
/*************************************************************************
Gets the number of threads in the system. */
Gets the number of threads in the system. */
ulint
ulint
...
...
innobase/include/srv0start.h
View file @
e90a57aa
...
@@ -12,6 +12,56 @@ Created 10/10/1995 Heikki Tuuri
...
@@ -12,6 +12,56 @@ Created 10/10/1995 Heikki Tuuri
#include "univ.i"
#include "univ.i"
/*************************************************************************
Normalizes a directory path for Windows: converts slashes to backslashes. */
void
srv_normalize_path_for_win
(
/*=======================*/
char
*
str
);
/* in/out: null-terminated character string */
/*************************************************************************
Adds a slash or a backslash to the end of a string if it is missing
and the string is not empty. */
char
*
srv_add_path_separator_if_needed
(
/*=============================*/
/* out, own: string which has the separator if the
string is not empty */
char
*
str
);
/* in: null-terminated character string */
/*************************************************************************
Reads the data files and their sizes from a character string given in
the .cnf file. */
ibool
srv_parse_data_file_paths_and_sizes
(
/*================================*/
/* out: TRUE if ok, FALSE if parsing
error */
char
*
str
,
/* in: the data file path string */
char
***
data_file_names
,
/* out, own: array of data file
names */
ulint
**
data_file_sizes
,
/* out, own: array of data file sizes
in megabytes */
ulint
**
data_file_is_raw_partition
,
/* out, own: array of flags
showing which data files are raw
partitions */
ulint
*
n_data_files
,
/* out: number of data files */
ibool
*
is_auto_extending
,
/* out: TRUE if the last data file is
auto-extending */
ulint
*
max_auto_extend_size
);
/* out: max auto extend size for the
last file if specified, 0 if not */
/*************************************************************************
Reads log group home directories from a character string given in
the .cnf file. */
ibool
srv_parse_log_group_home_dirs
(
/*==========================*/
/* out: TRUE if ok, FALSE if parsing
error */
char
*
str
,
/* in: character string */
char
***
log_group_home_dirs
);
/* out, own: log group home dirs */
/********************************************************************
/********************************************************************
Starts Innobase and creates a new database if database files
Starts Innobase and creates a new database if database files
are not found and the user wants. Server parameters are
are not found and the user wants. Server parameters are
...
...
innobase/include/trx0sys.h
View file @
e90a57aa
...
@@ -44,6 +44,15 @@ half-written pages in the data files. */
...
@@ -44,6 +44,15 @@ half-written pages in the data files. */
void
void
trx_sys_doublewrite_restore_corrupt_pages
(
void
);
trx_sys_doublewrite_restore_corrupt_pages
(
void
);
/*===========================================*/
/*===========================================*/
/********************************************************************
Determines if a page number is located inside the doublewrite buffer. */
ibool
trx_doublewrite_page_inside
(
/*========================*/
/* out: TRUE if the location is inside
the two blocks of the doublewrite buffer */
ulint
page_no
);
/* in: page number */
/*******************************************************************
/*******************************************************************
Checks if a page address is the trx sys header page. */
Checks if a page address is the trx sys header page. */
UNIV_INLINE
UNIV_INLINE
...
...
innobase/include/ut0byte.h
View file @
e90a57aa
...
@@ -55,6 +55,15 @@ ut_dulint_get_low(
...
@@ -55,6 +55,15 @@ ut_dulint_get_low(
/* out: 32 bits in ulint */
/* out: 32 bits in ulint */
dulint
d
);
/* in: dulint */
dulint
d
);
/* in: dulint */
/***********************************************************
/***********************************************************
Converts a dulint (a struct of 2 ulints) to ib_longlong, which is a 64-bit
integer type. */
UNIV_INLINE
ib_longlong
ut_conv_dulint_to_longlong
(
/*=======================*/
/* out: value in ib_longlong type */
dulint
d
);
/* in: dulint */
/***********************************************************
Tests if a dulint is zero. */
Tests if a dulint is zero. */
UNIV_INLINE
UNIV_INLINE
ibool
ibool
...
...
innobase/include/ut0rnd.h
View file @
e90a57aa
...
@@ -35,7 +35,7 @@ ut_rnd_gen_next_ulint(
...
@@ -35,7 +35,7 @@ ut_rnd_gen_next_ulint(
/*************************************************************
/*************************************************************
The following function generates 'random' ulint integers which
The following function generates 'random' ulint integers which
enumerate the value space (let there be N of them) of ulint integers
enumerate the value space (let there be N of them) of ulint integers
in a pseudo
random fashion. Note that the same integer is repeated
in a pseudo
-
random fashion. Note that the same integer is repeated
always after N calls to the generator. */
always after N calls to the generator. */
UNIV_INLINE
UNIV_INLINE
ulint
ulint
...
...
innobase/include/ut0ut.h
View file @
e90a57aa
...
@@ -17,6 +17,16 @@ Created 1/20/1994 Heikki Tuuri
...
@@ -17,6 +17,16 @@ Created 1/20/1994 Heikki Tuuri
typedef
time_t
ib_time_t
;
typedef
time_t
ib_time_t
;
/************************************************************
Gets the high 32 bits in a ulint. That is makes a shift >> 32,
but since there seem to be compiler bugs in both gcc and Visual C++,
we do this by a special conversion. */
ulint
ut_get_high32
(
/*==========*/
/* out: a >> 32 */
ulint
a
);
/* in: ulint */
/**********************************************************
/**********************************************************
Calculates the minimum of two ulints. */
Calculates the minimum of two ulints. */
UNIV_INLINE
UNIV_INLINE
...
@@ -144,6 +154,15 @@ void
...
@@ -144,6 +154,15 @@ void
ut_print_timestamp
(
ut_print_timestamp
(
/*===============*/
/*===============*/
FILE
*
file
);
/* in: file where to print */
FILE
*
file
);
/* in: file where to print */
/**************************************************************
Returns current year, month, day. */
void
ut_get_year_month_day
(
/*==================*/
ulint
*
year
,
/* out: current year */
ulint
*
month
,
/* out: month */
ulint
*
day
);
/* out: day */
/*****************************************************************
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */
in microseconds on 100 MHz Pentium + Visual C++. */
...
...
innobase/log/log0log.c
View file @
e90a57aa
/******************************************************
/******************************************************
Database log
Database log
(c) 1995-1997 Inno
DB
Oy
(c) 1995-1997 Inno
base
Oy
Created 12/9/1995 Heikki Tuuri
Created 12/9/1995 Heikki Tuuri
*******************************************************/
*******************************************************/
...
@@ -24,6 +24,9 @@ Created 12/9/1995 Heikki Tuuri
...
@@ -24,6 +24,9 @@ Created 12/9/1995 Heikki Tuuri
#include "trx0sys.h"
#include "trx0sys.h"
#include "trx0trx.h"
#include "trx0trx.h"
/* Current free limit; protected by the log sys mutex; 0 means uninitialized */
ulint
log_fsp_current_free_limit
=
0
;
/* Global log system variable */
/* Global log system variable */
log_t
*
log_sys
=
NULL
;
log_t
*
log_sys
=
NULL
;
...
@@ -95,6 +98,32 @@ void
...
@@ -95,6 +98,32 @@ void
log_archive_margin
(
void
);
log_archive_margin
(
void
);
/*====================*/
/*====================*/
/********************************************************************
Sets the global variable log_fsp_current_free_limit. Also makes a checkpoint,
so that we know that the limit has been written to a log checkpoint field
on disk. */
void
log_fsp_current_free_limit_set_and_checkpoint
(
/*==========================================*/
ulint
limit
)
/* in: limit to set */
{
ibool
success
;
mutex_enter
(
&
(
log_sys
->
mutex
));
log_fsp_current_free_limit
=
limit
;
mutex_exit
(
&
(
log_sys
->
mutex
));
/* Try to make a synchronous checkpoint */
success
=
FALSE
;
while
(
!
success
)
{
success
=
log_checkpoint
(
TRUE
,
TRUE
);
}
}
/********************************************************************
/********************************************************************
Returns the oldest modified block lsn in the pool, or log_sys->lsn if none
Returns the oldest modified block lsn in the pool, or log_sys->lsn if none
...
@@ -436,6 +465,51 @@ log_group_calc_lsn_offset(
...
@@ -436,6 +465,51 @@ log_group_calc_lsn_offset(
return
(
log_group_calc_real_offset
(
offset
,
group
));
return
(
log_group_calc_real_offset
(
offset
,
group
));
}
}
/***********************************************************************
Calculates where in log files we find a specified lsn. */
ulint
log_calc_where_lsn_is
(
/*==================*/
/* out: log file number */
ib_longlong
*
log_file_offset
,
/* out: offset in that file
(including the header) */
dulint
first_header_lsn
,
/* in: first log file start
lsn */
dulint
lsn
,
/* in: lsn whose position to
determine */
ulint
n_log_files
,
/* in: total number of log
files */
ib_longlong
log_file_size
)
/* in: log file size
(including the header) */
{
ib_longlong
ib_lsn
;
ib_longlong
ib_first_header_lsn
;
ib_longlong
capacity
=
log_file_size
-
LOG_FILE_HDR_SIZE
;
ulint
file_no
;
ib_longlong
add_this_many
;
ib_lsn
=
ut_conv_dulint_to_longlong
(
lsn
);
ib_first_header_lsn
=
ut_conv_dulint_to_longlong
(
first_header_lsn
);
if
(
ib_lsn
<
ib_first_header_lsn
)
{
add_this_many
=
1
+
(
ib_first_header_lsn
-
ib_lsn
)
/
(
capacity
*
(
ib_longlong
)
n_log_files
);
ib_lsn
+=
add_this_many
*
capacity
*
(
ib_longlong
)
n_log_files
;
}
ut_a
(
ib_lsn
>=
ib_first_header_lsn
);
file_no
=
((
ulint
)((
ib_lsn
-
ib_first_header_lsn
)
/
capacity
))
%
n_log_files
;
*
log_file_offset
=
(
ib_lsn
-
ib_first_header_lsn
)
%
capacity
;
*
log_file_offset
=
*
log_file_offset
+
LOG_FILE_HDR_SIZE
;
return
(
file_no
);
}
/************************************************************
/************************************************************
Sets the field values in group to correspond to a given lsn. For this function
Sets the field values in group to correspond to a given lsn. For this function
to work, the values must already be correctly initialized to correspond to
to work, the values must already be correctly initialized to correspond to
...
@@ -653,7 +727,7 @@ log_init(void)
...
@@ -653,7 +727,7 @@ log_init(void)
#ifdef UNIV_LOG_DEBUG
#ifdef UNIV_LOG_DEBUG
recv_sys_create
();
recv_sys_create
();
recv_sys_init
();
recv_sys_init
(
FALSE
,
buf_pool_get_curr_size
()
);
recv_sys
->
parse_start_lsn
=
log_sys
->
lsn
;
recv_sys
->
parse_start_lsn
=
log_sys
->
lsn
;
recv_sys
->
scanned_lsn
=
log_sys
->
lsn
;
recv_sys
->
scanned_lsn
=
log_sys
->
lsn
;
...
@@ -1002,9 +1076,28 @@ loop:
...
@@ -1002,9 +1076,28 @@ loop:
}
}
if
(
log_debug_writes
)
{
if
(
log_debug_writes
)
{
ulint
i
;
printf
(
printf
(
"Writing log file segment to group %lu offset %lu len %lu
\n
"
,
"Writing log file segment to group %lu offset %lu len %lu
\n
"
group
->
id
,
next_offset
,
write_len
);
"start lsn %lu %lu
\n
"
,
group
->
id
,
next_offset
,
write_len
,
ut_dulint_get_high
(
start_lsn
),
ut_dulint_get_low
(
start_lsn
));
printf
(
"First block n:o %lu last block n:o %lu
\n
"
,
log_block_get_hdr_no
(
buf
),
log_block_get_hdr_no
(
buf
+
write_len
-
OS_FILE_LOG_BLOCK_SIZE
));
ut_a
(
log_block_get_hdr_no
(
buf
)
==
log_block_convert_lsn_to_no
(
start_lsn
));
for
(
i
=
0
;
i
<
write_len
/
OS_FILE_LOG_BLOCK_SIZE
;
i
++
)
{
ut_a
(
log_block_get_hdr_no
(
buf
)
+
i
==
log_block_get_hdr_no
(
buf
+
i
*
OS_FILE_LOG_BLOCK_SIZE
));
}
}
}
if
(
log_do_write
)
{
if
(
log_do_write
)
{
...
@@ -1346,7 +1439,7 @@ log_group_checkpoint(
...
@@ -1346,7 +1439,7 @@ log_group_checkpoint(
ulint
i
;
ulint
i
;
ut_ad
(
mutex_own
(
&
(
log_sys
->
mutex
)));
ut_ad
(
mutex_own
(
&
(
log_sys
->
mutex
)));
ut_a
d
(
LOG_CHECKPOINT_SIZE
<=
OS_FILE_LOG_BLOCK_SIZE
);
ut_a
(
LOG_CHECKPOINT_SIZE
<=
OS_FILE_LOG_BLOCK_SIZE
);
buf
=
group
->
checkpoint_buf
;
buf
=
group
->
checkpoint_buf
;
...
@@ -1394,6 +1487,15 @@ log_group_checkpoint(
...
@@ -1394,6 +1487,15 @@ log_group_checkpoint(
LOG_CHECKPOINT_CHECKSUM_2
-
LOG_CHECKPOINT_LSN
);
LOG_CHECKPOINT_CHECKSUM_2
-
LOG_CHECKPOINT_LSN
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_CHECKSUM_2
,
fold
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_CHECKSUM_2
,
fold
);
/* Starting from InnoDB-3.23.50, we also write info on allocated
size in the tablespace */
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_FSP_FREE_LIMIT
,
log_fsp_current_free_limit
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_FSP_MAGIC_N
,
LOG_CHECKPOINT_FSP_MAGIC_N_VAL
);
/* We alternate the physical place of the checkpoint info in the first
/* We alternate the physical place of the checkpoint info in the first
log file */
log file */
...
@@ -1428,6 +1530,48 @@ log_group_checkpoint(
...
@@ -1428,6 +1530,48 @@ log_group_checkpoint(
}
}
}
}
/**********************************************************
Writes info to a buffer of a log group when log files are created in
backup restoration. */
void
log_reset_first_header_and_checkpoint
(
/*==================================*/
byte
*
hdr_buf
,
/* in: buffer which will be written to the start
of the first log file */
dulint
lsn
)
/* in: lsn of the start of the first log file
+ LOG_BLOCK_HDR_SIZE */
{
ulint
fold
;
byte
*
buf
;
mach_write_to_4
(
hdr_buf
+
LOG_GROUP_ID
,
0
);
mach_write_to_8
(
hdr_buf
+
LOG_FILE_START_LSN
,
lsn
);
buf
=
hdr_buf
+
LOG_CHECKPOINT_1
;
mach_write_to_8
(
buf
+
LOG_CHECKPOINT_NO
,
ut_dulint_zero
);
mach_write_to_8
(
buf
+
LOG_CHECKPOINT_LSN
,
lsn
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_OFFSET
,
LOG_FILE_HDR_SIZE
+
LOG_BLOCK_HDR_SIZE
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_LOG_BUF_SIZE
,
2
*
1024
*
1024
);
mach_write_to_8
(
buf
+
LOG_CHECKPOINT_ARCHIVED_LSN
,
ut_dulint_max
);
fold
=
ut_fold_binary
(
buf
,
LOG_CHECKPOINT_CHECKSUM_1
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_CHECKSUM_1
,
fold
);
fold
=
ut_fold_binary
(
buf
+
LOG_CHECKPOINT_LSN
,
LOG_CHECKPOINT_CHECKSUM_2
-
LOG_CHECKPOINT_LSN
);
mach_write_to_4
(
buf
+
LOG_CHECKPOINT_CHECKSUM_2
,
fold
);
/* Starting from InnoDB-3.23.50, we should also write info on
allocated size in the tablespace, but unfortunately we do not
know it here */
}
/**********************************************************
/**********************************************************
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */
Reads a checkpoint info from a log group header to log_sys->checkpoint_buf. */
...
@@ -2795,7 +2939,10 @@ log_check_log_recs(
...
@@ -2795,7 +2939,10 @@ log_check_log_recs(
ut_memcpy
(
scan_buf
,
start
,
end
-
start
);
ut_memcpy
(
scan_buf
,
start
,
end
-
start
);
recv_scan_log_recs
(
FALSE
,
scan_buf
,
end
-
start
,
recv_scan_log_recs
(
TRUE
,
buf_pool_get_curr_size
()
-
RECV_POOL_N_FREE_BLOCKS
*
UNIV_PAGE_SIZE
,
FALSE
,
scan_buf
,
end
-
start
,
ut_dulint_align_down
(
buf_start_lsn
,
ut_dulint_align_down
(
buf_start_lsn
,
OS_FILE_LOG_BLOCK_SIZE
),
OS_FILE_LOG_BLOCK_SIZE
),
&
contiguous_lsn
,
&
scanned_lsn
);
&
contiguous_lsn
,
&
scanned_lsn
);
...
...
innobase/log/log0recv.c
View file @
e90a57aa
This diff is collapsed.
Click to expand it.
innobase/mem/mem0mem.c
View file @
e90a57aa
...
@@ -234,7 +234,8 @@ mem_heap_add_block(
...
@@ -234,7 +234,8 @@ mem_heap_add_block(
new_size
=
2
*
mem_block_get_len
(
block
);
new_size
=
2
*
mem_block_get_len
(
block
);
if
(
heap
->
type
!=
MEM_HEAP_DYNAMIC
)
{
if
(
heap
->
type
!=
MEM_HEAP_DYNAMIC
)
{
ut_ad
(
n
<=
MEM_MAX_ALLOC_IN_BUF
);
/* From the buffer pool we allocate buffer frames */
ut_a
(
n
<=
MEM_MAX_ALLOC_IN_BUF
);
if
(
new_size
>
MEM_MAX_ALLOC_IN_BUF
)
{
if
(
new_size
>
MEM_MAX_ALLOC_IN_BUF
)
{
new_size
=
MEM_MAX_ALLOC_IN_BUF
;
new_size
=
MEM_MAX_ALLOC_IN_BUF
;
...
...
innobase/os/os0file.c
View file @
e90a57aa
This diff is collapsed.
Click to expand it.
innobase/rem/rem0cmp.c
View file @
e90a57aa
...
@@ -55,7 +55,8 @@ cmp_debug_dtuple_rec_with_match(
...
@@ -55,7 +55,8 @@ cmp_debug_dtuple_rec_with_match(
contains the value for current comparison */
contains the value for current comparison */
/*****************************************************************
/*****************************************************************
This function is used to compare two data fields for which the data type
This function is used to compare two data fields for which the data type
is such that we must use MySQL code to compare them. */
is such that we must use MySQL code to compare them. The prototype here
must be a copy of the the one in ha_innobase.cc! */
int
int
innobase_mysql_cmp
(
innobase_mysql_cmp
(
...
...
innobase/row/row0ins.c
View file @
e90a57aa
...
@@ -391,7 +391,7 @@ row_ins_check_foreign_constraint(
...
@@ -391,7 +391,7 @@ row_ins_check_foreign_constraint(
/* out: DB_SUCCESS, DB_LOCK_WAIT,
/* out: DB_SUCCESS, DB_LOCK_WAIT,
DB_NO_REFERENCED_ROW,
DB_NO_REFERENCED_ROW,
or DB_ROW_IS_REFERENCED */
or DB_ROW_IS_REFERENCED */
ibool
check_ref
,
/* in: TRUE
I
f we want to check that
ibool
check_ref
,
/* in: TRUE
i
f we want to check that
the referenced table is ok, FALSE if we
the referenced table is ok, FALSE if we
want to to check the foreign key table */
want to to check the foreign key table */
dict_foreign_t
*
foreign
,
/* in: foreign constraint; NOTE that the
dict_foreign_t
*
foreign
,
/* in: foreign constraint; NOTE that the
...
@@ -411,10 +411,23 @@ row_ins_check_foreign_constraint(
...
@@ -411,10 +411,23 @@ row_ins_check_foreign_constraint(
ibool
moved
;
ibool
moved
;
int
cmp
;
int
cmp
;
ulint
err
;
ulint
err
;
ulint
i
;
mtr_t
mtr
;
mtr_t
mtr
;
ut_ad
(
rw_lock_own
(
&
dict_foreign_key_check_lock
,
RW_LOCK_SHARED
));
ut_ad
(
rw_lock_own
(
&
dict_foreign_key_check_lock
,
RW_LOCK_SHARED
));
/* If any of the foreign key fields in entry is SQL NULL, we
suppress the foreign key check: this is compatible with Oracle,
for example */
for
(
i
=
0
;
i
<
foreign
->
n_fields
;
i
++
)
{
if
(
UNIV_SQL_NULL
==
dfield_get_len
(
dtuple_get_nth_field
(
entry
,
i
)))
{
return
(
DB_SUCCESS
);
}
}
if
(
check_ref
)
{
if
(
check_ref
)
{
check_table
=
foreign
->
referenced_table
;
check_table
=
foreign
->
referenced_table
;
check_index
=
foreign
->
referenced_index
;
check_index
=
foreign
->
referenced_index
;
...
@@ -591,6 +604,8 @@ row_ins_scan_sec_index_for_duplicate(
...
@@ -591,6 +604,8 @@ row_ins_scan_sec_index_for_duplicate(
dtuple_t
*
entry
,
/* in: index entry */
dtuple_t
*
entry
,
/* in: index entry */
que_thr_t
*
thr
)
/* in: query thread */
que_thr_t
*
thr
)
/* in: query thread */
{
{
ulint
n_unique
;
ulint
i
;
int
cmp
;
int
cmp
;
ulint
n_fields_cmp
;
ulint
n_fields_cmp
;
rec_t
*
rec
;
rec_t
*
rec
;
...
@@ -599,6 +614,20 @@ row_ins_scan_sec_index_for_duplicate(
...
@@ -599,6 +614,20 @@ row_ins_scan_sec_index_for_duplicate(
ibool
moved
;
ibool
moved
;
mtr_t
mtr
;
mtr_t
mtr
;
n_unique
=
dict_index_get_n_unique
(
index
);
/* If the secondary index is unique, but one of the fields in the
n_unique first fields is NULL, a unique key violation cannot occur,
since we define NULL != NULL in this case */
for
(
i
=
0
;
i
<
n_unique
;
i
++
)
{
if
(
UNIV_SQL_NULL
==
dfield_get_len
(
dtuple_get_nth_field
(
entry
,
i
)))
{
return
(
DB_SUCCESS
);
}
}
mtr_start
(
&
mtr
);
mtr_start
(
&
mtr
);
/* Store old value on n_fields_cmp */
/* Store old value on n_fields_cmp */
...
...
innobase/row/row0mysql.c
View file @
e90a57aa
...
@@ -1881,6 +1881,28 @@ loop:
...
@@ -1881,6 +1881,28 @@ loop:
return
(
err
);
return
(
err
);
}
}
/*************************************************************************
Checks if a table name contains the string "/#sql" which denotes temporary
tables in MySQL. */
static
ibool
row_is_mysql_tmp_table_name
(
/*========================*/
/* out: TRUE if temporary table */
char
*
name
)
/* in: table name in the form 'database/tablename' */
{
ulint
i
;
for
(
i
=
0
;
i
<=
ut_strlen
(
name
)
-
5
;
i
++
)
{
if
(
ut_memcmp
(
name
+
i
,
"/#sql"
,
5
)
==
0
)
{
return
(
TRUE
);
}
}
return
(
FALSE
);
}
/*************************************************************************
/*************************************************************************
Renames a table for MySQL. */
Renames a table for MySQL. */
...
@@ -1944,6 +1966,17 @@ row_rename_table_for_mysql(
...
@@ -1944,6 +1966,17 @@ row_rename_table_for_mysql(
str2
=
str2
=
"';
\n
old_table_name := '"
;
"';
\n
old_table_name := '"
;
if
(
row_is_mysql_tmp_table_name
(
new_name
))
{
/* We want to preserve the original foreign key
constraint definitions despite the name change */
str3
=
"';
\n
"
"UPDATE SYS_TABLES SET NAME = new_table_name
\n
"
"WHERE NAME = old_table_name;
\n
"
"END;
\n
"
;
}
else
{
str3
=
str3
=
"';
\n
"
"';
\n
"
"UPDATE SYS_TABLES SET NAME = new_table_name
\n
"
"UPDATE SYS_TABLES SET NAME = new_table_name
\n
"
...
@@ -1952,8 +1985,8 @@ row_rename_table_for_mysql(
...
@@ -1952,8 +1985,8 @@ row_rename_table_for_mysql(
"WHERE FOR_NAME = old_table_name;
\n
"
"WHERE FOR_NAME = old_table_name;
\n
"
"UPDATE SYS_FOREIGN SET REF_NAME = new_table_name
\n
"
"UPDATE SYS_FOREIGN SET REF_NAME = new_table_name
\n
"
"WHERE REF_NAME = old_table_name;
\n
"
"WHERE REF_NAME = old_table_name;
\n
"
"COMMIT WORK;
\n
"
"END;
\n
"
;
"END;
\n
"
;
}
len
=
ut_strlen
(
str1
);
len
=
ut_strlen
(
str1
);
...
@@ -2028,7 +2061,32 @@ row_rename_table_for_mysql(
...
@@ -2028,7 +2061,32 @@ row_rename_table_for_mysql(
trx_general_rollback_for_mysql
(
trx
,
FALSE
,
NULL
);
trx_general_rollback_for_mysql
(
trx
,
FALSE
,
NULL
);
trx
->
error_state
=
DB_SUCCESS
;
trx
->
error_state
=
DB_SUCCESS
;
}
else
{
}
else
{
ut_a
(
dict_table_rename_in_cache
(
table
,
new_name
));
ut_a
(
dict_table_rename_in_cache
(
table
,
new_name
,
!
row_is_mysql_tmp_table_name
(
new_name
)));
if
(
row_is_mysql_tmp_table_name
(
old_name
))
{
err
=
dict_load_foreigns
(
new_name
);
if
(
err
!=
DB_SUCCESS
)
{
ut_print_timestamp
(
stderr
);
fprintf
(
stderr
,
" InnoDB: Error: in ALTER TABLE table %s
\n
"
"InnoDB: has or is referenced in foreign key constraints
\n
"
"InnoDB: which are not compatible with the new table definition.
\n
"
,
new_name
);
ut_a
(
dict_table_rename_in_cache
(
table
,
old_name
,
FALSE
));
trx
->
error_state
=
DB_SUCCESS
;
trx_general_rollback_for_mysql
(
trx
,
FALSE
,
NULL
);
trx
->
error_state
=
DB_SUCCESS
;
}
}
}
}
funct_exit:
funct_exit:
mutex_exit
(
&
(
dict_sys
->
mutex
));
mutex_exit
(
&
(
dict_sys
->
mutex
));
...
...
innobase/row/row0sel.c
View file @
e90a57aa
...
@@ -2233,7 +2233,7 @@ row_sel_get_clust_rec_for_mysql(
...
@@ -2233,7 +2233,7 @@ row_sel_get_clust_rec_for_mysql(
(or old_vers) is not rec; in that case we must ignore
(or old_vers) is not rec; in that case we must ignore
such row because in our snapshot rec would not have existed.
such row because in our snapshot rec would not have existed.
Remember that from rec we cannot see directly which transaction
Remember that from rec we cannot see directly which transaction
id corrsponds to it: we have to go to the clustered index
id corr
e
sponds to it: we have to go to the clustered index
record. A query where we want to fetch all rows where
record. A query where we want to fetch all rows where
the secondary index value is in some interval would return
the secondary index value is in some interval would return
a wrong result if we would not drop rows which we come to
a wrong result if we would not drop rows which we come to
...
@@ -2244,6 +2244,12 @@ row_sel_get_clust_rec_for_mysql(
...
@@ -2244,6 +2244,12 @@ row_sel_get_clust_rec_for_mysql(
&&
!
row_sel_sec_rec_is_for_clust_rec
(
rec
,
sec_index
,
&&
!
row_sel_sec_rec_is_for_clust_rec
(
rec
,
sec_index
,
clust_rec
,
clust_index
))
{
clust_rec
,
clust_index
))
{
clust_rec
=
NULL
;
clust_rec
=
NULL
;
}
else
{
#ifdef UNIV_SEARCH_DEBUG
ut_a
(
clust_rec
==
NULL
||
row_sel_sec_rec_is_for_clust_rec
(
rec
,
sec_index
,
clust_rec
,
clust_index
));
#endif
}
}
}
}
...
@@ -2399,7 +2405,12 @@ row_sel_try_search_shortcut_for_mysql(
...
@@ -2399,7 +2405,12 @@ row_sel_try_search_shortcut_for_mysql(
btr_pcur_open_with_no_init
(
index
,
search_tuple
,
PAGE_CUR_GE
,
btr_pcur_open_with_no_init
(
index
,
search_tuple
,
PAGE_CUR_GE
,
BTR_SEARCH_LEAF
,
pcur
,
BTR_SEARCH_LEAF
,
pcur
,
RW_S_LATCH
,
mtr
);
#ifndef UNIV_SEARCH_DEBUG
RW_S_LATCH
,
#else
0
,
#endif
mtr
);
rec
=
btr_pcur_get_rec
(
pcur
);
rec
=
btr_pcur_get_rec
(
pcur
);
if
(
!
page_rec_is_user_rec
(
rec
))
{
if
(
!
page_rec_is_user_rec
(
rec
))
{
...
@@ -2623,15 +2634,18 @@ row_search_for_mysql(
...
@@ -2623,15 +2634,18 @@ row_search_for_mysql(
goto
no_shortcut
;
goto
no_shortcut
;
}
}
#ifndef UNIV_SEARCH_DEBUG
if
(
!
trx
->
has_search_latch
)
{
if
(
!
trx
->
has_search_latch
)
{
rw_lock_s_lock
(
&
btr_search_latch
);
rw_lock_s_lock
(
&
btr_search_latch
);
trx
->
has_search_latch
=
TRUE
;
trx
->
has_search_latch
=
TRUE
;
}
}
#endif
shortcut
=
row_sel_try_search_shortcut_for_mysql
(
&
rec
,
shortcut
=
row_sel_try_search_shortcut_for_mysql
(
&
rec
,
prebuilt
,
&
mtr
);
prebuilt
,
&
mtr
);
if
(
shortcut
==
SEL_FOUND
)
{
if
(
shortcut
==
SEL_FOUND
)
{
#ifdef UNIV_SEARCH_DEBUG
ut_a
(
0
==
cmp_dtuple_rec
(
search_tuple
,
rec
));
#endif
row_sel_store_mysql_rec
(
buf
,
prebuilt
,
rec
);
row_sel_store_mysql_rec
(
buf
,
prebuilt
,
rec
);
mtr_commit
(
&
mtr
);
mtr_commit
(
&
mtr
);
...
@@ -2793,7 +2807,9 @@ rec_loop:
...
@@ -2793,7 +2807,9 @@ rec_loop:
/* The record matches enough */
/* The record matches enough */
ut_ad
(
mode
==
PAGE_CUR_GE
);
ut_ad
(
mode
==
PAGE_CUR_GE
);
#ifdef UNIV_SEARCH_DEBUG
ut_a
(
0
==
cmp_dtuple_rec
(
search_tuple
,
rec
));
#endif
}
else
if
(
match_mode
==
ROW_SEL_EXACT
)
{
}
else
if
(
match_mode
==
ROW_SEL_EXACT
)
{
/* Test if the index record matches completely to search_tuple
/* Test if the index record matches completely to search_tuple
in prebuilt: if not, then we return with DB_RECORD_NOT_FOUND */
in prebuilt: if not, then we return with DB_RECORD_NOT_FOUND */
...
...
innobase/row/row0upd.c
View file @
e90a57aa
...
@@ -142,7 +142,7 @@ try_again:
...
@@ -142,7 +142,7 @@ try_again:
/*************************************************************************
/*************************************************************************
Checks if possible foreign key constraints hold after a delete of the record
Checks if possible foreign key constraints hold after a delete of the record
under pcur. NOTE that this function will temporarily commit mtr and lose
under pcur. NOTE that this function will temporarily commit mtr and lose
the
pcur position! */
pcur position! */
static
static
ulint
ulint
...
...
innobase/srv/srv0srv.c
View file @
e90a57aa
...
@@ -69,13 +69,19 @@ char* srv_main_thread_op_info = "";
...
@@ -69,13 +69,19 @@ char* srv_main_thread_op_info = "";
names, where the file name itself may also contain a path */
names, where the file name itself may also contain a path */
char
*
srv_data_home
=
NULL
;
char
*
srv_data_home
=
NULL
;
char
*
srv_logs_home
=
NULL
;
char
*
srv_arch_dir
=
NULL
;
char
*
srv_arch_dir
=
NULL
;
ulint
srv_n_data_files
=
0
;
ulint
srv_n_data_files
=
0
;
char
**
srv_data_file_names
=
NULL
;
char
**
srv_data_file_names
=
NULL
;
ulint
*
srv_data_file_sizes
=
NULL
;
/* size in database pages */
ulint
*
srv_data_file_sizes
=
NULL
;
/* size in database pages */
ibool
srv_auto_extend_last_data_file
=
FALSE
;
/* if TRUE, then we
auto-extend the last data
file */
ulint
srv_last_file_size_max
=
0
;
/* if != 0, this tells
the max size auto-extending
may increase the last data
file size */
ulint
*
srv_data_file_is_raw_partition
=
NULL
;
ulint
*
srv_data_file_is_raw_partition
=
NULL
;
/* If the following is TRUE we do not allow inserts etc. This protects
/* If the following is TRUE we do not allow inserts etc. This protects
...
@@ -1596,7 +1602,7 @@ srv_read_initfile(
...
@@ -1596,7 +1602,7 @@ srv_read_initfile(
/*************************************************************************
/*************************************************************************
Initializes the server. */
Initializes the server. */
static
void
void
srv_init
(
void
)
srv_init
(
void
)
/*==========*/
/*==========*/
...
@@ -1664,7 +1670,7 @@ srv_init(void)
...
@@ -1664,7 +1670,7 @@ srv_init(void)
/*************************************************************************
/*************************************************************************
Initializes the synchronization primitives, memory system, and the thread
Initializes the synchronization primitives, memory system, and the thread
local storage. */
local storage. */
static
void
void
srv_general_init
(
void
)
srv_general_init
(
void
)
/*==================*/
/*==================*/
...
@@ -1686,6 +1692,7 @@ srv_conc_enter_innodb(
...
@@ -1686,6 +1692,7 @@ srv_conc_enter_innodb(
trx_t
*
trx
)
/* in: transaction object associated with the
trx_t
*
trx
)
/* in: transaction object associated with the
thread */
thread */
{
{
ibool
has_slept
=
FALSE
;
srv_conc_slot_t
*
slot
;
srv_conc_slot_t
*
slot
;
ulint
i
;
ulint
i
;
...
@@ -1703,7 +1710,7 @@ srv_conc_enter_innodb(
...
@@ -1703,7 +1710,7 @@ srv_conc_enter_innodb(
return
;
return
;
}
}
retry:
os_fast_mutex_lock
(
&
srv_conc_mutex
);
os_fast_mutex_lock
(
&
srv_conc_mutex
);
if
(
srv_conc_n_threads
<
(
lint
)
srv_thread_concurrency
)
{
if
(
srv_conc_n_threads
<
(
lint
)
srv_thread_concurrency
)
{
...
@@ -1717,6 +1724,22 @@ srv_conc_enter_innodb(
...
@@ -1717,6 +1724,22 @@ srv_conc_enter_innodb(
return
;
return
;
}
}
/* If the transaction is not holding resources, let it sleep
for 100 milliseconds, and try again then */
if
(
!
has_slept
&&
!
trx
->
has_search_latch
&&
NULL
==
UT_LIST_GET_FIRST
(
trx
->
trx_locks
))
{
has_slept
=
TRUE
;
/* We let is sleep only once to avoid
starvation */
os_fast_mutex_unlock
(
&
srv_conc_mutex
);
os_thread_sleep
(
100000
);
goto
retry
;
}
/* Too many threads inside: put the current thread to a queue */
/* Too many threads inside: put the current thread to a queue */
for
(
i
=
0
;
i
<
OS_THREAD_MAX_N
;
i
++
)
{
for
(
i
=
0
;
i
<
OS_THREAD_MAX_N
;
i
++
)
{
...
@@ -1908,6 +1931,9 @@ srv_normalize_init_values(void)
...
@@ -1908,6 +1931,9 @@ srv_normalize_init_values(void)
*
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
*
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
}
}
srv_last_file_size_max
=
srv_last_file_size_max
*
((
1024
*
1024
)
/
UNIV_PAGE_SIZE
);
srv_log_file_size
=
srv_log_file_size
/
UNIV_PAGE_SIZE
;
srv_log_file_size
=
srv_log_file_size
/
UNIV_PAGE_SIZE
;
srv_log_buffer_size
=
srv_log_buffer_size
/
UNIV_PAGE_SIZE
;
srv_log_buffer_size
=
srv_log_buffer_size
/
UNIV_PAGE_SIZE
;
...
...
innobase/srv/srv0start.c
View file @
e90a57aa
This diff is collapsed.
Click to expand it.
innobase/trx/trx0sys.c
View file @
e90a57aa
...
@@ -20,11 +20,42 @@ Created 3/26/1996 Heikki Tuuri
...
@@ -20,11 +20,42 @@ Created 3/26/1996 Heikki Tuuri
#include "srv0srv.h"
#include "srv0srv.h"
#include "trx0purge.h"
#include "trx0purge.h"
#include "log0log.h"
#include "log0log.h"
#include "os0file.h"
/* The transaction system */
/* The transaction system */
trx_sys_t
*
trx_sys
=
NULL
;
trx_sys_t
*
trx_sys
=
NULL
;
trx_doublewrite_t
*
trx_doublewrite
=
NULL
;
trx_doublewrite_t
*
trx_doublewrite
=
NULL
;
/********************************************************************
Determines if a page number is located inside the doublewrite buffer. */
ibool
trx_doublewrite_page_inside
(
/*========================*/
/* out: TRUE if the location is inside
the two blocks of the doublewrite buffer */
ulint
page_no
)
/* in: page number */
{
if
(
trx_doublewrite
==
NULL
)
{
return
(
FALSE
);
}
if
(
page_no
>=
trx_doublewrite
->
block1
&&
page_no
<
trx_doublewrite
->
block1
+
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
)
{
return
(
TRUE
);
}
if
(
page_no
>=
trx_doublewrite
->
block2
&&
page_no
<
trx_doublewrite
->
block2
+
TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
)
{
return
(
TRUE
);
}
return
(
FALSE
);
}
/********************************************************************
/********************************************************************
Creates or initialializes the doublewrite buffer at a database start. */
Creates or initialializes the doublewrite buffer at a database start. */
static
static
...
@@ -36,6 +67,11 @@ trx_doublewrite_init(
...
@@ -36,6 +67,11 @@ trx_doublewrite_init(
{
{
trx_doublewrite
=
mem_alloc
(
sizeof
(
trx_doublewrite_t
));
trx_doublewrite
=
mem_alloc
(
sizeof
(
trx_doublewrite_t
));
/* When we have the doublewrite buffer in use, we do not need to
call os_file_flush (Unix fsync) after every write. */
os_do_not_call_flush_at_each_write
=
TRUE
;
mutex_create
(
&
(
trx_doublewrite
->
mutex
));
mutex_create
(
&
(
trx_doublewrite
->
mutex
));
mutex_set_level
(
&
(
trx_doublewrite
->
mutex
),
SYNC_DOUBLEWRITE
);
mutex_set_level
(
&
(
trx_doublewrite
->
mutex
),
SYNC_DOUBLEWRITE
);
...
...
innobase/ut/ut0mem.c
View file @
e90a57aa
...
@@ -121,6 +121,7 @@ ut_malloc(
...
@@ -121,6 +121,7 @@ ut_malloc(
{
{
return
(
ut_malloc_low
(
n
,
TRUE
));
return
(
ut_malloc_low
(
n
,
TRUE
));
}
}
/**************************************************************************
/**************************************************************************
Frees a memory block allocated with ut_malloc. */
Frees a memory block allocated with ut_malloc. */
...
...
innobase/ut/ut0ut.c
View file @
e90a57aa
...
@@ -16,6 +16,24 @@ Created 5/11/1994 Heikki Tuuri
...
@@ -16,6 +16,24 @@ Created 5/11/1994 Heikki Tuuri
ibool
ut_always_false
=
FALSE
;
ibool
ut_always_false
=
FALSE
;
/************************************************************
Gets the high 32 bits in a ulint. That is makes a shift >> 32,
but since there seem to be compiler bugs in both gcc and Visual C++,
we do this by a special conversion. */
ulint
ut_get_high32
(
/*==========*/
/* out: a >> 32 */
ulint
a
)
/* in: ulint */
{
if
(
sizeof
(
ulint
)
==
4
)
{
return
(
0
);
}
return
(
a
>>
32
);
}
/************************************************************
/************************************************************
The following function returns a clock time in milliseconds. */
The following function returns a clock time in milliseconds. */
...
@@ -70,7 +88,6 @@ ut_print_timestamp(
...
@@ -70,7 +88,6 @@ ut_print_timestamp(
(
int
)
cal_tm
.
wMinute
,
(
int
)
cal_tm
.
wMinute
,
(
int
)
cal_tm
.
wSecond
);
(
int
)
cal_tm
.
wSecond
);
#else
#else
struct
tm
cal_tm
;
struct
tm
cal_tm
;
struct
tm
*
cal_tm_ptr
;
struct
tm
*
cal_tm_ptr
;
time_t
tm
;
time_t
tm
;
...
@@ -83,10 +100,9 @@ ut_print_timestamp(
...
@@ -83,10 +100,9 @@ ut_print_timestamp(
#else
#else
cal_tm_ptr
=
localtime
(
&
tm
);
cal_tm_ptr
=
localtime
(
&
tm
);
#endif
#endif
fprintf
(
file
,
"%02d%02d%02d %2d:%02d:%02d"
,
fprintf
(
file
,
"%02d%02d%02d %2d:%02d:%02d"
,
cal_tm_ptr
->
tm_year
%
100
,
cal_tm_ptr
->
tm_year
%
100
,
cal_tm_ptr
->
tm_mon
+
1
,
cal_tm_ptr
->
tm_mon
+
1
,
cal_tm_ptr
->
tm_mday
,
cal_tm_ptr
->
tm_mday
,
cal_tm_ptr
->
tm_hour
,
cal_tm_ptr
->
tm_hour
,
cal_tm_ptr
->
tm_min
,
cal_tm_ptr
->
tm_min
,
...
@@ -94,6 +110,39 @@ ut_print_timestamp(
...
@@ -94,6 +110,39 @@ ut_print_timestamp(
#endif
#endif
}
}
/**************************************************************
Returns current year, month, day. */
void
ut_get_year_month_day
(
/*==================*/
ulint
*
year
,
/* out: current year */
ulint
*
month
,
/* out: month */
ulint
*
day
)
/* out: day */
{
#ifdef __WIN__
SYSTEMTIME
cal_tm
;
GetLocalTime
(
&
cal_tm
);
*
year
=
(
ulint
)
cal_tm
.
wYear
;
*
month
=
(
ulint
)
cal_tm
.
wMonth
;
*
day
=
(
ulint
)
cal_tm
.
wDay
;
#else
struct
tm
cal_tm
;
struct
tm
*
cal_tm_ptr
;
time_t
tm
;
time
(
&
tm
);
cal_tm_ptr
=
localtime
(
&
tm
);
*
year
=
(
ulint
)
cal_tm_ptr
->
tm_year
;
*
month
=
(
ulint
)
cal_tm_ptr
->
tm_mon
+
1
;
*
day
=
(
ulint
)
cal_tm_ptr
->
tm_mday
;
#endif
}
/*****************************************************************
/*****************************************************************
Runs an idle loop on CPU. The argument gives the desired delay
Runs an idle loop on CPU. The argument gives the desired delay
in microseconds on 100 MHz Pentium + Visual C++. */
in microseconds on 100 MHz Pentium + Visual C++. */
...
...
sql/ha_innobase.cc
View file @
e90a57aa
This diff is collapsed.
Click to expand it.
sql/ha_innobase.h
View file @
e90a57aa
...
@@ -154,7 +154,8 @@ class ha_innobase: public handler
...
@@ -154,7 +154,8 @@ class ha_innobase: public handler
int
rename_table
(
const
char
*
from
,
const
char
*
to
);
int
rename_table
(
const
char
*
from
,
const
char
*
to
);
int
check
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
int
check
(
THD
*
thd
,
HA_CHECK_OPT
*
check_opt
);
char
*
update_table_comment
(
const
char
*
comment
);
char
*
update_table_comment
(
const
char
*
comment
);
char
*
get_foreign_key_create_info
();
void
free_foreign_key_create_info
(
char
*
str
);
THR_LOCK_DATA
**
store_lock
(
THD
*
thd
,
THR_LOCK_DATA
**
to
,
THR_LOCK_DATA
**
store_lock
(
THD
*
thd
,
THR_LOCK_DATA
**
to
,
enum
thr_lock_type
lock_type
);
enum
thr_lock_type
lock_type
);
longlong
get_auto_increment
();
longlong
get_auto_increment
();
...
...
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