Index: mysqlse/ha_sphinx.cc =================================================================== --- mysqlse/ha_sphinx.cc (revision 2668) +++ mysqlse/ha_sphinx.cc (working copy) @@ -24,7 +24,16 @@ #include -#if MYSQL_VERSION_ID>50100 +#if MYSQL_VERSION_ID>=50508 +#include "sql_priv.h" +#include "probes_mysql.h" +#include "sql_class.h" // SSV +#include "sql_plugin.h" +#include "sql_array.h" +#ifndef VOID +#define VOID void +#endif +#elif MYSQL_VERSION_ID>50100 #include "mysql_priv.h" #include #else @@ -135,7 +144,7 @@ #define SPHINXSE_MAX_ALLOC (16*1024*1024) #define SPHINXSE_MAX_KEYWORDSTATS 4096 -#define SPHINXSE_VERSION "0.9.9 ($Revision: 2653 $)" +#define SPHINXSE_VERSION "1.11-dev ($Revision: 2653 $) / patched by www.coreseek.cn" // FIXME? the following is cut-n-paste from sphinx.h and searchd.cpp // cut-n-paste is somewhat simpler that adding dependencies however.. @@ -144,7 +153,7 @@ { SPHINX_SEARCHD_PROTO = 1, SEARCHD_COMMAND_SEARCH = 0, - VER_COMMAND_SEARCH = 0x116, + VER_COMMAND_SEARCH = 0x117, }; /// search query sorting orders @@ -184,7 +193,7 @@ SPH_RANK_PROXIMITY = 4, ///< phrase proximity SPH_RANK_MATCHANY = 5, ///< emulate old match-any weighting SPH_RANK_FIELDMASK = 6, ///< sets bits where there were matches - SPH_RANK_SPH04 = 7, ///< codename SPH04, phrase proximity + bm25 + head/exact boost + SPH_RANK_SPH04 = 7, ///< sets bits where there were matches SPH_RANK_TOTAL, SPH_RANK_DEFAULT = SPH_RANK_PROXIMITY_BM25 @@ -210,7 +219,7 @@ SPH_ATTR_BOOL = 4, ///< this attr is a boolean bit field SPH_ATTR_FLOAT = 5, SPH_ATTR_BIGINT = 6, - + SPH_ATTR_STRING = 7, SPH_ATTR_MULTI = 0x40000000UL ///< this attr has multiple values (0 or more) }; @@ -674,9 +683,13 @@ { sphinx_init = 1; VOID ( pthread_mutex_init ( &sphinx_mutex, MY_MUTEX_INIT_FAST ) ); +#if MYSQL_VERSION_ID>=50508 + my_hash_init ( &sphinx_open_tables, system_charset_info, 32, 0, 0, + sphinx_get_key, 0, 0 ); +#else hash_init ( &sphinx_open_tables, system_charset_info, 32, 0, 0, sphinx_get_key, 0, 0 ); - +#endif #if MYSQL_VERSION_ID > 50100 handlerton * hton = (handlerton*) p; hton->state = SHOW_OPTION_YES; @@ -724,7 +737,11 @@ sphinx_init = 0; if ( sphinx_open_tables.records ) error = 1; - hash_free ( &sphinx_open_tables ); +#if MYSQL_VERSION_ID>=50508 + my_hash_free ( &sphinx_open_tables ); +#else + hash_free ( &sphinx_open_tables ); +#endif pthread_mutex_destroy ( &sphinx_mutex ); } @@ -1128,7 +1145,9 @@ for ( ;; ) { // check if we already have this share -#if MYSQL_VERSION_ID>=50120 +#if MYSQL_VERSION_ID>=50508 + pShare = (CSphSEShare*) my_hash_search ( &sphinx_open_tables, (const uchar *) table_name, strlen(table_name) ); +#elif MYSQL_VERSION_ID>=50120 pShare = (CSphSEShare*) hash_search ( &sphinx_open_tables, (const uchar *) table_name, strlen(table_name) ); #else #ifdef __WIN__ @@ -1162,7 +1181,7 @@ // try to hash it pShare->m_iTableNameLen = strlen(table_name); pShare->m_sTable = sphDup ( table_name ); - if ( my_hash_insert ( &sphinx_open_tables, (const byte *)pShare ) ) + if ( my_hash_insert ( &sphinx_open_tables, (const byte *)pShare ) ) { SafeDelete ( pShare ); break; @@ -1186,7 +1205,11 @@ if ( !--pShare->m_iUseCount ) { - hash_delete ( &sphinx_open_tables, (byte *)pShare ); +#if MYSQL_VERSION_ID>=50508 + my_hash_delete ( &sphinx_open_tables, (byte *)pShare ); +#else + hash_delete ( &sphinx_open_tables, (byte *)pShare ); +#endif SafeDelete ( pShare ); } @@ -1971,7 +1994,10 @@ static const char * ha_sphinx_exts[] = { NullS }; -#if MYSQL_VERSION_ID<50100 +#if MYSQL_VERSION_ID>=50508 +ha_sphinx::ha_sphinx ( handlerton * hton, TABLE_SHARE * table ) + : handler ( hton, table ) +#elif MYSQL_VERSION_ID<50100 ha_sphinx::ha_sphinx ( TABLE_ARG * table ) : handler ( &sphinx_hton, table ) #else @@ -2296,7 +2322,7 @@ static inline bool IsIDField ( Field * pField ) { - enum_field_types eType = pField->type(); + enum_field_types eType = pField->type(); if ( eType==MYSQL_TYPE_LONGLONG ) return true; @@ -2378,7 +2404,7 @@ uint32 ha_sphinx::UnpackDword () { - if ( m_pCur+sizeof(uint32)>m_pResponseEnd ) // NOLINT + if ( m_pCur+sizeof(uint32)>m_pResponseEnd ) { m_pCur = m_pResponseEnd; m_bUnpackError = true; @@ -2386,7 +2412,7 @@ } uint32 uRes = ntohl ( sphUnalignedRead ( *(uint32*)m_pCur ) ); - m_pCur += sizeof(uint32); // NOLINT + m_pCur += sizeof(uint32); return uRes; } @@ -2548,17 +2574,22 @@ assert ( pStats ); char * pCurSave = m_pCur; - for ( uint i=0; istore ( (const char*)sMessage, iLen, &my_charset_bin ); + break; + default: my_error ( ER_QUERY_ON_FOREIGN_DATA_SOURCE, MYF(0), "INTERNAL ERROR: unhandled attr type" ); SafeDeleteArray ( m_pResponse ); @@ -3504,3 +3552,4 @@ // // $Id$ // + Index: mysqlse/ha_sphinx.h =================================================================== --- mysqlse/ha_sphinx.h (revision 2668) +++ mysqlse/ha_sphinx.h (working copy) @@ -6,8 +6,9 @@ #pragma interface // gcc class implementation #endif - -#if MYSQL_VERSION_ID>50100 +#if MYSQL_VERSION_ID>=50508 +#define TABLE_ARG TABLE_SHARE +#elif MYSQL_VERSION_ID>50100 #define TABLE_ARG st_table_share #else #define TABLE_ARG st_table @@ -46,7 +47,9 @@ bool m_bUnpackError; ///< any errors while unpacking response public: -#if MYSQL_VERSION_ID<50100 +#if MYSQL_VERSION_ID>=50508 + ha_sphinx ( handlerton * hton, TABLE_SHARE * table_arg ); +#elif MYSQL_VERSION_ID<50100 ha_sphinx ( TABLE_ARG * table_arg ); #else ha_sphinx ( handlerton * hton, TABLE_ARG * table_arg ); @@ -165,3 +168,4 @@ // // $Id$ // + Index: mysqlse/CMakeLists.txt =================================================================== --- mysqlse/CMakeLists.txt (revision 2668) +++ mysqlse/CMakeLists.txt (working copy) @@ -8,4 +8,10 @@ ${CMAKE_SOURCE_DIR}/regex) SET(SPHINX_SOURCES ha_sphinx.cc) +IF(MYSQL_VERSION_ID LESS 50508) ADD_LIBRARY(sphinx ha_sphinx.cc) +ELSE() +SET(SPHINX_PLUGIN_DYNAMIC "ha_sphinx") +MYSQL_ADD_PLUGIN(sphinx ${SPHINX_SOURCES} STORAGE_ENGINE MODULE_ONLY LINK_LIBRARIES mysys) +ENDIF() +