[Rt-commit] rt branch, 4.0/mysql-fts, updated. rt-4.0.0-229-g01f01dc

Alex Vandiver alexmv at bestpractical.com
Fri May 6 15:52:38 EDT 2011


The branch, 4.0/mysql-fts has been updated
       via  01f01dc5d4b60cf066d331795109bf5e3c321891 (commit)
       via  5024fd730f98860998558264cf81fae13c9d392e (commit)
       via  6f4a74cf049e8442bbd3697995b7fd9b68fb75e9 (commit)
       via  8184d0dd6ca2dba83388e5bbc7eff49bac049eb4 (commit)
       via  8d3788994d7ab67a2131992063e1d4c0739a22af (commit)
      from  0c29841b426b0134c925004f2e4a55f77d5b9571 (commit)

Summary of changes:
 lib/RT/Tickets.pm               |    2 ++
 sbin/rt-setup-fulltext-index.in |   22 ++++++++++++++--------
 t/fts/indexed_mysql.t           |    5 +++++
 t/fts/not_indexed.t             |    6 ++++--
 4 files changed, 25 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit 8d3788994d7ab67a2131992063e1d4c0739a22af
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 6 14:21:45 2011 -0400

    Revert "Since we will immediately limit on fields of these tables, they need not be left"
    
    This reverts commit ca91cf50be71497f04fd4bcb2f10ce304678cf4a.  The LEFT
    JOIN is necessary because the full-text condition may not be required
    for a row to match.

diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index adf7c1c..35d43e9 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -772,6 +772,7 @@ sub _TransContentLimit {
     my $txn_alias = $self->JoinTransactions;
     unless ( defined $self->{_sql_trattachalias} ) {
         $self->{_sql_trattachalias} = $self->_SQLJoin(
+            TYPE   => 'LEFT', # not all txns have an attachment
             ALIAS1 => $txn_alias,
             FIELD1 => 'id',
             TABLE2 => 'Attachments',
@@ -786,6 +787,7 @@ sub _TransContentLimit {
         my $alias;
         if ( $config->{'Table'} and $config->{'Table'} ne "Attachments") {
             $alias = $self->{'_sql_aliases'}{'full_text'} ||= $self->_SQLJoin(
+                TYPE   => 'LEFT',
                 ALIAS1 => $self->{'_sql_trattachalias'},
                 FIELD1 => 'id',
                 TABLE2 => $config->{'Table'},

commit 8184d0dd6ca2dba83388e5bbc7eff49bac049eb4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 6 14:31:50 2011 -0400

    Fix tests, and test all three possibilities of (1||0), (0||1), (1||1)

diff --git a/t/fts/not_indexed.t b/t/fts/not_indexed.t
index 93ede31..f0549fb 100644
--- a/t/fts/not_indexed.t
+++ b/t/fts/not_indexed.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use RT::Test tests => 13;
+use RT::Test tests => 17;
 
 RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 0 );
 
@@ -53,7 +53,9 @@ sub run_test {
 run_tests(
     "Content LIKE 'book'" => { book => 1, bar => 0 },
     "Content LIKE 'bar'" => { book => 0, bar => 1  },
-    "(Content LIKE 'bar' OR Subject LIKE 'con')" => { 'no content' => 1 },
+    "(Content LIKE 'baz' OR Subject LIKE 'con')" => { 'no content' => 1 },
+    "(Content LIKE 'bar' OR Subject LIKE 'con')" => { 'no content' => 1, bar => 1 },
+    "(Content LIKE 'bar' OR Subject LIKE 'missing')" => { bar => 1 },
 );
 
 

commit 6f4a74cf049e8442bbd3697995b7fd9b68fb75e9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 6 14:48:04 2011 -0400

    Allow command-line options to override for prompts

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 678e880..11ec854 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -119,6 +119,12 @@ GetOptions(
     'dry-run!'       => \$OPT{'dryrun'},
     'binary!'        => \$OPT{'binary'},
 
+    'table=s'        => \$OPT{'table'},
+    'column=s'       => \$OPT{'column'},
+    'url=s'          => \$OPT{'url'},
+    'maxmatches=i'   => \$OPT{'maxmatches'},
+    'index-type=s'   => \$OPT{'index-type'},
+
     'dba=s'          => \$DB{'admin'},
     'dba-password=s' => \$DB{'admin_password'},
 ) or show_help();
@@ -134,19 +140,19 @@ $dbh->{'PrintError'} = 1;
 
 if ( $DB{'type'} eq 'mysql' ) {
     check_sphinx();
-    my $table = prompt(
+    my $table = $OPT{'table'} || prompt(
         message => "Enter name of a new Mysql table that will be used to connect to the\n"
                  . "Sphinx server:",
         default => $DEFAULT{'table'},
         silent  => !$OPT{'ask'},
     );
-    my $url = prompt(
+    my $url = $OPT{'url'} || prompt(
         message => "Enter URL of the sphinx search server; this should be of the form\n"
                  . "sphinx://<server>:<port>/<index name>",
         default => 'sphinx://localhost:3312/rt',
         silent  => !$OPT{'ask'},
     );
-    my $maxmatches = prompt(
+    my $maxmatches = $OPT{'maxmatches'} || prompt(
         message => "Maximum number of matches to return; this is the maximum number of\n"
                  . "attachment records returned by the search, not the maximum number\n"
                  . "of tickets.  Both your RT_SiteConfig.pm and your sphinx.conf must\n"
@@ -239,14 +245,14 @@ END
 }
 elsif ( $DB{'type'} eq 'Pg' ) {
     check_tsvalue();
-    my $table = prompt(
+    my $table = $OPT{'table'} || prompt(
         message => "Enter the name of a DB table that will be used to store the Pg tsvector.\n"
                  . "You may either use the existing Attachments table, or create a new\n"
                  . "table.",
         default => $DEFAULT{'table'},
         silent  => !$OPT{'ask'},
     );
-    my $column = prompt(
+    my $column = $OPT{'column'} || prompt(
         message => 'Enter the name of a column that will be used to store the Pg tsvector:',
         default => $DEFAULT{'column'},
         silent  => !$OPT{'ask'},
@@ -264,15 +270,15 @@ elsif ( $DB{'type'} eq 'Pg' ) {
             ."$column tsvector )";
     }
 
-    my $index_type;
-    do {
+    my $index_type = $OPT{'index-type'} || '';
+    while ( $index_type ne 'gist' and $index_type ne 'gin' ) {
         $index_type = lc prompt(
             message => "You may choose between GiST or GIN indexes; the former is several times\n"
                      . "slower to search, but takes less space on disk and is faster to update.",
             default => 'GiST',
             silent  => !$OPT{'ask'},
         );
-    } while ( $index_type ne 'gist' && $index_type ne 'gin' );
+    }
 
     do_error_is_ok( dba_handle() => $drop )
         unless $OPT{'dryrun'};

commit 5024fd730f98860998558264cf81fae13c9d392e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 6 14:48:30 2011 -0400

    Don't conflict with an existing searchd on the  default port

diff --git a/t/fts/indexed_mysql.t b/t/fts/indexed_mysql.t
index 9909f94..51cb4f1 100644
--- a/t/fts/indexed_mysql.t
+++ b/t/fts/indexed_mysql.t
@@ -25,11 +25,13 @@ ok $q && $q->id, 'loaded or created queue';
 my $queue = $q->Name;
 
 sub setup_indexing {
+    my $port = RT::Test->generate_port;
     my ($exit_code, $output) = RT::Test->run_and_capture(
         'no-ask'       => 1,
         command        => $RT::SbinPath .'/rt-setup-fulltext-index',
         dba            => $ENV{'RT_DBA_USER'},
         'dba-password' => $ENV{'RT_DBA_PASSWORD'},
+        url            => "sphinx://localhost:$port/rt",
     );
     ok(!$exit_code, "setted up index");
     diag "output: $output" if $ENV{'TEST_VERBOSE'};

commit 01f01dc5d4b60cf066d331795109bf5e3c321891
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 6 15:30:31 2011 -0400

    searchd does not pick up the new indexes immediately; sleep a second in the test

diff --git a/t/fts/indexed_mysql.t b/t/fts/indexed_mysql.t
index 51cb4f1..afb9409 100644
--- a/t/fts/indexed_mysql.t
+++ b/t/fts/indexed_mysql.t
@@ -73,6 +73,9 @@ sub sync_index {
     close $fh;
     my $exit_code = $?>>8;
     ok(!$exit_code, "indexed") or diag "output: $output";
+
+    # We may need to wait a second for searchd to pick up the changes
+    sleep 1;
 }
 
 sub run_tests {

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


More information about the Rt-commit mailing list