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
49530701
Commit
49530701
authored
Mar 02, 2005
by
heikki@hundin.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ha_innodb.cc:
Correct indentation + some small style corrections
parent
a60ae957
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
97 deletions
+118
-97
sql/ha_innodb.cc
sql/ha_innodb.cc
+118
-97
No files found.
sql/ha_innodb.cc
View file @
49530701
/* Copyright (C) 2000 MySQL AB & Innobase Oy
/* Copyright (C) 2000
-2005
MySQL AB & Innobase Oy
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
...
...
@@ -336,14 +336,18 @@ innobase_release_temporary_latches(
/*===============================*/
THD
*
thd
)
{
trx_t
*
trx
;
if
(
!
innodb_inited
)
{
return
;
}
trx_t
*
trx
=
(
trx_t
*
)
thd
->
ha_data
[
innobase_hton
.
slot
];
if
(
trx
)
trx
=
(
trx_t
*
)
thd
->
ha_data
[
innobase_hton
.
slot
];
if
(
trx
)
{
innobase_release_stat_resources
(
trx
);
}
}
/************************************************************************
...
...
@@ -743,14 +747,15 @@ transaction internally. */
static
void
register_trans
(
/*===========
=
*/
/*===========*/
THD
*
thd
)
/* in: thd to use the handle */
{
/*
r
egister the start of the statement */
/*
R
egister the start of the statement */
trans_register_ha
(
thd
,
FALSE
,
&
innobase_hton
);
if
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))
{
/*
n
o autocommit mode, register for a transaction */
/*
N
o autocommit mode, register for a transaction */
trans_register_ha
(
thd
,
TRUE
,
&
innobase_hton
);
}
}
...
...
@@ -1051,7 +1056,7 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/*************************************************************************
Opens an InnoDB database. */
handlerton
*
handlerton
*
innobase_init
(
void
)
/*===============*/
/* out: TRUE if error */
...
...
@@ -1346,13 +1351,15 @@ innobase_commit_low(
return
;
}
/* The following will be enabled later when we put the 4.1 functionality back
to 5.0. */
#ifdef DISABLE_HAVE_REPLICATION
if
(
current_thd
->
slave_thread
)
{
/* Update the replication position info inside InnoDB */
trx
->
mysql_master_log_file_name
=
active_mi
->
rli
.
group_master_log_name
;
trx
->
mysql_master_log_pos
=
((
ib_longlong
)
trx
->
mysql_master_log_pos
=
((
ib_longlong
)
active_mi
->
rli
.
future_group_master_log_pos
);
}
#endif
/* HAVE_REPLICATION */
...
...
@@ -1456,7 +1463,8 @@ innobase_commit(
"InnoDB: but trx->conc_state != TRX_NOT_STARTED
\n
"
);
}
if
(
all
||
(
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))))
{
if
(
all
||
(
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))))
{
/* We were instructed to commit the whole transaction, or
this is an SQL statement end and autocommit is on */
...
...
@@ -1489,10 +1497,9 @@ innobase_commit(
DBUG_RETURN
(
0
);
}
/*
don't delete it - it may be re-enabled later
as an optimization for the most common case InnoDB+binlog
*/
/* The following defined-out code will be enabled later when we put the
MySQL-4.1 functionality back to 5.0. This is needed to get InnoDB Hot Backup
to work. */
#if 0
/*********************************************************************
This is called when MySQL writes the binlog entry for the current
...
...
@@ -1627,7 +1634,8 @@ innobase_rollback(
row_unlock_table_autoinc_for_mysql
(
trx
);
}
if
(
all
||
(
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))))
{
if
(
all
||
(
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))))
{
error
=
trx_rollback_for_mysql
(
trx
);
trx
->
active_trans
=
0
;
...
...
@@ -1686,6 +1694,7 @@ innobase_rollback_to_savepoint(
ib_longlong
mysql_binlog_cache_pos
;
int
error
=
0
;
trx_t
*
trx
;
char
name
[
64
];
DBUG_ENTER
(
"innobase_rollback_to_savepoint"
);
...
...
@@ -1698,8 +1707,8 @@ innobase_rollback_to_savepoint(
innobase_release_stat_resources
(
trx
);
/* TODO: use provided savepoint data area to store savepoint data */
char
name
[
64
];
longlong2str
((
ulonglong
)
savepoint
,
name
,
36
);
longlong2str
((
ulonglong
)
savepoint
,
name
,
36
);
error
=
trx_rollback_to_savepoint_for_mysql
(
trx
,
name
,
&
mysql_binlog_cache_pos
);
...
...
@@ -1708,26 +1717,27 @@ innobase_rollback_to_savepoint(
/*********************************************************************
Release transaction savepoint name. */
static
int
static
int
innobase_release_savepoint
(
/*=======================
====
*/
/*=======================*/
/* out: 0 if success, HA_ERR_NO_SAVEPOINT if
no savepoint with the given name */
THD
*
thd
,
/* in: handle to the MySQL thread of the user
whose transaction should be rolled back */
void
*
savepoint
)
/* in: savepoint data */
void
*
savepoint
)
/* in: savepoint data */
{
int
error
=
0
;
trx_t
*
trx
;
char
name
[
64
];
DBUG_ENTER
(
"innobase_release_savepoint"
);
trx
=
check_trx_exists
(
thd
);
/* TODO: use provided savepoint data area to store savepoint data */
char
name
[
64
];
longlong2str
((
ulonglong
)
savepoint
,
name
,
36
);
longlong2str
((
ulonglong
)
savepoint
,
name
,
36
);
error
=
trx_release_savepoint_for_mysql
(
trx
,
name
);
...
...
@@ -1736,13 +1746,13 @@ innobase_release_savepoint(
/*********************************************************************
Sets a transaction savepoint. */
static
int
static
int
innobase_savepoint
(
/*===============*/
/* out: always 0, that is, always succeeds */
THD
*
thd
,
/* in: handle to the MySQL thread */
void
*
savepoint
)
/* in: savepoint data */
void
*
savepoint
)
/* in: savepoint data */
{
int
error
=
0
;
trx_t
*
trx
;
...
...
@@ -1911,7 +1921,8 @@ ha_innobase::open(
fields when packed actually became 1 byte longer, when we also
stored the string length as the first byte. */
upd_and_key_val_buff_len
=
table
->
s
->
reclength
+
table
->
s
->
max_key_length
upd_and_key_val_buff_len
=
table
->
s
->
reclength
+
table
->
s
->
max_key_length
+
MAX_REF_PARTS
*
3
;
if
(
!
(
mysql_byte
*
)
my_multi_malloc
(
MYF
(
MY_WME
),
&
upd_buff
,
upd_and_key_val_buff_len
,
...
...
@@ -1963,7 +1974,8 @@ ha_innobase::open(
innobase_prebuilt
=
row_create_prebuilt
(
ib_table
);
((
row_prebuilt_t
*
)
innobase_prebuilt
)
->
mysql_row_len
=
table
->
s
->
reclength
;
((
row_prebuilt_t
*
)
innobase_prebuilt
)
->
mysql_row_len
=
table
->
s
->
reclength
;
/* Looks like MySQL-3.23 sometimes has primary key number != 0 */
...
...
@@ -1985,13 +1997,11 @@ ha_innobase::open(
((
row_prebuilt_t
*
)
innobase_prebuilt
)
->
clust_index_was_generated
=
FALSE
;
/*
MySQL allocates the buffer for ref. key_info->key_length
/* MySQL allocates the buffer for ref. key_info->key_length
includes space for all key columns + one byte for each column
that may be NULL. ref_length must be as exact as possible to
save space, because all row reference buffers are allocated
based on ref_length.
*/
based on ref_length. */
ref_length
=
table
->
key_info
[
primary_key
].
key_length
;
}
else
{
...
...
@@ -2013,15 +2023,13 @@ ha_innobase::open(
ref_length
=
DATA_ROW_ID_LEN
;
/*
If we automatically created the clustered index, then
/* If we automatically created the clustered index, then
MySQL does not know about it, and MySQL must NOT be aware
of the index used on scan, to make it avoid checking if we
update the column of the index. That is why we assert below
that key_used_on_scan is the undefined value MAX_KEY.
The column is the row id in the automatical generation case,
and it will never be updated anyway.
*/
and it will never be updated anyway. */
if
(
key_used_on_scan
!=
MAX_KEY
)
{
fprintf
(
stderr
,
...
...
@@ -2611,7 +2619,8 @@ ha_innobase::write_row(
"InnoDB: Dump of 200 bytes around transaction.all: "
,
stderr
);
ut_print_buf
(
stderr
,
((
byte
*
)(
&
(
current_thd
->
ha_data
[
innobase_hton
.
slot
])))
-
100
,
200
);
((
byte
*
)(
&
(
current_thd
->
ha_data
[
innobase_hton
.
slot
])))
-
100
,
200
);
putc
(
'\n'
,
stderr
);
ut_error
;
}
...
...
@@ -2646,7 +2655,7 @@ ha_innobase::write_row(
src_table
=
lock_get_src_table
(
prebuilt
->
trx
,
prebuilt
->
table
,
&
mode
);
if
(
!
src_table
)
{
no_commit:
no_commit:
/* Unknown situation: do not commit */
/*
ut_print_timestamp(stderr);
...
...
@@ -2669,6 +2678,7 @@ ha_innobase::write_row(
}
else
{
/* Ensure that there are no other table locks than
LOCK_IX and LOCK_AUTO_INC on the destination table. */
if
(
!
lock_is_table_exclusive
(
prebuilt
->
table
,
prebuilt
->
trx
))
{
goto
no_commit
;
...
...
@@ -2765,8 +2775,8 @@ ha_innobase::write_row(
error
=
row_lock_table_autoinc_for_mysql
(
prebuilt
);
if
(
error
!=
DB_SUCCESS
)
{
error
=
convert_error_code_to_mysql
(
error
,
user_thd
);
error
=
convert_error_code_to_mysql
(
error
,
user_thd
);
goto
func_exit
;
}
dict_table_autoinc_update
(
prebuilt
->
table
,
auto_inc
);
...
...
@@ -2785,7 +2795,6 @@ func_exit:
DBUG_RETURN
(
error
);
}
/******************************************************************
Converts field data for storage in an InnoDB update vector. */
inline
...
...
@@ -4674,21 +4683,27 @@ ha_innobase::read_time(
ha_rows
total_rows
;
double
time_for_scan
;
if
(
index
!=
table
->
s
->
primary_key
)
return
handler
::
read_time
(
index
,
ranges
,
rows
);
// Not clustered
if
(
index
!=
table
->
s
->
primary_key
)
{
/* Not clustered */
return
(
handler
::
read_time
(
index
,
ranges
,
rows
));
}
if
(
rows
<=
2
)
{
if
(
rows
<=
2
)
return
(
double
)
rows
;
return
((
double
)
rows
);
}
/* Assume that the read time is proportional to the scan time for all
rows + at most one seek per range. */
time_for_scan
=
scan_time
();
if
((
total_rows
=
estimate_rows_upper_bound
())
<
rows
)
return
time_for_scan
;
if
((
total_rows
=
estimate_rows_upper_bound
())
<
rows
)
{
return
(
ranges
+
(
double
)
rows
/
(
double
)
total_rows
*
time_for_scan
);
return
(
time_for_scan
);
}
return
(
ranges
+
(
double
)
rows
/
(
double
)
total_rows
*
time_for_scan
);
}
/*************************************************************************
...
...
@@ -5624,7 +5639,6 @@ innodb_export_status(void)
srv_export_innodb_status
();
}
/****************************************************************************
Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
Monitor to the client. */
...
...
@@ -5636,6 +5650,8 @@ innodb_show_status(
{
Protocol
*
protocol
=
thd
->
protocol
;
trx_t
*
trx
;
long
flen
;
char
*
str
;
DBUG_ENTER
(
"innodb_show_status"
);
...
...
@@ -5652,14 +5668,13 @@ innodb_show_status(
/* We let the InnoDB Monitor to output at most 64000 bytes of text. */
long
flen
;
char
*
str
;
mutex_enter_noninline
(
&
srv_monitor_file_mutex
);
rewind
(
srv_monitor_file
);
srv_printf_innodb_monitor
(
srv_monitor_file
);
flen
=
ftell
(
srv_monitor_file
);
os_file_set_eof
(
srv_monitor_file
);
if
(
flen
<
0
)
{
flen
=
0
;
}
else
if
(
flen
>
64000
-
1
)
{
...
...
@@ -5669,9 +5684,9 @@ innodb_show_status(
/* allocate buffer for the string, and
read the contents of the temporary file */
if
(
!
(
str
=
my_malloc
(
flen
+
1
,
MYF
(
0
))))
{
if
(
!
(
str
=
my_malloc
(
flen
+
1
,
MYF
(
0
))))
{
mutex_exit_noninline
(
&
srv_monitor_file_mutex
);
DBUG_RETURN
(
TRUE
);
}
...
...
@@ -5686,7 +5701,6 @@ innodb_show_status(
if
(
protocol
->
send_fields
(
&
field_list
,
Protocol
::
SEND_NUM_ROWS
|
Protocol
::
SEND_EOF
))
{
my_free
(
str
,
MYF
(
0
));
DBUG_RETURN
(
TRUE
);
...
...
@@ -5696,10 +5710,12 @@ innodb_show_status(
protocol
->
store
(
str
,
flen
,
system_charset_info
);
my_free
(
str
,
MYF
(
0
));
if
(
protocol
->
write
())
DBUG_RETURN
(
TRUE
);
if
(
protocol
->
write
())
{
DBUG_RETURN
(
TRUE
);
}
send_eof
(
thd
);
DBUG_RETURN
(
FALSE
);
}
...
...
@@ -6115,7 +6131,8 @@ ha_innobase::cmp_ref(
/* Do type-aware comparison of Primary Key members. PK members
are always NOT NULL, so no checks for NULL are performed */
KEY_PART_INFO
*
key_part
=
table
->
key_info
[
table
->
s
->
primary_key
].
key_part
;
KEY_PART_INFO
*
key_part
=
table
->
key_info
[
table
->
s
->
primary_key
].
key_part
;
KEY_PART_INFO
*
key_part_end
=
key_part
+
table
->
key_info
[
table
->
s
->
primary_key
].
key_parts
;
for
(;
key_part
!=
key_part_end
;
++
key_part
)
{
...
...
@@ -6260,19 +6277,21 @@ innobase_query_is_update(void)
thd
=
(
THD
*
)
innobase_current_thd
();
if
(
thd
->
lex
->
sql_command
==
SQLCOM_REPLACE
||
if
(
thd
->
lex
->
sql_command
==
SQLCOM_REPLACE
||
thd
->
lex
->
sql_command
==
SQLCOM_REPLACE_SELECT
||
(
thd
->
lex
->
sql_command
==
SQLCOM_LOAD
&&
thd
->
lex
->
duplicates
==
DUP_REPLACE
))
{
return
true
;
(
thd
->
lex
->
sql_command
==
SQLCOM_LOAD
&&
thd
->
lex
->
duplicates
==
DUP_REPLACE
))
{
return
(
1
);
}
if
(
thd
->
lex
->
sql_command
==
SQLCOM_INSERT
&&
thd
->
lex
->
duplicates
==
DUP_UPDATE
)
{
return
true
;
if
(
thd
->
lex
->
sql_command
==
SQLCOM_INSERT
&&
thd
->
lex
->
duplicates
==
DUP_UPDATE
)
{
return
(
1
);
}
return
false
;
return
(
0
)
;
}
}
...
...
@@ -6308,7 +6327,8 @@ innobase_xa_prepare(
"InnoDB: but trx->conc_state != TRX_NOT_STARTED
\n
"
);
}
if
(
all
||
(
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))))
{
if
(
all
||
(
!
(
thd
->
options
&
(
OPTION_NOT_AUTOCOMMIT
|
OPTION_BEGIN
))))
{
/* We were instructed to prepare the whole transaction, or
this is an SQL statement end and autocommit is on */
...
...
@@ -6359,10 +6379,11 @@ innobase_xa_recover(
uint
len
)
/* in: number of slots in xid_list */
{
if
(
len
==
0
||
xid_list
==
NULL
)
{
return
0
;
return
(
0
);
}
return
(
trx_recover_for_mysql
(
xid_list
,
len
));
return
(
trx_recover_for_mysql
(
xid_list
,
len
));
}
/***********************************************************************
...
...
@@ -6373,7 +6394,7 @@ int
innobase_commit_by_xid
(
/*===================*/
/* out: 0 or error number */
XID
*
xid
)
/*
in: X/Open XA Transaction I
dentification */
XID
*
xid
)
/*
in: X/Open XA transaction i
dentification */
{
trx_t
*
trx
;
...
...
@@ -6396,7 +6417,7 @@ int
innobase_rollback_by_xid
(
/*=====================*/
/* out: 0 or error number */
XID
*
xid
)
/* in
: X/Open XA Transaction I
denfification */
XID
*
xid
)
/* in
: X/Open XA transaction i
denfification */
{
trx_t
*
trx
;
...
...
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