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
abc5ef2b
Commit
abc5ef2b
authored
Feb 18, 2001
by
monty@donna.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up ha_innobase.cc from whitespace
parent
d218ebcc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
137 additions
and
138 deletions
+137
-138
sql/ha_innobase.cc
sql/ha_innobase.cc
+137
-138
No files found.
sql/ha_innobase.cc
View file @
abc5ef2b
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & Innobase Oy
& Innobase Oy
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
(at your option) any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
...
@@ -76,7 +75,7 @@ bool innobase_skip = 0;
...
@@ -76,7 +75,7 @@ bool innobase_skip = 0;
uint
innobase_init_flags
=
0
;
uint
innobase_init_flags
=
0
;
ulong
innobase_cache_size
=
0
;
ulong
innobase_cache_size
=
0
;
long
innobase_mirrored_log_groups
,
innobase_log_files_in_group
,
long
innobase_mirrored_log_groups
,
innobase_log_files_in_group
,
innobase_log_file_size
,
innobase_log_buffer_size
,
innobase_log_file_size
,
innobase_log_buffer_size
,
innobase_buffer_pool_size
,
innobase_additional_mem_pool_size
,
innobase_buffer_pool_size
,
innobase_additional_mem_pool_size
,
innobase_file_io_threads
,
innobase_lock_wait_timeout
;
innobase_file_io_threads
,
innobase_lock_wait_timeout
;
...
@@ -197,9 +196,9 @@ check_trx_exists(
...
@@ -197,9 +196,9 @@ check_trx_exists(
if
(
trx
==
NULL
)
{
if
(
trx
==
NULL
)
{
assert
(
thd
!=
NULL
);
assert
(
thd
!=
NULL
);
trx
=
trx_allocate_for_mysql
();
trx
=
trx_allocate_for_mysql
();
thd
->
transaction
.
all
.
innobase_tid
=
trx
;
thd
->
transaction
.
all
.
innobase_tid
=
trx
;
/* The execution of a single SQL statement is denoted by
/* The execution of a single SQL statement is denoted by
a 'transaction' handle which is a NULL pointer: Innobase
a 'transaction' handle which is a NULL pointer: Innobase
remembers internally where the latest SQL statement
remembers internally where the latest SQL statement
...
@@ -234,7 +233,7 @@ ha_innobase::update_thd(
...
@@ -234,7 +233,7 @@ ha_innobase::update_thd(
}
}
user_thd
=
thd
;
user_thd
=
thd
;
return
(
0
);
return
(
0
);
}
}
...
@@ -262,7 +261,7 @@ innobase_parse_data_file_paths_and_sizes(void)
...
@@ -262,7 +261,7 @@ innobase_parse_data_file_paths_and_sizes(void)
while
(
*
str
!=
'\0'
)
{
while
(
*
str
!=
'\0'
)
{
path
=
str
;
path
=
str
;
while
(
*
str
!=
':'
&&
*
str
!=
'\0'
)
{
while
(
*
str
!=
':'
&&
*
str
!=
'\0'
)
{
str
++
;
str
++
;
}
}
...
@@ -271,7 +270,7 @@ innobase_parse_data_file_paths_and_sizes(void)
...
@@ -271,7 +270,7 @@ innobase_parse_data_file_paths_and_sizes(void)
}
}
str
++
;
str
++
;
size
=
strtoul
(
str
,
&
endp
,
10
);
size
=
strtoul
(
str
,
&
endp
,
10
);
str
=
endp
;
str
=
endp
;
...
@@ -294,7 +293,7 @@ innobase_parse_data_file_paths_and_sizes(void)
...
@@ -294,7 +293,7 @@ innobase_parse_data_file_paths_and_sizes(void)
return
(
FALSE
);
return
(
FALSE
);
}
}
}
}
srv_data_file_names
=
(
char
**
)
ut_malloc
(
i
*
sizeof
(
void
*
));
srv_data_file_names
=
(
char
**
)
ut_malloc
(
i
*
sizeof
(
void
*
));
srv_data_file_sizes
=
(
ulint
*
)
ut_malloc
(
i
*
sizeof
(
ulint
));
srv_data_file_sizes
=
(
ulint
*
)
ut_malloc
(
i
*
sizeof
(
ulint
));
...
@@ -304,20 +303,20 @@ innobase_parse_data_file_paths_and_sizes(void)
...
@@ -304,20 +303,20 @@ innobase_parse_data_file_paths_and_sizes(void)
str
=
innobase_data_file_path
;
str
=
innobase_data_file_path
;
i
=
0
;
i
=
0
;
while
(
*
str
!=
'\0'
)
{
while
(
*
str
!=
'\0'
)
{
path
=
str
;
path
=
str
;
while
(
*
str
!=
':'
&&
*
str
!=
'\0'
)
{
while
(
*
str
!=
':'
&&
*
str
!=
'\0'
)
{
str
++
;
str
++
;
}
}
if
(
*
str
==
':'
)
{
if
(
*
str
==
':'
)
{
/* Make path a null-terminated string */
/* Make path a null-terminated string */
*
str
=
'\0'
;
*
str
=
'\0'
;
str
++
;
str
++
;
}
}
size
=
strtoul
(
str
,
&
endp
,
10
);
size
=
strtoul
(
str
,
&
endp
,
10
);
str
=
endp
;
str
=
endp
;
...
@@ -337,7 +336,7 @@ innobase_parse_data_file_paths_and_sizes(void)
...
@@ -337,7 +336,7 @@ innobase_parse_data_file_paths_and_sizes(void)
}
}
}
}
return
(
TRUE
);
return
(
TRUE
);
}
}
/*************************************************************************
/*************************************************************************
...
@@ -362,7 +361,7 @@ innobase_parse_log_group_home_dirs(void)
...
@@ -362,7 +361,7 @@ innobase_parse_log_group_home_dirs(void)
while
(
*
str
!=
'\0'
)
{
while
(
*
str
!=
'\0'
)
{
path
=
str
;
path
=
str
;
while
(
*
str
!=
';'
&&
*
str
!=
'\0'
)
{
while
(
*
str
!=
';'
&&
*
str
!=
'\0'
)
{
str
++
;
str
++
;
}
}
...
@@ -375,7 +374,7 @@ innobase_parse_log_group_home_dirs(void)
...
@@ -375,7 +374,7 @@ innobase_parse_log_group_home_dirs(void)
return
(
FALSE
);
return
(
FALSE
);
}
}
}
}
if
(
i
!=
(
ulint
)
innobase_mirrored_log_groups
)
{
if
(
i
!=
(
ulint
)
innobase_mirrored_log_groups
)
{
return
(
FALSE
);
return
(
FALSE
);
...
@@ -387,25 +386,25 @@ innobase_parse_log_group_home_dirs(void)
...
@@ -387,25 +386,25 @@ innobase_parse_log_group_home_dirs(void)
str
=
innobase_log_group_home_dir
;
str
=
innobase_log_group_home_dir
;
i
=
0
;
i
=
0
;
while
(
*
str
!=
'\0'
)
{
while
(
*
str
!=
'\0'
)
{
path
=
str
;
path
=
str
;
while
(
*
str
!=
';'
&&
*
str
!=
'\0'
)
{
while
(
*
str
!=
';'
&&
*
str
!=
'\0'
)
{
str
++
;
str
++
;
}
}
if
(
*
str
==
';'
)
{
if
(
*
str
==
';'
)
{
*
str
=
'\0'
;
*
str
=
'\0'
;
str
++
;
str
++
;
}
}
srv_log_group_home_dirs
[
i
]
=
path
;
srv_log_group_home_dirs
[
i
]
=
path
;
i
++
;
i
++
;
}
}
return
(
TRUE
);
return
(
TRUE
);
}
}
/*************************************************************************
/*************************************************************************
...
@@ -414,12 +413,12 @@ Opens an Innobase database. */
...
@@ -414,12 +413,12 @@ Opens an Innobase database. */
bool
bool
innobase_init
(
void
)
innobase_init
(
void
)
/*===============*/
/*===============*/
/* out: TRUE if error */
/* out: TRUE if error */
{
{
int
err
;
int
err
;
bool
ret
;
bool
ret
;
ibool
test_bool
;
ibool
test_bool
;
DBUG_ENTER
(
"innobase_init"
);
DBUG_ENTER
(
"innobase_init"
);
test_bool
=
TRUE
;
test_bool
=
TRUE
;
...
@@ -439,7 +438,7 @@ innobase_init(void)
...
@@ -439,7 +438,7 @@ innobase_init(void)
if
(
ret
==
FALSE
)
{
if
(
ret
==
FALSE
)
{
return
(
TRUE
);
return
(
TRUE
);
}
}
ret
=
innobase_parse_log_group_home_dirs
();
ret
=
innobase_parse_log_group_home_dirs
();
if
(
ret
==
FALSE
)
{
if
(
ret
==
FALSE
)
{
...
@@ -447,20 +446,20 @@ innobase_init(void)
...
@@ -447,20 +446,20 @@ innobase_init(void)
}
}
srv_n_log_groups
=
(
ulint
)
innobase_mirrored_log_groups
;
srv_n_log_groups
=
(
ulint
)
innobase_mirrored_log_groups
;
srv_n_log_files
=
(
ulint
)
innobase_log_files_in_group
;
srv_n_log_files
=
(
ulint
)
innobase_log_files_in_group
;
srv_log_file_size
=
(
ulint
)
innobase_log_file_size
;
srv_log_file_size
=
(
ulint
)
innobase_log_file_size
;
srv_log_archive_on
=
(
ulint
)
innobase_log_archive
;
srv_log_archive_on
=
(
ulint
)
innobase_log_archive
;
srv_log_buffer_size
=
(
ulint
)
innobase_log_buffer_size
;
srv_log_buffer_size
=
(
ulint
)
innobase_log_buffer_size
;
srv_flush_log_at_trx_commit
=
(
ulint
)
innobase_flush_log_at_trx_commit
;
srv_flush_log_at_trx_commit
=
(
ulint
)
innobase_flush_log_at_trx_commit
;
srv_use_native_aio
=
0
;
srv_use_native_aio
=
0
;
srv_pool_size
=
(
ulint
)
innobase_buffer_pool_size
;
srv_pool_size
=
(
ulint
)
innobase_buffer_pool_size
;
srv_mem_pool_size
=
(
ulint
)
innobase_additional_mem_pool_size
;
srv_mem_pool_size
=
(
ulint
)
innobase_additional_mem_pool_size
;
srv_n_file_io_threads
=
(
ulint
)
innobase_file_io_threads
;
srv_n_file_io_threads
=
(
ulint
)
innobase_file_io_threads
;
srv_lock_wait_timeout
=
(
ulint
)
innobase_lock_wait_timeout
;
srv_lock_wait_timeout
=
(
ulint
)
innobase_lock_wait_timeout
;
err
=
innobase_start_or_create_for_mysql
();
err
=
innobase_start_or_create_for_mysql
();
...
@@ -493,7 +492,7 @@ innobase_end(void)
...
@@ -493,7 +492,7 @@ innobase_end(void)
return
(
1
);
return
(
1
);
}
}
return
(
0
);
return
(
0
);
}
}
...
@@ -511,7 +510,7 @@ innobase_flush_logs(void)
...
@@ -511,7 +510,7 @@ innobase_flush_logs(void)
DBUG_ENTER
(
"innobase_flush_logs"
);
DBUG_ENTER
(
"innobase_flush_logs"
);
log_make_checkpoint_at
(
ut_dulint_max
,
TRUE
);
log_make_checkpoint_at
(
ut_dulint_max
,
TRUE
);
DBUG_RETURN
(
result
);
DBUG_RETURN
(
result
);
}
}
...
@@ -581,7 +580,7 @@ innobase_rollback(
...
@@ -581,7 +580,7 @@ innobase_rollback(
{
{
int
error
=
0
;
int
error
=
0
;
trx_t
*
trx
;
trx_t
*
trx
;
DBUG_ENTER
(
"innobase_rollback"
);
DBUG_ENTER
(
"innobase_rollback"
);
DBUG_PRINT
(
"trans"
,
(
"aborting transaction"
));
DBUG_PRINT
(
"trans"
,
(
"aborting transaction"
));
...
@@ -608,13 +607,13 @@ innobase_close_connection(
...
@@ -608,13 +607,13 @@ innobase_close_connection(
whose transaction should be rolled back */
whose transaction should be rolled back */
{
{
if
(
NULL
!=
thd
->
transaction
.
all
.
innobase_tid
)
{
if
(
NULL
!=
thd
->
transaction
.
all
.
innobase_tid
)
{
trx_free_for_mysql
((
trx_t
*
)
trx_free_for_mysql
((
trx_t
*
)
(
thd
->
transaction
.
all
.
innobase_tid
));
(
thd
->
transaction
.
all
.
innobase_tid
));
}
}
return
(
0
);
return
(
0
);
}
}
/**********************************************************************
/**********************************************************************
Prints an error message. */
Prints an error message. */
...
@@ -678,7 +677,7 @@ normalize_table_name(
...
@@ -678,7 +677,7 @@ normalize_table_name(
assert
(
ptr
>
name
);
assert
(
ptr
>
name
);
ptr
--
;
ptr
--
;
while
(
ptr
>=
name
&&
*
ptr
!=
'\\'
&&
*
ptr
!=
'/'
)
{
while
(
ptr
>=
name
&&
*
ptr
!=
'\\'
&&
*
ptr
!=
'/'
)
{
ptr
--
;
ptr
--
;
}
}
...
@@ -689,7 +688,7 @@ normalize_table_name(
...
@@ -689,7 +688,7 @@ normalize_table_name(
norm_name
[
name_ptr
-
db_ptr
-
1
]
=
'/'
;
norm_name
[
name_ptr
-
db_ptr
-
1
]
=
'/'
;
}
}
/*********************************************************************
/*********************************************************************
Creates and opens a handle to a table which already exists in an Innnobase
Creates and opens a handle to a table which already exists in an Innnobase
database. */
database. */
...
@@ -730,18 +729,18 @@ ha_innobase::open(
...
@@ -730,18 +729,18 @@ ha_innobase::open(
&
upd_buff
,
buff_len
,
&
upd_buff
,
buff_len
,
&
key_val_buff
,
buff_len
,
&
key_val_buff
,
buff_len
,
NullS
))
{
NullS
))
{
free_share
(
share
);
free_share
(
share
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
/* MySQL allocates the buffer for ref */
/* MySQL allocates the buffer for ref */
ref_length
=
buff_len
;
ref_length
=
buff_len
;
/* Get pointer to a table object in Innobase dictionary cache */
/* Get pointer to a table object in Innobase dictionary cache */
if
(
NULL
==
(
ib_table
=
dict_table_get
(
norm_name
,
NULL
)))
{
if
(
NULL
==
(
ib_table
=
dict_table_get
(
norm_name
,
NULL
)))
{
free_share
(
share
);
free_share
(
share
);
my_free
((
char
*
)
upd_buff
,
MYF
(
0
));
my_free
((
char
*
)
upd_buff
,
MYF
(
0
));
my_errno
=
ENOENT
;
my_errno
=
ENOENT
;
...
@@ -749,7 +748,7 @@ ha_innobase::open(
...
@@ -749,7 +748,7 @@ ha_innobase::open(
}
}
innobase_prebuilt
=
row_create_prebuilt
(
ib_table
);
innobase_prebuilt
=
row_create_prebuilt
(
ib_table
);
((
row_prebuilt_t
*
)
innobase_prebuilt
)
->
mysql_row_len
=
table
->
reclength
;
((
row_prebuilt_t
*
)
innobase_prebuilt
)
->
mysql_row_len
=
table
->
reclength
;
primary_key
=
MAX_KEY
;
primary_key
=
MAX_KEY
;
...
@@ -765,7 +764,7 @@ ha_innobase::open(
...
@@ -765,7 +764,7 @@ ha_innobase::open(
((
row_prebuilt_t
*
)
innobase_prebuilt
)
((
row_prebuilt_t
*
)
innobase_prebuilt
)
->
clust_index_was_generated
=
FALSE
;
->
clust_index_was_generated
=
FALSE
;
primary_key
=
0
;
primary_key
=
0
;
key_used_on_scan
=
0
;
key_used_on_scan
=
0
;
}
else
{
}
else
{
((
row_prebuilt_t
*
)
innobase_prebuilt
)
((
row_prebuilt_t
*
)
innobase_prebuilt
)
...
@@ -773,12 +772,12 @@ ha_innobase::open(
...
@@ -773,12 +772,12 @@ ha_innobase::open(
assert
(
key_used_on_scan
==
MAX_KEY
);
assert
(
key_used_on_scan
==
MAX_KEY
);
}
}
/* Init table lock structure */
/* Init table lock structure */
thr_lock_data_init
(
&
share
->
lock
,
&
lock
,(
void
*
)
0
);
thr_lock_data_init
(
&
share
->
lock
,
&
lock
,(
void
*
)
0
);
info
(
HA_STATUS_NO_LOCK
|
HA_STATUS_VARIABLE
|
HA_STATUS_CONST
);
info
(
HA_STATUS_NO_LOCK
|
HA_STATUS_VARIABLE
|
HA_STATUS_CONST
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
...
@@ -789,7 +788,7 @@ void
...
@@ -789,7 +788,7 @@ void
ha_innobase
::
initialize
(
void
)
ha_innobase
::
initialize
(
void
)
/*=========================*/
/*=========================*/
{
{
}
}
/**********************************************************************
/**********************************************************************
Closes a handle to an Innobase table. */
Closes a handle to an Innobase table. */
...
@@ -823,7 +822,7 @@ uint
...
@@ -823,7 +822,7 @@ uint
get_field_offset
(
get_field_offset
(
/*=============*/
/*=============*/
/* out: offset */
/* out: offset */
TABLE
*
table
,
/* in: MySQL table object */
TABLE
*
table
,
/* in: MySQL table object */
Field
*
field
)
/* in: MySQL field object */
Field
*
field
)
/* in: MySQL field object */
{
{
return
((
uint
)
(
field
->
ptr
-
(
char
*
)
table
->
record
[
0
]));
return
((
uint
)
(
field
->
ptr
-
(
char
*
)
table
->
record
[
0
]));
...
@@ -837,7 +836,7 @@ uint
...
@@ -837,7 +836,7 @@ uint
field_in_record_is_null
(
field_in_record_is_null
(
/*====================*/
/*====================*/
/* out: 1 if NULL, 0 otherwise */
/* out: 1 if NULL, 0 otherwise */
TABLE
*
table
,
/* in: MySQL table object */
TABLE
*
table
,
/* in: MySQL table object */
Field
*
field
,
/* in: MySQL field object */
Field
*
field
,
/* in: MySQL field object */
char
*
record
)
/* in: a row in MySQL format */
char
*
record
)
/* in: a row in MySQL format */
{
{
...
@@ -847,7 +846,7 @@ field_in_record_is_null(
...
@@ -847,7 +846,7 @@ field_in_record_is_null(
return
(
0
);
return
(
0
);
}
}
null_offset
=
(
uint
)
((
char
*
)
field
->
null_ptr
null_offset
=
(
uint
)
((
char
*
)
field
->
null_ptr
-
(
char
*
)
table
->
record
[
0
]);
-
(
char
*
)
table
->
record
[
0
]);
...
@@ -866,7 +865,7 @@ inline
...
@@ -866,7 +865,7 @@ inline
void
void
set_field_in_record_to_null
(
set_field_in_record_to_null
(
/*========================*/
/*========================*/
TABLE
*
table
,
/* in: MySQL table object */
TABLE
*
table
,
/* in: MySQL table object */
Field
*
field
,
/* in: MySQL field object */
Field
*
field
,
/* in: MySQL field object */
char
*
record
)
/* in: a row in MySQL format */
char
*
record
)
/* in: a row in MySQL format */
{
{
...
@@ -884,7 +883,7 @@ inline
...
@@ -884,7 +883,7 @@ inline
void
void
reset_null_bits
(
reset_null_bits
(
/*============*/
/*============*/
TABLE
*
table
,
/* in: MySQL table object */
TABLE
*
table
,
/* in: MySQL table object */
char
*
record
)
/* in: a row in MySQL format */
char
*
record
)
/* in: a row in MySQL format */
{
{
bzero
(
record
,
table
->
null_bytes
);
bzero
(
record
,
table
->
null_bytes
);
...
@@ -899,10 +898,10 @@ If you change this function, remember to update the prototype there! */
...
@@ -899,10 +898,10 @@ If you change this function, remember to update the prototype there! */
int
int
innobase_mysql_cmp
(
innobase_mysql_cmp
(
/*===============*/
/*===============*/
/* out: 1, 0, -1, if a is greater,
/* out: 1, 0, -1, if a is greater,
equal, less than b, respectively */
equal, less than b, respectively */
int
mysql_type
,
/* in: MySQL type */
int
mysql_type
,
/* in: MySQL type */
unsigned
char
*
a
,
/* in: data field */
unsigned
char
*
a
,
/* in: data field */
unsigned
int
a_length
,
/* in: data field length,
unsigned
int
a_length
,
/* in: data field length,
not UNIV_SQL_NULL */
not UNIV_SQL_NULL */
...
@@ -912,7 +911,7 @@ innobase_mysql_cmp(
...
@@ -912,7 +911,7 @@ innobase_mysql_cmp(
{
{
enum_field_types
mysql_tp
;
enum_field_types
mysql_tp
;
assert
(
a_length
!=
UNIV_SQL_NULL
);
assert
(
a_length
!=
UNIV_SQL_NULL
);
assert
(
b_length
!=
UNIV_SQL_NULL
);
assert
(
b_length
!=
UNIV_SQL_NULL
);
mysql_tp
=
(
enum_field_types
)
mysql_type
;
mysql_tp
=
(
enum_field_types
)
mysql_type
;
...
@@ -960,7 +959,7 @@ get_innobase_type_from_mysql_type(
...
@@ -960,7 +959,7 @@ get_innobase_type_from_mysql_type(
return
(
DATA_VARCHAR
);
return
(
DATA_VARCHAR
);
}
else
{
}
else
{
return
(
DATA_VARMYSQL
);
return
(
DATA_VARMYSQL
);
}
}
case
FIELD_TYPE_STRING
:
if
(
field
->
flags
&
BINARY_FLAG
)
{
case
FIELD_TYPE_STRING
:
if
(
field
->
flags
&
BINARY_FLAG
)
{
return
(
DATA_FIXBINARY
);
return
(
DATA_FIXBINARY
);
...
@@ -970,7 +969,7 @@ get_innobase_type_from_mysql_type(
...
@@ -970,7 +969,7 @@ get_innobase_type_from_mysql_type(
return
(
DATA_CHAR
);
return
(
DATA_CHAR
);
}
else
{
}
else
{
return
(
DATA_MYSQL
);
return
(
DATA_MYSQL
);
}
}
case
FIELD_TYPE_LONG
:
case
FIELD_TYPE_LONG
:
case
FIELD_TYPE_LONGLONG
:
case
FIELD_TYPE_LONGLONG
:
case
FIELD_TYPE_TINY
:
case
FIELD_TYPE_TINY
:
...
@@ -1002,7 +1001,7 @@ get_innobase_type_from_mysql_type(
...
@@ -1002,7 +1001,7 @@ get_innobase_type_from_mysql_type(
return
(
0
);
return
(
0
);
}
}
/***********************************************************************
/***********************************************************************
Stores a key value for a row to a buffer. */
Stores a key value for a row to a buffer. */
...
@@ -1019,7 +1018,7 @@ ha_innobase::store_key_val_for_row(
...
@@ -1019,7 +1018,7 @@ ha_innobase::store_key_val_for_row(
KEY_PART_INFO
*
key_part
=
key_info
->
key_part
;
KEY_PART_INFO
*
key_part
=
key_info
->
key_part
;
KEY_PART_INFO
*
end
=
key_part
+
key_info
->
key_parts
;
KEY_PART_INFO
*
end
=
key_part
+
key_info
->
key_parts
;
char
*
buff_start
=
buff
;
char
*
buff_start
=
buff
;
DBUG_ENTER
(
"store_key_val_for_row"
);
DBUG_ENTER
(
"store_key_val_for_row"
);
for
(;
key_part
!=
end
;
key_part
++
)
{
for
(;
key_part
!=
end
;
key_part
++
)
{
...
@@ -1035,7 +1034,7 @@ ha_innobase::store_key_val_for_row(
...
@@ -1035,7 +1034,7 @@ ha_innobase::store_key_val_for_row(
*
buff
++
=
0
;
*
buff
++
=
0
;
}
}
memcpy
(
buff
,
record
+
key_part
->
offset
,
key_part
->
length
);
memcpy
(
buff
,
record
+
key_part
->
offset
,
key_part
->
length
);
buff
+=
key_part
->
length
;
buff
+=
key_part
->
length
;
}
}
...
@@ -1059,14 +1058,14 @@ build_template(
...
@@ -1059,14 +1058,14 @@ build_template(
{
{
dict_index_t
*
index
;
dict_index_t
*
index
;
dict_index_t
*
clust_index
;
dict_index_t
*
clust_index
;
mysql_row_templ_t
*
templ
;
mysql_row_templ_t
*
templ
;
Field
*
field
;
Field
*
field
;
ulint
n_fields
;
ulint
n_fields
;
ulint
n_requested_fields
=
0
;
ulint
n_requested_fields
=
0
;
ulint
i
;
ulint
i
;
clust_index
=
dict_table_get_first_index_noninline
(
prebuilt
->
table
);
clust_index
=
dict_table_get_first_index_noninline
(
prebuilt
->
table
);
if
(
!
prebuilt
->
in_update_remember_pos
)
{
if
(
!
prebuilt
->
in_update_remember_pos
)
{
/* We are building a temporary table: fetch all columns */
/* We are building a temporary table: fetch all columns */
...
@@ -1085,7 +1084,7 @@ build_template(
...
@@ -1085,7 +1084,7 @@ build_template(
}
else
{
}
else
{
index
=
clust_index
;
index
=
clust_index
;
}
}
if
(
index
==
clust_index
)
{
if
(
index
==
clust_index
)
{
prebuilt
->
need_to_access_clustered
=
TRUE
;
prebuilt
->
need_to_access_clustered
=
TRUE
;
}
else
{
}
else
{
...
@@ -1101,10 +1100,10 @@ build_template(
...
@@ -1101,10 +1100,10 @@ build_template(
mem_alloc_noninline
(
mem_alloc_noninline
(
n_fields
*
sizeof
(
mysql_row_templ_t
));
n_fields
*
sizeof
(
mysql_row_templ_t
));
}
}
prebuilt
->
template_type
=
templ_type
;
prebuilt
->
template_type
=
templ_type
;
prebuilt
->
null_bitmap_len
=
table
->
null_bytes
;
prebuilt
->
null_bitmap_len
=
table
->
null_bytes
;
prebuilt
->
templ_contains_blob
=
FALSE
;
prebuilt
->
templ_contains_blob
=
FALSE
;
for
(
i
=
0
;
i
<
n_fields
;
i
++
)
{
for
(
i
=
0
;
i
<
n_fields
;
i
++
)
{
...
@@ -1173,7 +1172,7 @@ skip_field:
...
@@ -1173,7 +1172,7 @@ skip_field:
templ
->
rec_field_no
=
templ
->
rec_field_no
=
(
index
->
table
->
cols
+
templ
->
col_no
)
->
clust_pos
;
(
index
->
table
->
cols
+
templ
->
col_no
)
->
clust_pos
;
}
}
}
}
if
(
templ_type
==
ROW_MYSQL_REC_FIELDS
if
(
templ_type
==
ROW_MYSQL_REC_FIELDS
&&
prebuilt
->
select_lock_type
!=
LOCK_NONE
)
{
&&
prebuilt
->
select_lock_type
!=
LOCK_NONE
)
{
...
@@ -1194,7 +1193,7 @@ ha_innobase::write_row(
...
@@ -1194,7 +1193,7 @@ ha_innobase::write_row(
{
{
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
int
error
;
int
error
;
DBUG_ENTER
(
"write_row"
);
DBUG_ENTER
(
"write_row"
);
statistic_increment
(
ha_write_count
,
&
LOCK_status
);
statistic_increment
(
ha_write_count
,
&
LOCK_status
);
...
@@ -1206,7 +1205,7 @@ ha_innobase::write_row(
...
@@ -1206,7 +1205,7 @@ ha_innobase::write_row(
if
(
table
->
next_number_field
&&
record
==
table
->
record
[
0
])
{
if
(
table
->
next_number_field
&&
record
==
table
->
record
[
0
])
{
update_auto_increment
();
update_auto_increment
();
}
}
if
(
prebuilt
->
mysql_template
==
NULL
if
(
prebuilt
->
mysql_template
==
NULL
||
prebuilt
->
template_type
!=
ROW_MYSQL_WHOLE_ROW
)
{
||
prebuilt
->
template_type
!=
ROW_MYSQL_WHOLE_ROW
)
{
/* Build the template used in converting quickly between
/* Build the template used in converting quickly between
...
@@ -1218,7 +1217,7 @@ ha_innobase::write_row(
...
@@ -1218,7 +1217,7 @@ ha_innobase::write_row(
error
=
row_insert_for_mysql
((
byte
*
)
record
,
prebuilt
);
error
=
row_insert_for_mysql
((
byte
*
)
record
,
prebuilt
);
error
=
convert_error_code_to_mysql
(
error
);
error
=
convert_error_code_to_mysql
(
error
);
/* Tell Innobase server that there might be work for
/* Tell Innobase server that there might be work for
utility threads: */
utility threads: */
...
@@ -1249,7 +1248,7 @@ innobase_convert_and_store_changed_col(
...
@@ -1249,7 +1248,7 @@ innobase_convert_and_store_changed_col(
}
else
if
(
col_type
==
DATA_INT
)
{
}
else
if
(
col_type
==
DATA_INT
)
{
/* Store integer data in Innobase in a big-endian
/* Store integer data in Innobase in a big-endian
format, sign bit negated, if signed */
format, sign bit negated, if signed */
for
(
i
=
0
;
i
<
len
;
i
++
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
{
buf
[
len
-
1
-
i
]
=
data
[
i
];
buf
[
len
-
1
-
i
]
=
data
[
i
];
}
}
...
@@ -1261,7 +1260,7 @@ innobase_convert_and_store_changed_col(
...
@@ -1261,7 +1260,7 @@ innobase_convert_and_store_changed_col(
data
=
buf
;
data
=
buf
;
buf
+=
len
;
buf
+=
len
;
}
}
ufield
->
new_val
.
data
=
data
;
ufield
->
new_val
.
data
=
data
;
ufield
->
new_val
.
len
=
len
;
ufield
->
new_val
.
len
=
len
;
...
@@ -1302,14 +1301,14 @@ calc_row_difference(
...
@@ -1302,14 +1301,14 @@ calc_row_difference(
/* We use upd_buff to convert changed fields */
/* We use upd_buff to convert changed fields */
buf
=
upd_buff
;
buf
=
upd_buff
;
for
(
i
=
0
;
i
<
n_fields
;
i
++
)
{
for
(
i
=
0
;
i
<
n_fields
;
i
++
)
{
field
=
table
->
field
[
i
];
field
=
table
->
field
[
i
];
if
(
thd
->
query_id
!=
field
->
query_id
)
{
if
(
thd
->
query_id
!=
field
->
query_id
)
{
/* TODO: check that these fields cannot have
/* TODO: check that these fields cannot have
changed! */
changed! */
goto
skip_field
;
goto
skip_field
;
}
}
...
@@ -1319,7 +1318,7 @@ calc_row_difference(
...
@@ -1319,7 +1318,7 @@ calc_row_difference(
n_len
=
field
->
pack_length
();
n_len
=
field
->
pack_length
();
col_type
=
get_innobase_type_from_mysql_type
(
field
);
col_type
=
get_innobase_type_from_mysql_type
(
field
);
is_unsigned
=
(
ulint
)
(
field
->
flags
&
UNSIGNED_FLAG
);
is_unsigned
=
(
ulint
)
(
field
->
flags
&
UNSIGNED_FLAG
);
switch
(
col_type
)
{
switch
(
col_type
)
{
...
@@ -1335,7 +1334,7 @@ calc_row_difference(
...
@@ -1335,7 +1334,7 @@ calc_row_difference(
default:
default:
;
;
}
}
if
(
field
->
null_ptr
)
{
if
(
field
->
null_ptr
)
{
if
(
field_in_record_is_null
(
table
,
field
,
if
(
field_in_record_is_null
(
table
,
field
,
(
char
*
)
old_row
))
{
(
char
*
)
old_row
))
{
...
@@ -1379,7 +1378,7 @@ overhead for CPU when we check which fields are actually updated.
...
@@ -1379,7 +1378,7 @@ overhead for CPU when we check which fields are actually updated.
TODO: currently Innobase does not prevent the 'Halloween problem':
TODO: currently Innobase does not prevent the 'Halloween problem':
in a searched update a single row can get updated several times
in a searched update a single row can get updated several times
if its index columns are updated! */
if its index columns are updated! */
int
int
ha_innobase
::
update_row
(
ha_innobase
::
update_row
(
/*====================*/
/*====================*/
...
@@ -1392,7 +1391,7 @@ ha_innobase::update_row(
...
@@ -1392,7 +1391,7 @@ ha_innobase::update_row(
int
error
=
0
;
int
error
=
0
;
DBUG_ENTER
(
"update_row"
);
DBUG_ENTER
(
"update_row"
);
if
(
prebuilt
->
upd_node
)
{
if
(
prebuilt
->
upd_node
)
{
uvect
=
prebuilt
->
upd_node
->
update
;
uvect
=
prebuilt
->
upd_node
->
update
;
}
else
{
}
else
{
...
@@ -1442,10 +1441,10 @@ ha_innobase::delete_row(
...
@@ -1442,10 +1441,10 @@ ha_innobase::delete_row(
}
}
/* This is a delete */
/* This is a delete */
prebuilt
->
upd_node
->
is_delete
=
TRUE
;
prebuilt
->
upd_node
->
is_delete
=
TRUE
;
prebuilt
->
in_update_remember_pos
=
TRUE
;
prebuilt
->
in_update_remember_pos
=
TRUE
;
error
=
row_update_for_mysql
((
byte
*
)
record
,
prebuilt
);
error
=
row_update_for_mysql
((
byte
*
)
record
,
prebuilt
);
error
=
convert_error_code_to_mysql
(
error
);
error
=
convert_error_code_to_mysql
(
error
);
...
@@ -1514,7 +1513,7 @@ convert_search_mode_to_innobase(
...
@@ -1514,7 +1513,7 @@ convert_search_mode_to_innobase(
return
(
0
);
return
(
0
);
}
}
/**************************************************************************
/**************************************************************************
Positions an index cursor to the index specified in the handle. Fetches the
Positions an index cursor to the index specified in the handle. Fetches the
row if any. */
row if any. */
...
@@ -1541,7 +1540,7 @@ ha_innobase::index_read(
...
@@ -1541,7 +1540,7 @@ ha_innobase::index_read(
DBUG_ENTER
(
"index_read"
);
DBUG_ENTER
(
"index_read"
);
statistic_increment
(
ha_read_key_count
,
&
LOCK_status
);
statistic_increment
(
ha_read_key_count
,
&
LOCK_status
);
index
=
prebuilt
->
index
;
index
=
prebuilt
->
index
;
/* Note that if the select is used for an update, we always
/* Note that if the select is used for an update, we always
...
@@ -1566,7 +1565,7 @@ ha_innobase::index_read(
...
@@ -1566,7 +1565,7 @@ ha_innobase::index_read(
dtuple_set_n_fields
(
prebuilt
->
search_tuple
,
0
);
dtuple_set_n_fields
(
prebuilt
->
search_tuple
,
0
);
}
}
mode
=
convert_search_mode_to_innobase
(
find_flag
);
mode
=
convert_search_mode_to_innobase
(
find_flag
);
match_mode
=
0
;
match_mode
=
0
;
...
@@ -1598,7 +1597,7 @@ ha_innobase::index_read(
...
@@ -1598,7 +1597,7 @@ ha_innobase::index_read(
error
=
convert_error_code_to_mysql
(
ret
);
error
=
convert_error_code_to_mysql
(
ret
);
table
->
status
=
STATUS_NOT_FOUND
;
table
->
status
=
STATUS_NOT_FOUND
;
}
}
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
@@ -1619,12 +1618,12 @@ ha_innobase::change_active_index(
...
@@ -1619,12 +1618,12 @@ ha_innobase::change_active_index(
statistic_increment
(
ha_read_key_count
,
&
LOCK_status
);
statistic_increment
(
ha_read_key_count
,
&
LOCK_status
);
DBUG_ENTER
(
"index_read_idx"
);
DBUG_ENTER
(
"index_read_idx"
);
active_index
=
keynr
;
active_index
=
keynr
;
if
(
keynr
!=
MAX_KEY
&&
table
->
keys
>
0
)
{
if
(
keynr
!=
MAX_KEY
&&
table
->
keys
>
0
)
{
key
=
table
->
key_info
+
active_index
;
key
=
table
->
key_info
+
active_index
;
prebuilt
->
index
=
dict_table_get_index_noninline
(
prebuilt
->
index
=
dict_table_get_index_noninline
(
prebuilt
->
table
,
key
->
name
);
prebuilt
->
table
,
key
->
name
);
}
else
{
}
else
{
...
@@ -1633,7 +1632,7 @@ ha_innobase::change_active_index(
...
@@ -1633,7 +1632,7 @@ ha_innobase::change_active_index(
}
}
dtuple_set_n_fields
(
prebuilt
->
search_tuple
,
prebuilt
->
index
->
n_fields
);
dtuple_set_n_fields
(
prebuilt
->
search_tuple
,
prebuilt
->
index
->
n_fields
);
dict_index_copy_types
(
prebuilt
->
search_tuple
,
prebuilt
->
index
,
dict_index_copy_types
(
prebuilt
->
search_tuple
,
prebuilt
->
index
,
prebuilt
->
index
->
n_fields
);
prebuilt
->
index
->
n_fields
);
assert
(
prebuilt
->
index
);
assert
(
prebuilt
->
index
);
...
@@ -1641,7 +1640,7 @@ ha_innobase::change_active_index(
...
@@ -1641,7 +1640,7 @@ ha_innobase::change_active_index(
/* Maybe MySQL changes the active index for a handle also
/* Maybe MySQL changes the active index for a handle also
during some queries, we do not know: then it is safest to build
during some queries, we do not know: then it is safest to build
the template such that all columns will be fetched */
the template such that all columns will be fetched */
build_template
(
prebuilt
,
user_thd
,
table
,
ROW_MYSQL_WHOLE_ROW
);
build_template
(
prebuilt
,
user_thd
,
table
,
ROW_MYSQL_WHOLE_ROW
);
return
(
0
);
return
(
0
);
...
@@ -1688,9 +1687,9 @@ ha_innobase::general_fetch(
...
@@ -1688,9 +1687,9 @@ ha_innobase::general_fetch(
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
ulint
ret
;
ulint
ret
;
int
error
=
0
;
int
error
=
0
;
DBUG_ENTER
(
"general_fetch"
);
DBUG_ENTER
(
"general_fetch"
);
ret
=
row_search_for_mysql
(
buf
,
0
,
prebuilt
,
match_mode
,
direction
);
ret
=
row_search_for_mysql
(
buf
,
0
,
prebuilt
,
match_mode
,
direction
);
if
(
ret
==
DB_SUCCESS
)
{
if
(
ret
==
DB_SUCCESS
)
{
...
@@ -1708,7 +1707,7 @@ ha_innobase::general_fetch(
...
@@ -1708,7 +1707,7 @@ ha_innobase::general_fetch(
error
=
convert_error_code_to_mysql
(
ret
);
error
=
convert_error_code_to_mysql
(
ret
);
table
->
status
=
STATUS_NOT_FOUND
;
table
->
status
=
STATUS_NOT_FOUND
;
}
}
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
@@ -1866,14 +1865,14 @@ ha_innobase::rnd_next(
...
@@ -1866,14 +1865,14 @@ ha_innobase::rnd_next(
}
else
{
}
else
{
error
=
general_fetch
(
buf
,
ROW_SEL_NEXT
,
0
);
error
=
general_fetch
(
buf
,
ROW_SEL_NEXT
,
0
);
}
}
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
/**************************************************************************
/**************************************************************************
Fetches a row from the table based on a reference. TODO: currently we use
Fetches a row from the table based on a reference. TODO: currently we use
'ref_stored_len' of the handle as the key length. This may change. */
'ref_stored_len' of the handle as the key length. This may change. */
int
int
ha_innobase
::
rnd_pos
(
ha_innobase
::
rnd_pos
(
/*=================*/
/*=================*/
...
@@ -1885,10 +1884,10 @@ ha_innobase::rnd_pos(
...
@@ -1885,10 +1884,10 @@ ha_innobase::rnd_pos(
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
int
error
;
int
error
;
uint
keynr
=
active_index
;
uint
keynr
=
active_index
;
DBUG_ENTER
(
"rnd_pos"
);
DBUG_ENTER
(
"rnd_pos"
);
statistic_increment
(
ha_read_rnd_count
,
&
LOCK_status
);
statistic_increment
(
ha_read_rnd_count
,
&
LOCK_status
);
if
(
prebuilt
->
clust_index_was_generated
)
{
if
(
prebuilt
->
clust_index_was_generated
)
{
/* No primary key was defined for the table and we
/* No primary key was defined for the table and we
generated the clustered index from the row id: the
generated the clustered index from the row id: the
...
@@ -1899,11 +1898,11 @@ ha_innobase::rnd_pos(
...
@@ -1899,11 +1898,11 @@ ha_innobase::rnd_pos(
}
else
{
}
else
{
change_active_index
(
primary_key
);
change_active_index
(
primary_key
);
}
}
error
=
index_read
(
buf
,
pos
,
ref_stored_len
,
HA_READ_KEY_EXACT
);
error
=
index_read
(
buf
,
pos
,
ref_stored_len
,
HA_READ_KEY_EXACT
);
change_active_index
(
keynr
);
change_active_index
(
keynr
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
@@ -1948,7 +1947,7 @@ int
...
@@ -1948,7 +1947,7 @@ int
ha_innobase
::
extra
(
ha_innobase
::
extra
(
/*===============*/
/*===============*/
/* out: 0 or error number */
/* out: 0 or error number */
enum
ha_extra_function
operation
)
enum
ha_extra_function
operation
)
/* in: HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE */
/* in: HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE */
{
{
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
row_prebuilt_t
*
prebuilt
=
(
row_prebuilt_t
*
)
innobase_prebuilt
;
...
@@ -1992,10 +1991,10 @@ ha_innobase::external_lock(
...
@@ -1992,10 +1991,10 @@ ha_innobase::external_lock(
update_thd
(
thd
);
update_thd
(
thd
);
trx
=
prebuilt
->
trx
;
trx
=
prebuilt
->
trx
;
prebuilt
->
sql_stat_start
=
TRUE
;
prebuilt
->
sql_stat_start
=
TRUE
;
prebuilt
->
in_update_remember_pos
=
TRUE
;
prebuilt
->
in_update_remember_pos
=
TRUE
;
if
(
lock_type
==
F_WRLCK
)
{
if
(
lock_type
==
F_WRLCK
)
{
/* If this is a SELECT, then it is in UPDATE TABLE ...
/* If this is a SELECT, then it is in UPDATE TABLE ...
or SELECT ... FOR UPDATE */
or SELECT ... FOR UPDATE */
...
@@ -2006,14 +2005,14 @@ ha_innobase::external_lock(
...
@@ -2006,14 +2005,14 @@ ha_innobase::external_lock(
if
(
trx
->
n_mysql_tables_in_use
==
0
)
{
if
(
trx
->
n_mysql_tables_in_use
==
0
)
{
trx_mark_sql_stat_end
(
trx
);
trx_mark_sql_stat_end
(
trx
);
}
}
trx
->
n_mysql_tables_in_use
++
;
trx
->
n_mysql_tables_in_use
++
;
}
else
{
}
else
{
trx
->
n_mysql_tables_in_use
--
;
trx
->
n_mysql_tables_in_use
--
;
}
}
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
/*********************************************************************
/*********************************************************************
Creates a table definition to an Innobase database. */
Creates a table definition to an Innobase database. */
...
@@ -2034,7 +2033,7 @@ create_table_def(
...
@@ -2034,7 +2033,7 @@ create_table_def(
ulint
nulls_allowed
;
ulint
nulls_allowed
;
ulint
unsigned_type
;
ulint
unsigned_type
;
ulint
i
;
ulint
i
;
DBUG_ENTER
(
"create_table_def"
);
DBUG_ENTER
(
"create_table_def"
);
DBUG_PRINT
(
"enter"
,
(
"table_name: %s"
,
table_name
));
DBUG_PRINT
(
"enter"
,
(
"table_name: %s"
,
table_name
));
...
@@ -2044,7 +2043,7 @@ create_table_def(
...
@@ -2044,7 +2043,7 @@ create_table_def(
created in tablespace 0 */
created in tablespace 0 */
table
=
dict_mem_table_create
((
char
*
)
table_name
,
0
,
n_cols
);
table
=
dict_mem_table_create
((
char
*
)
table_name
,
0
,
n_cols
);
for
(
i
=
0
;
i
<
n_cols
;
i
++
)
{
for
(
i
=
0
;
i
<
n_cols
;
i
++
)
{
field
=
form
->
field
[
i
];
field
=
form
->
field
[
i
];
...
@@ -2087,7 +2086,7 @@ create_index(
...
@@ -2087,7 +2086,7 @@ create_index(
uint
key_num
)
/* in: index number */
uint
key_num
)
/* in: index number */
{
{
dict_index_t
*
index
;
dict_index_t
*
index
;
int
error
;
int
error
;
ulint
n_fields
;
ulint
n_fields
;
KEY
*
key
;
KEY
*
key
;
KEY_PART_INFO
*
key_part
;
KEY_PART_INFO
*
key_part
;
...
@@ -2095,17 +2094,17 @@ create_index(
...
@@ -2095,17 +2094,17 @@ create_index(
ulint
i
;
ulint
i
;
DBUG_ENTER
(
"create_index"
);
DBUG_ENTER
(
"create_index"
);
key
=
form
->
key_info
+
key_num
;
key
=
form
->
key_info
+
key_num
;
n_fields
=
key
->
key_parts
;
n_fields
=
key
->
key_parts
;
ind_type
=
0
;
ind_type
=
0
;
if
(
strcmp
(
key
->
name
,
"PRIMARY"
)
==
0
)
{
if
(
strcmp
(
key
->
name
,
"PRIMARY"
)
==
0
)
{
ind_type
=
ind_type
|
DICT_CLUSTERED
;
ind_type
=
ind_type
|
DICT_CLUSTERED
;
}
}
if
(
key
->
flags
&
HA_NOSAME
)
{
if
(
key
->
flags
&
HA_NOSAME
)
{
ind_type
=
ind_type
|
DICT_UNIQUE
;
ind_type
=
ind_type
|
DICT_UNIQUE
;
}
}
...
@@ -2142,8 +2141,8 @@ create_clustered_index_when_no_primary(
...
@@ -2142,8 +2141,8 @@ create_clustered_index_when_no_primary(
const
char
*
table_name
)
/* in: table name */
const
char
*
table_name
)
/* in: table name */
{
{
dict_index_t
*
index
;
dict_index_t
*
index
;
int
error
;
int
error
;
/* The first '0' below specifies that everything in Innobase is
/* The first '0' below specifies that everything in Innobase is
currently created in file space 0 */
currently created in file space 0 */
...
@@ -2177,7 +2176,7 @@ ha_innobase::create(
...
@@ -2177,7 +2176,7 @@ ha_innobase::create(
uint
i
;
uint
i
;
char
name2
[
1000
];
char
name2
[
1000
];
char
norm_name
[
1000
];
char
norm_name
[
1000
];
DBUG_ENTER
(
"ha_innobase::create"
);
DBUG_ENTER
(
"ha_innobase::create"
);
trx
=
trx_allocate_for_mysql
();
trx
=
trx_allocate_for_mysql
();
...
@@ -2194,7 +2193,7 @@ ha_innobase::create(
...
@@ -2194,7 +2193,7 @@ ha_innobase::create(
name2
[
name_len
-
4
]
=
'\0'
;
name2
[
name_len
-
4
]
=
'\0'
;
normalize_table_name
(
norm_name
,
name2
);
normalize_table_name
(
norm_name
,
name2
);
/* Create the table definition in Innobase */
/* Create the table definition in Innobase */
if
(
error
=
create_table_def
(
trx
,
form
,
norm_name
))
{
if
(
error
=
create_table_def
(
trx
,
form
,
norm_name
))
{
...
@@ -2213,9 +2212,9 @@ ha_innobase::create(
...
@@ -2213,9 +2212,9 @@ ha_innobase::create(
if
(
strcmp
(
key
->
name
,
"PRIMARY"
)
==
0
)
{
if
(
strcmp
(
key
->
name
,
"PRIMARY"
)
==
0
)
{
primary_key_no
=
(
int
)
i
;
primary_key_no
=
(
int
)
i
;
}
}
}
}
/* Create the keys */
/* Create the keys */
if
(
form
->
keys
==
0
||
primary_key_no
==
-
1
)
{
if
(
form
->
keys
==
0
||
primary_key_no
==
-
1
)
{
...
@@ -2224,10 +2223,10 @@ ha_innobase::create(
...
@@ -2224,10 +2223,10 @@ ha_innobase::create(
by Innobase */
by Innobase */
error
=
create_clustered_index_when_no_primary
(
trx
,
error
=
create_clustered_index_when_no_primary
(
trx
,
norm_name
);
norm_name
);
if
(
error
)
{
if
(
error
)
{
trx_commit_for_mysql
(
trx
);
trx_commit_for_mysql
(
trx
);
trx_free_for_mysql
(
trx
);
trx_free_for_mysql
(
trx
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
...
@@ -2236,7 +2235,7 @@ ha_innobase::create(
...
@@ -2236,7 +2235,7 @@ ha_innobase::create(
if
(
primary_key_no
!=
-
1
)
{
if
(
primary_key_no
!=
-
1
)
{
/* In Innobase the clustered index must always be created
/* In Innobase the clustered index must always be created
first */
first */
if
(
error
=
create_index
(
trx
,
form
,
norm_name
,
if
(
error
=
create_index
(
trx
,
form
,
norm_name
,
(
uint
)
primary_key_no
))
{
(
uint
)
primary_key_no
))
{
trx_commit_for_mysql
(
trx
);
trx_commit_for_mysql
(
trx
);
...
@@ -2261,13 +2260,13 @@ ha_innobase::create(
...
@@ -2261,13 +2260,13 @@ ha_innobase::create(
}
}
}
}
}
}
trx_commit_for_mysql
(
trx
);
trx_commit_for_mysql
(
trx
);
innobase_table
=
dict_table_get
(
norm_name
,
NULL
);
innobase_table
=
dict_table_get
(
norm_name
,
NULL
);
assert
(
innobase_table
);
assert
(
innobase_table
);
/* Tell the Innobase server that there might be work for
/* Tell the Innobase server that there might be work for
utility threads: */
utility threads: */
...
@@ -2295,7 +2294,7 @@ ha_innobase::delete_table(
...
@@ -2295,7 +2294,7 @@ ha_innobase::delete_table(
int
error
;
int
error
;
trx_t
*
trx
;
trx_t
*
trx
;
char
norm_name
[
1000
];
char
norm_name
[
1000
];
DBUG_ENTER
(
"ha_innobase::delete_table"
);
DBUG_ENTER
(
"ha_innobase::delete_table"
);
trx
=
trx_allocate_for_mysql
();
trx
=
trx_allocate_for_mysql
();
...
@@ -2303,16 +2302,16 @@ ha_innobase::delete_table(
...
@@ -2303,16 +2302,16 @@ ha_innobase::delete_table(
name_len
=
strlen
(
name
);
name_len
=
strlen
(
name
);
assert
(
name_len
<
1000
);
assert
(
name_len
<
1000
);
/* Strangely, MySQL passes the table name without the '.frm'
/* Strangely, MySQL passes the table name without the '.frm'
extension, in contrast to ::create */
extension, in contrast to ::create */
normalize_table_name
(
norm_name
,
name
);
normalize_table_name
(
norm_name
,
name
);
/* Drop the table in Innobase */
/* Drop the table in Innobase */
error
=
row_drop_table_for_mysql
(
norm_name
,
trx
,
FALSE
);
error
=
row_drop_table_for_mysql
(
norm_name
,
trx
,
FALSE
);
/* Tell the Innobase server that there might be work for
/* Tell the Innobase server that there might be work for
utility threads: */
utility threads: */
...
@@ -2341,7 +2340,7 @@ ha_innobase::rename_table(
...
@@ -2341,7 +2340,7 @@ ha_innobase::rename_table(
trx_t
*
trx
;
trx_t
*
trx
;
char
norm_from
[
1000
];
char
norm_from
[
1000
];
char
norm_to
[
1000
];
char
norm_to
[
1000
];
DBUG_ENTER
(
"ha_innobase::rename_table"
);
DBUG_ENTER
(
"ha_innobase::rename_table"
);
trx
=
trx_allocate_for_mysql
();
trx
=
trx_allocate_for_mysql
();
...
@@ -2351,14 +2350,14 @@ ha_innobase::rename_table(
...
@@ -2351,14 +2350,14 @@ ha_innobase::rename_table(
assert
(
name_len1
<
1000
);
assert
(
name_len1
<
1000
);
assert
(
name_len2
<
1000
);
assert
(
name_len2
<
1000
);
normalize_table_name
(
norm_from
,
from
);
normalize_table_name
(
norm_from
,
from
);
normalize_table_name
(
norm_to
,
to
);
normalize_table_name
(
norm_to
,
to
);
/* Rename the table in Innobase */
/* Rename the table in Innobase */
error
=
row_rename_table_for_mysql
(
norm_from
,
norm_to
,
trx
);
error
=
row_rename_table_for_mysql
(
norm_from
,
norm_to
,
trx
);
/* Tell the Innobase server that there might be work for
/* Tell the Innobase server that there might be work for
utility threads: */
utility threads: */
...
@@ -2405,26 +2404,26 @@ ha_innobase::records_in_range(
...
@@ -2405,26 +2404,26 @@ ha_innobase::records_in_range(
ulint
mode2
;
ulint
mode2
;
void
*
heap1
;
void
*
heap1
;
void
*
heap2
;
void
*
heap2
;
DBUG_ENTER
(
"records_in_range"
);
DBUG_ENTER
(
"records_in_range"
);
active_index
=
keynr
;
active_index
=
keynr
;
key
=
table
->
key_info
+
active_index
;
key
=
table
->
key_info
+
active_index
;
index
=
dict_table_get_index_noninline
(
prebuilt
->
table
,
key
->
name
);
index
=
dict_table_get_index_noninline
(
prebuilt
->
table
,
key
->
name
);
range_start
=
dtuple_create_for_mysql
(
&
heap1
,
key
->
key_parts
);
range_start
=
dtuple_create_for_mysql
(
&
heap1
,
key
->
key_parts
);
dict_index_copy_types
(
range_start
,
index
,
index
->
n_fields
);
dict_index_copy_types
(
range_start
,
index
,
index
->
n_fields
);
range_end
=
dtuple_create_for_mysql
(
&
heap2
,
key
->
key_parts
);
range_end
=
dtuple_create_for_mysql
(
&
heap2
,
key
->
key_parts
);
dict_index_copy_types
(
range_end
,
index
,
index
->
n_fields
);
dict_index_copy_types
(
range_end
,
index
,
index
->
n_fields
);
row_sel_convert_mysql_key_to_innobase
(
row_sel_convert_mysql_key_to_innobase
(
range_start
,
(
byte
*
)
key_val_buff
,
index
,
range_start
,
(
byte
*
)
key_val_buff
,
index
,
(
byte
*
)
start_key
,
(
byte
*
)
start_key
,
(
ulint
)
start_key_len
);
(
ulint
)
start_key_len
);
row_sel_convert_mysql_key_to_innobase
(
row_sel_convert_mysql_key_to_innobase
(
range_end
,
(
byte
*
)
key_val_buff2
,
index
,
range_end
,
(
byte
*
)
key_val_buff2
,
index
,
(
byte
*
)
end_key
,
(
byte
*
)
end_key
,
...
@@ -2437,7 +2436,7 @@ ha_innobase::records_in_range(
...
@@ -2437,7 +2436,7 @@ ha_innobase::records_in_range(
mode1
,
range_end
,
mode2
);
mode1
,
range_end
,
mode2
);
dtuple_free_for_mysql
(
heap1
);
dtuple_free_for_mysql
(
heap1
);
dtuple_free_for_mysql
(
heap2
);
dtuple_free_for_mysql
(
heap2
);
my_free
((
char
*
)
key_val_buff2
,
MYF
(
0
));
my_free
((
char
*
)
key_val_buff2
,
MYF
(
0
));
DBUG_RETURN
((
ha_rows
)
n_rows
);
DBUG_RETURN
((
ha_rows
)
n_rows
);
...
@@ -2457,7 +2456,7 @@ ha_innobase::scan_time()
...
@@ -2457,7 +2456,7 @@ ha_innobase::scan_time()
/* In the following formula we assume that scanning 5 pages
/* In the following formula we assume that scanning 5 pages
takes the same time as a disk seek: */
takes the same time as a disk seek: */
return
((
double
)
(
1
+
prebuilt
->
table
->
stat_clustered_index_size
/
5
));
return
((
double
)
(
1
+
prebuilt
->
table
->
stat_clustered_index_size
/
5
));
}
}
...
@@ -2475,7 +2474,7 @@ ha_innobase::info(
...
@@ -2475,7 +2474,7 @@ ha_innobase::info(
dict_index_t
*
index
;
dict_index_t
*
index
;
uint
rec_per_key
;
uint
rec_per_key
;
uint
i
;
uint
i
;
DBUG_ENTER
(
"info"
);
DBUG_ENTER
(
"info"
);
ib_table
=
prebuilt
->
table
;
ib_table
=
prebuilt
->
table
;
...
@@ -2512,7 +2511,7 @@ ha_innobase::info(
...
@@ -2512,7 +2511,7 @@ ha_innobase::info(
if
(
prebuilt
->
clust_index_was_generated
)
{
if
(
prebuilt
->
clust_index_was_generated
)
{
index
=
dict_table_get_next_index_noninline
(
index
);
index
=
dict_table_get_next_index_noninline
(
index
);
}
}
for
(
i
=
0
;
i
<
table
->
keys
;
i
++
)
{
for
(
i
=
0
;
i
<
table
->
keys
;
i
++
)
{
if
(
index
->
stat_n_diff_key_vals
==
0
)
{
if
(
index
->
stat_n_diff_key_vals
==
0
)
{
rec_per_key
=
records
;
rec_per_key
=
records
;
...
@@ -2520,13 +2519,13 @@ ha_innobase::info(
...
@@ -2520,13 +2519,13 @@ ha_innobase::info(
rec_per_key
=
records
/
rec_per_key
=
records
/
index
->
stat_n_diff_key_vals
;
index
->
stat_n_diff_key_vals
;
}
}
table
->
key_info
[
i
].
rec_per_key
[
table
->
key_info
[
i
].
rec_per_key
[
table
->
key_info
[
i
].
key_parts
-
1
]
table
->
key_info
[
i
].
key_parts
-
1
]
=
rec_per_key
;
=
rec_per_key
;
index
=
dict_table_get_next_index_noninline
(
index
);
index
=
dict_table_get_next_index_noninline
(
index
);
}
}
}
}
if
(
flag
&
HA_STATUS_ERRKEY
)
{
if
(
flag
&
HA_STATUS_ERRKEY
)
{
...
@@ -2657,7 +2656,7 @@ ha_innobase::store_lock(
...
@@ -2657,7 +2656,7 @@ ha_innobase::store_lock(
}
}
*
to
++=
&
lock
;
*
to
++=
&
lock
;
return
(
to
);
return
(
to
);
}
}
...
...
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