Drizzled Public API Documentation

defs_ms.h

00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh (H&G2JCtL)
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-07-04
00023  *
00024  * Global definitions.
00025  *
00026  */
00027 
00028 #pragma once
00029 #ifndef __DEFS_MS_H__
00030 #define __DEFS_MS_H__
00031 
00032 #include "cslib/CSDefs.h"
00033 
00034 #define MS_IDENTIFIER_CHAR_COUNT  64
00035 
00036 #define MS_IDENTIFIER_NAME_SIZE   ((MS_IDENTIFIER_CHAR_COUNT * 3) + 1)  // The identifier length as UTF-8
00037 
00038 #define MS_TABLE_NAME_SIZE      MS_IDENTIFIER_NAME_SIZE         // The maximum length of a table name 
00039 #define MS_DATABASE_NAME_SIZE   MS_IDENTIFIER_NAME_SIZE
00040 
00041 #define MS_TABLE_URL_SIZE     (MS_DATABASE_NAME_SIZE + MS_TABLE_NAME_SIZE)
00042 
00043 #define MS_CONNECTION_THREAD    1000
00044 #define MS_TEMP_LOG_THREAD      1001
00045 #define MS_COMPACTOR_THREAD     1002
00046 
00047 #ifdef DEBUG
00048 #define MS_DEFAULT_TEMP_LOG_WAIT  (200*60)
00049 
00050 // Set MS_DEFAULT_TEMP_LOG_WAIT high to prevent 
00051 // BLOBs from being deleted while walking through 
00052 // the code in the debugger.
00053 //#define MS_DEFAULT_TEMP_LOG_WAIT  (200*60) 
00054 #else
00055 #define MS_DEFAULT_TEMP_LOG_WAIT  (10*60)
00056 #endif
00057 
00058 /* Default compactor wait time in seconds! */
00059 #define MS_COMPACTOR_POLLS
00060 #ifdef MS_COMPACTOR_POLLS
00061 #ifdef DEBUG
00062 #define MS_COMPACTOR_POLL_FREQ    1000    // milli-seconds
00063 #else
00064 #define MS_COMPACTOR_POLL_FREQ    3000
00065 #endif
00066 #else
00067 #ifdef DEBUG
00068 #define MS_DEFAULT_COMPACTOR_WAIT 120
00069 #else
00070 #define MS_DEFAULT_COMPACTOR_WAIT 30
00071 #endif
00072 #endif
00073 
00074 #ifdef DEBUG
00075 //#define MS_DEFAULT_GARBAGE_LEVEL  1
00076 #define MS_DEFAULT_GARBAGE_LEVEL  10
00077 #else
00078 #define MS_DEFAULT_GARBAGE_LEVEL  50
00079 #endif
00080 
00081 #ifdef DEBUG
00082 #define MS_REPO_THRESHOLD_DEF   "20MB"
00083 //#define MS_REPO_THRESHOLD_DEF   "32K"
00084 #else
00085 #define MS_REPO_THRESHOLD_DEF   "128MB"
00086 #endif
00087 
00088 #ifdef DEBUG
00089 #define MS_TEMP_LOG_THRESHOLD_DEF "32K"
00090 #else
00091 #define MS_TEMP_LOG_THRESHOLD_DEF "32MB"
00092 #endif
00093 
00094 #define MS_HTTP_METADATA_HEADERS_DEF "Content-Type"
00095 
00096 #ifdef DEBUG
00097 #define MS_COMPACTOR_BUFFER_SIZE  (4*1024)
00098 #else
00099 #define MS_COMPACTOR_BUFFER_SIZE  (64*1024)
00100 #endif
00101 
00102 #define MS_BACKUP_BUFFER_SIZE MS_COMPACTOR_BUFFER_SIZE
00103 
00104 /*
00105  * The time (in seconds) that a connection thread will stay alive, when it is idle:
00106  */
00107 #ifdef DEBUG
00108 #define MS_IDLE_THREAD_TIMEOUT    (10)
00109 #else
00110 #define MS_IDLE_THREAD_TIMEOUT    (40)
00111 #endif
00112 
00113 /*
00114  * The timeout, in milli-seconds, before the HTTP server will close an inactive HTTP connection.
00115 */
00116 #define MS_DEFAULT_KEEP_ALIVE   (10) 
00117 
00118 #ifdef DRIZZLED
00119 #include <boost/dynamic_bitset.hpp>
00120 /* Drizzle is stuck at this level: */
00121 #define MYSQL_VERSION_ID          60005
00122 
00123 #define TABLE_LIST              TableList
00124 #define TABLE               drizzled::Table
00125 #define Field               drizzled::Field
00126 //#define enum_field_types          drizzled::enum_field_types
00127 
00128 #define my_charset_bin            drizzled::my_charset_bin
00129 #define THR_LOCK              drizzled::THR_LOCK
00130 
00131 #define TABLE_SHARE             TableShare
00132 #define THD                 drizzled::Session
00133 #define MYSQL_THD             Session *
00134 #define THR_THD               THR_Session
00135 #define STRUCT_TABLE            class Table
00136 #define MY_BITMAP             boost::dynamic_bitset<>
00137 
00138 #define MYSQL_TYPE_TIMESTAMP        DRIZZLE_TYPE_TIMESTAMP
00139 #define MYSQL_TYPE_LONG           DRIZZLE_TYPE_LONG
00140 #define MYSQL_TYPE_SHORT          DRIZZLE_TYPE_LONG
00141 #define MYSQL_TYPE_STRING         DRIZZLE_TYPE_VARCHAR
00142 #define MYSQL_TYPE_VARCHAR          DRIZZLE_TYPE_VARCHAR
00143 #define MYSQL_TYPE_LONGLONG         DRIZZLE_TYPE_LONGLONG
00144 #define MYSQL_TYPE_BLOB           DRIZZLE_TYPE_BLOB
00145 #define MYSQL_TYPE_LONG_BLOB        DRIZZLE_TYPE_BLOB
00146 #define MYSQL_TYPE_ENUM           DRIZZLE_TYPE_ENUM
00147 #define MYSQL_PLUGIN_VAR_HEADER       DRIZZLE_PLUGIN_VAR_HEADER
00148 #define MYSQL_STORAGE_ENGINE_PLUGIN     DRIZZLE_STORAGE_ENGINE_PLUGIN
00149 #define MYSQL_INFORMATION_SCHEMA_PLUGIN   DRIZZLE_INFORMATION_SCHEMA_PLUGIN
00150 #define memcpy_fixed            memcpy
00151 #define bfill(m, len, ch)         memset(m, ch, len)
00152 
00153 #define mx_tmp_use_all_columns(x, y)    (x)->use_all_columns(y)
00154 #define mx_tmp_restore_column_map(x, y)   (x)->restore_column_map(y)
00155 
00156 #define MX_TABLE_TYPES_T          handler::Table_flags
00157 #define MX_UINT8_T              uint8_t
00158 #define MX_ULONG_T              uint32_t
00159 #define MX_ULONGLONG_T            uint64_t
00160 #define MX_LONGLONG_T           uint64_t
00161 #define MX_CHARSET_INFO           struct charset_info_st
00162 #define MX_CONST_CHARSET_INFO       const struct charset_info_st      
00163 #define MX_CONST              const
00164 #define my_bool               bool
00165 #define int16               int16_t
00166 #define int32               int32_t
00167 #define uint16                uint16_t
00168 #define uint32                uint32_t
00169 #define uchar               unsigned char
00170 #define longlong              int64_t
00171 #define ulonglong             uint64_t
00172 
00173 #define HAVE_LONG_LONG
00174 
00175 #define my_malloc(x, y)           malloc(x)
00176 #define my_free(x, y)           free(x)
00177 
00178 #define HA_CAN_SQL_HANDLER          0
00179 #define HA_CAN_INSERT_DELAYED       0
00180 #define HA_BINLOG_ROW_CAPABLE       0
00181 
00182 #define max                 cmax
00183 #define min                 cmin
00184 
00185 #define NullS               NULL
00186 
00187 #define current_thd             current_session
00188 #define thd_charset             session_charset
00189 #define thd_query             session_query
00190 #define thd_slave_thread          session_slave_thread
00191 #define thd_non_transactional_update    session_non_transactional_update
00192 #define thd_binlog_format         session_binlog_format
00193 #define thd_mark_transaction_to_rollback  session_mark_transaction_to_rollback
00194 #define current_thd             current_session
00195 #define thd_sql_command(x)            ((x)->getSqlCommand())
00196 #define thd_test_options          session_test_options
00197 #define thd_killed              session_killed
00198 #define thd_tx_isolation(x)         ((x)->getTxIsolation())
00199 #define thd_in_lock_tables          session_in_lock_tables
00200 #define thd_tablespace_op(x)          ((x)->doingTablespaceOperation())
00201 #define thd_alloc             session_alloc
00202 #define thd_make_lex_string         session_make_lex_string
00203 
00204 #define my_pthread_setspecific_ptr(T, V)  pthread_setspecific(T, (void*) (V))
00205 
00206 #define mysql_real_data_home        drizzle_real_data_home
00207 
00208 #define mi_int4store(T,A)   { uint32_t def_temp= (uint32_t) (A);\
00209                               ((unsigned char*) (T))[3]= (unsigned char) (def_temp);\
00210                               ((unsigned char*) (T))[2]= (unsigned char) (def_temp >> 8);\
00211                               ((unsigned char*) (T))[1]= (unsigned char) (def_temp >> 16);\
00212                               ((unsigned char*) (T))[0]= (unsigned char) (def_temp >> 24); }
00213 
00214 #define mi_uint4korr(A) ((uint32_t) (((uint32_t) (((const unsigned char*) (A))[3])) +\
00215                                    (((uint32_t) (((const unsigned char*) (A))[2])) << 8) +\
00216                                    (((uint32_t) (((const unsigned char*) (A))[1])) << 16) +\
00217                                    (((uint32_t) (((const unsigned char*) (A))[0])) << 24)))
00218                    
00219 #define mi_int8store(T,A)   { uint64_t def_temp= (uint64_t) (A);\
00220                               ((unsigned char*) (T))[7]= (unsigned char) (def_temp);\
00221                               ((unsigned char*) (T))[6]= (unsigned char) (def_temp >> 8);\
00222                               ((unsigned char*) (T))[5]= (unsigned char) (def_temp >> 16);\
00223                               ((unsigned char*) (T))[4]= (unsigned char) (def_temp >> 24);\
00224                               ((unsigned char*) (T))[3]= (unsigned char) (def_temp >> 32);\
00225                               ((unsigned char*) (T))[2]= (unsigned char) (def_temp >> 40);\
00226                               ((unsigned char*) (T))[1]= (unsigned char) (def_temp >> 48);\
00227                               ((unsigned char*) (T))[0]= (unsigned char) (def_temp >> 56); }
00228 
00229 #define mi_uint8korr(A) ((uint64_t) (((uint64_t) (((const unsigned char*) (A))[7])) +\
00230                                    (((uint64_t) (((const unsigned char*) (A))[6])) << 8) +\
00231                                    (((uint64_t) (((const unsigned char*) (A))[5])) << 16) +\
00232                                    (((uint64_t) (((const unsigned char*) (A))[4])) << 24) +\
00233                                    (((uint64_t) (((const unsigned char*) (A))[3])) << 32) +\
00234                                    (((uint64_t) (((const unsigned char*) (A))[2])) << 40) +\
00235                                    (((uint64_t) (((const unsigned char*) (A))[1])) << 48) +\
00236                                    (((uint64_t) (((const unsigned char*) (A))[0])) << 56)))
00237                    
00238 #else // DRIZZLED
00239 /* The MySQL case: */
00240 #define STRUCT_TABLE            struct st_table
00241 
00242 #define mx_tmp_use_all_columns        dbug_tmp_use_all_columns
00243 #define mx_tmp_restore_column_map(x, y)   dbug_tmp_restore_column_map((x)->read_set, y)
00244 
00245 #define MX_TABLE_TYPES_T          ulonglong
00246 #define MX_UINT8_T              uint8
00247 #define MX_ULONG_T              ulong
00248 #define MX_ULONGLONG_T            ulonglong
00249 #define MX_LONGLONG_T           longlong
00250 #define MX_CHARSET_INFO           CHARSET_INFO
00251 #define MX_CONST_CHARSET_INFO       struct charset_info_st      
00252 #define MX_CONST              
00253 
00254 #endif // DRIZZLED
00255 
00256 #endif