<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    604 MySQL Technical Reference for Version 4.0.3 8.4.7  Building Client Programs If you compile MySQL clients that you've written yourself or that you obtain from a third- party, they must be linked using the -lmysqlclient -lz option on the link command.  You may also need to specify a -L option to tell the linker where to nd the library.  For exam- ple,  if the library is installed in `/usr/local/mysql/lib',  use  -L/usr/local/mysql/lib -lmysqlclient -lz on the link command. For clients that use MySQL header les,  you may need to specify a  -I  option when you compile them (for example,  -I/usr/local/mysql/include), so the compiler can nd the header les. 8.4.8  How to Make a Threaded Client The  client  library  is  almost  thread-safe.   The  biggest  problem  is  that  the  subroutines  in `net.c' that read from sockets are not interrupt safe.  This was done with the thought that you might want to have your own alarm that can break a long read to a server.  If you install interrupt handlers for the SIGPIPE interrupt, the socket handling should be thread-safe. In the older binaries we distribute on our web site (http://www.mysql.com/), the client libraries are not normally compiled with the thread-safe option (the Windows binaries are by  default  compiled  to  be  thread-safe).   Newer  binary  distributions  should  have  both  a normal and a thread-safe client library. To  get  a  threaded  client  where  you  can  interrupt  the  client  from  other  threads  and  set timeouts when talking with the MySQL server, you should use the -lmysys, -lmystrings, and -ldbug libraries and the net_serv.o code that the server uses. If you don't need interrupts or timeouts, you can just compile a thread-safe client library (mysqlclient_r)  and use this.  See  Section 8.4 [MySQL C API], page 555.  In this case you don't have to worry about the net_serv.o object le or the other MySQL libraries. When using a threaded client and you want to use timeouts and interrupts, you can make great use of the routines in the `thr_alarm.c' le.  If you are using routines from the mysys library, the only thing you must remember is to call my_init()  rst!  See Section 8.4.4 [C Thread functions], page 599. All functions except mysql_real_connect() are by default thread-safe. The following notes describe  how  to  compile  a  thread-safe  client  library  and  use  it  in  a  thread-safe  manner. (The notes below for mysql_real_connect() actually apply to mysql_connect() as well, but because mysql_connect() is deprecated, you should be using mysql_real_connect() anyway.) To make  mysql_real_connect()  thread-safe,  you must recompile the client library with this command: shell> ./configure --enable-thread-safe-client This will create a thread-safe client library libmysqlclient_r.  (Assuming your OS has a thread-safe gethostbyname_r() function.)  This library is thread-safe per connection.  You can let two threads share the same connection with the following caveats:
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    MERCHANT ACCOUNTS
    DEDICATED SERVERS
    E-COMMERCE HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN
    REGISTRATION
    MANAGE
    YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    Corporate Info
    ABOUT US
    OUR NETWORK
    CONTACT US
    SITE MAP
    Copyright © 2002 Dyntex Group, Inc. All Rights Reserved
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide