mysql Module

Jan Janak

   <jan@iptel.org>

Edited by

Daniel-Constantin Mierla

   <miconda@gmail.com>

   Copyright © 2006 Voice Sistem SRL
   Revision History
   Revision $Revision: 5901 $ $Date$
     __________________________________________________________

   Table of Contents

   1. Admin Guide

        1.1. Overview
        1.2. Dependencies

              1.2.1. OpenSIPS Modules
              1.2.2. External Libraries or Applications

        1.3. Exported Parameters

              1.3.1. exec_query_threshold (integer)
              1.3.2. timeout_interval (integer)
              1.3.3. max_db_queries (integer)
              1.3.4. max_db_retries (integer)

        1.4. Exported Functions
        1.5. Installation
        1.6. Exported Events

              1.6.1. E_MYSQL_CONNECTION

   List of Examples

   1.1. Set exec_query_threshold parameter
   1.2. Set timeout_interval parameter
   1.3. Set max_db_queries parameter
   1.4. Set max_db_retries parameter

Chapter 1. Admin Guide

1.1. Overview

   This is a module which provides MySQL connectivity for
   OpenSIPS. It implements the DB API defined in OpenSIPS.

1.2. Dependencies

1.2.1. OpenSIPS Modules

   The following modules must be loaded before this module:
     * No dependencies on other OpenSIPS modules.

1.2.2. External Libraries or Applications

   The following libraries or applications must be installed
   before running OpenSIPS with this module loaded:
     * libmysqlclient-dev - the development libraries of
       mysql-client.

1.3. Exported Parameters

1.3.1. exec_query_threshold (integer)

   If queries take longer than 'exec_query_threshold'
   microseconds, warning messages will be written to logging
   facility.

   Default value is 0 - disabled.

   Example 1.1. Set exec_query_threshold parameter
...
modparam("db_mysql", "exec_query_threshold", 60000)
...

1.3.2. timeout_interval (integer)

   Time interval after which a connection attempt (read or write
   request) is aborted. The value counts three times, as several
   retries are done from the driver before it gives up.

   The read timeout parameter is ignored on driver versions prior
   to “5.1.12”, “5.0.25” and “4.1.22”. The write timeout parameter
   is ignored on version prior to “5.1.12” and “5.0.25”, the “4.1”
   release don't support it at all.

   Default value is 2 (6 sec).

   Example 1.2. Set timeout_interval parameter
...
modparam("db_mysql", "timeout_interval", 2)
...

1.3.3. max_db_queries (integer)

   The maximum number of database queries to be executed. If this
   parameter is set improperly, it is set to default value.

   Default value is 2.

   Example 1.3. Set max_db_queries parameter
...
modparam("db_mysql", "max_db_queries", 2)
...

1.3.4. max_db_retries (integer)

   The maximum number of database connection retries. If this
   parameter is set improperly, it is set to default value.

   Default value is 3.

   Example 1.4. Set max_db_retries parameter
...
modparam("db_mysql", "max_db_retries", 2)
...

1.4. Exported Functions

   No function exported to be used from configuration file.

1.5. Installation

   Because it dependes on an external library, the mysql module is
   not compiled and installed by default. You can use one of the
   next options.
     * - edit the "Makefile" and remove "db_mysql" from
       "excluded_modules" list. Then follow the standard procedure
       to install OpenSIPS: "make all; make install".
     * - from command line use: 'make all
       include_modules="db_mysql"; make install
       include_modules="db_mysql"'.

1.6. Exported Events

1.6.1.  E_MYSQL_CONNECTION

   This event is raised when a MySQL connection is lost or
   recovered.

   Parameters:
     * url - the URL of the connection as specified by the db_url
       parameter.
     * status - connected if the connection recovered, or
       disconnected if the connection was lost.
