[Commits] bzr commit into Mariadb 5.2, with Maria 2.0:maria/5.2 branch (knielsen:2822)

knielsen at knielsen-hq.org knielsen at knielsen-hq.org
Fri Jul 9 15:10:51 EEST 2010


#At lp:maria/5.2

 2822 knielsen at knielsen-hq.org	2010-07-09
      Apply Serg's fixes for SphinxSE.
      modified:
        storage/sphinx/Makefile.am
        storage/sphinx/ha_sphinx.cc
        storage/sphinx/ha_sphinx.h

=== modified file 'storage/sphinx/Makefile.am'
--- a/storage/sphinx/Makefile.am	2010-07-03 06:51:52 +0000
+++ b/storage/sphinx/Makefile.am	2010-07-09 12:10:49 +0000
@@ -25,12 +25,8 @@ INCLUDES =              -I$(top_srcdir)/
 			-I$(top_srcdir)/regex \
 			-I$(top_srcdir)/sql \
                         -I$(srcdir)
-WRAPLIBS=
 
-LDADD =
-
-DEFS= @DEFS@ \
-      -D_REENTRANT -D_PTHREADS -DENGINE -DSTORAGE_ENGINE -DMYSQL_SERVER
+DEFS= @DEFS@ -D_REENTRANT -D_PTHREADS -DMYSQL_SERVER
 
 noinst_HEADERS =	ha_sphinx.h
 
@@ -44,8 +40,8 @@ ha_sphinx_la_CFLAGS =	$(AM_CFLAGS) -DMYS
 ha_sphinx_la_SOURCES =	ha_sphinx.cc
 
 sphinx_la_LDFLAGS = -module
-sphinx_la_CXXFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-sphinx_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+sphinx_la_CXXFLAGS = $(AM_CFLAGS)
+sphinx_la_CFLAGS = $(AM_CFLAGS)
 sphinx_la_SOURCES = snippets_udf.cc
 
 EXTRA_LIBRARIES =	libsphinx.a

=== modified file 'storage/sphinx/ha_sphinx.cc'
--- a/storage/sphinx/ha_sphinx.cc	2010-07-01 11:16:48 +0000
+++ b/storage/sphinx/ha_sphinx.cc	2010-07-09 12:10:49 +0000
@@ -66,6 +66,10 @@
 #define UNALIGNED_RAM_ACCESS 1
 #endif
 
+#if MYSQL_VERSION_ID<50100
+#define thd_ha_data(X,Y) (X)->ha_data[sphinx_hton.slot]
+#define ha_thd()         current_thd
+#endif // <50100
 
 #if UNALIGNED_RAM_ACCESS
 
@@ -656,6 +660,7 @@ static int sphinx_init_func ( void * p )
 		hton->show_status		= sphinx_show_status;
 		hton->panic				= sphinx_panic;
 		hton->flags				= HTON_CAN_RECREATE;
+		sphinx_hton_ptr = hton;
 		#endif
 	}
 	SPH_RET(0);
