<< 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

    Chapter 8:  MySQL APIs 605    Two threads can't send a query to the MySQL server at the same time on the same connection.   In  particular,  you  have  to  ensure  that  between  a  mysql_query()  and mysql_store_result() no other thread is using the same connection.    Many  threads  can  access  di erent  result  sets  that  are  retrieved  with  mysql_store_ result().    If you use  mysql_use_result,  you have to ensure that no other thread is using the same connection until the result set is closed.  However, it really is best for threaded clients that share the same connection to use mysql_store_result().    If you want to use multiple threads on the same connection, you must have a mutex lock around your mysql_query() and mysql_store_result() call combination.  Once mysql_store_result() is ready, the lock can be released and other threads may query the same connection.    If  you  program  with  POSIX  threads,   you  can  use   pthread_mutex_lock()   and pthread_mutex_unlock() to establish and release a mutex lock. You need to know the following if you have a thread that is calling MySQL functions which did not create the connection to the MySQL database: When you call  mysql_init()  or  mysql_connect(),  MySQL will create a thread speci c variable for the thread that is used by the debug library (among other things). If  you  call  a  MySQL  function,  before  the  thread  has  called  mysql_init()  or  mysql_ connect(),  the thread will not have the necessary thread speci c 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: 1.   Call  my_init()  at  the  start  of  your  program  if  it  calls  any  other  MySQL  function before calling mysql_real_connect(). 2.   Call mysql_thread_init() in the thread handler before calling any MySQL function. 3.   In the thread, call mysql_thread_end() before calling pthread_exit().  This will free the memory used by MySQL thread speci c variables. You  may  get  some  errors  because  of  unde ned  symbols  when  linking  your  client  with libmysqlclient_r.  In most cases this is because you haven't included the thread libraries on the link/compile line. 8.4.9  libmysqld, the Embedded MySQL Server Library 8.4.9.1  Overview of the Embedded MySQL Server Library The embedded MySQL server library makes it possible to run a full-featured MySQL server inside the client application.  The main bene ts are increased speed and more simple man- agement for embedded applications. The API is identical for the embedded MySQL version and the client/server version.  To change an old threaded application to use the embedded library, you normally only have to add calls to the following functions:
     

    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