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
323e683c
Commit
323e683c
authored
Sep 07, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
c26246b0
9bafeecb
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
27 deletions
+77
-27
client/mysql.cc
client/mysql.cc
+14
-15
mysql-test/r/rpl_set_charset.result
mysql-test/r/rpl_set_charset.result
+0
-1
mysql-test/r/select.result
mysql-test/r/select.result
+16
-0
mysql-test/t/rpl_set_charset.test
mysql-test/t/rpl_set_charset.test
+1
-3
mysql-test/t/select.test
mysql-test/t/select.test
+21
-0
sql/log_event.cc
sql/log_event.cc
+10
-4
sql/slave.cc
sql/slave.cc
+9
-4
sql/sql_db.cc
sql/sql_db.cc
+5
-0
sql/sql_select.cc
sql/sql_select.cc
+1
-0
No files found.
client/mysql.cc
View file @
323e683c
...
@@ -2602,32 +2602,31 @@ com_use(String *buffer __attribute__((unused)), char *line)
...
@@ -2602,32 +2602,31 @@ com_use(String *buffer __attribute__((unused)), char *line)
put_info
(
"USE must be followed by a database name"
,
INFO_ERROR
);
put_info
(
"USE must be followed by a database name"
,
INFO_ERROR
);
return
0
;
return
0
;
}
}
/*
/*
We need to recheck the current database, because it may change
We need to recheck the current database, because it may change
under our feet, for example if DROP DATABASE or RENAME DATABASE
under our feet, for example if DROP DATABASE or RENAME DATABASE
(latter one not yet available by the time the comment was written)
(latter one not yet available by the time the comment was written)
*/
*/
current_db
=
0
;
// Let's reset current_db, assume it's gone
/* Let's reset current_db, assume it's gone */
/*
my_free
(
current_db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
We don't care about in case of an error below because current_db
current_db
=
0
;
was just set to 0.
/*
We don't care about in case of an error below because current_db
was just set to 0.
*/
*/
if
(
!
mysql_query
(
&
mysql
,
"SELECT DATABASE()"
)
&&
if
(
!
mysql_query
(
&
mysql
,
"SELECT DATABASE()"
)
&&
(
res
=
mysql_use_result
(
&
mysql
)))
(
res
=
mysql_use_result
(
&
mysql
)))
{
{
row
=
mysql_fetch_row
(
res
);
row
=
mysql_fetch_row
(
res
);
if
(
row
[
0
]
&&
if
(
row
[
0
])
(
!
current_db
||
cmp_database
(
charset_info
,
current_db
,
row
[
0
])))
{
{
my_free
(
current_db
,
MYF
(
MY_ALLOW_ZERO_PTR
));
current_db
=
my_strdup
(
row
[
0
],
MYF
(
MY_WME
));
current_db
=
my_strdup
(
row
[
0
],
MYF
(
MY_WME
));
}
}
(
void
)
mysql_fetch_row
(
res
);
// Read eof
(
void
)
mysql_fetch_row
(
res
);
// Read eof
mysql_free_result
(
res
);
mysql_free_result
(
res
);
}
}
if
(
!
current_db
||
cmp_database
(
c
harset_info
,
current_db
,
tmp
))
if
(
!
current_db
||
cmp_database
(
c
urrent_db
,
tmp
))
{
{
if
(
one_database
)
if
(
one_database
)
skip_updates
=
1
;
skip_updates
=
1
;
...
...
mysql-test/r/rpl_set_charset.result
View file @
323e683c
...
@@ -45,5 +45,4 @@ C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0
...
@@ -45,5 +45,4 @@ C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF C0
D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0
D0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF D0
E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0
E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF E0
F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0
F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF F0
drop table t1;
drop database mysqltest1;
drop database mysqltest1;
mysql-test/r/select.result
View file @
323e683c
...
@@ -2348,3 +2348,19 @@ select * from t2,t3 where t2.s = t3.s;
...
@@ -2348,3 +2348,19 @@ select * from t2,t3 where t2.s = t3.s;
s s
s s
two two
two two
drop table t1, t2, t3;
drop table t1, t2, t3;
CREATE TABLE t1 (
i int(11) NOT NULL default '0',
c char(10) NOT NULL default '',
PRIMARY KEY (i),
UNIQUE KEY c (c)
) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'a');
INSERT INTO t1 VALUES (2,'b');
INSERT INTO t1 VALUES (3,'c');
EXPLAIN SELECT i FROM t1 WHERE i=1;
table type possible_keys key key_len ref rows Extra
t1 const PRIMARY PRIMARY 4 const 1 Using index
EXPLAIN SELECT i FROM t1 WHERE i=1;
table type possible_keys key key_len ref rows Extra
t1 const PRIMARY PRIMARY 4 const 1 Using index
DROP TABLE t1;
mysql-test/t/rpl_set_charset.test
View file @
323e683c
...
@@ -27,9 +27,7 @@ use mysqltest1;
...
@@ -27,9 +27,7 @@ use mysqltest1;
select
"--- on slave ---"
;
select
"--- on slave ---"
;
select
hex
(
a
),
b
from
t1
order
by
b
;
select
hex
(
a
),
b
from
t1
order
by
b
;
connection
master
;
connection
master
;
drop
table
t1
;
drop
database
mysqltes
t1
;
save_master_pos
;
save_master_pos
;
connection
slave
;
connection
slave
;
sync_with_master
;
sync_with_master
;
connection
master
;
drop
database
mysqltest1
;
mysql-test/t/select.test
View file @
323e683c
...
@@ -1880,3 +1880,24 @@ select * from t3 where s = 'one';
...
@@ -1880,3 +1880,24 @@ select * from t3 where s = 'one';
select
*
from
t1
,
t2
where
t1
.
s
=
t2
.
s
;
select
*
from
t1
,
t2
where
t1
.
s
=
t2
.
s
;
select
*
from
t2
,
t3
where
t2
.
s
=
t3
.
s
;
select
*
from
t2
,
t3
where
t2
.
s
=
t3
.
s
;
drop
table
t1
,
t2
,
t3
;
drop
table
t1
,
t2
,
t3
;
#
# Covering index is mentioned in EXPLAIN output for const tables (bug #5333)
#
CREATE
TABLE
t1
(
i
int
(
11
)
NOT
NULL
default
'0'
,
c
char
(
10
)
NOT
NULL
default
''
,
PRIMARY
KEY
(
i
),
UNIQUE
KEY
c
(
c
)
)
TYPE
=
MyISAM
;
INSERT
INTO
t1
VALUES
(
1
,
'a'
);
INSERT
INTO
t1
VALUES
(
2
,
'b'
);
INSERT
INTO
t1
VALUES
(
3
,
'c'
);
EXPLAIN
SELECT
i
FROM
t1
WHERE
i
=
1
;
EXPLAIN
SELECT
i
FROM
t1
WHERE
i
=
1
;
DROP
TABLE
t1
;
sql/log_event.cc
View file @
323e683c
...
@@ -977,7 +977,7 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
...
@@ -977,7 +977,7 @@ void Query_log_event::print(FILE* file, bool short_form, char* last_db)
int
Query_log_event
::
exec_event
(
struct
st_relay_log_info
*
rli
)
int
Query_log_event
::
exec_event
(
struct
st_relay_log_info
*
rli
)
{
{
int
expected_error
,
actual_error
=
0
;
int
expected_error
,
actual_error
=
0
;
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
// thd->db_length is set later if needed
/*
/*
InnoDB internally stores the master log position it has processed so far;
InnoDB internally stores the master log position it has processed so far;
...
@@ -995,6 +995,11 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
...
@@ -995,6 +995,11 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
if
(
db_ok
(
thd
->
db
,
replicate_do_db
,
replicate_ignore_db
))
if
(
db_ok
(
thd
->
db
,
replicate_do_db
,
replicate_ignore_db
))
{
{
thd
->
set_time
((
time_t
)
when
);
thd
->
set_time
((
time_t
)
when
);
/*
We cannot use db_len from event to fill thd->db_length, because
rewrite_db() may have changed db.
*/
thd
->
db_length
=
thd
->
db
?
strlen
(
thd
->
db
)
:
0
;
thd
->
query_length
=
q_len
;
thd
->
query_length
=
q_len
;
thd
->
query
=
(
char
*
)
query
;
thd
->
query
=
(
char
*
)
query
;
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
...
@@ -1082,7 +1087,7 @@ end:
...
@@ -1082,7 +1087,7 @@ end:
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
db
=
0
;
// prevent db from being freed
thd
->
db
=
0
;
// prevent db from being freed
thd
->
query
=
0
;
// just to be sure
thd
->
query
=
0
;
// just to be sure
thd
->
query_length
=
0
;
thd
->
query_length
=
thd
->
db_length
=
0
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
free_root
(
&
thd
->
mem_root
,
MYF
(
MY_KEEP_PREALLOC
));
free_root
(
&
thd
->
mem_root
,
MYF
(
MY_KEEP_PREALLOC
));
...
@@ -1693,7 +1698,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
...
@@ -1693,7 +1698,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
bool
use_rli_only_for_errors
)
bool
use_rli_only_for_errors
)
{
{
char
*
load_data_query
=
0
;
char
*
load_data_query
=
0
;
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
thd
->
db
=
(
char
*
)
rewrite_db
(
db
);
// thd->db_length is set later if needed
DBUG_ASSERT
(
thd
->
query
==
0
);
DBUG_ASSERT
(
thd
->
query
==
0
);
thd
->
query_length
=
0
;
// Should not be needed
thd
->
query_length
=
0
;
// Should not be needed
thd
->
query_error
=
0
;
thd
->
query_error
=
0
;
...
@@ -1728,6 +1733,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
...
@@ -1728,6 +1733,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
if
(
db_ok
(
thd
->
db
,
replicate_do_db
,
replicate_ignore_db
))
if
(
db_ok
(
thd
->
db
,
replicate_do_db
,
replicate_ignore_db
))
{
{
thd
->
set_time
((
time_t
)
when
);
thd
->
set_time
((
time_t
)
when
);
thd
->
db_length
=
thd
->
db
?
strlen
(
thd
->
db
)
:
0
;
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
query_id
=
query_id
++
;
thd
->
query_id
=
query_id
++
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
...
@@ -1854,7 +1860,7 @@ Slave: load data infile on table '%s' at log position %s in log \
...
@@ -1854,7 +1860,7 @@ Slave: load data infile on table '%s' at log position %s in log \
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
db
=
0
;
thd
->
db
=
0
;
thd
->
query
=
0
;
thd
->
query
=
0
;
thd
->
query_length
=
0
;
thd
->
query_length
=
thd
->
db_length
=
0
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
close_thread_tables
(
thd
);
close_thread_tables
(
thd
);
if
(
load_data_query
)
if
(
load_data_query
)
...
...
sql/slave.cc
View file @
323e683c
...
@@ -1290,6 +1290,7 @@ be equal for replication to work";
...
@@ -1290,6 +1290,7 @@ be equal for replication to work";
Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD
Used by fetch_master_table (used by LOAD TABLE tblname FROM MASTER and LOAD
DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it
DATA FROM MASTER). Drops the table (if 'overwrite' is true) and recreates it
from the dump. Honours replication inclusion/exclusion rules.
from the dump. Honours replication inclusion/exclusion rules.
db must be non-zero (guarded by assertion).
RETURN VALUES
RETURN VALUES
0 success
0 success
...
@@ -1300,8 +1301,8 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
...
@@ -1300,8 +1301,8 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
const
char
*
table_name
,
bool
overwrite
)
const
char
*
table_name
,
bool
overwrite
)
{
{
ulong
packet_len
;
ulong
packet_len
;
char
*
query
;
char
*
query
,
*
save_db
;
char
*
save_db
;
uint32
save_db_length
;
Vio
*
save_vio
;
Vio
*
save_vio
;
HA_CHECK_OPT
check_opt
;
HA_CHECK_OPT
check_opt
;
TABLE_LIST
tables
;
TABLE_LIST
tables
;
...
@@ -1357,9 +1358,13 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
...
@@ -1357,9 +1358,13 @@ static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db,
thd
->
proc_info
=
"Creating table from master dump"
;
thd
->
proc_info
=
"Creating table from master dump"
;
// save old db in case we are creating in a different database
// save old db in case we are creating in a different database
save_db
=
thd
->
db
;
save_db
=
thd
->
db
;
save_db_length
=
thd
->
db_length
;
thd
->
db
=
(
char
*
)
db
;
thd
->
db
=
(
char
*
)
db
;
DBUG_ASSERT
(
thd
->
db
);
thd
->
db_length
=
strlen
(
thd
->
db
);
mysql_parse
(
thd
,
thd
->
query
,
packet_len
);
// run create table
mysql_parse
(
thd
,
thd
->
query
,
packet_len
);
// run create table
thd
->
db
=
save_db
;
// leave things the way the were before
thd
->
db
=
save_db
;
// leave things the way the were before
thd
->
db_length
=
save_db_length
;
thd
->
options
=
save_options
;
thd
->
options
=
save_options
;
if
(
thd
->
query_error
)
if
(
thd
->
query_error
)
...
@@ -3225,7 +3230,7 @@ err:
...
@@ -3225,7 +3230,7 @@ err:
IO_RPL_LOG_NAME
,
llstr
(
mi
->
master_log_pos
,
llbuff
));
IO_RPL_LOG_NAME
,
llstr
(
mi
->
master_log_pos
,
llbuff
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
query
=
thd
->
db
=
0
;
// extra safety
thd
->
query
=
thd
->
db
=
0
;
// extra safety
thd
->
query_length
=
0
;
thd
->
query_length
=
thd
->
db_length
=
0
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
if
(
mysql
)
if
(
mysql
)
{
{
...
@@ -3391,7 +3396,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
...
@@ -3391,7 +3396,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
err:
err:
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_lock
(
&
LOCK_thread_count
));
thd
->
query
=
thd
->
db
=
0
;
// extra safety
thd
->
query
=
thd
->
db
=
0
;
// extra safety
thd
->
query_length
=
0
;
thd
->
query_length
=
thd
->
db_length
=
0
;
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
VOID
(
pthread_mutex_unlock
(
&
LOCK_thread_count
));
thd
->
proc_info
=
"Waiting for slave mutex on exit"
;
thd
->
proc_info
=
"Waiting for slave mutex on exit"
;
pthread_mutex_lock
(
&
rli
->
run_lock
);
pthread_mutex_lock
(
&
rli
->
run_lock
);
...
...
sql/sql_db.cc
View file @
323e683c
...
@@ -852,6 +852,11 @@ err:
...
@@ -852,6 +852,11 @@ err:
communication packet (in case of 'connect' or 'COM_INIT_DB')
communication packet (in case of 'connect' or 'COM_INIT_DB')
we have to do end space removal in this function.
we have to do end space removal in this function.
NOTES
Do as little as possible in this function, as it is not called for the
replication slave SQL thread (for that thread, setting of thd->db is done
in ::exec_event() methods of log_event.cc).
RETURN VALUES
RETURN VALUES
0 ok
0 ok
1 error
1 error
...
...
sql/sql_select.cc
View file @
323e683c
...
@@ -5930,6 +5930,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
...
@@ -5930,6 +5930,7 @@ join_read_const_table(JOIN_TAB *tab, POSITION *pos)
{
{
table
->
key_read
=
1
;
table
->
key_read
=
1
;
table
->
file
->
extra
(
HA_EXTRA_KEYREAD
);
table
->
file
->
extra
(
HA_EXTRA_KEYREAD
);
tab
->
index
=
tab
->
ref
.
key
;
}
}
if
((
error
=
join_read_const
(
tab
)))
if
((
error
=
join_read_const
(
tab
)))
{
{
...
...
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