@@ -1134,7 +1139,6 @@ static int free_share ( CSphSEShare * pS
 #if MYSQL_VERSION_ID>50100
 static handler * sphinx_create_handler ( handlerton * hton, TABLE_SHARE * table, MEM_ROOT * mem_root )
 {
-	sphinx_hton_ptr = hton;
 	return new ( mem_root ) ha_sphinx ( hton, table );
 }
 #endif
@@ -1929,8 +1933,6 @@ ha_sphinx::ha_sphinx ( handlerton * hton
 	, m_dUnboundFields ( NULL )
 {
 	SPH_ENTER_METHOD();
-	if ( current_thd )
-		current_thd->variables.engine_condition_pushdown = true;
 	SPH_VOID_RET();
 }
 
@@ -1960,11 +1962,7 @@ int ha_sphinx::open ( const char * name,
 
 	thr_lock_data_init ( &m_pShare->m_tLock, &m_tLock, NULL );
 
-	#if MYSQL_VERSION_ID>50100
 	*thd_ha_data ( table->in_use, ht ) = NULL;
-	#else
-	table->in_use->ha_data [ sphinx_hton.slot ] = NULL;
-	#endif
 
 	SPH_RET(0);
 }
@@ -2410,11 +2408,7 @@ CSphSEThreadData * ha_sphinx::GetTls()
 {
 	// where do we store that pointer in today's version?
 	CSphSEThreadData ** ppTls;
-#if MYSQL_VERSION_ID>50100
-	ppTls = (CSphSEThreadData**) thd_ha_data ( table->in_use, ht );
-#else
-	ppTls = (CSphSEThreadData**) &current_thd->ha_data[sphinx_hton.slot];
-#endif // >50100
+	ppTls = (CSphSEThreadData**) thd_ha_data ( ha_thd(), ht );
 
 	// allocate if needed
 	if ( !*ppTls )
@@ -2997,139 +2991,73 @@ int ha_sphinx::create ( const char * nam
 #define SHOW_VAR_FUNC_BUFF_SIZE 1024
 #endif
 
-CSphSEStats * sphinx_get_stats ( THD * thd, SHOW_VAR * out )
+static int sphinx_showfunc ( THD * thd, SHOW_VAR * out, char * sBuffer )
 {
-#if MYSQL_VERSION_ID>50100	
-	if ( sphinx_hton_ptr )
-	{
-		CSphSEThreadData *pTls = (CSphSEThreadData *) *thd_ha_data ( thd, sphinx_hton_ptr );
-
-		if ( pTls && pTls->m_bStats )
-			return &pTls->m_tStats;
-	}
-#else
-	CSphSEThreadData *pTls = (CSphSEThreadData *) thd->ha_data[sphinx_hton.slot];
-	if ( pTls && pTls->m_bStats )
-		return &pTls->m_tStats;
-#endif
-	
-	out->type = SHOW_CHAR;
-	out->value = "";
+	CSphSEThreadData *pTls = (CSphSEThreadData *) *thd_ha_data ( thd, sphinx_hton_ptr );
+	CSphSEStats * pStats = ( pTls && pTls->m_bStats ) ? &pTls->m_tStats : 0;
+    SHOW_VAR *array = (SHOW_VAR*)thd_alloc(thd, sizeof(SHOW_VAR)*7);
+    out->type = SHOW_ARRAY;
+    out->value = (char*)array;
+    if (pStats)
+    {
+        array[0].name = "total";
+        array[0].type = SHOW_INT;
+        array[0].value = (char *) &pStats->m_iMatchesTotal;
+        array[1].name = "total_found";
+        array[1].type = SHOW_INT;
+        array[1].value = (char *) &pStats->m_iMatchesFound;
+        array[2].name = "time";
+        array[2].type = SHOW_INT;
+        array[2].value = (char *) &pStats->m_iQueryMsec;
+        array[3].name = "word_count";
+        array[3].type = SHOW_INT;
+        array[3].value = (char *) &pStats->m_iWords;
+        array[4].name = "error";
+        array[4].type = SHOW_CHAR;
+        array[4].value = (char *) &pStats->m_sLastMessage;
+        array[5].name = "words";
+        array[5].type = SHOW_CHAR;
+        array[5].value = sBuffer;
+        sBuffer[0] = 0;
+
+        if ( pStats->m_iWords )
+        {
+            uint uBuffLen = 0;
+        
+            // the following is partially based on code in sphinx_show_status()
+            for ( int i=0; i<pStats->m_iWords; i++ )
+            {
+                CSphSEWordStats & tWord = pStats->m_dWords[i];
+                uBuffLen = my_snprintf ( sBuffer, SHOW_VAR_FUNC_BUFF_SIZE, "%s%s:%d:%d ", sBuffer,
+                    tWord.m_sWord, tWord.m_iDocs, tWord.m_iHits );
+            }
+
+            if ( uBuffLen > 0 )
+            {
+                // trim last space
+                sBuffer [ --uBuffLen ] = 0;
+            
+                if ( pTls->m_pQueryCharset )
+                {
+                    // String::c_ptr() will nul-terminate the buffer.
+                    //
+                    // NOTE: It's not entirely clear whether this conversion is necessary at all.
+                    
+                    String sConvert;
+                    uint iErrors;
+                    sConvert.copy ( sBuffer, uBuffLen, pTls->m_pQueryCharset, system_charset_info, &iErrors );
+                    memcpy ( sBuffer, sConvert.c_ptr(), sConvert.length() + 1 );
+                }
+            }
+        }
+        
+        array[6].name = 0; // terminate the array
+    }
+    else
+      array[0].name = 0;
 	return 0;
 }
 
-int sphinx_showfunc_total ( THD * thd, SHOW_VAR * out, char * )
-{
-	CSphSEStats * pStats = sphinx_get_stats ( thd, out );
-	if ( pStats )
-	{
-		out->type = SHOW_INT;
-		out->value = (char *) &pStats->m_iMatchesTotal;
-	}
-	return 0;
-}
-
-int sphinx_showfunc_total_found ( THD * thd, SHOW_VAR * out, char * )
-{
-	CSphSEStats * pStats = sphinx_get_stats ( thd, out );
-	if ( pStats )
-	{
-		out->type = SHOW_INT;
-		out->value = (char *) &pStats->m_iMatchesFound;
-	}
-	return 0;
-}
-
-int sphinx_showfunc_time ( THD * thd, SHOW_VAR * out, char * )
-{
-	CSphSEStats * pStats = sphinx_get_stats ( thd, out );
-	if ( pStats )
-	{
-		out->type = SHOW_INT;
-		out->value = (char *) &pStats->m_iQueryMsec;
-	}
-	return 0;
-}
-
-int sphinx_showfunc_word_count ( THD * thd, SHOW_VAR * out, char * )
-{
-	CSphSEStats * pStats = sphinx_get_stats ( thd, out );
-	if ( pStats )
-	{
-		out->type = SHOW_INT;
-		out->value = (char *) &pStats->m_iWords;
-	}
-	return 0;
-}
-
-int sphinx_showfunc_words ( THD * thd, SHOW_VAR * out, char * sBuffer )
-{
-#if MYSQL_VERSION_ID>50100	
-	if ( sphinx_hton_ptr )
-	{
-		CSphSEThreadData * pTls = (CSphSEThreadData *) *thd_ha_data ( thd, sphinx_hton_ptr );
-#else
-	{
-		CSphSEThreadData * pTls = (CSphSEThreadData *) thd->ha_data[sphinx_hton.slot];
-#endif		
-		if ( pTls && pTls->m_bStats )
-		{
-			CSphSEStats * pStats = &pTls->m_tStats;
-			if ( pStats && pStats->m_iWords )
-			{
-				uint uBuffLen = 0;
-			
-				out->type = SHOW_CHAR;
-				out->value = sBuffer;
-				
-				// the following is partially based on code in sphinx_show_status()
-				sBuffer[0] = 0;
-				for ( int i=0; i<pStats->m_iWords; i++ )
-				{
-					CSphSEWordStats & tWord = pStats->m_dWords[i];
-					uBuffLen = my_snprintf ( sBuffer, SHOW_VAR_FUNC_BUFF_SIZE, "%s%s:%d:%d ", sBuffer,
-						tWord.m_sWord, tWord.m_iDocs, tWord.m_iHits );
-				}
-
-				if ( uBuffLen > 0 )
-				{
-					// trim last space
-					sBuffer [ --uBuffLen ] = 0;
-				
-					if ( pTls->m_pQueryCharset )
-					{
-						// String::c_ptr() will nul-terminate the buffer.
-						//
-						// NOTE: It's not entirely clear whether this conversion is necessary at all.
-						
-						String sConvert;
-						uint iErrors;
-						sConvert.copy ( sBuffer, uBuffLen, pTls->m_pQueryCharset, system_charset_info, &iErrors );
-						memcpy ( sBuffer, sConvert.c_ptr(), sConvert.length() + 1 );
-					}
-				}
-
-				return 0;
-			}
-		}
-	}
-
-	out->type = SHOW_CHAR;
-	out->value = "";
-	return 0;
-}
-
-int sphinx_showfunc_error ( THD * thd, SHOW_VAR * out, char * )
-{
-	CSphSEStats * pStats = sphinx_get_stats ( thd, out );
-	if ( pStats && pStats->m_bLastError )
-	{
-		out->type = SHOW_CHAR;
-		out->value = pStats->m_sLastMessage;
-	}
-	return 0;
-}
-	
 #if MYSQL_VERSION_ID>50100
 struct st_mysql_storage_engine sphinx_storage_engine =
 {
@@ -3138,12 +3066,7 @@ struct st_mysql_storage_engine sphinx_st
 
 struct st_mysql_show_var sphinx_status_vars[] =
 {
-	{"sphinx_total",		(char *)sphinx_showfunc_total,			SHOW_FUNC},
-	{"sphinx_total_found",	(char *)sphinx_showfunc_total_found,	SHOW_FUNC},
-	{"sphinx_time",			(char *)sphinx_showfunc_time,			SHOW_FUNC},
-	{"sphinx_word_count",	(char *)sphinx_showfunc_word_count,		SHOW_FUNC},
-	{"sphinx_words",		(char *)sphinx_showfunc_words,			SHOW_FUNC},
-	{"sphinx_error",		(char *)sphinx_showfunc_error,			SHOW_FUNC},
+	{"sphinx",     (char *)sphinx_showfunc,      			SHOW_FUNC},
 	{0, 0, (enum_mysql_show_type)0}
 };
 
@@ -3165,6 +3088,7 @@ mysql_declare_plugin(sphinx)
 }
 mysql_declare_plugin_end;
 
+#ifdef maria_declare_plugin
 maria_declare_plugin(sphinx)
 {
 	MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -3179,9 +3103,10 @@ maria_declare_plugin(sphinx)
 	sphinx_status_vars,
 	NULL,
 	"0.1", // string version
-	MariaDB_PLUGIN_MATURITY_STABLE
+	MariaDB_PLUGIN_MATURITY_EXPERIMENTAL
 }
 maria_declare_plugin_end;
+#endif
 
 #endif // >50100
 

=== modified file 'storage/sphinx/ha_sphinx.h'
--- a/storage/sphinx/ha_sphinx.h	2010-05-14 22:23:57 +0000
+++ b/storage/sphinx/ha_sphinx.h	2010-07-09 12:10:49 +0000
@@ -153,12 +153,6 @@ private:
 bool sphinx_show_status ( THD * thd );
 #endif
 
-int sphinx_showfunc_total_found ( THD *, SHOW_VAR *, char * );
-int sphinx_showfunc_total ( THD *, SHOW_VAR *, char * );
-int sphinx_showfunc_time ( THD *, SHOW_VAR *, char * );
-int sphinx_showfunc_word_count ( THD *, SHOW_VAR *, char * );
-int sphinx_showfunc_words ( THD *, SHOW_VAR *, char * );
-
 //
 // $Id: ha_sphinx.h 1428 2008-09-05 18:06:30Z xale $
 //



More information about the commits mailing list