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
6d6f0511
Commit
6d6f0511
authored
Jan 04, 2003
by
monty@mashka.mysql.fi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for DROP TEMPORARY TABLE
Removed mysql_warnings() API function. Post merge fixes.
parent
07daf316
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
89 additions
and
69 deletions
+89
-69
client/mysqltest.c
client/mysqltest.c
+8
-3
include/mysql.h
include/mysql.h
+0
-1
libmysql/libmysql.c
libmysql/libmysql.c
+0
-12
mysql-test/r/rpl_log_pos.result
mysql-test/r/rpl_log_pos.result
+3
-3
mysql-test/t/connect.test
mysql-test/t/connect.test
+0
-2
mysql-test/t/rpl_log_pos.test
mysql-test/t/rpl_log_pos.test
+4
-4
sql/item.h
sql/item.h
+2
-1
sql/item_create.cc
sql/item_create.cc
+2
-1
sql/mysql_priv.h
sql/mysql_priv.h
+4
-3
sql/sql_db.cc
sql/sql_db.cc
+1
-1
sql/sql_parse.cc
sql/sql_parse.cc
+18
-11
sql/sql_repl.cc
sql/sql_repl.cc
+4
-4
sql/sql_table.cc
sql/sql_table.cc
+43
-23
No files found.
client/mysqltest.c
View file @
6d6f0511
...
...
@@ -2207,10 +2207,15 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
/* Add all warnings to the result */
if
(
!
disable_result_log
&&
mysql_warning_count
(
mysql
))
{
MYSQL_RES
*
warn_res
=
mysql_warnings
(
mysql
);
MYSQL_RES
*
warn_res
=
0
;
uint
count
=
mysql_warning_count
(
mysql
);
if
(
!
mysql_real_query
(
mysql
,
"SHOW WARNINGS"
,
13
))
{
warn_res
=
mysql_store_result
(
mysql
);
}
if
(
!
warn_res
)
verbose_msg
(
"Warning count is %
d
but didn't get any warnings
\n
"
,
mysql_warning_count
(
mysql
)
);
verbose_msg
(
"Warning count is %
u
but didn't get any warnings
\n
"
,
count
);
else
{
dynstr_append_mem
(
ds
,
"Warnings:
\n
"
,
10
);
...
...
include/mysql.h
View file @
6d6f0511
...
...
@@ -381,7 +381,6 @@ MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
MYSQL_RES
*
STDCALL
mysql_list_processes
(
MYSQL
*
mysql
);
MYSQL_RES
*
STDCALL
mysql_store_result
(
MYSQL
*
mysql
);
MYSQL_RES
*
STDCALL
mysql_use_result
(
MYSQL
*
mysql
);
MYSQL_RES
*
STDCALL
mysql_warnings
(
MYSQL
*
mysql
);
int
STDCALL
mysql_options
(
MYSQL
*
mysql
,
enum
mysql_option
option
,
const
char
*
arg
);
void
STDCALL
mysql_free_result
(
MYSQL_RES
*
result
);
...
...
libmysql/libmysql.c
View file @
6d6f0511
...
...
@@ -3515,18 +3515,6 @@ uint STDCALL mysql_thread_safe(void)
#endif
}
MYSQL_RES
*
STDCALL
mysql_warnings
(
MYSQL
*
mysql
)
{
uint
warning_count
;
DBUG_ENTER
(
"mysql_warnings"
);
/* Save warning count as mysql_real_query may change this */
warning_count
=
mysql
->
warning_count
;
if
(
mysql_real_query
(
mysql
,
"SHOW WARNINGS"
,
13
))
DBUG_RETURN
(
0
);
mysql
->
warning_count
=
warning_count
;
DBUG_RETURN
(
mysql_store_result
(
mysql
));
}
/****************************************************************************
Some support functions
****************************************************************************/
...
...
mysql-test/r/rpl_log_pos.result
View file @
6d6f0511
...
...
@@ -10,9 +10,9 @@ master-bin.000001 79
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 127
s
lave stop
;
s
top slave
;
change master to master_log_pos=73;
s
lave start
;
s
tart slave
;
stop slave;
change master to master_log_pos=73;
show slave status;
...
...
@@ -35,7 +35,7 @@ create table if not exists t1 (n int);
drop table if exists t1;
create table t1 (n int);
insert into t1 values (1),(2),(3);
s
lave stop
;
s
top slave
;
change master to master_log_pos=79;
start slave;
select * from t1;
...
...
mysql-test/t/connect.test
View file @
6d6f0511
...
...
@@ -63,5 +63,3 @@ show tables;
#--error 1045
#connect (con1,localhost,test,zorro,);
#--error 1045
mysql-test/t/rpl_log_pos.test
View file @
6d6f0511
...
...
@@ -6,9 +6,9 @@ show master status;
sync_slave_with_master
;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
show
slave
status
;
s
lave
stop
;
s
top
slave
;
change
master
to
master_log_pos
=
73
;
s
lave
start
;
s
tart
slave
;
sleep
5
;
stop
slave
;
...
...
@@ -19,7 +19,7 @@ start slave;
sleep
5
;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
show
slave
status
;
s
lave
stop
;
s
top
slave
;
change
master
to
master_log_pos
=
173
;
--
replace_result
3306
MASTER_PORT
9306
MASTER_PORT
3334
MASTER_PORT
3336
MASTER_PORT
start
slave
;
...
...
@@ -34,7 +34,7 @@ create table t1 (n int);
insert
into
t1
values
(
1
),(
2
),(
3
);
save_master_pos
;
connection
slave
;
s
lave
stop
;
s
top
slave
;
change
master
to
master_log_pos
=
79
;
start
slave
;
sync_with_master
;
...
...
sql/item.h
View file @
6d6f0511
...
...
@@ -381,7 +381,8 @@ class Item_string :public Item
name
=
(
char
*
)
str_value
.
ptr
();
decimals
=
NOT_FIXED_DEC
;
}
Item_string
(
const
char
*
name_par
,
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
)
Item_string
(
const
char
*
name_par
,
const
char
*
str
,
uint
length
,
CHARSET_INFO
*
cs
)
{
str_value
.
set
(
str
,
length
,
cs
);
max_length
=
length
;
...
...
sql/item_create.cc
View file @
6d6f0511
...
...
@@ -311,7 +311,8 @@ Item *create_func_current_user()
length
=
(
uint
)
(
strxmov
(
buff
,
thd
->
priv_user
,
"@"
,
thd
->
host_or_ip
,
NullS
)
-
buff
);
return
new
Item_string
(
"CURRENT_USER()"
,
thd
->
memdup
(
buff
,
length
),
length
);
return
new
Item_string
(
"CURRENT_USER()"
,
thd
->
memdup
(
buff
,
length
),
length
,
default_charset_info
);
}
Item
*
create_func_quarter
(
Item
*
a
)
...
...
sql/mysql_priv.h
View file @
6d6f0511
...
...
@@ -323,11 +323,12 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
int
mysql_alter_db
(
THD
*
thd
,
const
char
*
db
,
HA_CREATE_INFO
*
create
);
int
mysql_rm_db
(
THD
*
thd
,
char
*
db
,
bool
if_exists
,
bool
silent
);
void
mysql_binlog_send
(
THD
*
thd
,
char
*
log_ident
,
my_off_t
pos
,
ushort
flags
);
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
);
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
,
my_bool
drop_temporary
);
int
mysql_rm_table_part2
(
THD
*
thd
,
TABLE_LIST
*
tables
,
bool
if_exists
,
bool
log_query
);
bool
drop_temporary
,
bool
log_query
);
int
mysql_rm_table_part2_with_lock
(
THD
*
thd
,
TABLE_LIST
*
tables
,
bool
if_exists
,
bool
if_exists
,
bool
drop_temporary
,
bool
log_query
);
int
quick_rm_table
(
enum
db_type
base
,
const
char
*
db
,
const
char
*
table_name
);
...
...
sql/sql_db.cc
View file @
6d6f0511
...
...
@@ -468,7 +468,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
my_dirend
(
dirp
);
if
(
thd
->
killed
||
(
tot_list
&&
mysql_rm_table_part2_with_lock
(
thd
,
tot_list
,
1
,
1
)))
(
tot_list
&&
mysql_rm_table_part2_with_lock
(
thd
,
tot_list
,
1
,
0
,
1
)))
DBUG_RETURN
(
-
1
);
/*
...
...
sql/sql_parse.cc
View file @
6d6f0511
...
...
@@ -963,7 +963,7 @@ bool do_command(THD *thd)
}
else
if
(
!
packet_length
)
{
send_error
(
net
,
net
->
last_errno
,
NullS
);
send_error
(
thd
,
net
->
last_errno
,
NullS
);
net
->
error
=
0
;
DBUG_RETURN
(
FALSE
);
}
...
...
@@ -1629,7 +1629,9 @@ mysql_execute_command(THD *thd)
{
res
=
mysqld_show_warnings
(
thd
,
(
ulong
)
((
1L
<<
(
uint
)
MYSQL_ERROR
::
WARN_LEVEL_NOTE
)
|
(
1L
<<
(
uint
)
MYSQL_ERROR
::
WARN_LEVEL_WARN
)));
(
1L
<<
(
uint
)
MYSQL_ERROR
::
WARN_LEVEL_WARN
)
|
(
1L
<<
(
uint
)
MYSQL_ERROR
::
WARN_LEVEL_ERROR
)
));
break
;
}
case
SQLCOM_SHOW_ERRORS
:
...
...
@@ -1883,7 +1885,7 @@ mysql_execute_command(THD *thd)
*/
if
(
thd
->
locked_tables
||
thd
->
active_transaction
())
{
send_error
(
&
thd
->
net
,
ER_LOCK_OR_ACTIVE_TRANSACTION
);
send_error
(
thd
,
ER_LOCK_OR_ACTIVE_TRANSACTION
);
break
;
}
{
...
...
@@ -2293,12 +2295,17 @@ mysql_execute_command(THD *thd)
}
case
SQLCOM_DROP_TABLE
:
{
if
(
check_table_access
(
thd
,
DROP_ACL
,
tables
))
goto
error
;
/* purecov: inspected */
if
(
end_active_trans
(
thd
))
res
=
-
1
;
else
res
=
mysql_rm_table
(
thd
,
tables
,
lex
->
drop_if_exists
);
if
(
!
lex
->
drop_temporary
)
{
if
(
check_table_access
(
thd
,
DROP_ACL
,
tables
))
goto
error
;
/* purecov: inspected */
if
(
end_active_trans
(
thd
))
{
res
=
-
1
;
break
;
}
}
res
=
mysql_rm_table
(
thd
,
tables
,
lex
->
drop_if_exists
,
lex
->
drop_temporary
);
}
break
;
case
SQLCOM_DROP_INDEX
:
...
...
@@ -3777,9 +3784,9 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables)
if
(
thd
&&
!
error_already_sent
)
{
if
(
result
)
send_error
(
&
thd
->
net
,
0
);
send_error
(
thd
,
0
);
else
send_ok
(
&
thd
->
net
);
send_ok
(
thd
);
}
return
result
;
...
...
sql/sql_repl.cc
View file @
6d6f0511
...
...
@@ -757,7 +757,7 @@ int reset_slave(THD *thd, MASTER_INFO* mi)
err:
unlock_slave_threads
(
mi
);
if
(
thd
&&
error
)
send_error
(
&
thd
->
net
,
sql_errno
,
errmsg
);
send_error
(
thd
,
sql_errno
,
errmsg
);
DBUG_RETURN
(
error
);
}
...
...
@@ -802,7 +802,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
init_thread_mask
(
&
thread_mask
,
mi
,
0
/*not inverse*/
);
if
(
thread_mask
)
// We refuse if any slave thread is running
{
net_printf
(
&
thd
,
ER_SLAVE_MUST_STOP
);
net_printf
(
thd
,
ER_SLAVE_MUST_STOP
);
unlock_slave_threads
(
mi
);
DBUG_RETURN
(
1
);
}
...
...
@@ -874,7 +874,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
0
/* not only reset, but also reinit */
,
&
errmsg
))
{
net_printf
(
&
thd
,
0
,
"Failed purging old relay logs: %s"
,
errmsg
);
net_printf
(
thd
,
0
,
"Failed purging old relay logs: %s"
,
errmsg
);
unlock_slave_threads
(
mi
);
DBUG_RETURN
(
1
);
}
...
...
@@ -908,7 +908,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
unlock_slave_threads
(
mi
);
thd
->
proc_info
=
0
;
send_ok
(
&
thd
);
send_ok
(
thd
);
DBUG_RETURN
(
0
);
}
...
...
sql/sql_table.cc
View file @
6d6f0511
...
...
@@ -46,7 +46,8 @@ static int copy_data_between_tables(TABLE *from,TABLE *to,
** This will wait for all users to free the table before dropping it
*****************************************************************************/
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
)
int
mysql_rm_table
(
THD
*
thd
,
TABLE_LIST
*
tables
,
my_bool
if_exists
,
my_bool
drop_temporary
)
{
int
error
;
DBUG_ENTER
(
"mysql_rm_table"
);
...
...
@@ -57,7 +58,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
thd
->
mysys_var
->
current_cond
=
&
COND_refresh
;
VOID
(
pthread_mutex_lock
(
&
LOCK_open
));
if
(
global_read_lock
)
if
(
!
drop_temporary
&&
global_read_lock
)
{
if
(
thd
->
global_read_lock
)
{
...
...
@@ -72,7 +73,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
}
}
error
=
mysql_rm_table_part2
(
thd
,
tables
,
if_exists
,
0
);
error
=
mysql_rm_table_part2
(
thd
,
tables
,
if_exists
,
drop_temporary
,
0
);
err:
pthread_mutex_unlock
(
&
LOCK_open
);
...
...
@@ -91,14 +92,15 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
int
mysql_rm_table_part2_with_lock
(
THD
*
thd
,
TABLE_LIST
*
tables
,
bool
if_exists
,
bool
dont_log_query
)
bool
d
rop_temporary
,
bool
d
ont_log_query
)
{
int
error
;
thd
->
mysys_var
->
current_mutex
=
&
LOCK_open
;
thd
->
mysys_var
->
current_cond
=
&
COND_refresh
;
VOID
(
pthread_mutex_lock
(
&
LOCK_open
));
error
=
mysql_rm_table_part2
(
thd
,
tables
,
if_exists
,
dont_log_query
);
error
=
mysql_rm_table_part2
(
thd
,
tables
,
if_exists
,
drop_temporary
,
dont_log_query
);
pthread_mutex_unlock
(
&
LOCK_open
);
VOID
(
pthread_cond_broadcast
(
&
COND_refresh
));
// Signal to refresh
...
...
@@ -111,6 +113,17 @@ int mysql_rm_table_part2_with_lock(THD *thd,
}
/*
Execute the drop of a normal or temporary table
SYNOPSIS
mysql_rm_table_part2()
thd Thread handler
tables Tables to drop
if_exists If set, don't give an error if table doesn't exists.
In this case we give an warning of level 'NOTE'
drop_temporary Only drop temporary tables
dont_log_query Don't log the query
TODO:
When logging to the binary log, we should log
tmp_tables and transactional tables as separate statements if we
...
...
@@ -120,10 +133,15 @@ int mysql_rm_table_part2_with_lock(THD *thd,
The current code only writes DROP statements that only uses temporary
tables to the cache binary log. This should be ok on most cases, but
not all.
RETURN
0 ok
1 Error
-1 Thread was killed
*/
int
mysql_rm_table_part2
(
THD
*
thd
,
TABLE_LIST
*
tables
,
bool
if_exists
,
bool
dont_log_query
)
bool
d
rop_temporary
,
bool
d
ont_log_query
)
{
TABLE_LIST
*
table
;
char
path
[
FN_REFLEN
];
...
...
@@ -142,26 +160,28 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
continue
;
// removed temporary table
}
abort_locked_tables
(
thd
,
db
,
table
->
real_name
);
while
(
remove_table_from_cache
(
thd
,
db
,
table
->
real_name
)
&&
!
thd
->
killed
)
{
dropping_tables
++
;
(
void
)
pthread_cond_wait
(
&
COND_refresh
,
&
LOCK_open
);
dropping_tables
--
;
}
drop_locked_tables
(
thd
,
db
,
table
->
real_name
);
if
(
thd
->
killed
)
DBUG_RETURN
(
-
1
);
/* remove form file and isam files */
strxmov
(
path
,
mysql_data_home
,
"/"
,
db
,
"/"
,
table
->
real_name
,
reg_ext
,
NullS
);
(
void
)
unpack_filename
(
path
,
path
);
error
=
0
;
if
(
!
drop_temporary
)
{
abort_locked_tables
(
thd
,
db
,
table
->
real_name
);
while
(
remove_table_from_cache
(
thd
,
db
,
table
->
real_name
)
&&
!
thd
->
killed
)
{
dropping_tables
++
;
(
void
)
pthread_cond_wait
(
&
COND_refresh
,
&
LOCK_open
);
dropping_tables
--
;
}
drop_locked_tables
(
thd
,
db
,
table
->
real_name
);
if
(
thd
->
killed
)
DBUG_RETURN
(
-
1
);
table_type
=
get_table_type
(
path
);
/* remove form file and isam files */
strxmov
(
path
,
mysql_data_home
,
"/"
,
db
,
"/"
,
table
->
real_name
,
reg_ext
,
NullS
);
(
void
)
unpack_filename
(
path
,
path
);
if
(
access
(
path
,
F_OK
))
table_type
=
get_table_type
(
path
);
}
if
(
drop_temporary
||
access
(
path
,
F_OK
))
{
if
(
if_exists
)
store_warning
(
thd
,
ER_BAD_TABLE_ERROR
,
table
->
real_name
);
...
...
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