Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ac7b17ea
Commit
ac7b17ea
authored
Jul 27, 2007
by
malff/marcsql@weblab.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review changes
parent
c7bbd891
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
40 deletions
+50
-40
sql/handler.cc
sql/handler.cc
+2
-0
sql/lock.cc
sql/lock.cc
+30
-11
sql/log.cc
sql/log.cc
+17
-25
sql/log.h
sql/log.h
+0
-3
sql/sql_parse.cc
sql/sql_parse.cc
+1
-1
No files found.
sql/handler.cc
View file @
ac7b17ea
...
@@ -3658,6 +3658,8 @@ int handler::ha_write_row(uchar *buf)
...
@@ -3658,6 +3658,8 @@ int handler::ha_write_row(uchar *buf)
Write a record to the engine bypassing row-level binary logging.
Write a record to the engine bypassing row-level binary logging.
This method is used internally by the server for writing to
This method is used internally by the server for writing to
performance schema tables, which are never replicated.
performance schema tables, which are never replicated.
TODO: Merge this function with ha_write_row(), and provide a way
to disable the binlog there.
*/
*/
int
handler
::
ha_write_row_no_binlog
(
uchar
*
buf
)
int
handler
::
ha_write_row_no_binlog
(
uchar
*
buf
)
{
{
...
...
sql/lock.cc
View file @
ac7b17ea
...
@@ -111,21 +111,23 @@ static void print_lock_error(int error, const char *);
...
@@ -111,21 +111,23 @@ static void print_lock_error(int error, const char *);
static
int
thr_lock_errno_to_mysql
[]
=
static
int
thr_lock_errno_to_mysql
[]
=
{
0
,
1
,
ER_LOCK_WAIT_TIMEOUT
,
ER_LOCK_DEADLOCK
};
{
0
,
1
,
ER_LOCK_WAIT_TIMEOUT
,
ER_LOCK_DEADLOCK
};
MYSQL_LOCK
*
mysql_lock_tables
(
THD
*
thd
,
TABLE
**
tables
,
uint
count
,
/**
uint
flags
,
bool
*
need_reopen
)
Perform semantic checks for mysql_lock_tables.
@param thd The current thread
@param tables The tables to lock
@param count The number of tables to lock
@param flags Lock flags
@return 0 if all the check passed, non zero if a check failed.
*/
int
mysql_lock_tables_check
(
THD
*
thd
,
TABLE
**
tables
,
uint
count
,
uint
flags
)
{
{
MYSQL_LOCK
*
sql_lock
;
TABLE
*
write_lock_used
;
int
rc
;
uint
i
;
bool
log_table_write_query
;
bool
log_table_write_query
;
uint
system_count
;
uint
system_count
;
uint
i
;
DBUG_ENTER
(
"mysql_lock_tables"
);
DBUG_ENTER
(
"mysql_lock_tables
_check
"
);
*
need_reopen
=
FALSE
;
system_count
=
0
;
system_count
=
0
;
log_table_write_query
=
(
is_log_table_write_query
(
thd
->
lex
->
sql_command
)
log_table_write_query
=
(
is_log_table_write_query
(
thd
->
lex
->
sql_command
)
||
((
flags
&
MYSQL_LOCK_PERF_SCHEMA
)
!=
0
));
||
((
flags
&
MYSQL_LOCK_PERF_SCHEMA
)
!=
0
));
...
@@ -154,7 +156,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
...
@@ -154,7 +156,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
||
(
thd
->
lex
->
sql_command
==
SQLCOM_LOCK_TABLES
))
||
(
thd
->
lex
->
sql_command
==
SQLCOM_LOCK_TABLES
))
{
{
my_error
(
ER_CANT_LOCK_LOG_TABLE
,
MYF
(
0
));
my_error
(
ER_CANT_LOCK_LOG_TABLE
,
MYF
(
0
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
1
);
}
}
}
}
...
@@ -173,9 +175,26 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
...
@@ -173,9 +175,26 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
if
((
system_count
>
0
)
&&
(
system_count
<
count
))
if
((
system_count
>
0
)
&&
(
system_count
<
count
))
{
{
my_error
(
ER_WRONG_LOCK_OF_SYSTEM_TABLE
,
MYF
(
0
));
my_error
(
ER_WRONG_LOCK_OF_SYSTEM_TABLE
,
MYF
(
0
));
DBUG_RETURN
(
0
);
DBUG_RETURN
(
1
);
}
}
DBUG_RETURN
(
0
);
}
MYSQL_LOCK
*
mysql_lock_tables
(
THD
*
thd
,
TABLE
**
tables
,
uint
count
,
uint
flags
,
bool
*
need_reopen
)
{
MYSQL_LOCK
*
sql_lock
;
TABLE
*
write_lock_used
;
int
rc
;
DBUG_ENTER
(
"mysql_lock_tables"
);
*
need_reopen
=
FALSE
;
if
(
mysql_lock_tables_check
(
thd
,
tables
,
count
,
flags
))
DBUG_RETURN
(
NULL
);
for
(;;)
for
(;;)
{
{
if
(
!
(
sql_lock
=
get_lock_data
(
thd
,
tables
,
count
,
GET_LOCK_STORE_LOCKS
,
if
(
!
(
sql_lock
=
get_lock_data
(
thd
,
tables
,
count
,
GET_LOCK_STORE_LOCKS
,
...
...
sql/log.cc
View file @
ac7b17ea
...
@@ -708,19 +708,10 @@ bool Log_to_file_event_handler::
...
@@ -708,19 +708,10 @@ bool Log_to_file_event_handler::
longlong
query_time
,
longlong
lock_time
,
bool
is_command
,
longlong
query_time
,
longlong
lock_time
,
bool
is_command
,
const
char
*
sql_text
,
uint
sql_text_len
)
const
char
*
sql_text
,
uint
sql_text_len
)
{
{
bool
res
;
return
mysql_slow_log
.
write
(
thd
,
current_time
,
query_start_arg
,
(
void
)
pthread_mutex_lock
(
mysql_slow_log
.
get_log_lock
());
/* TODO: MYSQL_QUERY_LOG::write is not thread-safe */
res
=
mysql_slow_log
.
write
(
thd
,
current_time
,
query_start_arg
,
user_host
,
user_host_len
,
user_host
,
user_host_len
,
query_time
,
lock_time
,
is_command
,
query_time
,
lock_time
,
is_command
,
sql_text
,
sql_text_len
);
sql_text
,
sql_text_len
);
(
void
)
pthread_mutex_unlock
(
mysql_slow_log
.
get_log_lock
());
return
res
;
}
}
...
@@ -736,18 +727,9 @@ bool Log_to_file_event_handler::
...
@@ -736,18 +727,9 @@ bool Log_to_file_event_handler::
const
char
*
sql_text
,
uint
sql_text_len
,
const
char
*
sql_text
,
uint
sql_text_len
,
CHARSET_INFO
*
client_cs
)
CHARSET_INFO
*
client_cs
)
{
{
bool
res
;
return
mysql_log
.
write
(
event_time
,
user_host
,
user_host_len
,
(
void
)
pthread_mutex_lock
(
mysql_log
.
get_log_lock
());
/* TODO: MYSQL_QUERY_LOG::write is not thread-safe */
res
=
mysql_log
.
write
(
event_time
,
user_host
,
user_host_len
,
thread_id
,
command_type
,
command_type_len
,
thread_id
,
command_type
,
command_type_len
,
sql_text
,
sql_text_len
);
sql_text
,
sql_text_len
);
(
void
)
pthread_mutex_unlock
(
mysql_log
.
get_log_lock
());
return
res
;
}
}
...
@@ -1959,6 +1941,8 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
...
@@ -1959,6 +1941,8 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
struct
tm
start
;
struct
tm
start
;
uint
time_buff_len
=
0
;
uint
time_buff_len
=
0
;
(
void
)
pthread_mutex_lock
(
&
LOCK_log
);
/* Test if someone closed between the is_open test and lock */
/* Test if someone closed between the is_open test and lock */
if
(
is_open
())
if
(
is_open
())
{
{
...
@@ -2003,6 +1987,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
...
@@ -2003,6 +1987,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
goto
err
;
goto
err
;
}
}
(
void
)
pthread_mutex_unlock
(
&
LOCK_log
);
return
FALSE
;
return
FALSE
;
err:
err:
...
@@ -2011,6 +1996,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
...
@@ -2011,6 +1996,7 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host,
write_error
=
1
;
write_error
=
1
;
sql_print_error
(
ER
(
ER_ERROR_ON_WRITE
),
name
,
errno
);
sql_print_error
(
ER
(
ER_ERROR_ON_WRITE
),
name
,
errno
);
}
}
(
void
)
pthread_mutex_unlock
(
&
LOCK_log
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -2053,8 +2039,13 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
...
@@ -2053,8 +2039,13 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
bool
error
=
0
;
bool
error
=
0
;
DBUG_ENTER
(
"MYSQL_QUERY_LOG::write"
);
DBUG_ENTER
(
"MYSQL_QUERY_LOG::write"
);
(
void
)
pthread_mutex_lock
(
&
LOCK_log
);
if
(
!
is_open
())
if
(
!
is_open
())
{
(
void
)
pthread_mutex_unlock
(
&
LOCK_log
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
if
(
is_open
())
if
(
is_open
())
{
// Safety agains reopen
{
// Safety agains reopen
...
@@ -2158,6 +2149,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
...
@@ -2158,6 +2149,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time,
}
}
}
}
}
}
(
void
)
pthread_mutex_unlock
(
&
LOCK_log
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
sql/log.h
View file @
ac7b17ea
...
@@ -213,9 +213,6 @@ class MYSQL_QUERY_LOG: public MYSQL_LOG
...
@@ -213,9 +213,6 @@ class MYSQL_QUERY_LOG: public MYSQL_LOG
WRITE_CACHE
);
WRITE_CACHE
);
}
}
/* TODO: fix MYSQL_LOG::write to be thread safe instead. */
inline
pthread_mutex_t
*
get_log_lock
()
{
return
&
LOCK_log
;
}
private:
private:
time_t
last_time
;
time_t
last_time
;
};
};
...
...
sql/sql_parse.cc
View file @
ac7b17ea
...
@@ -210,7 +210,7 @@ void init_update_queries(void)
...
@@ -210,7 +210,7 @@ void init_update_queries(void)
sql_command_flags
[
SQLCOM_CREATE_VIEW
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_CREATE_VIEW
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_DROP_VIEW
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_DROP_VIEW
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_CREATE_EVENT
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_CREATE_EVENT
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_ALTER_EVENT
]
=
CF_CHANGES_DATA
|
CF_WRITE_LOGS_COMMAND
;
sql_command_flags
[
SQLCOM_ALTER_EVENT
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_DROP_EVENT
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_DROP_EVENT
]
=
CF_CHANGES_DATA
;
sql_command_flags
[
SQLCOM_UPDATE
]
=
CF_CHANGES_DATA
|
CF_HAS_ROW_COUNT
;
sql_command_flags
[
SQLCOM_UPDATE
]
=
CF_CHANGES_DATA
|
CF_HAS_ROW_COUNT
;
...
...
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