{"id":4775,"date":"2012-03-21T15:57:59","date_gmt":"2012-03-21T13:57:59","guid":{"rendered":"http:\/\/code.openark.org\/blog\/?p=4775"},"modified":"2012-03-21T15:59:30","modified_gmt":"2012-03-21T13:59:30","slug":"sphinx-sphinx_snippets-mysql-5-5","status":"publish","type":"post","link":"https:\/\/code.openark.org\/blog\/mysql\/sphinx-sphinx_snippets-mysql-5-5","title":{"rendered":"sphinx, sphinx_snippets() &#038; MySQL 5.5"},"content":{"rendered":"<p>I&#8217;ve written a patch which completes Sphinx&#8217;s integration with MySQL <strong>5.5<\/strong>.<\/p>\n<p>Up until a couple months ago, Sphinx would not compile with MySQL <strong>5.5<\/strong> at all. This is, thankfully, resolved as of Sphinx <strong>2.0.3<\/strong>.<\/p>\n<p>However, to my disdain, I&#8217;ve found out that it only partially work: the <a href=\"http:\/\/sphinxsearch.com\/docs\/manual-2.0.4.html#sphinxse-snippets\">sphinx_snippets()<\/a> user defined function is not included within the plugin library. After some quick poking I discovered that it was not added to the build, and when added, would not compile.<\/p>\n<p>I rely on <strong>sphinx_snippets()<\/strong> quite a lot, and like it. Eventually I wrote the fix to the <strong>snippets_udf.cc<\/strong> which allows it to run in a MySQL <strong>5.5<\/strong> server.<\/p>\n<p>Here are the changes for the <strong>2.0.4<\/strong> version of Sphinx:<\/p>\n<ul>\n<li><a href=\"http:\/\/code.openark.org\/blog\/wp-content\/uploads\/2012\/03\/snippets_udf.cc\">snippets_udf.cc<\/a><\/li>\n<li><a href=\"http:\/\/code.openark.org\/blog\/wp-content\/uploads\/2012\/03\/CMakeLists.txt\">CMakeLists.txt<\/a><\/li>\n<\/ul>\n<p>Replace your <strong>2.0.4<\/strong> files with these two and get on compiling your MySQL server.<\/p>\n<h4>Compilation guide<\/h4>\n<p>For completeness, here&#8217;s how to compile Percona Server <strong>5.5<\/strong> with Sphinx <strong>2.0.4<\/strong> including the above patches:<!--more--><\/p>\n<p>Get <a href=\"http:\/\/www.percona.com\/downloads\/Percona-Server-5.5\/LATEST\/\">Percona Server source code<\/a> and <a href=\"http:\/\/sphinxsearch.com\/downloads\/release\/\">Sphinx Search source code<\/a>.<\/p>\n<p>I&#8217;ll be using Percona Server <strong>5.5.21-25.0<\/strong>. I use <strong>\/data\/tmp\/mysql<\/strong> as compilation path, and install MySQL on <strong>\/usr\/local\/mysql55<\/strong>.<\/p>\n<blockquote>\n<pre>mkdir -p \/data\/tmp\/mysql\r\ncd \/data\/tmp\/mysql\r\ntar xzfv Percona-Server-5.5.21-rel25.0.tar.gz\r\ntar xzfv sphinx-2.0.4-release.tar.gz\r\ncd Percona-Server-5.5.21-rel25.0\/\r\ncp -R \/data\/tmp\/mysql\/sphinx-2.0.4-release\/mysqlse storage\/sphinx<\/pre>\n<\/blockquote>\n<p>Overwrite with patched files included in this post:<\/p>\n<blockquote>\n<pre>cp \/tmp\/CMakeLists.txt storage\/sphinx\/CMakeLists.txt\r\ncp \/tmp\/snippets_udf.cc storage\/sphinx\/snippets_udf.cc<\/pre>\n<\/blockquote>\n<p>Build MySQL:<\/p>\n<blockquote>\n<pre>sh BUILD\/autorun.sh\r\n.\/configure --with-plugin-sphinx --prefix=\/usr\/local\/mysql55\r\nmake\r\nsudo make install<\/pre>\n<\/blockquote>\n<p>Install the mysql55 service:<\/p>\n<blockquote>\n<pre>cd \/usr\/local\/mysql55\r\nsudo cp support-files\/mysql.server \/etc\/init.d\/mysql55<\/pre>\n<\/blockquote>\n<p>In <strong>\/etc\/bash.bashrc<\/strong>, add:<\/p>\n<blockquote>\n<pre>export PATH=\/usr\/local\/mysql55\/bin:${PATH}<\/pre>\n<\/blockquote>\n<p>Start MySQL:<\/p>\n<blockquote>\n<pre>sudo service mysql55 start<\/pre>\n<\/blockquote>\n<p>Login to MySQL as an administrato (typically <strong>root<\/strong>) and install Sphinx:<\/p>\n<blockquote>\n<pre>mysql&gt; INSTALL PLUGIN sphinx SONAME 'ha_sphinx.so';\r\nmysql&gt; CREATE FUNCTION sphinx_snippets RETURNS STRING SONAME 'ha_sphinx.so';<\/pre>\n<\/blockquote>\n<h4>Notes<\/h4>\n<p>See also <a href=\"http:\/\/sphinxsearch.com\/bugs\/view.php?id=1090\">http:\/\/sphinxsearch.com\/bugs\/view.php?id=1090<\/a> and <a href=\"http:\/\/sphinxsearch.com\/forum\/view.html?id=8982\">http:\/\/sphinxsearch.com\/forum\/view.html?id=8982<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve written a patch which completes Sphinx&#8217;s integration with MySQL 5.5. Up until a couple months ago, Sphinx would not compile with MySQL 5.5 at all. This is, thankfully, resolved as of Sphinx 2.0.3. However, to my disdain, I&#8217;ve found out that it only partially work: the sphinx_snippets() user defined function is not included within [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[5],"tags":[120,57,44],"class_list":["post-4775","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-development","tag-open-source","tag-sphinx"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bZZp-1f1","_links":{"self":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/4775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/comments?post=4775"}],"version-history":[{"count":22,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/4775\/revisions"}],"predecessor-version":[{"id":4801,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/4775\/revisions\/4801"}],"wp:attachment":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/media?parent=4775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/categories?post=4775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/tags?post=4775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}