mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed some threading issues that Guilhem found (and its what I get for copy and pasting from elsewhere without thinking about it). Added depracted messages to BACKUP, RESTORE, and LOAD TABLE FROM MASTER (which doesn't work well).
This commit is contained in:
@ -48,15 +48,19 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \
|
|||||||
$(top_srcdir)/mysys/my_vle.c \
|
$(top_srcdir)/mysys/my_vle.c \
|
||||||
$(top_srcdir)/mysys/base64.c
|
$(top_srcdir)/mysys/base64.c
|
||||||
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
|
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
|
||||||
mysqlslap_LDADD = $(LDADD) $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS)
|
mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
||||||
mysqlimport_LDADD = $(LDADD) $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
@CLIENT_EXTRA_LDFLAGS@ \
|
||||||
|
$(top_builddir)/libmysql_r/libmysqlclient_r.la \
|
||||||
|
$(top_builddir)/mysys/libmysys.a
|
||||||
|
mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \
|
||||||
|
@CLIENT_EXTRA_LDFLAGS@ \
|
||||||
|
$(top_builddir)/libmysql_r/libmysqlclient_r.la \
|
||||||
$(top_builddir)/mysys/libmysys.a
|
$(top_builddir)/mysys/libmysys.a
|
||||||
mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c
|
mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c
|
||||||
mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix)
|
mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix)
|
||||||
mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix)
|
mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix)
|
||||||
mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix)
|
mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix)
|
||||||
mysqlslap_SOURCES= mysqlslap.c $(top_srcdir)/mysys/my_lock.c \
|
mysqlslap_SOURCES= mysqlslap.c \
|
||||||
$(top_srcdir)/mysys/my_alarm.c \
|
|
||||||
$(yassl_dummy_link_fix)
|
$(yassl_dummy_link_fix)
|
||||||
mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix)
|
mysqldump_SOURCES= mysqldump.c my_user.c $(yassl_dummy_link_fix)
|
||||||
mysqlimport_SOURCES= mysqlimport.c \
|
mysqlimport_SOURCES= mysqlimport.c \
|
||||||
|
@ -516,7 +516,11 @@ pthread_handler_t worker_thread(void *arg)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
char *raw_table_name= (char *)arg;
|
char *raw_table_name= (char *)arg;
|
||||||
MYSQL *mysql;
|
MYSQL *mysql= 0;
|
||||||
|
|
||||||
|
if (mysql_thread_init())
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))
|
if (!(mysql= db_connect(current_host,current_db,current_user,opt_password)))
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
@ -528,6 +532,9 @@ pthread_handler_t worker_thread(void *arg)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
We are not currently catching the error here.
|
||||||
|
*/
|
||||||
if((error= write_to_table(raw_table_name, mysql)))
|
if((error= write_to_table(raw_table_name, mysql)))
|
||||||
if (exitcode == 0)
|
if (exitcode == 0)
|
||||||
exitcode= error;
|
exitcode= error;
|
||||||
@ -539,6 +546,8 @@ error:
|
|||||||
pthread_mutex_lock(&counter_mutex);
|
pthread_mutex_lock(&counter_mutex);
|
||||||
counter--;
|
counter--;
|
||||||
pthread_mutex_unlock(&counter_mutex);
|
pthread_mutex_unlock(&counter_mutex);
|
||||||
|
my_thread_end();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ TODO:
|
|||||||
#define RAND_STRING_SIZE 126
|
#define RAND_STRING_SIZE 126
|
||||||
|
|
||||||
#include "client_priv.h"
|
#include "client_priv.h"
|
||||||
|
#include <my_pthread.h>
|
||||||
#include <my_sys.h>
|
#include <my_sys.h>
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
@ -89,7 +90,6 @@ TODO:
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <my_pthread.h>
|
|
||||||
|
|
||||||
#define MYSLAPLOCK "/myslaplock.lck"
|
#define MYSLAPLOCK "/myslaplock.lck"
|
||||||
#define MYSLAPLOCK_DIR "/tmp"
|
#define MYSLAPLOCK_DIR "/tmp"
|
||||||
@ -170,6 +170,7 @@ typedef struct thread_context thread_context;
|
|||||||
struct thread_context {
|
struct thread_context {
|
||||||
statement *stmt;
|
statement *stmt;
|
||||||
ulonglong limit;
|
ulonglong limit;
|
||||||
|
bool thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct conclusions conclusions;
|
typedef struct conclusions conclusions;
|
||||||
@ -974,6 +975,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
|
|||||||
|
|
||||||
con.stmt= stmts;
|
con.stmt= stmts;
|
||||||
con.limit= limit;
|
con.limit= limit;
|
||||||
|
con.thread= opt_use_threads ? 1 :0;
|
||||||
|
|
||||||
lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));
|
lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));
|
||||||
|
|
||||||
@ -1096,8 +1098,8 @@ int
|
|||||||
run_task(thread_context *con)
|
run_task(thread_context *con)
|
||||||
{
|
{
|
||||||
ulonglong counter= 0, queries;
|
ulonglong counter= 0, queries;
|
||||||
File lock_file;
|
File lock_file= -1;
|
||||||
MYSQL mysql;
|
MYSQL *mysql;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
statement *ptr;
|
statement *ptr;
|
||||||
@ -1105,19 +1107,25 @@ run_task(thread_context *con)
|
|||||||
DBUG_ENTER("run_task");
|
DBUG_ENTER("run_task");
|
||||||
DBUG_PRINT("info", ("task script \"%s\"", con->stmt->string));
|
DBUG_PRINT("info", ("task script \"%s\"", con->stmt->string));
|
||||||
|
|
||||||
mysql_init(&mysql);
|
if (!(mysql= mysql_init(NULL)))
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
if (con->thread && mysql_thread_init())
|
||||||
|
goto end;
|
||||||
|
|
||||||
DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user));
|
DBUG_PRINT("info", ("trying to connect to host %s as user %s", host, user));
|
||||||
lock_file= my_open(lock_file_str, O_RDWR, MYF(0));
|
lock_file= my_open(lock_file_str, O_RDWR, MYF(0));
|
||||||
my_lock(lock_file, F_RDLCK, 0, F_TO_EOF, MYF(0));
|
my_lock(lock_file, F_RDLCK, 0, F_TO_EOF, MYF(0));
|
||||||
if (!opt_only_print)
|
if (!opt_only_print)
|
||||||
{
|
{
|
||||||
if (!(mysql_real_connect(&mysql, host, user, opt_password,
|
if (!(mysql= mysql_real_connect(NULL, host, user, opt_password,
|
||||||
"mysqlslap", opt_mysql_port, opt_mysql_unix_port,
|
create_schema_string,
|
||||||
0)))
|
opt_mysql_port,
|
||||||
|
opt_mysql_unix_port,
|
||||||
|
0)))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql));
|
fprintf(stderr,"%s: %s\n",my_progname,mysql_error(mysql));
|
||||||
exit(1);
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBUG_PRINT("info", ("connected."));
|
DBUG_PRINT("info", ("connected."));
|
||||||
@ -1133,15 +1141,15 @@ limit_not_met:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mysql_real_query(&mysql, ptr->string, ptr->length))
|
if (mysql_real_query(mysql, ptr->string, ptr->length))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
|
fprintf(stderr,"%s: Cannot run query %.*s ERROR : %s\n",
|
||||||
my_progname, (uint)ptr->length, ptr->string, mysql_error(&mysql));
|
my_progname, (uint)ptr->length, ptr->string, mysql_error(mysql));
|
||||||
exit(1);
|
goto end;
|
||||||
}
|
}
|
||||||
if (mysql_field_count(&mysql))
|
if (mysql_field_count(mysql))
|
||||||
{
|
{
|
||||||
result= mysql_store_result(&mysql);
|
result= mysql_store_result(mysql);
|
||||||
while ((row = mysql_fetch_row(result)))
|
while ((row = mysql_fetch_row(result)))
|
||||||
counter++;
|
counter++;
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
@ -1150,18 +1158,25 @@ limit_not_met:
|
|||||||
queries++;
|
queries++;
|
||||||
|
|
||||||
if (con->limit && queries == con->limit)
|
if (con->limit && queries == con->limit)
|
||||||
DBUG_RETURN(0);
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (con->limit && queries < con->limit)
|
if (con->limit && queries < con->limit)
|
||||||
goto limit_not_met;
|
goto limit_not_met;
|
||||||
|
|
||||||
my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
|
end:
|
||||||
my_close(lock_file, MYF(0));
|
|
||||||
|
if (lock_file != -1)
|
||||||
|
{
|
||||||
|
my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
|
||||||
|
my_close(lock_file, MYF(0));
|
||||||
|
}
|
||||||
|
|
||||||
if (!opt_only_print)
|
if (!opt_only_print)
|
||||||
mysql_close(&mysql);
|
mysql_close(mysql);
|
||||||
|
|
||||||
|
if (con->thread)
|
||||||
|
my_thread_end();
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,20 +6,26 @@ Table Op Msg_type Msg_text
|
|||||||
test.t4 backup error Failed copying .frm file (errno: X)
|
test.t4 backup error Failed copying .frm file (errno: X)
|
||||||
test.t4 backup status Operation failed
|
test.t4 backup status Operation failed
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Warning 1287 'BACKUP TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X)
|
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/bogus/t4.frm' (Errcode: X)
|
||||||
backup table t4 to '../tmp';
|
backup table t4 to '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t4 backup status OK
|
test.t4 backup status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'BACKUP TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
backup table t4 to '../tmp';
|
backup table t4 to '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t4 backup error Failed copying .frm file (errno: X)
|
test.t4 backup error Failed copying .frm file (errno: X)
|
||||||
test.t4 backup status Operation failed
|
test.t4 backup status Operation failed
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Warning 1287 'BACKUP TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X)
|
Error 1 Can't create/write to file 'MYSQLTEST_VARDIR/tmp/t4.frm' (Errcode: X)
|
||||||
drop table t4;
|
drop table t4;
|
||||||
restore table t4 from '../tmp';
|
restore table t4 from '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t4 restore status OK
|
test.t4 restore status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'RESTORE TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
select count(*) from t4;
|
select count(*) from t4;
|
||||||
count(*)
|
count(*)
|
||||||
0
|
0
|
||||||
@ -28,15 +34,20 @@ insert into t1 values (23),(45),(67);
|
|||||||
backup table t1 to '../tmp';
|
backup table t1 to '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 backup status OK
|
test.t1 backup status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'BACKUP TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
drop table t1;
|
drop table t1;
|
||||||
restore table t1 from '../bogus';
|
restore table t1 from '../bogus';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
t1 restore error Failed copying .frm file
|
t1 restore error Failed copying .frm file
|
||||||
Warnings:
|
Warnings:
|
||||||
|
Warning 1287 'RESTORE TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X)
|
Error 29 File 'MYSQLTEST_VARDIR/bogus/t1.frm' not found (Errcode: X)
|
||||||
restore table t1 from '../tmp';
|
restore table t1 from '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 restore status OK
|
test.t1 restore status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'RESTORE TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
select n from t1;
|
select n from t1;
|
||||||
n
|
n
|
||||||
23
|
23
|
||||||
@ -50,12 +61,16 @@ backup table t2,t3 to '../tmp';
|
|||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t2 backup status OK
|
test.t2 backup status OK
|
||||||
test.t3 backup status OK
|
test.t3 backup status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'BACKUP TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
drop table t1,t2,t3;
|
drop table t1,t2,t3;
|
||||||
restore table t1,t2,t3 from '../tmp';
|
restore table t1,t2,t3 from '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 restore status OK
|
test.t1 restore status OK
|
||||||
test.t2 restore status OK
|
test.t2 restore status OK
|
||||||
test.t3 restore status OK
|
test.t3 restore status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'RESTORE TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
select n from t1;
|
select n from t1;
|
||||||
n
|
n
|
||||||
23
|
23
|
||||||
@ -75,10 +90,14 @@ drop table t1,t2,t3,t4;
|
|||||||
restore table t1 from '../tmp';
|
restore table t1 from '../tmp';
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t1 restore status OK
|
test.t1 restore status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'RESTORE TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
rename table t1 to t5;
|
rename table t1 to t5;
|
||||||
lock tables t5 write;
|
lock tables t5 write;
|
||||||
backup table t5 to '../tmp';
|
backup table t5 to '../tmp';
|
||||||
unlock tables;
|
unlock tables;
|
||||||
Table Op Msg_type Msg_text
|
Table Op Msg_type Msg_text
|
||||||
test.t5 backup status OK
|
test.t5 backup status OK
|
||||||
|
Warnings:
|
||||||
|
Warning 1287 'BACKUP TABLE' is deprecated; use 'Command will be removed in next version.' instead
|
||||||
drop table t5;
|
drop table t5;
|
||||||
|
@ -5350,6 +5350,7 @@ restore:
|
|||||||
RESTORE_SYM table_or_tables
|
RESTORE_SYM table_or_tables
|
||||||
{
|
{
|
||||||
Lex->sql_command = SQLCOM_RESTORE_TABLE;
|
Lex->sql_command = SQLCOM_RESTORE_TABLE;
|
||||||
|
WARN_DEPRECATED("RESTORE TABLE", "Command will be removed in next version.");
|
||||||
}
|
}
|
||||||
table_list FROM TEXT_STRING_sys
|
table_list FROM TEXT_STRING_sys
|
||||||
{
|
{
|
||||||
@ -5360,6 +5361,7 @@ backup:
|
|||||||
BACKUP_SYM table_or_tables
|
BACKUP_SYM table_or_tables
|
||||||
{
|
{
|
||||||
Lex->sql_command = SQLCOM_BACKUP_TABLE;
|
Lex->sql_command = SQLCOM_BACKUP_TABLE;
|
||||||
|
WARN_DEPRECATED("BACKUP TABLE", "Command will be removed in next version.");
|
||||||
}
|
}
|
||||||
table_list TO_SYM TEXT_STRING_sys
|
table_list TO_SYM TEXT_STRING_sys
|
||||||
{
|
{
|
||||||
@ -8666,7 +8668,8 @@ load: LOAD DATA_SYM
|
|||||||
LOAD TABLE_SYM table_ident FROM MASTER_SYM
|
LOAD TABLE_SYM table_ident FROM MASTER_SYM
|
||||||
{
|
{
|
||||||
LEX *lex=Lex;
|
LEX *lex=Lex;
|
||||||
if (lex->sphead)
|
WARN_DEPRECATED("LOAD TABLE from MASTER", "Command will be removed in next version.");
|
||||||
|
if (lex->sphead)
|
||||||
{
|
{
|
||||||
my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");
|
my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
Reference in New Issue
Block a user