Initial import of SpinxSE, with fixes for MariaDB.
This commit is contained in:
parent
2be1a25faa
commit
6197332366
11
storage/sphinx/CMakeLists.txt
Normal file
11
storage/sphinx/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
||||
ADD_DEFINITIONS(-DMYSQL_SERVER)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/sql
|
||||
${CMAKE_SOURCE_DIR}/extra/yassl/include
|
||||
${CMAKE_SOURCE_DIR}/regex)
|
||||
|
||||
SET(SPHINX_SOURCES ha_sphinx.cc)
|
||||
ADD_LIBRARY(sphinx ha_sphinx.cc)
|
55
storage/sphinx/Makefile.am
Normal file
55
storage/sphinx/Makefile.am
Normal file
@ -0,0 +1,55 @@
|
||||
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
#called from the top level Makefile
|
||||
|
||||
MYSQLDATAdir = $(localstatedir)
|
||||
MYSQLSHAREdir = $(pkgdatadir)
|
||||
MYSQLBASEdir= $(prefix)
|
||||
MYSQLLIBdir= $(pkglibdir)
|
||||
pkgplugindir = $(pkglibdir)/plugin
|
||||
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/regex \
|
||||
-I$(top_srcdir)/sql \
|
||||
-I$(srcdir)
|
||||
|
||||
DEFS= @DEFS@ -D_REENTRANT -D_PTHREADS -DMYSQL_SERVER
|
||||
|
||||
noinst_HEADERS = ha_sphinx.h
|
||||
|
||||
EXTRA_LTLIBRARIES = ha_sphinx.la
|
||||
pkgplugin_LTLIBRARIES = @plugin_sphinx_shared_target@ sphinx.la
|
||||
|
||||
ha_sphinx_la_LDFLAGS = -module -rpath $(MYSQLLIBdir) \
|
||||
-L$(top_builddir)/libservices -lmysqlservices
|
||||
ha_sphinx_la_CXXFLAGS= $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
|
||||
ha_sphinx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
|
||||
ha_sphinx_la_SOURCES = ha_sphinx.cc
|
||||
|
||||
sphinx_la_LDFLAGS = -module
|
||||
sphinx_la_CXXFLAGS = $(AM_CFLAGS)
|
||||
sphinx_la_CFLAGS = $(AM_CFLAGS)
|
||||
sphinx_la_SOURCES = snippets_udf.cc
|
||||
|
||||
EXTRA_LIBRARIES = libsphinx.a
|
||||
noinst_LIBRARIES = @plugin_sphinx_static_target@
|
||||
libsphinx_a_CXXFLAGS = $(AM_CFLAGS)
|
||||
libsphinx_a_CFLAGS = $(AM_CFLAGS)
|
||||
libsphinx_a_SOURCES= ha_sphinx.cc
|
||||
|
||||
EXTRA_DIST = CMakeLists.txt
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
37
storage/sphinx/gen_data.php
Normal file
37
storage/sphinx/gen_data.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
$file_name= $argv[1];
|
||||
|
||||
//echo $file_name;
|
||||
|
||||
$cont= file_get_contents($file_name);
|
||||
|
||||
$words= explode(" ", $cont);
|
||||
|
||||
//echo "words: ".(count($words))."\n";
|
||||
|
||||
$cw = count($words);
|
||||
|
||||
echo "REPLACE INTO test.documents ( id, group_id, date_added, title, content ) VALUES\n";
|
||||
|
||||
|
||||
for ($i=1; $i<=100000; $i++)
|
||||
{
|
||||
$count_words= mt_rand(10,30);
|
||||
$pred = "";
|
||||
for ($j=0; $j<$count_words; $j++)
|
||||
{
|
||||
$pred .= chop($words[mt_rand(1, $cw-1)])." ";
|
||||
}
|
||||
$count_words= mt_rand(3,5);
|
||||
$tit = "";
|
||||
for ($j=0; $j<$count_words; $j++)
|
||||
{
|
||||
$tit .= chop($words[mt_rand(1, $cw-1)])." ";
|
||||
}
|
||||
echo "($i,".mt_rand(1,20).",NOW(),'".addslashes($tit)."','".addslashes($pred)."'),\n";
|
||||
}
|
||||
echo "(0,1,now(),'end','eND');\n";
|
||||
|
||||
|
||||
?>
|
3115
storage/sphinx/ha_sphinx.cc
Normal file
3115
storage/sphinx/ha_sphinx.cc
Normal file
File diff suppressed because it is too large
Load Diff
158
storage/sphinx/ha_sphinx.h
Normal file
158
storage/sphinx/ha_sphinx.h
Normal file
@ -0,0 +1,158 @@
|
||||
//
|
||||
// $Id: ha_sphinx.h 1428 2008-09-05 18:06:30Z xale $
|
||||
//
|
||||
|
||||
#ifdef USE_PRAGMA_INTERFACE
|
||||
#pragma interface // gcc class implementation
|
||||
#endif
|
||||
|
||||
|
||||
#if MYSQL_VERSION_ID>50100
|
||||
#define TABLE_ARG st_table_share
|
||||
#else
|
||||
#define TABLE_ARG st_table
|
||||
#endif
|
||||
|
||||
|
||||
#if MYSQL_VERSION_ID>=50120
|
||||
typedef uchar byte;
|
||||
#endif
|
||||
|
||||
|
||||
/// forward decls
|
||||
class THD;
|
||||
struct CSphReqQuery;
|
||||
struct CSphSEShare;
|
||||
struct CSphSEAttr;
|
||||
struct CSphSEStats;
|
||||
struct CSphSEThreadData;
|
||||
|
||||
/// Sphinx SE handler class
|
||||
class ha_sphinx : public handler
|
||||
{
|
||||
protected:
|
||||
THR_LOCK_DATA m_tLock; ///< MySQL lock
|
||||
|
||||
CSphSEShare * m_pShare; ///< shared lock info
|
||||
|
||||
uint m_iMatchesTotal;
|
||||
uint m_iCurrentPos;
|
||||
const byte * m_pCurrentKey;
|
||||
uint m_iCurrentKeyLen;
|
||||
|
||||
char * m_pResponse; ///< searchd response storage
|
||||
char * m_pResponseEnd; ///< searchd response storage end (points to wilderness!)
|
||||
char * m_pCur; ///< current position into response
|
||||
bool m_bUnpackError; ///< any errors while unpacking response
|
||||
|
||||
public:
|
||||
#if MYSQL_VERSION_ID<50100
|
||||
ha_sphinx ( TABLE_ARG * table_arg );
|
||||
#else
|
||||
ha_sphinx ( handlerton * hton, TABLE_ARG * table_arg );
|
||||
#endif
|
||||
~ha_sphinx () {}
|
||||
|
||||
const char * table_type () const { return "SPHINX"; } ///< SE name for display purposes
|
||||
const char * index_type ( uint ) { return "HASH"; } ///< index type name for display purposes
|
||||
const char ** bas_ext () const; ///< my file extensions
|
||||
|
||||
#if MYSQL_VERSION_ID>50100
|
||||
ulonglong table_flags () const { return HA_CAN_INDEX_BLOBS; } ///< bitmap of implemented flags (see handler.h for more info)
|
||||
#else
|
||||
ulong table_flags () const { return HA_CAN_INDEX_BLOBS; } ///< bitmap of implemented flags (see handler.h for more info)
|
||||
#endif
|
||||
|
||||
ulong index_flags ( uint, uint, bool ) const { return 0; } ///< bitmap of flags that says how SE implements indexes
|
||||
uint max_supported_record_length () const { return HA_MAX_REC_LENGTH; }
|
||||
uint max_supported_keys () const { return 1; }
|
||||
uint max_supported_key_parts () const { return 1; }
|
||||
uint max_supported_key_length () const { return MAX_KEY_LENGTH; }
|
||||
uint max_supported_key_part_length () const { return MAX_KEY_LENGTH; }
|
||||
|
||||
#if MYSQL_VERSION_ID>50100
|
||||
virtual double scan_time () { return (double)( stats.records+stats.deleted )/20.0 + 10; } ///< called in test_quick_select to determine if indexes should be used
|
||||
#else
|
||||
virtual double scan_time () { return (double)( records+deleted )/20.0 + 10; } ///< called in test_quick_select to determine if indexes should be used
|
||||
#endif
|
||||
|
||||
virtual double read_time ( ha_rows rows ) { return (double)rows/20.0 + 1; } ///< index read time estimate
|
||||
|
||||
public:
|
||||
int open ( const char * name, int mode, uint test_if_locked );
|
||||
int close ();
|
||||
|
||||
int write_row ( uchar * buf );
|
||||
int update_row ( const uchar * old_data, uchar * new_data );
|
||||
int delete_row ( const uchar * buf );
|
||||
|
||||
int index_init ( uint keynr, bool sorted ); // 5.1.x
|
||||
int index_init ( uint keynr ) { return index_init ( keynr, false ); } // 5.0.x
|
||||
|
||||
int index_end ();
|
||||
int index_read ( byte * buf, const byte * key, uint key_len, enum ha_rkey_function find_flag );
|
||||
int index_read_idx ( byte * buf, uint idx, const byte * key, uint key_len, enum ha_rkey_function find_flag );
|
||||
int index_next ( byte * buf );
|
||||
int index_next_same ( byte * buf, const byte * key, uint keylen );
|
||||
int index_prev ( byte * buf );
|
||||
int index_first ( byte * buf );
|
||||
int index_last ( byte * buf );
|
||||
|
||||
int get_rec ( byte * buf, const byte * key, uint keylen );
|
||||
|
||||
int rnd_init ( bool scan );
|
||||
int rnd_end ();
|
||||
int rnd_next ( byte * buf );
|
||||
int rnd_pos ( byte * buf, byte * pos );
|
||||
void position ( const byte * record );
|
||||
|
||||
#if MYSQL_VERSION_ID>=50030
|
||||
int info ( uint );
|
||||
#else
|
||||
void info ( uint );
|
||||
#endif
|
||||
|
||||
int reset();
|
||||
int external_lock ( THD * thd, int lock_type );
|
||||
int delete_all_rows ();
|
||||
ha_rows records_in_range ( uint inx, key_range * min_key, key_range * max_key );
|
||||
|
||||
int delete_table ( const char * from );
|
||||
int rename_table ( const char * from, const char * to );
|
||||
int create ( const char * name, TABLE * form, HA_CREATE_INFO * create_info );
|
||||
|
||||
THR_LOCK_DATA **store_lock ( THD * thd, THR_LOCK_DATA ** to, enum thr_lock_type lock_type );
|
||||
|
||||
public:
|
||||
virtual const COND * cond_push ( const COND *cond );
|
||||
virtual void cond_pop ();
|
||||
|
||||
private:
|
||||
uint32 m_iFields;
|
||||
char ** m_dFields;
|
||||
|
||||
uint32 m_iAttrs;
|
||||
CSphSEAttr * m_dAttrs;
|
||||
int m_bId64;
|
||||
|
||||
int * m_dUnboundFields;
|
||||
|
||||
private:
|
||||
int ConnectToSearchd ( const char * sQueryHost, int iQueryPort );
|
||||
|
||||
uint32 UnpackDword ();
|
||||
char * UnpackString ();
|
||||
bool UnpackSchema ();
|
||||
bool UnpackStats ( CSphSEStats * pStats );
|
||||
|
||||
CSphSEThreadData * GetTls ();
|
||||
};
|
||||
|
||||
|
||||
#if MYSQL_VERSION_ID < 50100
|
||||
bool sphinx_show_status ( THD * thd );
|
||||
#endif
|
||||
|
||||
//
|
||||
// $Id: ha_sphinx.h 1428 2008-09-05 18:06:30Z xale $
|
||||
//
|
36
storage/sphinx/make-patch.sh
Normal file
36
storage/sphinx/make-patch.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
OUT=$1
|
||||
ORIG=$2
|
||||
NEW=$3
|
||||
|
||||
if [ ! \( "$1" -a "$2" -a "$3" \) ]; then
|
||||
echo "$0 <patch> <original> <new>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILES='
|
||||
/config/ac-macros/ha_sphinx.m4
|
||||
/configure.in
|
||||
/libmysqld/Makefile.am
|
||||
/sql/handler.cc
|
||||
/sql/handler.h
|
||||
/sql/Makefile.am
|
||||
/sql/mysqld.cc
|
||||
/sql/mysql_priv.h
|
||||
/sql/set_var.cc
|
||||
/sql/sql_lex.h
|
||||
/sql/sql_parse.cc
|
||||
/sql/sql_yacc.yy
|
||||
/sql/structs.h
|
||||
/sql/sql_show.cc
|
||||
'
|
||||
|
||||
rm -f $OUT
|
||||
if [ -e $OUT ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for name in $FILES; do
|
||||
diff -BNru "$ORIG$name" "$NEW$name" >> $OUT
|
||||
done
|
6
storage/sphinx/plug.in
Normal file
6
storage/sphinx/plug.in
Normal file
@ -0,0 +1,6 @@
|
||||
MYSQL_STORAGE_ENGINE(sphinx,,[Sphinx Storage Engine],
|
||||
[SE client for Sphinx search daemon], [])
|
||||
MYSQL_PLUGIN_DIRECTORY(sphinx, [storage/sphinx])
|
||||
MYSQL_PLUGIN_STATIC(sphinx, [libsphinx.a])
|
||||
MYSQL_PLUGIN_DYNAMIC(sphinx, [ha_sphinx.la])
|
||||
|
766
storage/sphinx/snippets_udf.cc
Normal file
766
storage/sphinx/snippets_udf.cc
Normal file
@ -0,0 +1,766 @@
|
||||
//
|
||||
// $Id: snippets_udf.cc 2058 2009-11-07 04:01:57Z shodan $
|
||||
//
|
||||
|
||||
//
|
||||
// Copyright (c) 2001-2008, Andrew Aksyonoff. All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License. You should have
|
||||
// received a copy of the GPL license along with this program; if you
|
||||
// did not, you can find it at http://www.gnu.org/
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/un.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <mysql_version.h>
|
||||
|
||||
#if MYSQL_VERSION_ID>50100
|
||||
#include "mysql_priv.h"
|
||||
#include <mysql/plugin.h>
|
||||
#else
|
||||
#include "../mysql_priv.h"
|
||||
#endif
|
||||
|
||||
#include <mysys_err.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
#if MYSQL_VERSION_ID>=50120
|
||||
typedef uchar byte;
|
||||
#endif
|
||||
|
||||
/// partially copy-pasted stuff that should be moved elsewhere
|
||||
|
||||
#if UNALIGNED_RAM_ACCESS
|
||||
|
||||
/// pass-through wrapper
|
||||
template < typename T > inline T sphUnalignedRead ( const T & tRef )
|
||||
{
|
||||
return tRef;
|
||||
}
|
||||
|
||||
/// pass-through wrapper
|
||||
template < typename T > void sphUnalignedWrite ( void * pPtr, const T & tVal )
|
||||
{
|
||||
*(T*)pPtr = tVal;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/// unaligned read wrapper for some architectures (eg. SPARC)
|
||||
template < typename T >
|
||||
inline T sphUnalignedRead ( const T & tRef )
|
||||
{
|
||||
T uTmp;
|
||||
byte * pSrc = (byte *) &tRef;
|
||||
byte * pDst = (byte *) &uTmp;
|
||||
for ( int i=0; i<(int)sizeof(T); i++ )
|
||||
*pDst++ = *pSrc++;
|
||||
return uTmp;
|
||||
}
|
||||
|
||||
/// unaligned write wrapper for some architectures (eg. SPARC)
|
||||
template < typename T >
|
||||
void sphUnalignedWrite ( void * pPtr, const T & tVal )
|
||||
{
|
||||
byte * pDst = (byte *) pPtr;
|
||||
byte * pSrc = (byte *) &tVal;
|
||||
for ( int i=0; i<(int)sizeof(T); i++ )
|
||||
*pDst++ = *pSrc++;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define SPHINXSE_MAX_ALLOC (16*1024*1024)
|
||||
|
||||
#define SafeDelete(_arg) { if ( _arg ) delete ( _arg ); (_arg) = NULL; }
|
||||
#define SafeDeleteArray(_arg) { if ( _arg ) delete [] ( _arg ); (_arg) = NULL; }
|
||||
|
||||
#define Min(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
typedef unsigned int DWORD;
|
||||
|
||||
inline DWORD sphF2DW ( float f ) { union { float f; uint32 d; } u; u.f = f; return u.d; }
|
||||
|
||||
static char * sphDup ( const char * sSrc, int iLen=-1 )
|
||||
{
|
||||
if ( !sSrc )
|
||||
return NULL;
|
||||
|
||||
if ( iLen<0 )
|
||||
iLen = strlen(sSrc);
|
||||
|
||||
char * sRes = new char [ 1+iLen ];
|
||||
memcpy ( sRes, sSrc, iLen );
|
||||
sRes[iLen] = '\0';
|
||||
return sRes;
|
||||
}
|
||||
|
||||
static inline void sphShowErrno ( const char * sCall )
|
||||
{
|
||||
char sError[256];
|
||||
snprintf ( sError, sizeof(sError), "%s() failed: [%d] %s", sCall, errno, strerror(errno) );
|
||||
my_error ( ER_QUERY_ON_FOREIGN_DATA_SOURCE, MYF(0), sError );
|
||||
}
|
||||
|
||||
static const bool sphReportErrors = true;
|
||||
|
||||
static bool sphSend ( int iFd, const char * pBuffer, int iSize, bool bReportErrors = false )
|
||||
{
|
||||
assert ( pBuffer );
|
||||
assert ( iSize > 0 );
|
||||
|
||||
const int iResult = send ( iFd, pBuffer, iSize, 0 );
|
||||
if ( iResult != iSize )
|
||||
{
|
||||
if ( bReportErrors ) sphShowErrno("send");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool sphRecv ( int iFd, char * pBuffer, int iSize, bool bReportErrors = false )
|
||||
{
|
||||
assert ( pBuffer );
|
||||
assert ( iSize > 0 );
|
||||
|
||||
while ( iSize )
|
||||
{
|
||||
const int iResult = recv ( iFd, pBuffer, iSize, 0 );
|
||||
if ( iResult > 0 )
|
||||
{
|
||||
iSize -= iResult;
|
||||
pBuffer += iSize;
|
||||
}
|
||||
else if ( iResult == 0 )
|
||||
{
|
||||
if ( bReportErrors )
|
||||
my_error ( ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), "recv() failed: disconnected" );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( bReportErrors ) sphShowErrno("recv");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
SPHINX_SEARCHD_PROTO = 1,
|
||||
|
||||
SEARCHD_COMMAND_SEARCH = 0,
|
||||
SEARCHD_COMMAND_EXCERPT = 1,
|
||||
|
||||
VER_COMMAND_SEARCH = 0x116,
|
||||
VER_COMMAND_EXCERPT = 0x100,
|
||||
};
|
||||
|
||||
/// known answers
|
||||
enum
|
||||
{
|
||||
SEARCHD_OK = 0, ///< general success, command-specific reply follows
|
||||
SEARCHD_ERROR = 1, ///< general failure, error message follows
|
||||
SEARCHD_RETRY = 2, ///< temporary failure, error message follows, client should retry later
|
||||
SEARCHD_WARNING = 3 ///< general success, warning message and command-specific reply follow
|
||||
};
|
||||
|
||||
#define SPHINXSE_DEFAULT_SCHEME "sphinx"
|
||||
#define SPHINXSE_DEFAULT_HOST "127.0.0.1"
|
||||
#define SPHINXSE_DEFAULT_PORT 9312
|
||||
#define SPHINXSE_DEFAULT_INDEX "*"
|
||||
|
||||
class CSphBuffer
|
||||
{
|
||||
private:
|
||||
bool m_bOverrun;
|
||||
int m_iSize;
|
||||
int m_iLeft;
|
||||
char * m_pBuffer;
|
||||
char * m_pCurrent;
|
||||
|
||||
public:
|
||||
CSphBuffer ( const int iSize )
|
||||
: m_bOverrun ( false )
|
||||
, m_iSize ( iSize )
|
||||
, m_iLeft ( iSize )
|
||||
{
|
||||
assert ( iSize > 0 );
|
||||
m_pBuffer = new char[iSize];
|
||||
m_pCurrent = m_pBuffer;
|
||||
}
|
||||
|
||||
~CSphBuffer ()
|
||||
{
|
||||
SafeDelete ( m_pBuffer );
|
||||
}
|
||||
|
||||
const char * Ptr() const { return m_pBuffer; }
|
||||
|
||||
bool Finalize()
|
||||
{
|
||||
return !( m_bOverrun || m_iLeft != 0 || m_pCurrent - m_pBuffer != m_iSize );
|
||||
}
|
||||
|
||||
void SendBytes ( const void * pBytes, int iBytes );
|
||||
|
||||
void SendWord ( short int v ) { v = ntohs(v); SendBytes ( &v, sizeof(v) ); }
|
||||
void SendInt ( int v ) { v = ntohl(v); SendBytes ( &v, sizeof(v) ); }
|
||||
void SendDword ( DWORD v ) { v = ntohl(v) ;SendBytes ( &v, sizeof(v) ); }
|
||||
void SendUint64 ( ulonglong v ) { SendDword ( uint(v>>32) ); SendDword ( uint(v&0xFFFFFFFFUL) ); }
|
||||
void SendString ( const char * v ) { SendString ( v, strlen(v) ); }
|
||||
void SendString ( const char * v, int iLen ) { SendDword(iLen); SendBytes ( v, iLen ); }
|
||||
void SendFloat ( float v ) { SendDword ( sphF2DW(v) ); }
|
||||
};
|
||||
|
||||
void CSphBuffer::SendBytes ( const void * pBytes, int iBytes )
|
||||
{
|
||||
if ( m_iLeft < iBytes )
|
||||
{
|
||||
m_bOverrun = true;
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy ( m_pCurrent, pBytes, iBytes );
|
||||
|
||||
m_pCurrent += iBytes;
|
||||
m_iLeft -= iBytes;
|
||||
}
|
||||
|
||||
struct CSphUrl
|
||||
{
|
||||
char * m_sBuffer;
|
||||
char * m_sFormatted;
|
||||
|
||||
char * m_sScheme;
|
||||
char * m_sHost;
|
||||
char * m_sIndex;
|
||||
|
||||
int m_iPort;
|
||||
|
||||
CSphUrl()
|
||||
: m_sBuffer ( NULL )
|
||||
, m_sFormatted ( NULL )
|
||||
, m_sScheme ( SPHINXSE_DEFAULT_SCHEME )
|
||||
, m_sHost ( SPHINXSE_DEFAULT_HOST )
|
||||
, m_sIndex ( SPHINXSE_DEFAULT_INDEX )
|
||||
, m_iPort ( SPHINXSE_DEFAULT_PORT )
|
||||
{}
|
||||
|
||||
~CSphUrl()
|
||||
{
|
||||
SafeDeleteArray ( m_sFormatted );
|
||||
SafeDeleteArray ( m_sBuffer );
|
||||
}
|
||||
|
||||
bool Parse ( const char * sUrl, int iLen );
|
||||
int Connect();
|
||||
const char * Format();
|
||||
};
|
||||
|
||||
const char * CSphUrl::Format()
|
||||
{
|
||||
if ( !m_sFormatted )
|
||||
{
|
||||
int iSize = 15 + strlen(m_sHost) + strlen(m_sIndex);
|
||||
m_sFormatted = new char [ iSize ];
|
||||
if ( m_iPort )
|
||||
snprintf ( m_sFormatted, iSize, "inet://%s:%d/%s", m_sHost, m_iPort, m_sIndex );
|
||||
else
|
||||
snprintf ( m_sFormatted, iSize, "unix://%s/%s", m_sHost, m_sIndex );
|
||||
}
|
||||
return m_sFormatted;
|
||||
}
|
||||
|
||||
// the following scheme variants are recognized
|
||||
//
|
||||
// inet://host/index
|
||||
// inet://host:port/index
|
||||
// unix://unix/domain/socket:index
|
||||
// unix://unix/domain/socket
|
||||
bool CSphUrl::Parse ( const char * sUrl, int iLen )
|
||||
{
|
||||
bool bOk = true;
|
||||
while ( iLen )
|
||||
{
|
||||
bOk = false;
|
||||
|
||||
m_sBuffer = sphDup ( sUrl, iLen );
|
||||
m_sScheme = m_sBuffer;
|
||||
|
||||
m_sHost = strstr ( m_sBuffer, "://" );
|
||||
if ( !m_sHost )
|
||||
break;
|
||||
m_sHost[0] = '\0';
|
||||
m_sHost += 2;
|
||||
|
||||
if ( !strcmp ( m_sScheme, "unix" ) )
|
||||
{
|
||||
// unix-domain socket
|
||||
m_iPort = 0;
|
||||
if (!( m_sIndex = strrchr ( m_sHost, ':' ) ))
|
||||
m_sIndex = SPHINXSE_DEFAULT_INDEX;
|
||||
else
|
||||
{
|
||||
*m_sIndex++ = '\0';
|
||||
if ( !*m_sIndex )
|
||||
m_sIndex = SPHINXSE_DEFAULT_INDEX;
|
||||
}
|
||||
bOk = true;
|
||||
break;
|
||||
}
|
||||
if( strcmp ( m_sScheme, "sphinx" ) != 0 && strcmp ( m_sScheme, "inet" ) != 0 )
|
||||
break;
|
||||
|
||||
// inet
|
||||
m_sHost++;
|
||||
char * sPort = strchr ( m_sHost, ':' );
|
||||
if ( sPort )
|
||||
{
|
||||
*sPort++ = '\0';
|
||||
if ( *sPort )
|
||||
{
|
||||
m_sIndex = strchr ( sPort, '/' );
|
||||
if ( m_sIndex )
|
||||
*m_sIndex++ = '\0';
|
||||
else
|
||||
m_sIndex = SPHINXSE_DEFAULT_INDEX;
|
||||
|
||||
m_iPort = atoi(sPort);
|
||||
if ( !m_iPort )
|
||||
m_iPort = SPHINXSE_DEFAULT_PORT;
|
||||
}
|
||||
} else
|
||||
{
|
||||
m_sIndex = strchr ( m_sHost, '/' );
|
||||
if ( m_sIndex )
|
||||
*m_sIndex++ = '\0';
|
||||
else
|
||||
m_sIndex = SPHINXSE_DEFAULT_INDEX;
|
||||
}
|
||||
|
||||
bOk = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return bOk;
|
||||
}
|
||||
|
||||
int CSphUrl::Connect()
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
#ifndef __WIN__
|
||||
struct sockaddr_un saun;
|
||||
#endif
|
||||
|
||||
int iDomain = 0;
|
||||
int iSockaddrSize = 0;
|
||||
struct sockaddr * pSockaddr = NULL;
|
||||
|
||||
in_addr_t ip_addr;
|
||||
|
||||
if ( m_iPort )
|
||||
{
|
||||
iDomain = AF_INET;
|
||||
iSockaddrSize = sizeof(sin);
|
||||
pSockaddr = (struct sockaddr *) &sin;
|
||||
|
||||
memset ( &sin, 0, sizeof(sin) );
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(m_iPort);
|
||||
|
||||
// resolve address
|
||||
if ( (int)( ip_addr=inet_addr(m_sHost) ) != (int)INADDR_NONE )
|
||||
memcpy ( &sin.sin_addr, &ip_addr, sizeof(ip_addr) );
|
||||
else
|
||||
{
|
||||
int tmp_errno;
|
||||
struct hostent tmp_hostent, *hp;
|
||||
char buff2 [ GETHOSTBYNAME_BUFF_SIZE ];
|
||||
|
||||
hp = my_gethostbyname_r ( m_sHost, &tmp_hostent,
|
||||
buff2, sizeof(buff2), &tmp_errno );
|
||||
if ( !hp )
|
||||
{
|
||||
my_gethostbyname_r_free();
|
||||
|
||||
char sError[256];
|
||||
snprintf ( sError, sizeof(sError), "failed to resolve searchd host (name=%s)", m_sHost );
|
||||
|
||||
my_error ( ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), sError );
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) );
|
||||
my_gethostbyname_r_free();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef __WIN__
|
||||
iDomain = AF_UNIX;
|
||||
iSockaddrSize = sizeof(saun);
|
||||
pSockaddr = (struct sockaddr *) &saun;
|
||||
|
||||
memset ( &saun, 0, sizeof(saun) );
|
||||
saun.sun_family = AF_UNIX;
|
||||
strncpy ( saun.sun_path, m_sHost, sizeof(saun.sun_path)-1 );
|
||||
#else
|
||||
my_error ( ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), "Unix-domain sockets are not supported on Windows" );
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// connect to searchd and exchange versions
|
||||
uint uServerVersion;
|
||||
uint uClientVersion = htonl ( SPHINX_SEARCHD_PROTO );
|
||||
int iSocket = -1;
|
||||
char * pError = NULL;
|
||||
do
|
||||
{
|
||||
iSocket = socket ( iDomain, SOCK_STREAM, 0 );
|
||||
if ( iSocket == -1 )
|
||||
{
|
||||
pError = "Failed to create client socket";
|
||||
break;
|
||||
}
|
||||
|
||||
if ( connect ( iSocket, pSockaddr, iSockaddrSize ) == -1)
|
||||
{
|
||||
pError = "Failed to connect to searchd";
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !sphRecv ( iSocket, (char *)&uServerVersion, sizeof(uServerVersion) ) )
|
||||
{
|
||||
pError = "Failed to receive searchd version";
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !sphSend ( iSocket, (char *)&uClientVersion, sizeof(uClientVersion) ) )
|
||||
{
|
||||
pError = "Failed to send client version";
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(0);
|
||||
|
||||
// fixme: compare versions?
|
||||
|
||||
if ( pError )
|
||||
{
|
||||
char sError[1024];
|
||||
snprintf ( sError, sizeof(sError), "%s [%d] %s", Format(), errno, strerror(errno) );
|
||||
my_error ( ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0), sError );
|
||||
|
||||
if ( iSocket != -1 )
|
||||
close ( iSocket );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return iSocket;
|
||||
}
|
||||
|
||||
struct CSphResponse
|
||||
{
|
||||
char * m_pBuffer;
|
||||
char * m_pBody;
|
||||
|
||||
CSphResponse ()
|
||||
: m_pBuffer ( NULL )
|
||||
, m_pBody ( NULL )
|
||||
{}
|
||||
|
||||
CSphResponse ( DWORD uSize )
|
||||
: m_pBody ( NULL )
|
||||
{
|
||||
m_pBuffer = new char[uSize];
|
||||
}
|
||||
|
||||
~CSphResponse ()
|
||||
{
|
||||
SafeDeleteArray ( m_pBuffer );
|
||||
}
|
||||
|
||||
static CSphResponse * Read ( int iSocket, int iClientVersion );
|
||||
};
|
||||
|
||||
CSphResponse *
|
||||
CSphResponse::Read ( int iSocket, int iClientVersion )
|
||||
{
|
||||
char sHeader[8];
|
||||
if ( !sphRecv ( iSocket, sHeader, sizeof(sHeader) ) )
|
||||
return NULL;
|
||||
|
||||
int iStatus = ntohs ( sphUnalignedRead ( *(short int *) &sHeader[0] ) );
|
||||
int iVersion = ntohs ( sphUnalignedRead ( *(short int *) &sHeader[2] ) );
|
||||
DWORD uLength = ntohl ( sphUnalignedRead ( *(DWORD *) &sHeader[4] ) );
|
||||
|
||||
if ( iVersion < iClientVersion ) // fixme: warn
|
||||
;
|
||||
|
||||
if ( uLength <= SPHINXSE_MAX_ALLOC )
|
||||
{
|
||||
CSphResponse * pResponse = new CSphResponse ( uLength );
|
||||
if ( !sphRecv ( iSocket, pResponse->m_pBuffer, uLength ) )
|
||||
{
|
||||
SafeDelete ( pResponse );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pResponse->m_pBody = pResponse->m_pBuffer;
|
||||
if ( iStatus != SEARCHD_OK )
|
||||
{
|
||||
DWORD uSize = ntohl ( *(DWORD *)pResponse->m_pBuffer );
|
||||
if ( iStatus == SEARCHD_WARNING )
|
||||
pResponse->m_pBody += uSize; // fixme: report the warning somehow
|
||||
else
|
||||
{
|
||||
char * sMessage = sphDup ( pResponse->m_pBuffer + sizeof(DWORD), uSize );
|
||||
my_error ( ER_QUERY_ON_FOREIGN_DATA_SOURCE, MYF(0), sMessage );
|
||||
SafeDelete ( sMessage );
|
||||
SafeDelete ( pResponse );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return pResponse;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/// udf
|
||||
|
||||
extern "C"
|
||||
{
|
||||
my_bool sphinx_snippets_init ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sMessage );
|
||||
void sphinx_snippets_deinit ( UDF_INIT * pUDF );
|
||||
char * sphinx_snippets ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sResult, unsigned long * pLength, char * pIsNull, char * sError );
|
||||
};
|
||||
|
||||
#define MAX_MESSAGE_LENGTH 255
|
||||
#define MAX_RESULT_LENGTH 255
|
||||
|
||||
struct CSphSnippets
|
||||
{
|
||||
CSphUrl m_tUrl;
|
||||
CSphResponse * m_pResponse;
|
||||
|
||||
int m_iBeforeMatch;
|
||||
int m_iAfterMatch;
|
||||
int m_iChunkSeparator;
|
||||
int m_iLimit;
|
||||
int m_iAround;
|
||||
int m_iFlags;
|
||||
|
||||
CSphSnippets()
|
||||
: m_pResponse(NULL)
|
||||
, m_iBeforeMatch(0)
|
||||
, m_iAfterMatch(0)
|
||||
, m_iChunkSeparator(0)
|
||||
// defaults
|
||||
, m_iLimit(256)
|
||||
, m_iAround(5)
|
||||
, m_iFlags(1)
|
||||
{
|
||||
}
|
||||
|
||||
~CSphSnippets()
|
||||
{
|
||||
SafeDelete ( m_pResponse );
|
||||
}
|
||||
};
|
||||
|
||||
#define KEYWORD(NAME) else if ( strncmp ( NAME, pArgs->attributes[i], pArgs->attribute_lengths[i] ) == 0 )
|
||||
|
||||
#define CHECK_TYPE(TYPE) \
|
||||
if ( pArgs->arg_type[i] != TYPE ) \
|
||||
{ \
|
||||
snprintf ( sMessage, MAX_MESSAGE_LENGTH, \
|
||||
"%.*s argument must be a string", \
|
||||
(int)pArgs->attribute_lengths[i], \
|
||||
pArgs->attributes[i] ); \
|
||||
bFail = true; \
|
||||
break; \
|
||||
} \
|
||||
if ( TYPE == STRING_RESULT && !pArgs->args[i] ) \
|
||||
{ \
|
||||
snprintf ( sMessage, MAX_MESSAGE_LENGTH, \
|
||||
"%.*s argument must be constant (and not NULL)", \
|
||||
(int)pArgs->attribute_lengths[i], \
|
||||
pArgs->attributes[i] ); \
|
||||
bFail = true; \
|
||||
break; \
|
||||
}
|
||||
|
||||
#define STRING CHECK_TYPE(STRING_RESULT)
|
||||
#define INT CHECK_TYPE(INT_RESULT); int iValue = *(long long *)pArgs->args[i]
|
||||
|
||||
my_bool sphinx_snippets_init ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sMessage )
|
||||
{
|
||||
if ( pArgs->arg_count < 3 )
|
||||
{
|
||||
strncpy ( sMessage, "insufficient arguments", MAX_MESSAGE_LENGTH );
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool bFail = false;
|
||||
CSphSnippets * pOpts = new CSphSnippets;
|
||||
for ( uint i = 0; i < pArgs->arg_count; i++ )
|
||||
{
|
||||
if ( i < 3 )
|
||||
{
|
||||
if ( pArgs->arg_type[i] != STRING_RESULT )
|
||||
{
|
||||
strncpy ( sMessage, "first three arguments must be of string type", MAX_MESSAGE_LENGTH );
|
||||
bFail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KEYWORD("sphinx")
|
||||
{
|
||||
STRING;
|
||||
if ( !pOpts->m_tUrl.Parse ( pArgs->args[i], pArgs->lengths[i] ) )
|
||||
{
|
||||
strncpy ( sMessage, "failed to parse connection string", MAX_MESSAGE_LENGTH );
|
||||
bFail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
KEYWORD("before_match") { STRING; pOpts->m_iBeforeMatch = i; }
|
||||
KEYWORD("after_match") { STRING; pOpts->m_iAfterMatch = i; }
|
||||
KEYWORD("chunk_separator") { STRING; pOpts->m_iChunkSeparator = i; }
|
||||
KEYWORD("limit") { INT; pOpts->m_iLimit = iValue; }
|
||||
KEYWORD("around") { INT; pOpts->m_iAround = iValue; }
|
||||
KEYWORD("exact_phrase") { INT; if ( iValue ) pOpts->m_iFlags |= 2; }
|
||||
KEYWORD("single_passage") { INT; if ( iValue ) pOpts->m_iFlags |= 4; }
|
||||
KEYWORD("use_boundaries") { INT; if ( iValue ) pOpts->m_iFlags |= 8; }
|
||||
KEYWORD("weight_order") { INT; if ( iValue ) pOpts->m_iFlags |= 16; }
|
||||
else
|
||||
{
|
||||
snprintf ( sMessage, MAX_MESSAGE_LENGTH, "unrecognized argument: %.*s",
|
||||
(int)pArgs->attribute_lengths[i], pArgs->attributes[i] );
|
||||
bFail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bFail )
|
||||
{
|
||||
SafeDelete ( pOpts );
|
||||
return 1;
|
||||
}
|
||||
pUDF->ptr = (char *)pOpts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#undef STRING
|
||||
#undef INT
|
||||
#undef KEYWORD
|
||||
#undef CHECK_TYPE
|
||||
|
||||
#define ARG(i) pArgs->args[i], pArgs->lengths[i]
|
||||
#define ARG_LEN(VAR, LEN) ( VAR ? pArgs->lengths[VAR] : LEN )
|
||||
|
||||
#define SEND_STRING(INDEX, DEFAULT) \
|
||||
if ( INDEX ) \
|
||||
tBuffer.SendString ( ARG(INDEX) ); \
|
||||
else \
|
||||
tBuffer.SendString ( DEFAULT, sizeof(DEFAULT) - 1 );
|
||||
|
||||
|
||||
char * sphinx_snippets ( UDF_INIT * pUDF, UDF_ARGS * pArgs, char * sResult, unsigned long * pLength, char * pIsNull, char * pError )
|
||||
{
|
||||
CSphSnippets * pOpts = (CSphSnippets *)pUDF->ptr;
|
||||
assert ( pOpts );
|
||||
|
||||
if ( !pArgs->args[0] || !pArgs->args[1] || !pArgs->args[2] )
|
||||
{
|
||||
*pIsNull = 1;
|
||||
return sResult;
|
||||
}
|
||||
|
||||
const int iSize =
|
||||
8 + // header
|
||||
8 +
|
||||
4 + pArgs->lengths[1] + // index
|
||||
4 + pArgs->lengths[2] + // words
|
||||
4 + ARG_LEN ( pOpts->m_iBeforeMatch, 3 ) +
|
||||
4 + ARG_LEN ( pOpts->m_iAfterMatch, 4 ) +
|
||||
4 + ARG_LEN ( pOpts->m_iChunkSeparator, 5 ) +
|
||||
12 +
|
||||
4 + pArgs->lengths[0]; // document
|
||||
|
||||
CSphBuffer tBuffer(iSize);
|
||||
|
||||
tBuffer.SendWord ( SEARCHD_COMMAND_EXCERPT );
|
||||
tBuffer.SendWord ( VER_COMMAND_EXCERPT );
|
||||
tBuffer.SendDword ( iSize - 8 );
|
||||
|
||||
tBuffer.SendDword ( 0 );
|
||||
tBuffer.SendDword ( pOpts->m_iFlags );
|
||||
|
||||
tBuffer.SendString ( ARG(1) ); // index
|
||||
tBuffer.SendString ( ARG(2) ); // words
|
||||
|
||||
SEND_STRING ( pOpts->m_iBeforeMatch, "<b>" );
|
||||
SEND_STRING ( pOpts->m_iAfterMatch, "</b>" );
|
||||
SEND_STRING ( pOpts->m_iChunkSeparator, " ... " );
|
||||
|
||||
tBuffer.SendInt ( pOpts->m_iLimit );
|
||||
tBuffer.SendInt ( pOpts->m_iAround );
|
||||
|
||||
// single document
|
||||
tBuffer.SendInt ( 1 );
|
||||
tBuffer.SendString ( ARG(0) );
|
||||
|
||||
int iSocket = -1;
|
||||
do
|
||||
{
|
||||
if ( !tBuffer.Finalize() )
|
||||
{
|
||||
my_error ( ER_QUERY_ON_FOREIGN_DATA_SOURCE, MYF(0), "INTERNAL ERROR: failed to build request" );
|
||||
break;
|
||||
}
|
||||
|
||||
iSocket = pOpts->m_tUrl.Connect();
|
||||
if ( iSocket == -1 ) break;
|
||||
if ( !sphSend ( iSocket, tBuffer.Ptr(), iSize, sphReportErrors ) ) break;
|
||||
|
||||
CSphResponse * pResponse = CSphResponse::Read ( iSocket, 0x100 );
|
||||
if ( !pResponse ) break;
|
||||
|
||||
close ( iSocket );
|
||||
pOpts->m_pResponse = pResponse;
|
||||
*pLength = ntohl( *(DWORD *)pResponse->m_pBody );
|
||||
return pResponse->m_pBody + sizeof(DWORD);
|
||||
}
|
||||
while(0);
|
||||
|
||||
if ( iSocket != -1 )
|
||||
close ( iSocket );
|
||||
|
||||
*pError = 1;
|
||||
return sResult;
|
||||
}
|
||||
|
||||
#undef SEND_STRING
|
||||
#undef ARG_LEN
|
||||
#undef ARG
|
||||
|
||||
void sphinx_snippets_deinit ( UDF_INIT * pUDF )
|
||||
{
|
||||
CSphSnippets * pOpts = (CSphSnippets *)pUDF->ptr;
|
||||
SafeDelete ( pOpts );
|
||||
}
|
||||
|
||||
//
|
||||
// $Id: snippets_udf.cc 2058 2009-11-07 04:01:57Z shodan $
|
||||
//
|
284
storage/sphinx/sphinx.5.0.22.diff
Normal file
284
storage/sphinx/sphinx.5.0.22.diff
Normal file
@ -0,0 +1,284 @@
|
||||
diff -B -N -r -u mysql-5.0.22/config/ac-macros/ha_sphinx.m4 mysql-5.0.22.sx/config/ac-macros/ha_sphinx.m4
|
||||
--- mysql-5.0.22/config/ac-macros/ha_sphinx.m4 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ mysql-5.0.22.sx/config/ac-macros/ha_sphinx.m4 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -0,0 +1,30 @@
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+dnl Macro: MYSQL_CHECK_EXAMPLEDB
|
||||
+dnl Sets HAVE_SPHINX_DB if --with-sphinx-storage-engine is used
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+AC_DEFUN([MYSQL_CHECK_SPHINXDB], [
|
||||
+ AC_ARG_WITH([sphinx-storage-engine],
|
||||
+ [
|
||||
+ --with-sphinx-storage-engine
|
||||
+ Enable the Sphinx Storage Engine],
|
||||
+ [sphinxdb="$withval"],
|
||||
+ [sphinxdb=no])
|
||||
+ AC_MSG_CHECKING([for example storage engine])
|
||||
+
|
||||
+ case "$sphinxdb" in
|
||||
+ yes )
|
||||
+ AC_DEFINE([HAVE_SPHINX_DB], [1], [Builds Sphinx Engine])
|
||||
+ AC_MSG_RESULT([yes])
|
||||
+ [sphinxdb=yes]
|
||||
+ ;;
|
||||
+ * )
|
||||
+ AC_MSG_RESULT([no])
|
||||
+ [sphinxdb=no]
|
||||
+ ;;
|
||||
+ esac
|
||||
+
|
||||
+])
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+dnl END OF MYSQL_CHECK_EXAMPLE SECTION
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+
|
||||
diff -B -N -r -u mysql-5.0.22/configure.in mysql-5.0.22.sx/configure.in
|
||||
--- mysql-5.0.22/configure.in 2006-05-25 10:56:45.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/configure.in 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -41,6 +41,7 @@
|
||||
sinclude(config/ac-macros/ha_berkeley.m4)
|
||||
sinclude(config/ac-macros/ha_blackhole.m4)
|
||||
sinclude(config/ac-macros/ha_example.m4)
|
||||
+sinclude(config/ac-macros/ha_sphinx.m4)
|
||||
sinclude(config/ac-macros/ha_federated.m4)
|
||||
sinclude(config/ac-macros/ha_innodb.m4)
|
||||
sinclude(config/ac-macros/ha_ndbcluster.m4)
|
||||
@@ -2450,6 +2451,7 @@
|
||||
MYSQL_CHECK_BDB
|
||||
MYSQL_CHECK_INNODB
|
||||
MYSQL_CHECK_EXAMPLEDB
|
||||
+MYSQL_CHECK_SPHINXDB
|
||||
MYSQL_CHECK_ARCHIVEDB
|
||||
MYSQL_CHECK_CSVDB
|
||||
MYSQL_CHECK_BLACKHOLEDB
|
||||
diff -B -N -r -u mysql-5.0.22/libmysqld/Makefile.am mysql-5.0.22.sx/libmysqld/Makefile.am
|
||||
--- mysql-5.0.22/libmysqld/Makefile.am 2006-05-25 10:56:55.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/libmysqld/Makefile.am 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -27,7 +27,7 @@
|
||||
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
|
||||
INCLUDES= @bdb_includes@ \
|
||||
-I$(top_builddir)/include -I$(top_srcdir)/include \
|
||||
- -I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples \
|
||||
+ -I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples -I$(top_srcdir)/sql/sphinx \
|
||||
-I$(top_srcdir)/regex \
|
||||
$(openssl_includes) $(yassl_includes) @ZLIB_INCLUDES@
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
|
||||
my_time.c
|
||||
sqlexamplessources = ha_example.cc ha_tina.cc
|
||||
+sqlsphinxsources = ha_sphinx.cc
|
||||
|
||||
noinst_HEADERS = embedded_priv.h emb_qcache.h
|
||||
|
||||
@@ -65,7 +66,7 @@
|
||||
parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
|
||||
ha_blackhole.cc ha_archive.cc my_user.c
|
||||
|
||||
-libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
|
||||
+libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources) $(sqlsphinxsources)
|
||||
libmysqld_a_SOURCES=
|
||||
|
||||
# automake misses these
|
||||
@@ -133,12 +134,16 @@
|
||||
rm -f $$f; \
|
||||
@LN_CP_F@ $(top_srcdir)/sql/examples/$$f $$f; \
|
||||
done; \
|
||||
+ for f in $(sqlsphinxsources); do \
|
||||
+ rm -f $$f; \
|
||||
+ @LN_CP_F@ $(top_srcdir)/sql/sphinx/$$f $$f; \
|
||||
+ done; \
|
||||
rm -f client_settings.h; \
|
||||
@LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h client_settings.h
|
||||
|
||||
|
||||
clean-local:
|
||||
- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlexamplessources) | sed "s;\.lo;.c;g"` \
|
||||
+ rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlexamplessources) $(sqlsphinxsources) | sed "s;\.lo;.c;g"` \
|
||||
$(top_srcdir)/linked_libmysqld_sources; \
|
||||
rm -f client_settings.h
|
||||
|
||||
diff -B -N -r -u mysql-5.0.22/sql/handler.cc mysql-5.0.22.sx/sql/handler.cc
|
||||
--- mysql-5.0.22/sql/handler.cc 2006-05-25 10:56:42.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/handler.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -78,6 +78,15 @@
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+extern handlerton sphinx_hton;
|
||||
+#else
|
||||
+handlerton sphinx_hton = { "SPHINX", SHOW_OPTION_NO, "SPHINX storage engine",
|
||||
+ DB_TYPE_SPHINX_DB, NULL, 0, 0, NULL, NULL,
|
||||
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
+ HTON_NO_FLAGS };
|
||||
+#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
extern handlerton innobase_hton;
|
||||
@@ -147,6 +156,7 @@
|
||||
&example_hton,
|
||||
&archive_hton,
|
||||
&tina_hton,
|
||||
+ &sphinx_hton,
|
||||
&ndbcluster_hton,
|
||||
&federated_hton,
|
||||
&myisammrg_hton,
|
||||
@@ -345,6 +355,12 @@
|
||||
return new (alloc) ha_tina(table);
|
||||
return NULL;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ case DB_TYPE_SPHINX_DB:
|
||||
+ if (have_sphinx_db == SHOW_OPTION_YES)
|
||||
+ return new (alloc) ha_sphinx(table);
|
||||
+ return NULL;
|
||||
+#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
case DB_TYPE_NDBCLUSTER:
|
||||
if (have_ndbcluster == SHOW_OPTION_YES)
|
||||
diff -B -N -r -u mysql-5.0.22/sql/handler.h mysql-5.0.22.sx/sql/handler.h
|
||||
--- mysql-5.0.22/sql/handler.h 2006-05-25 10:56:55.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/handler.h 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -183,8 +183,9 @@
|
||||
DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB,
|
||||
DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER,
|
||||
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB,
|
||||
- DB_TYPE_FEDERATED_DB,
|
||||
+ DB_TYPE_FEDERATED_DB,
|
||||
DB_TYPE_BLACKHOLE_DB,
|
||||
+ DB_TYPE_SPHINX_DB,
|
||||
DB_TYPE_DEFAULT // Must be last
|
||||
};
|
||||
|
||||
diff -B -N -r -u mysql-5.0.22/sql/Makefile.am mysql-5.0.22.sx/sql/Makefile.am
|
||||
--- mysql-5.0.22/sql/Makefile.am 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/Makefile.am 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -66,6 +66,7 @@
|
||||
sql_array.h sql_cursor.h \
|
||||
examples/ha_example.h ha_archive.h \
|
||||
examples/ha_tina.h ha_blackhole.h \
|
||||
+ sphinx/ha_sphinx.h \
|
||||
ha_federated.h
|
||||
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
||||
item.cc item_sum.cc item_buff.cc item_func.cc \
|
||||
@@ -102,6 +103,7 @@
|
||||
sp_cache.cc parse_file.cc sql_trigger.cc \
|
||||
examples/ha_example.cc ha_archive.cc \
|
||||
examples/ha_tina.cc ha_blackhole.cc \
|
||||
+ sphinx/ha_sphinx.cc \
|
||||
ha_federated.cc
|
||||
|
||||
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
||||
diff -B -N -r -u mysql-5.0.22/sql/mysqld.cc mysql-5.0.22.sx/sql/mysqld.cc
|
||||
--- mysql-5.0.22/sql/mysqld.cc 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/mysqld.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -6420,6 +6420,11 @@
|
||||
#else
|
||||
have_csv_db= SHOW_OPTION_NO;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ have_sphinx_db= SHOW_OPTION_YES;
|
||||
+#else
|
||||
+ have_sphinx_db= SHOW_OPTION_NO;
|
||||
+#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
have_ndbcluster=SHOW_OPTION_DISABLED;
|
||||
#else
|
||||
@@ -7457,6 +7462,7 @@
|
||||
#undef have_example_db
|
||||
#undef have_archive_db
|
||||
#undef have_csv_db
|
||||
+#undef have_sphinx_db
|
||||
#undef have_federated_db
|
||||
#undef have_partition_db
|
||||
#undef have_blackhole_db
|
||||
@@ -7467,6 +7473,7 @@
|
||||
SHOW_COMP_OPTION have_example_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_archive_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_csv_db= SHOW_OPTION_NO;
|
||||
+SHOW_COMP_OPTION have_sphinx_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_federated_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_partition_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_blackhole_db= SHOW_OPTION_NO;
|
||||
diff -B -N -r -u mysql-5.0.22/sql/mysql_priv.h mysql-5.0.22.sx/sql/mysql_priv.h
|
||||
--- mysql-5.0.22/sql/mysql_priv.h 2006-05-25 10:56:43.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/mysql_priv.h 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -1279,6 +1279,12 @@
|
||||
#else
|
||||
extern SHOW_COMP_OPTION have_csv_db;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+extern handlerton sphinx_hton;
|
||||
+#define have_sphinx_db sphinx_hton.state
|
||||
+#else
|
||||
+extern SHOW_COMP_OPTION have_sphinx_db;
|
||||
+#endif
|
||||
#ifdef HAVE_FEDERATED_DB
|
||||
extern handlerton federated_hton;
|
||||
#define have_federated_db federated_hton.state
|
||||
diff -B -N -r -u mysql-5.0.22/sql/set_var.cc mysql-5.0.22.sx/sql/set_var.cc
|
||||
--- mysql-5.0.22/sql/set_var.cc 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/set_var.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -809,6 +809,7 @@
|
||||
{"have_compress", (char*) &have_compress, SHOW_HAVE},
|
||||
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
|
||||
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
|
||||
+ {"have_sphinx", (char*) &have_sphinx_db, SHOW_HAVE},
|
||||
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
|
||||
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
|
||||
{"have_geometry", (char*) &have_geometry, SHOW_HAVE},
|
||||
diff -B -N -r -u mysql-5.0.22/sql/sql_lex.h mysql-5.0.22.sx/sql/sql_lex.h
|
||||
--- mysql-5.0.22/sql/sql_lex.h 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/sql_lex.h 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -58,6 +58,7 @@
|
||||
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
|
||||
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS,
|
||||
SQLCOM_SHOW_INNODB_STATUS, SQLCOM_SHOW_NDBCLUSTER_STATUS, SQLCOM_SHOW_MUTEX_STATUS,
|
||||
+ SQLCOM_SHOW_SPHINX_STATUS,
|
||||
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
|
||||
SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
|
||||
SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, SQLCOM_SHOW_TABLE_STATUS,
|
||||
diff -B -N -r -u mysql-5.0.22/sql/sql_parse.cc mysql-5.0.22.sx/sql/sql_parse.cc
|
||||
--- mysql-5.0.22/sql/sql_parse.cc 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/sql_parse.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+#endif
|
||||
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
#include "ha_ndbcluster.h"
|
||||
@@ -2722,6 +2725,15 @@
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ case SQLCOM_SHOW_SPHINX_STATUS:
|
||||
+ {
|
||||
+ if (check_global_access(thd, SUPER_ACL))
|
||||
+ goto error;
|
||||
+ res = sphinx_show_status(thd);
|
||||
+ break;
|
||||
+ }
|
||||
+#endif
|
||||
#ifdef HAVE_REPLICATION
|
||||
case SQLCOM_LOAD_MASTER_TABLE:
|
||||
{
|
||||
diff -B -N -r -u mysql-5.0.22/sql/sql_yacc.yy mysql-5.0.22.sx/sql/sql_yacc.yy
|
||||
--- mysql-5.0.22/sql/sql_yacc.yy 2006-05-25 10:56:43.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/sql_yacc.yy 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -6584,6 +6584,9 @@
|
||||
case DB_TYPE_INNODB:
|
||||
Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS;
|
||||
break;
|
||||
+ case DB_TYPE_SPHINX_DB:
|
||||
+ Lex->sql_command = SQLCOM_SHOW_SPHINX_STATUS;
|
||||
+ break;
|
||||
default:
|
||||
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "STATUS");
|
||||
YYABORT;
|
284
storage/sphinx/sphinx.5.0.27.diff
Normal file
284
storage/sphinx/sphinx.5.0.27.diff
Normal file
@ -0,0 +1,284 @@
|
||||
diff -B -N -r -u mysql-5.0.22/config/ac-macros/ha_sphinx.m4 mysql-5.0.22.sx/config/ac-macros/ha_sphinx.m4
|
||||
--- mysql-5.0.22/config/ac-macros/ha_sphinx.m4 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ mysql-5.0.22.sx/config/ac-macros/ha_sphinx.m4 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -0,0 +1,30 @@
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+dnl Macro: MYSQL_CHECK_EXAMPLEDB
|
||||
+dnl Sets HAVE_SPHINX_DB if --with-sphinx-storage-engine is used
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+AC_DEFUN([MYSQL_CHECK_SPHINXDB], [
|
||||
+ AC_ARG_WITH([sphinx-storage-engine],
|
||||
+ [
|
||||
+ --with-sphinx-storage-engine
|
||||
+ Enable the Sphinx Storage Engine],
|
||||
+ [sphinxdb="$withval"],
|
||||
+ [sphinxdb=no])
|
||||
+ AC_MSG_CHECKING([for example storage engine])
|
||||
+
|
||||
+ case "$sphinxdb" in
|
||||
+ yes )
|
||||
+ AC_DEFINE([HAVE_SPHINX_DB], [1], [Builds Sphinx Engine])
|
||||
+ AC_MSG_RESULT([yes])
|
||||
+ [sphinxdb=yes]
|
||||
+ ;;
|
||||
+ * )
|
||||
+ AC_MSG_RESULT([no])
|
||||
+ [sphinxdb=no]
|
||||
+ ;;
|
||||
+ esac
|
||||
+
|
||||
+])
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+dnl END OF MYSQL_CHECK_EXAMPLE SECTION
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+
|
||||
diff -B -N -r -u mysql-5.0.22/configure.in mysql-5.0.22.sx/configure.in
|
||||
--- mysql-5.0.22/configure.in 2006-05-25 10:56:45.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/configure.in 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -41,6 +41,7 @@
|
||||
sinclude(config/ac-macros/ha_berkeley.m4)
|
||||
sinclude(config/ac-macros/ha_blackhole.m4)
|
||||
sinclude(config/ac-macros/ha_example.m4)
|
||||
+sinclude(config/ac-macros/ha_sphinx.m4)
|
||||
sinclude(config/ac-macros/ha_federated.m4)
|
||||
sinclude(config/ac-macros/ha_innodb.m4)
|
||||
sinclude(config/ac-macros/ha_ndbcluster.m4)
|
||||
@@ -2450,6 +2451,7 @@
|
||||
MYSQL_CHECK_BDB
|
||||
MYSQL_CHECK_INNODB
|
||||
MYSQL_CHECK_EXAMPLEDB
|
||||
+MYSQL_CHECK_SPHINXDB
|
||||
MYSQL_CHECK_ARCHIVEDB
|
||||
MYSQL_CHECK_CSVDB
|
||||
MYSQL_CHECK_BLACKHOLEDB
|
||||
diff -B -N -r -u mysql-5.0.22/libmysqld/Makefile.am mysql-5.0.22.sx/libmysqld/Makefile.am
|
||||
--- mysql-5.0.22/libmysqld/Makefile.am 2006-05-25 10:56:55.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/libmysqld/Makefile.am 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -27,7 +27,7 @@
|
||||
-DSHAREDIR="\"$(MYSQLSHAREdir)\""
|
||||
INCLUDES= @bdb_includes@ \
|
||||
-I$(top_builddir)/include -I$(top_srcdir)/include \
|
||||
- -I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples \
|
||||
+ -I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples -I$(top_srcdir)/sql/sphinx \
|
||||
-I$(top_srcdir)/regex \
|
||||
$(openssl_includes) $(yassl_includes) @ZLIB_INCLUDES@
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
|
||||
my_time.c
|
||||
sqlexamplessources = ha_example.cc ha_tina.cc
|
||||
+sqlsphinxsources = ha_sphinx.cc
|
||||
|
||||
noinst_HEADERS = embedded_priv.h emb_qcache.h
|
||||
|
||||
@@ -65,7 +66,7 @@
|
||||
parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
|
||||
ha_blackhole.cc ha_archive.cc my_user.c
|
||||
|
||||
-libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
|
||||
+libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources) $(sqlsphinxsources)
|
||||
libmysqld_a_SOURCES=
|
||||
|
||||
# automake misses these
|
||||
@@ -133,12 +134,16 @@
|
||||
rm -f $$f; \
|
||||
@LN_CP_F@ $(top_srcdir)/sql/examples/$$f $$f; \
|
||||
done; \
|
||||
+ for f in $(sqlsphinxsources); do \
|
||||
+ rm -f $$f; \
|
||||
+ @LN_CP_F@ $(top_srcdir)/sql/sphinx/$$f $$f; \
|
||||
+ done; \
|
||||
rm -f client_settings.h; \
|
||||
@LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h client_settings.h
|
||||
|
||||
|
||||
clean-local:
|
||||
- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlexamplessources) | sed "s;\.lo;.c;g"` \
|
||||
+ rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlexamplessources) $(sqlsphinxsources) | sed "s;\.lo;.c;g"` \
|
||||
$(top_srcdir)/linked_libmysqld_sources; \
|
||||
rm -f client_settings.h
|
||||
|
||||
diff -B -N -r -u mysql-5.0.22/sql/handler.cc mysql-5.0.22.sx/sql/handler.cc
|
||||
--- mysql-5.0.22/sql/handler.cc 2006-05-25 10:56:42.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/handler.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -78,6 +78,15 @@
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+extern handlerton sphinx_hton;
|
||||
+#else
|
||||
+handlerton sphinx_hton = { "SPHINX", SHOW_OPTION_NO, "SPHINX storage engine",
|
||||
+ DB_TYPE_SPHINX_DB, NULL, 0, 0, NULL, NULL,
|
||||
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
+ HTON_NO_FLAGS };
|
||||
+#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
extern handlerton innobase_hton;
|
||||
@@ -147,6 +156,7 @@
|
||||
&example_hton,
|
||||
&archive_hton,
|
||||
&tina_hton,
|
||||
+ &sphinx_hton,
|
||||
&ndbcluster_hton,
|
||||
&federated_hton,
|
||||
&myisammrg_hton,
|
||||
@@ -345,6 +355,12 @@
|
||||
return new (alloc) ha_tina(table);
|
||||
return NULL;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ case DB_TYPE_SPHINX_DB:
|
||||
+ if (have_sphinx_db == SHOW_OPTION_YES)
|
||||
+ return new (alloc) ha_sphinx(table);
|
||||
+ return NULL;
|
||||
+#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
case DB_TYPE_NDBCLUSTER:
|
||||
if (have_ndbcluster == SHOW_OPTION_YES)
|
||||
diff -B -N -r -u mysql-5.0.22/sql/handler.h mysql-5.0.22.sx/sql/handler.h
|
||||
--- mysql-5.0.22/sql/handler.h 2006-05-25 10:56:55.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/handler.h 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -183,8 +183,9 @@
|
||||
DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB,
|
||||
DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER,
|
||||
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB,
|
||||
- DB_TYPE_FEDERATED_DB,
|
||||
+ DB_TYPE_FEDERATED_DB,
|
||||
DB_TYPE_BLACKHOLE_DB,
|
||||
+ DB_TYPE_SPHINX_DB,
|
||||
DB_TYPE_DEFAULT // Must be last
|
||||
};
|
||||
|
||||
diff -B -N -r -u mysql-5.0.22/sql/Makefile.am mysql-5.0.22.sx/sql/Makefile.am
|
||||
--- mysql-5.0.22/sql/Makefile.am 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/Makefile.am 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -66,6 +66,7 @@
|
||||
sql_array.h sql_cursor.h \
|
||||
examples/ha_example.h ha_archive.h \
|
||||
examples/ha_tina.h ha_blackhole.h \
|
||||
+ sphinx/ha_sphinx.h \
|
||||
ha_federated.h
|
||||
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
||||
item.cc item_sum.cc item_buff.cc item_func.cc \
|
||||
@@ -102,6 +103,7 @@
|
||||
sp_cache.cc parse_file.cc sql_trigger.cc \
|
||||
examples/ha_example.cc ha_archive.cc \
|
||||
examples/ha_tina.cc ha_blackhole.cc \
|
||||
+ sphinx/ha_sphinx.cc \
|
||||
ha_federated.cc
|
||||
|
||||
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
||||
diff -B -N -r -u mysql-5.0.22/sql/mysqld.cc mysql-5.0.22.sx/sql/mysqld.cc
|
||||
--- mysql-5.0.22/sql/mysqld.cc 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/mysqld.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -6420,6 +6420,11 @@
|
||||
#else
|
||||
have_csv_db= SHOW_OPTION_NO;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ have_sphinx_db= SHOW_OPTION_YES;
|
||||
+#else
|
||||
+ have_sphinx_db= SHOW_OPTION_NO;
|
||||
+#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
have_ndbcluster=SHOW_OPTION_DISABLED;
|
||||
#else
|
||||
@@ -7457,6 +7462,7 @@
|
||||
#undef have_example_db
|
||||
#undef have_archive_db
|
||||
#undef have_csv_db
|
||||
+#undef have_sphinx_db
|
||||
#undef have_federated_db
|
||||
#undef have_partition_db
|
||||
#undef have_blackhole_db
|
||||
@@ -7467,6 +7473,7 @@
|
||||
SHOW_COMP_OPTION have_example_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_archive_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_csv_db= SHOW_OPTION_NO;
|
||||
+SHOW_COMP_OPTION have_sphinx_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_federated_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_partition_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_blackhole_db= SHOW_OPTION_NO;
|
||||
diff -B -N -r -u mysql-5.0.22/sql/mysql_priv.h mysql-5.0.22.sx/sql/mysql_priv.h
|
||||
--- mysql-5.0.22/sql/mysql_priv.h 2006-05-25 10:56:43.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/mysql_priv.h 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -1279,6 +1279,12 @@
|
||||
#else
|
||||
extern SHOW_COMP_OPTION have_csv_db;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+extern handlerton sphinx_hton;
|
||||
+#define have_sphinx_db sphinx_hton.state
|
||||
+#else
|
||||
+extern SHOW_COMP_OPTION have_sphinx_db;
|
||||
+#endif
|
||||
#ifdef HAVE_FEDERATED_DB
|
||||
extern handlerton federated_hton;
|
||||
#define have_federated_db federated_hton.state
|
||||
diff -B -N -r -u mysql-5.0.22/sql/set_var.cc mysql-5.0.22.sx/sql/set_var.cc
|
||||
--- mysql-5.0.22/sql/set_var.cc 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/set_var.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -864,6 +864,7 @@
|
||||
{"have_compress", (char*) &have_compress, SHOW_HAVE},
|
||||
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
|
||||
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
|
||||
+ {"have_sphinx", (char*) &have_sphinx_db, SHOW_HAVE},
|
||||
{"have_dynamic_loading", (char*) &have_dlopen, SHOW_HAVE},
|
||||
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
|
||||
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
|
||||
diff -B -N -r -u mysql-5.0.22/sql/sql_lex.h mysql-5.0.22.sx/sql/sql_lex.h
|
||||
--- mysql-5.0.22/sql/sql_lex.h 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/sql_lex.h 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -58,6 +58,7 @@
|
||||
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
|
||||
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS,
|
||||
SQLCOM_SHOW_INNODB_STATUS, SQLCOM_SHOW_NDBCLUSTER_STATUS, SQLCOM_SHOW_MUTEX_STATUS,
|
||||
+ SQLCOM_SHOW_SPHINX_STATUS,
|
||||
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
|
||||
SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
|
||||
SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, SQLCOM_SHOW_TABLE_STATUS,
|
||||
diff -B -N -r -u mysql-5.0.22/sql/sql_parse.cc mysql-5.0.22.sx/sql/sql_parse.cc
|
||||
--- mysql-5.0.22/sql/sql_parse.cc 2006-05-25 10:56:41.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/sql_parse.cc 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -25,6 +25,9 @@
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+#endif
|
||||
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
#include "ha_ndbcluster.h"
|
||||
@@ -2722,6 +2725,15 @@
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ case SQLCOM_SHOW_SPHINX_STATUS:
|
||||
+ {
|
||||
+ if (check_global_access(thd, SUPER_ACL))
|
||||
+ goto error;
|
||||
+ res = sphinx_show_status(thd);
|
||||
+ break;
|
||||
+ }
|
||||
+#endif
|
||||
#ifdef HAVE_REPLICATION
|
||||
case SQLCOM_LOAD_MASTER_TABLE:
|
||||
{
|
||||
diff -B -N -r -u mysql-5.0.22/sql/sql_yacc.yy mysql-5.0.22.sx/sql/sql_yacc.yy
|
||||
--- mysql-5.0.22/sql/sql_yacc.yy 2006-05-25 10:56:43.000000000 +0200
|
||||
+++ mysql-5.0.22.sx/sql/sql_yacc.yy 2006-06-06 19:49:38.000000000 +0200
|
||||
@@ -6584,6 +6584,9 @@
|
||||
case DB_TYPE_INNODB:
|
||||
Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS;
|
||||
break;
|
||||
+ case DB_TYPE_SPHINX_DB:
|
||||
+ Lex->sql_command = SQLCOM_SHOW_SPHINX_STATUS;
|
||||
+ break;
|
||||
default:
|
||||
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "STATUS");
|
||||
YYABORT;
|
338
storage/sphinx/sphinx.5.0.37.diff
Normal file
338
storage/sphinx/sphinx.5.0.37.diff
Normal file
@ -0,0 +1,338 @@
|
||||
--- mysql-5.0.67/config/ac-macros/ha_sphinx.m4 1970-01-01 10:00:00.000000000 +1000
|
||||
+++ mysql-5.0.67-sphinx/config/ac-macros/ha_sphinx.m4 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -0,0 +1,30 @@
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+dnl Macro: MYSQL_CHECK_EXAMPLEDB
|
||||
+dnl Sets HAVE_SPHINX_DB if --with-sphinx-storage-engine is used
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+AC_DEFUN([MYSQL_CHECK_SPHINXDB], [
|
||||
+ AC_ARG_WITH([sphinx-storage-engine],
|
||||
+ [
|
||||
+ --with-sphinx-storage-engine
|
||||
+ Enable the Sphinx Storage Engine],
|
||||
+ [sphinxdb="$withval"],
|
||||
+ [sphinxdb=no])
|
||||
+ AC_MSG_CHECKING([for example storage engine])
|
||||
+
|
||||
+ case "$sphinxdb" in
|
||||
+ yes )
|
||||
+ AC_DEFINE([HAVE_SPHINX_DB], [1], [Builds Sphinx Engine])
|
||||
+ AC_MSG_RESULT([yes])
|
||||
+ [sphinxdb=yes]
|
||||
+ ;;
|
||||
+ * )
|
||||
+ AC_MSG_RESULT([no])
|
||||
+ [sphinxdb=no]
|
||||
+ ;;
|
||||
+ esac
|
||||
+
|
||||
+])
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+dnl END OF MYSQL_CHECK_EXAMPLE SECTION
|
||||
+dnl ---------------------------------------------------------------------------
|
||||
+
|
||||
--- mysql-5.0.67/configure.in 2008-08-04 23:19:07.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/configure.in 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -58,6 +58,7 @@
|
||||
sinclude(config/ac-macros/ha_berkeley.m4)
|
||||
sinclude(config/ac-macros/ha_blackhole.m4)
|
||||
sinclude(config/ac-macros/ha_example.m4)
|
||||
+sinclude(config/ac-macros/ha_sphinx.m4)
|
||||
sinclude(config/ac-macros/ha_federated.m4)
|
||||
sinclude(config/ac-macros/ha_innodb.m4)
|
||||
sinclude(config/ac-macros/ha_ndbcluster.m4)
|
||||
@@ -2625,6 +2626,7 @@
|
||||
MYSQL_CHECK_BDB
|
||||
MYSQL_CHECK_INNODB
|
||||
MYSQL_CHECK_EXAMPLEDB
|
||||
+MYSQL_CHECK_SPHINXDB
|
||||
MYSQL_CHECK_ARCHIVEDB
|
||||
MYSQL_CHECK_CSVDB
|
||||
MYSQL_CHECK_BLACKHOLEDB
|
||||
--- mysql-5.0.67/libmysqld/Makefile.am 2008-08-04 23:19:18.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/libmysqld/Makefile.am 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -29,6 +29,7 @@
|
||||
-I$(top_builddir)/include -I$(top_srcdir)/include \
|
||||
-I$(top_builddir)/sql -I$(top_srcdir)/sql \
|
||||
-I$(top_srcdir)/sql/examples \
|
||||
+ -I$(top_srcdir)/sql/sphinx \
|
||||
-I$(top_srcdir)/regex \
|
||||
$(openssl_includes) @ZLIB_INCLUDES@
|
||||
|
||||
@@ -39,6 +40,7 @@
|
||||
libmysqlsources = errmsg.c get_password.c libmysql.c client.c pack.c \
|
||||
my_time.c
|
||||
sqlexamplessources = ha_example.cc ha_tina.cc
|
||||
+sqlsphinxsources = ha_sphinx.cc
|
||||
|
||||
noinst_HEADERS = embedded_priv.h emb_qcache.h
|
||||
|
||||
@@ -67,7 +69,7 @@
|
||||
parse_file.cc sql_view.cc sql_trigger.cc my_decimal.cc \
|
||||
ha_blackhole.cc ha_archive.cc my_user.c
|
||||
|
||||
-libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources)
|
||||
+libmysqld_int_a_SOURCES= $(libmysqld_sources) $(libmysqlsources) $(sqlsources) $(sqlexamplessources) $(sqlsphinxsources)
|
||||
libmysqld_a_SOURCES=
|
||||
|
||||
# automake misses these
|
||||
@@ -147,12 +149,16 @@
|
||||
rm -f $$f; \
|
||||
@LN_CP_F@ $(top_srcdir)/sql/examples/$$f $$f; \
|
||||
done; \
|
||||
+ for f in $(sqlsphinxsources); do \
|
||||
+ rm -f $$f; \
|
||||
+ @LN_CP_F@ $(top_srcdir)/sql/sphinx/$$f $$f; \
|
||||
+ done; \
|
||||
rm -f client_settings.h; \
|
||||
@LN_CP_F@ $(top_srcdir)/libmysql/client_settings.h client_settings.h
|
||||
|
||||
|
||||
clean-local:
|
||||
- rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlexamplessources) | sed "s;\.lo;.c;g"` \
|
||||
+ rm -f `echo $(sqlsources) $(libmysqlsources) $(sqlexamplessources) $(sqlsphinxsources) | sed "s;\.lo;.c;g"` \
|
||||
$(top_srcdir)/linked_libmysqld_sources; \
|
||||
rm -f client_settings.h
|
||||
|
||||
--- mysql-5.0.67/sql/handler.cc 2008-08-04 23:20:04.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/handler.cc 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -77,6 +77,15 @@
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
HTON_NO_FLAGS };
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+extern handlerton sphinx_hton;
|
||||
+#else
|
||||
+handlerton sphinx_hton = { "SPHINX", SHOW_OPTION_NO, "SPHINX storage engine",
|
||||
+ DB_TYPE_SPHINX_DB, NULL, 0, 0, NULL, NULL,
|
||||
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
+ HTON_NO_FLAGS };
|
||||
+#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
extern handlerton innobase_hton;
|
||||
@@ -141,6 +150,7 @@
|
||||
&example_hton,
|
||||
&archive_hton,
|
||||
&tina_hton,
|
||||
+ &sphinx_hton,
|
||||
&ndbcluster_hton,
|
||||
&federated_hton,
|
||||
&myisammrg_hton,
|
||||
@@ -341,6 +351,12 @@
|
||||
return new (alloc) ha_tina(table);
|
||||
return NULL;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ case DB_TYPE_SPHINX_DB:
|
||||
+ if (have_sphinx_db == SHOW_OPTION_YES)
|
||||
+ return new (alloc) ha_sphinx(table);
|
||||
+ return NULL;
|
||||
+#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
case DB_TYPE_NDBCLUSTER:
|
||||
if (have_ndbcluster == SHOW_OPTION_YES)
|
||||
--- mysql-5.0.67/sql/handler.h 2008-08-04 23:20:04.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/handler.h 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -186,8 +186,9 @@
|
||||
DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB,
|
||||
DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER,
|
||||
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB,
|
||||
- DB_TYPE_FEDERATED_DB,
|
||||
+ DB_TYPE_FEDERATED_DB,
|
||||
DB_TYPE_BLACKHOLE_DB,
|
||||
+ DB_TYPE_SPHINX_DB,
|
||||
DB_TYPE_DEFAULT // Must be last
|
||||
};
|
||||
|
||||
--- mysql-5.0.67/sql/Makefile.am 2008-08-04 23:20:02.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/Makefile.am 2009-02-14 09:23:28.000000000 +1000
|
||||
@@ -68,6 +68,7 @@
|
||||
sql_array.h sql_cursor.h \
|
||||
examples/ha_example.h ha_archive.h \
|
||||
examples/ha_tina.h ha_blackhole.h \
|
||||
+ sphinx/ha_sphinx.h \
|
||||
ha_federated.h
|
||||
mysqld_SOURCES = sql_lex.cc sql_handler.cc \
|
||||
item.cc item_sum.cc item_buff.cc item_func.cc \
|
||||
@@ -105,6 +106,7 @@
|
||||
sp_cache.cc parse_file.cc sql_trigger.cc \
|
||||
examples/ha_example.cc ha_archive.cc \
|
||||
examples/ha_tina.cc ha_blackhole.cc \
|
||||
+ sphinx/ha_sphinx.cc \
|
||||
ha_federated.cc
|
||||
|
||||
gen_lex_hash_SOURCES = gen_lex_hash.cc
|
||||
@@ -174,6 +176,10 @@
|
||||
udf_example_la_SOURCES= udf_example.c
|
||||
udf_example_la_LDFLAGS= -module -rpath $(pkglibdir)
|
||||
|
||||
+pkglib_LTLIBRARIES = sphinx/sphinx.la
|
||||
+sphinx_sphinx_la_SOURCES = sphinx/snippets_udf.cc
|
||||
+sphinx_sphinx_la_LDFLAGS = -module
|
||||
+
|
||||
|
||||
# Don't update the files from bitkeeper
|
||||
%::SCCS/s.%
|
||||
--- mysql-5.0.67/sql/mysqld.cc 2008-08-04 23:20:07.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/mysqld.cc 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -36,6 +36,10 @@
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+#endif
|
||||
+
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#define OPT_INNODB_DEFAULT 1
|
||||
#else
|
||||
@@ -6633,6 +6637,13 @@
|
||||
{"Threads_running", (char*) &thread_running, SHOW_INT_CONST},
|
||||
{"Uptime", (char*) 0, SHOW_STARTTIME},
|
||||
{"Uptime_since_flush_status",(char*) 0, SHOW_FLUSHTIME},
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ {"sphinx_total", (char *)sphinx_showfunc_total, SHOW_SPHINX_FUNC},
|
||||
+ {"sphinx_total_found", (char *)sphinx_showfunc_total_found, SHOW_SPHINX_FUNC},
|
||||
+ {"sphinx_time", (char *)sphinx_showfunc_time, SHOW_SPHINX_FUNC},
|
||||
+ {"sphinx_word_count", (char *)sphinx_showfunc_word_count, SHOW_SPHINX_FUNC},
|
||||
+ {"sphinx_words", (char *)sphinx_showfunc_words, SHOW_SPHINX_FUNC},
|
||||
+#endif
|
||||
{NullS, NullS, SHOW_LONG}
|
||||
};
|
||||
|
||||
@@ -6875,6 +6886,11 @@
|
||||
#else
|
||||
have_csv_db= SHOW_OPTION_NO;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ have_sphinx_db= SHOW_OPTION_YES;
|
||||
+#else
|
||||
+ have_sphinx_db= SHOW_OPTION_NO;
|
||||
+#endif
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
have_ndbcluster=SHOW_OPTION_DISABLED;
|
||||
#else
|
||||
@@ -7983,6 +7999,7 @@
|
||||
#undef have_example_db
|
||||
#undef have_archive_db
|
||||
#undef have_csv_db
|
||||
+#undef have_sphinx_db
|
||||
#undef have_federated_db
|
||||
#undef have_partition_db
|
||||
#undef have_blackhole_db
|
||||
@@ -7993,6 +8010,7 @@
|
||||
SHOW_COMP_OPTION have_example_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_archive_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_csv_db= SHOW_OPTION_NO;
|
||||
+SHOW_COMP_OPTION have_sphinx_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_federated_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_partition_db= SHOW_OPTION_NO;
|
||||
SHOW_COMP_OPTION have_blackhole_db= SHOW_OPTION_NO;
|
||||
--- mysql-5.0.67/sql/mysql_priv.h 2008-08-04 23:20:07.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/mysql_priv.h 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -1439,6 +1439,12 @@
|
||||
#else
|
||||
extern SHOW_COMP_OPTION have_csv_db;
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+extern handlerton sphinx_hton;
|
||||
+#define have_sphinx_db sphinx_hton.state
|
||||
+#else
|
||||
+extern SHOW_COMP_OPTION have_sphinx_db;
|
||||
+#endif
|
||||
#ifdef HAVE_FEDERATED_DB
|
||||
extern handlerton federated_hton;
|
||||
#define have_federated_db federated_hton.state
|
||||
--- mysql-5.0.67/sql/set_var.cc 2008-08-04 23:20:08.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/set_var.cc 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -888,6 +888,7 @@
|
||||
{"have_compress", (char*) &have_compress, SHOW_HAVE},
|
||||
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
|
||||
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
|
||||
+ {"have_sphinx", (char*) &have_sphinx_db, SHOW_HAVE},
|
||||
{"have_dynamic_loading", (char*) &have_dlopen, SHOW_HAVE},
|
||||
{"have_example_engine", (char*) &have_example_db, SHOW_HAVE},
|
||||
{"have_federated_engine", (char*) &have_federated_db, SHOW_HAVE},
|
||||
--- mysql-5.0.67/sql/sql_lex.h 2008-08-04 23:20:10.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/sql_lex.h 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -57,6 +57,7 @@
|
||||
SQLCOM_SHOW_DATABASES, SQLCOM_SHOW_TABLES, SQLCOM_SHOW_FIELDS,
|
||||
SQLCOM_SHOW_KEYS, SQLCOM_SHOW_VARIABLES, SQLCOM_SHOW_LOGS, SQLCOM_SHOW_STATUS,
|
||||
SQLCOM_SHOW_INNODB_STATUS, SQLCOM_SHOW_NDBCLUSTER_STATUS, SQLCOM_SHOW_MUTEX_STATUS,
|
||||
+ SQLCOM_SHOW_SPHINX_STATUS,
|
||||
SQLCOM_SHOW_PROCESSLIST, SQLCOM_SHOW_MASTER_STAT, SQLCOM_SHOW_SLAVE_STAT,
|
||||
SQLCOM_SHOW_GRANTS, SQLCOM_SHOW_CREATE, SQLCOM_SHOW_CHARSETS,
|
||||
SQLCOM_SHOW_COLLATIONS, SQLCOM_SHOW_CREATE_DB, SQLCOM_SHOW_TABLE_STATUS,
|
||||
--- mysql-5.0.67/sql/sql_parse.cc 2008-08-04 23:20:10.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/sql_parse.cc 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -24,6 +24,9 @@
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
#include "ha_innodb.h"
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+#include "sphinx/ha_sphinx.h"
|
||||
+#endif
|
||||
|
||||
#ifdef HAVE_NDBCLUSTER_DB
|
||||
#include "ha_ndbcluster.h"
|
||||
@@ -3006,6 +3009,15 @@
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ case SQLCOM_SHOW_SPHINX_STATUS:
|
||||
+ {
|
||||
+ if (check_global_access(thd, SUPER_ACL))
|
||||
+ goto error;
|
||||
+ res = sphinx_show_status(thd);
|
||||
+ break;
|
||||
+ }
|
||||
+#endif
|
||||
#ifdef HAVE_REPLICATION
|
||||
case SQLCOM_LOAD_MASTER_TABLE:
|
||||
{
|
||||
--- mysql-5.0.67/sql/sql_yacc.yy 2008-08-04 23:20:12.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/sql_yacc.yy 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -7393,6 +7393,9 @@
|
||||
case DB_TYPE_INNODB:
|
||||
Lex->sql_command = SQLCOM_SHOW_INNODB_STATUS;
|
||||
break;
|
||||
+ case DB_TYPE_SPHINX_DB:
|
||||
+ Lex->sql_command = SQLCOM_SHOW_SPHINX_STATUS;
|
||||
+ break;
|
||||
default:
|
||||
my_error(ER_NOT_SUPPORTED_YET, MYF(0), "STATUS");
|
||||
MYSQL_YYABORT;
|
||||
--- mysql-5.0.67/sql/structs.h 2008-08-04 23:20:12.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/structs.h 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -188,6 +188,9 @@
|
||||
SHOW_SSL_CTX_SESS_TIMEOUTS, SHOW_SSL_CTX_SESS_CACHE_FULL,
|
||||
SHOW_SSL_GET_CIPHER_LIST,
|
||||
#endif /* HAVE_OPENSSL */
|
||||
+#ifdef HAVE_SPHINX_DB
|
||||
+ SHOW_SPHINX_FUNC,
|
||||
+#endif
|
||||
SHOW_NET_COMPRESSION,
|
||||
SHOW_RPL_STATUS, SHOW_SLAVE_RUNNING, SHOW_SLAVE_RETRIED_TRANS,
|
||||
SHOW_KEY_CACHE_LONG, SHOW_KEY_CACHE_CONST_LONG, SHOW_KEY_CACHE_LONGLONG,
|
||||
--- mysql-5.0.67/sql/sql_show.cc 2008-08-04 23:20:11.000000000 +1100
|
||||
+++ mysql-5.0.67-sphinx/sql/sql_show.cc 2009-02-14 09:15:48.000000000 +1000
|
||||
@@ -1473,6 +1473,16 @@
|
||||
value= (char*) ((sys_var*) value)->value_ptr(thd, value_type,
|
||||
&null_lex_str);
|
||||
}
|
||||
+ #ifdef HAVE_SPHINX_DB
|
||||
+ else if (show_type == SHOW_SPHINX_FUNC)
|
||||
+ {
|
||||
+ SHOW_VAR var;
|
||||
+ ((int (*)(THD *, SHOW_VAR *, char *))value)(thd, &var, buff);
|
||||
+
|
||||
+ value = var.value;
|
||||
+ show_type = var.type;
|
||||
+ }
|
||||
+ #endif /* HAVE_SPHINX_DB */
|
||||
|
||||
pos= end= buff;
|
||||
switch (show_type) {
|
Loading…
x
Reference in New Issue
Block a user