[Rt-commit] rt branch, 4.0/mysql-fts, created. rt-4.0.0-198-g7d8b153

Ruslan Zakirov ruz at bestpractical.com
Tue May 3 16:59:53 EDT 2011


The branch, 4.0/mysql-fts has been created
        at  7d8b153e6f84b2f4e776bd1941df6fe290cc46f1 (commit)

- Log -----------------------------------------------------------------
commit b2ca5f26b83639f7b780fb3bd8b61e4c5980f4a0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue May 3 22:02:05 2011 +0400

    mysql 5.1 has no 'have_sphinx' variable
    
    SphinxSE for 5.1 is a plugin without patch. Have_sphinx variable
    is not added. Instead information schema should be used for detection.

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 3bc78f0..dab3942 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -343,7 +343,15 @@ else {
 sub check_sphinx {
     my $dbh = $RT::Handle->dbh;
     my $sphinx = ($dbh->selectrow_array("show variables like 'have_sphinx'"))[1];
-    unless ( lc $sphinx eq 'yes' ) {
+    unless ( $sphinx ) {
+        local $dbh->{'PrintError'} = 0;
+        local $dbh->{'RaiseError'} = 0;
+        $sphinx = ($dbh->selectrow_array(
+            "select 'yes' from INFORMATION_SCHEMA.PLUGINS where PLUGIN_NAME = 'sphinx' AND PLUGIN_STATUS='active'"
+        ))[0];
+    }
+
+    unless ( lc($sphinx||'') eq 'yes' ) {
         print STDERR <<EOT;
 
 Your Mysql server has not been compiled with the Sphinx storage engine

commit 39f03a2a20194f3bb70e6e67a72ca48dbca882e1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:19:10 2011 +0400

    Sphinx restricts id to unisgned int, newer versions throw error

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index dab3942..4e92c74 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -151,7 +151,7 @@ if ( $DB{'type'} eq 'mysql' ) {
 
     my $schema = <<END;
 CREATE TABLE $table (
-    id     INTEGER NOT NULL,
+    id     INTEGER UNSIGNED NOT NULL,
     weight INTEGER NOT NULL,
     $DEFAULT{'column'}  VARCHAR(3072) NOT NULL,
     INDEX($DEFAULT{'column'})

commit d93045d138fa908ae13ee1293a7e9458e0cc8542
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:21:29 2011 +0400

    host/port are not generic methods, authority is

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 4e92c74..dd711ff 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -164,8 +164,7 @@ END
 
     require URI;
     my $urlo = URI->new( $url );
-    my $host  = $urlo->host;
-    my $port  = $urlo->port;
+    my ($host, $port)  = split /:/, $urlo->authority;
     my $index = $urlo->path;
 
     my $var_path = RT->var_path;

commit af90bde1a96cc0f40630d2a5a608b321a4ed6b2c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:22:13 2011 +0400

    get rid of 3.999-ish calls and DB schema

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index dd711ff..0746cc1 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -167,13 +167,13 @@ END
     my ($host, $port)  = split /:/, $urlo->authority;
     my $index = $urlo->path;
 
-    my $var_path = RT->var_path;
+    my $var_path = $RT::VarPath;
 
     my %sphinx_conf = ();
-    $sphinx_conf{'host'} = RT->config->get('DatabaseHost');
-    $sphinx_conf{'db'}   = RT->config->get('DatabaseName');
-    $sphinx_conf{'user'} = RT->config->get('DatabaseUser');
-    $sphinx_conf{'pass'} = RT->config->get('DatabasePassword');
+    $sphinx_conf{'host'} = RT->Config->Get('DatabaseHost');
+    $sphinx_conf{'db'}   = RT->Config->Get('DatabaseName');
+    $sphinx_conf{'user'} = RT->Config->Get('DatabaseUser');
+    $sphinx_conf{'pass'} = RT->Config->Get('DatabasePassword');
 
     print <<END
 
@@ -191,10 +191,10 @@ source rt {
     sql_pass        = $sphinx_conf{'pass'}
 
     sql_query       = \
-        SELECT a.id, a.content FROM Attachments a
-        JOIN Transactions txn ON a.transaction_id = txn.id AND txn.object_type = 'RT::Model::Ticket' \
-        JOIN Tickets t ON txn.object_id = t.id \
-        WHERE a.content_type = 'text/plain' AND t.Status != 'deleted'
+        SELECT a.id, a.content FROM Attachments a \
+        JOIN Transactions txn ON a.TransactionId = txn.id AND txn.ObjectType = 'RT::Ticket' \
+        JOIN Tickets t ON txn.ObjectId = t.id \
+        WHERE a.ContentType = 'text/plain' AND t.Status != 'deleted'
 
     sql_query_info  = SELECT * FROM Attachments WHERE id=\$id
 }

commit 937048032ab17743fafec3a6fe1b2eeb3dcade5c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:34:09 2011 +0400

    cleanup sphinx.conf we output

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 0746cc1..d6780ea 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -166,6 +166,7 @@ END
     my $urlo = URI->new( $url );
     my ($host, $port)  = split /:/, $urlo->authority;
     my $index = $urlo->path;
+    $index =~ s{^/+}{};
 
     my $var_path = $RT::VarPath;
 
@@ -190,16 +191,16 @@ source rt {
     sql_user        = $sphinx_conf{'user'}
     sql_pass        = $sphinx_conf{'pass'}
 
-    sql_query       = \
-        SELECT a.id, a.content FROM Attachments a \
-        JOIN Transactions txn ON a.TransactionId = txn.id AND txn.ObjectType = 'RT::Ticket' \
-        JOIN Tickets t ON txn.ObjectId = t.id \
+    sql_query       = \\
+        SELECT a.id, a.content FROM Attachments a \\
+        JOIN Transactions txn ON a.TransactionId = txn.id AND txn.ObjectType = 'RT::Ticket' \\
+        JOIN Tickets t ON txn.ObjectId = t.id \\
         WHERE a.ContentType = 'text/plain' AND t.Status != 'deleted'
 
     sql_query_info  = SELECT * FROM Attachments WHERE id=\$id
 }
 
-index \$index {
+index $index {
     source                  = rt
     path                    = $var_path/sphinx/index
     docinfo                 = extern

commit 606e5e609e98642cc9aa91364e0d94e3d7797f1b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:50:58 2011 +0400

    we use Column everywhere (config, script and docs)

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index c1b9ea1..78cdb8f 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -794,7 +794,7 @@ sub _TransContentLimit {
             $alias = $self->{'_sql_trattachalias'};
         }
 
-        my $field = $config->{'Field'} || 'Content';
+        my $field = $config->{'Column'} || 'Content';
         $field = 'Content' if $field =~ /\W/;
         if ( $db_type eq 'Oracle' ) {
             my $dbh = $RT::Handle->dbh;

commit a30bb0dbd89e451665d3b7d15ba6105c9c0d8f78
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:51:42 2011 +0400

    use local variable we prepared instead of original value

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 78cdb8f..6273710 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -823,7 +823,7 @@ sub _TransContentLimit {
             $self->_SQLLimit(
                 %rest,
                 ALIAS       => $alias,
-                FIELD       => $config->{'Column'},
+                FIELD       => $field,
                 OPERATOR    => '@@',
                 VALUE       => 'plainto_tsquery('. $dbh->quote($value) .')',
                 QUOTEVALUE  => 0,

commit 7d8b153e6f84b2f4e776bd1941df6fe290cc46f1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed May 4 00:52:43 2011 +0400

    we also support indexed search on mysql

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 6273710..c67b9a3 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -829,6 +829,15 @@ sub _TransContentLimit {
                 QUOTEVALUE  => 0,
             );
         }
+        elsif ( $db_type eq 'mysql' ) {
+            $self->_SQLLimit(
+                %rest,
+                ALIAS       => $alias,
+                FIELD       => $field,
+                OPERATOR    => $op,
+                VALUE       => $value,
+            );
+        }
         else {
             $RT::Logger->error( "Indexed full text search is not supported for $db_type" );
             $self->_SQLLimit( %rest, FIELD => 'id', VALUE => 0 );

-----------------------------------------------------------------------


More information about the Rt-commit mailing list