Fixed a problem using LOCK TABLES and BDB tables
Docs/manual.texi: Added description of C thread functions sql-bench/test-create.sh: Faster --fast option
This commit is contained in:
parent
07a887b383
commit
44e61cdad7
168
Docs/manual.texi
168
Docs/manual.texi
@ -6149,9 +6149,9 @@ Nothing; In the long run we plan to be fully ANSI 92 / ANSI 99 compliant.
|
|||||||
@menu
|
@menu
|
||||||
* Quick Standard Installation:: Quick Standard Installation of MySQL
|
* Quick Standard Installation:: Quick Standard Installation of MySQL
|
||||||
* General Installation Issues:: General Installation Issues
|
* General Installation Issues:: General Installation Issues
|
||||||
* Installing source:: Installing a MySQL source distribution
|
* Installing source:: Installing a MySQL source distribution
|
||||||
* Post-installation:: Post-installation setup and testing
|
* Post-installation:: Post-installation setup and testing
|
||||||
* Upgrade:: Upgrading/Downgrading MySQL
|
* Upgrade:: Upgrading/Downgrading MySQL
|
||||||
* Operating System Specific Notes:: Operating System Specific Notes
|
* Operating System Specific Notes:: Operating System Specific Notes
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
@ -8202,7 +8202,7 @@ If your client programs are using threads, you need to also compile a
|
|||||||
thread-safe version of the MySQL client library with the
|
thread-safe version of the MySQL client library with the
|
||||||
@code{--with-thread-safe-client} configure options. This will create a
|
@code{--with-thread-safe-client} configure options. This will create a
|
||||||
@code{libmysqlclient_r} library with which you should link your threaded
|
@code{libmysqlclient_r} library with which you should link your threaded
|
||||||
applications. @xref{Thread-safe clients}.
|
applications. @xref{Threaded clients}.
|
||||||
|
|
||||||
@item
|
@item
|
||||||
Options that pertain to particular systems can be found in the
|
Options that pertain to particular systems can be found in the
|
||||||
@ -38964,9 +38964,10 @@ likely it is that we can fix the problem!
|
|||||||
* C API datatypes:: C API Datatypes
|
* C API datatypes:: C API Datatypes
|
||||||
* C API function overview:: C API Function Overview
|
* C API function overview:: C API Function Overview
|
||||||
* C API functions:: C API Function Descriptions
|
* C API functions:: C API Function Descriptions
|
||||||
|
* C Thread functions::
|
||||||
* C API problems:: Common questions and problems when using the C API
|
* C API problems:: Common questions and problems when using the C API
|
||||||
* Building clients:: Building Client Programs
|
* Building clients:: Building Client Programs
|
||||||
* Thread-safe clients:: How to Make a Thread-safe Client
|
* Threaded clients:: How to Make a Threaded Client
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
The C API code is distributed with MySQL. It is included in the
|
The C API code is distributed with MySQL. It is included in the
|
||||||
@ -39007,7 +39008,7 @@ the buffer associated with a connection is not decreased until the connection
|
|||||||
is closed, at which time client memory is reclaimed.
|
is closed, at which time client memory is reclaimed.
|
||||||
|
|
||||||
For programming with threads, consult the 'how to make a thread-safe
|
For programming with threads, consult the 'how to make a thread-safe
|
||||||
client' chapter. @xref{Thread-safe clients}.
|
client' chapter. @xref{Threaded clients}.
|
||||||
|
|
||||||
|
|
||||||
@node C API datatypes, C API function overview, C, C
|
@node C API datatypes, C API function overview, C, C
|
||||||
@ -39455,7 +39456,7 @@ recently invoked function that can succeed or fail, allowing you to determine
|
|||||||
when an error occurred and what it was.
|
when an error occurred and what it was.
|
||||||
|
|
||||||
|
|
||||||
@node C API functions, C API problems, C API function overview, C
|
@node C API functions, C Thread functions, C API function overview, C
|
||||||
@subsection C API Function Descriptions
|
@subsection C API Function Descriptions
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
@ -40373,7 +40374,7 @@ of @code{mysql_field_count()} whether or not the statement was a
|
|||||||
|
|
||||||
@code{MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset)}
|
@code{MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result, MYSQL_FIELD_OFFSET offset)}
|
||||||
|
|
||||||
* Thread-safe clients:: How to Make a Thread-safe Client
|
* Threaded clients:: How to Make a Threaded Client
|
||||||
@subsubheading Description
|
@subsubheading Description
|
||||||
|
|
||||||
Sets the field cursor to the given offset. The next call to
|
Sets the field cursor to the given offset. The next call to
|
||||||
@ -41650,8 +41651,71 @@ The connection to the server was lost during the query.
|
|||||||
An unknown error occurred.
|
An unknown error occurred.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@node C Thread functions, C API problems, C API functions, C
|
||||||
|
@subsection C Threaded Function Descriptions
|
||||||
|
|
||||||
@node C API problems, Building clients, C API functions, C
|
You need to use the following functions when you want to create a
|
||||||
|
threaded client. @xref{Threaded clients}.
|
||||||
|
|
||||||
|
@menu
|
||||||
|
* my_init::
|
||||||
|
* my_thread_init()::
|
||||||
|
* my_thread_end()::
|
||||||
|
@end menu
|
||||||
|
|
||||||
|
@node my_init, my_thread_init(), C Thread functions, C Thread functions
|
||||||
|
@subsubsection @code{my_init()}
|
||||||
|
|
||||||
|
@findex @code{my_init()}
|
||||||
|
|
||||||
|
@subsubheading Description
|
||||||
|
|
||||||
|
This function needs to be called once in the program before calling any
|
||||||
|
MySQL function. This initializes some global variables that MySQL
|
||||||
|
needs. If you are using a thread safe client library, this will also
|
||||||
|
call @code{my_thread_init()} for this thread.
|
||||||
|
|
||||||
|
This is automaticly called by @code{mysql_init()}
|
||||||
|
and @code{mysql_connect()}.
|
||||||
|
|
||||||
|
@subsubheading Return Values
|
||||||
|
|
||||||
|
none.
|
||||||
|
|
||||||
|
@node my_thread_init(), my_thread_end(), my_init, C Thread functions
|
||||||
|
@subsubsection @code{my_thread_init()}
|
||||||
|
|
||||||
|
@findex @code{my_thread_init()}
|
||||||
|
|
||||||
|
@subsubheading Description
|
||||||
|
|
||||||
|
This function needs to be called for each created thread to initialize
|
||||||
|
thread specific variables.
|
||||||
|
|
||||||
|
This is automaticly called by @code{my_init()} and @code{mysql_connect()}.
|
||||||
|
|
||||||
|
@subsubheading Return Values
|
||||||
|
|
||||||
|
none.
|
||||||
|
|
||||||
|
@node my_thread_end(), , my_thread_init(), C Thread functions
|
||||||
|
@subsubsection @code{my_thread_end()}
|
||||||
|
|
||||||
|
@findex @code{my_thread_end()}
|
||||||
|
|
||||||
|
@subsubheading Description
|
||||||
|
|
||||||
|
This function needs to be called before calling @code{pthread_exit()} to
|
||||||
|
freed memory allocated by @code{my_thread_init()}.
|
||||||
|
|
||||||
|
Note that this function is NOT invoked automaticly be the client
|
||||||
|
library!
|
||||||
|
|
||||||
|
@subsubheading Return Values
|
||||||
|
|
||||||
|
none.
|
||||||
|
|
||||||
|
@node C API problems, Building clients, C Thread functions, C
|
||||||
@subsection Common questions and problems when using the C API
|
@subsection Common questions and problems when using the C API
|
||||||
|
|
||||||
@tindex @code{mysql_query()}
|
@tindex @code{mysql_query()}
|
||||||
@ -41806,7 +41870,7 @@ If this happens on your system, you must include the math library by
|
|||||||
adding @code{-lm} to the end of the compile/link line.
|
adding @code{-lm} to the end of the compile/link line.
|
||||||
|
|
||||||
|
|
||||||
@node Building clients, Thread-safe clients, C API problems, C
|
@node Building clients, Threaded clients, C API problems, C
|
||||||
@subsection Building Client Programs
|
@subsection Building Client Programs
|
||||||
|
|
||||||
@cindex client programs, building
|
@cindex client programs, building
|
||||||
@ -41827,11 +41891,11 @@ For clients that use MySQL header files, you may need to specify a
|
|||||||
files.
|
files.
|
||||||
|
|
||||||
|
|
||||||
@node Thread-safe clients, , Building clients, C
|
@node Threaded clients, , Building clients, C
|
||||||
@subsection How to Make a Thread-safe Client
|
@subsection How to Make a Threaded Client
|
||||||
|
|
||||||
@cindex clients, thread-safe
|
@cindex clients, threaded
|
||||||
@cindex thread-safe clients
|
@cindex threaded clients
|
||||||
|
|
||||||
The client library is almost thread safe. The biggest problem is
|
The client library is almost thread safe. The biggest problem is
|
||||||
that the subroutines in @file{net.c} that read from sockets are not
|
that the subroutines in @file{net.c} that read from sockets are not
|
||||||
@ -41846,20 +41910,21 @@ Windows binaries are by default compiled to be thread safe).
|
|||||||
Newer binary distributions should have both a normal and a
|
Newer binary distributions should have both a normal and a
|
||||||
thread-safe client library.
|
thread-safe client library.
|
||||||
|
|
||||||
To get a really thread-safe client where you can interrupt the client
|
To get a threaded client where you can interrupt the client from other
|
||||||
from other threads and set timeouts when talking with the MySQL
|
threads and set timeouts when talking with the MySQL server, you should
|
||||||
server, you should use the @code{-lmysys}, @code{-lstring}, and @code{-ldbug}
|
use the @code{-lmysys}, @code{-lstring}, and @code{-ldbug} libraries and
|
||||||
libraries and the @code{net_serv.o} code that the server uses.
|
the @code{net_serv.o} code that the server uses.
|
||||||
|
|
||||||
If you don't need interrupts or timeouts, you can just compile a thread
|
If you don't need interrupts or timeouts, you can just compile a thread
|
||||||
safe client library @code{(mysqlclient_r)} and use this. @xref{C,,
|
safe client library @code{(mysqlclient_r)} and use this. @xref{C,,
|
||||||
MySQL C API}. In this case you don't have to worry about the
|
MySQL C API}. In this case you don't have to worry about the
|
||||||
@code{net_serv.o} object file or the other MySQL libraries.
|
@code{net_serv.o} object file or the other MySQL libraries.
|
||||||
|
|
||||||
When using a threaded client and you want to use timeouts and interrupts,
|
When using a threaded client and you want to use timeouts and
|
||||||
you can make great use of the routines in the @file{thr_alarm.c} file.
|
interrupts, you can make great use of the routines in the
|
||||||
If you are using routines from the @code{mysys} library, the only thing
|
@file{thr_alarm.c} file. If you are using routines from the
|
||||||
you must remember is to call @code{my_init()} first!
|
@code{mysys} library, the only thing you must remember is to call
|
||||||
|
@code{my_init()} first! @xref{C Thread functions}.
|
||||||
|
|
||||||
All functions except @code{mysql_real_connect()} are by default
|
All functions except @code{mysql_real_connect()} are by default
|
||||||
thread safe. The following notes describe how to compile a thread safe
|
thread safe. The following notes describe how to compile a thread safe
|
||||||
@ -41906,11 +41971,38 @@ If you program with POSIX threads, you can use
|
|||||||
establish and release a mutex lock.
|
establish and release a mutex lock.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
You need to know the following if you have a thread that is calling
|
||||||
|
MySQL functions, but that thread has not created the connection to the
|
||||||
|
MySQL database:
|
||||||
|
|
||||||
|
When you call @code{mysql_init()} or @code{mysql_connect()}, MySQL will
|
||||||
|
create a thread specific variable for the thread that is used by the
|
||||||
|
debug library (among other things).
|
||||||
|
|
||||||
|
If you have in a thread call a MySQL function, before a thread has
|
||||||
|
called @code{mysql_init()} or @code{mysql_connect()}, the thread will
|
||||||
|
not have the necessary thread specific variables in place and you are
|
||||||
|
likely to end up with a core dump sooner or later.
|
||||||
|
|
||||||
|
The get things to work smoothly you have to do the following:
|
||||||
|
|
||||||
|
@enumerate
|
||||||
|
@item
|
||||||
|
Call @code{my_init()} at the start of your program if it calls
|
||||||
|
any other MySQL function before calling @code{mysql_real_connect()}.
|
||||||
|
@item
|
||||||
|
Call @code{my_thread_init()} in the thread handler before calling
|
||||||
|
any MySQL function.
|
||||||
|
@item
|
||||||
|
In the thread, call @code{my_thread_end()} before calling
|
||||||
|
@code{pthread_exit()}. This will free the memory used by MySQL thread
|
||||||
|
specific variables.
|
||||||
|
@end enumerate
|
||||||
|
|
||||||
You may get some errors because of undefined symbols when linking your
|
You may get some errors because of undefined symbols when linking your
|
||||||
client with @code{mysqlclient_r}. In most cases this is because you haven't
|
client with @code{mysqlclient_r}. In most cases this is because you haven't
|
||||||
included the thread libraries on the link/compile line.
|
included the thread libraries on the link/compile line.
|
||||||
|
|
||||||
|
|
||||||
@node Cplusplus, Java, C, Clients
|
@node Cplusplus, Java, C, Clients
|
||||||
@section MySQL C++ APIs
|
@section MySQL C++ APIs
|
||||||
|
|
||||||
@ -44221,34 +44313,6 @@ thread that is waiting on the disk-full condition will allow the other
|
|||||||
threads to continue.
|
threads to continue.
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
You need to know the following if you have a thread that is calling
|
|
||||||
MySQL functions, but that thread has not created the connection to the
|
|
||||||
MySQL database:
|
|
||||||
|
|
||||||
When you call @code{mysql_init()} or @code{mysql_connect()}, MySQL will
|
|
||||||
create a thread specific variable for the thread that is used by the
|
|
||||||
debug library (among other things).
|
|
||||||
|
|
||||||
If you have in a thread call a MySQL function, before a thread has
|
|
||||||
called @code{mysql_init()} or @code{mysql_connect()}, the thread will
|
|
||||||
not have the necessary thread specific variables in place and you are
|
|
||||||
likely to end up with a core dump sooner or later.
|
|
||||||
|
|
||||||
The get things to work smoothly you have to do the following:
|
|
||||||
|
|
||||||
@enumerate
|
|
||||||
@item
|
|
||||||
Call @code{my_init()} at the start of your program if it calls
|
|
||||||
any other MySQL function before calling @code{mysql_real_connect()}.
|
|
||||||
@item
|
|
||||||
Call @code{my_thread_init()} in the thread handler before calling
|
|
||||||
any MySQL function.
|
|
||||||
@item
|
|
||||||
In the thread, call @code{my_thread_end()} before calling
|
|
||||||
@code{pthread_exit()}. This will free the memory used by MySQL thread
|
|
||||||
specific variables.
|
|
||||||
@end enumerate
|
|
||||||
|
|
||||||
Exceptions to the above behaveour is when you use @code{REPAIR} or
|
Exceptions to the above behaveour is when you use @code{REPAIR} or
|
||||||
@code{OPTIMIZE} or when the indexes are created in a batch after an
|
@code{OPTIMIZE} or when the indexes are created in a batch after an
|
||||||
@code{LOAD DATA INFILE} or after an @code{ALTER TABLE} statement.
|
@code{LOAD DATA INFILE} or after an @code{ALTER TABLE} statement.
|
||||||
@ -46707,6 +46771,8 @@ not yet 100% confident in this code.
|
|||||||
@appendixsubsec Changes in release 3.23.42
|
@appendixsubsec Changes in release 3.23.42
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
|
Fixed a problem when using @code{LOCK TABLES} and @code{BDB} tables.
|
||||||
|
@item
|
||||||
Fixed problem with @code{REPAIR TABLE} on MyISAM tables with row lengths
|
Fixed problem with @code{REPAIR TABLE} on MyISAM tables with row lengths
|
||||||
between 65517 - 65520 bytes
|
between 65517 - 65520 bytes
|
||||||
@item
|
@item
|
||||||
|
@ -39,13 +39,21 @@ $opt_loop_count=10000; # Change this to make test harder/easier
|
|||||||
chomp($pwd = `pwd`); $pwd = "." if ($pwd eq '');
|
chomp($pwd = `pwd`); $pwd = "." if ($pwd eq '');
|
||||||
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
|
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
|
||||||
|
|
||||||
|
$create_loop_count=$opt_loop_count;
|
||||||
if ($opt_small_test)
|
if ($opt_small_test)
|
||||||
{
|
{
|
||||||
$opt_loop_count/=100;
|
$opt_loop_count/=100;
|
||||||
|
$create_loop_count/=1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
$max_tables=min($limits->{'max_tables'},$opt_loop_count);
|
$max_tables=min($limits->{'max_tables'},$opt_loop_count);
|
||||||
|
|
||||||
|
if ($opt_small_test)
|
||||||
|
{
|
||||||
|
$max_tables=10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print "Testing the speed of creating and droping tables\n";
|
print "Testing the speed of creating and droping tables\n";
|
||||||
print "Testing with $max_tables tables and $opt_loop_count loop count\n\n";
|
print "Testing with $max_tables tables and $opt_loop_count loop count\n\n";
|
||||||
|
|
||||||
@ -177,7 +185,7 @@ print "Testing create+drop\n";
|
|||||||
|
|
||||||
$loop_time=new Benchmark;
|
$loop_time=new Benchmark;
|
||||||
|
|
||||||
for ($i=1 ; $i <= $opt_loop_count ; $i++)
|
for ($i=1 ; $i <= $create_loop_count ; $i++)
|
||||||
{
|
{
|
||||||
do_many($dbh,$server->create("bench_$i",
|
do_many($dbh,$server->create("bench_$i",
|
||||||
["i int NOT NULL",
|
["i int NOT NULL",
|
||||||
@ -190,7 +198,7 @@ for ($i=1 ; $i <= $opt_loop_count ; $i++)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$end_time=new Benchmark;
|
$end_time=new Benchmark;
|
||||||
print "Time for create+drop ($opt_loop_count): " .
|
print "Time for create+drop ($create_loop_count): " .
|
||||||
timestr(timediff($end_time, $loop_time),"all") . "\n";
|
timestr(timediff($end_time, $loop_time),"all") . "\n";
|
||||||
|
|
||||||
if ($opt_fast && defined($server->{vacuum}))
|
if ($opt_fast && defined($server->{vacuum}))
|
||||||
|
@ -413,7 +413,10 @@ void close_thread_tables(THD *thd, bool locked)
|
|||||||
DBUG_ENTER("close_thread_tables");
|
DBUG_ENTER("close_thread_tables");
|
||||||
|
|
||||||
if (thd->locked_tables)
|
if (thd->locked_tables)
|
||||||
|
{
|
||||||
|
ha_commit_stmt(thd); // If select statement
|
||||||
DBUG_VOID_RETURN; // LOCK TABLES in use
|
DBUG_VOID_RETURN; // LOCK TABLES in use
|
||||||
|
}
|
||||||
|
|
||||||
TABLE *table,*next;
|
TABLE *table,*next;
|
||||||
bool found_old_table=0;
|
bool found_old_table=0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user