[Rt-commit] rt branch, 4.0/mysql-fts, updated. rt-4.0.0-213-ga3fc4ec
Alex Vandiver
alexmv at bestpractical.com
Thu May 5 16:48:47 EDT 2011
The branch, 4.0/mysql-fts has been updated
via a3fc4ec3c8992098473ec5ad4a6cd3ad6f35a4ad (commit)
via 21c99c80ea60623e2497fd94eadc3889cdd355db (commit)
via 8869a17145154928226362e2cae608ad427dfe51 (commit)
via d15c50306b4bdd99ee3d20da515c4162b6d4d2a9 (commit)
via dbfe8313247f15735503118cea65b9d2e3685d8f (commit)
via 7ec3ef1677d732ad5c8f62462a001b226aaf8611 (commit)
via af9c935ff986de58ff6e80bf119d4d81498789dd (commit)
via 49eef0687344df57168b3458dc9bf6a57560d1f4 (commit)
via a8bdbc76bf180f13995e87b39bb828e5af35209d (commit)
via ad0c132a903321b9e79a686afd1b2804b520420e (commit)
via 8aad388284e8c0c8eb57cfbcd6713e09ece69ea1 (commit)
via 7b651f2b26b67634a7a7c45c6bafd62cfebbe54d (commit)
via 4a6338c7eefeed5b60137ae2a0ab1330fd7c7313 (commit)
via 3ea82f572a7c011ea328ccadf104f55569138ce1 (commit)
via 824597b330031248e6661e5e1cc3c5030a4214a5 (commit)
from 7d8b153e6f84b2f4e776bd1941df6fe290cc46f1 (commit)
Summary of changes:
lib/RT/Config.pm | 39 ++++++++++++
lib/RT/Tickets.pm | 33 +++++++----
sbin/rt-setup-fulltext-index.in | 125 ++++++++++++++++++++++++---------------
3 files changed, 138 insertions(+), 59 deletions(-)
- Log -----------------------------------------------------------------
commit 824597b330031248e6661e5e1cc3c5030a4214a5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed May 4 15:58:35 2011 -0400
Typo fix
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index d6780ea..28bea92 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -181,7 +181,7 @@ END
Below is a simple Sphinx configuration which can be used to index all
text/plain attachments in your database. This configuration is not
ideal; you should read the Sphinx documentation to understand how to
-confiture it to better suit your needs.
+configure it to better suit your needs.
source rt {
type = mysql
commit 3ea82f572a7c011ea328ccadf104f55569138ce1
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 11:36:31 2011 -0400
Pg and mysql operate on their index from the config, not the given column
This splits the concept of the index column from the column said index
is based on. At current, only the 'Content' column is possible to be
indexed, but this helps clarify the distinction between the two
concepts.
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index c67b9a3..d876b3c 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -761,6 +761,7 @@ sub _TransContentLimit {
# way they get parsed in the tree they're in different subclauses.
my ( $self, $field, $op, $value, %rest ) = @_;
+ $field = 'Content' if $field =~ /\W/;
my $config = RT->Config->Get('FullTextSearch') || {};
unless ( $config->{'Enable'} ) {
@@ -794,8 +795,7 @@ sub _TransContentLimit {
$alias = $self->{'_sql_trattachalias'};
}
- my $field = $config->{'Column'} || 'Content';
- $field = 'Content' if $field =~ /\W/;
+ my $index = $config->{'Column'};
if ( $db_type eq 'Oracle' ) {
my $dbh = $RT::Handle->dbh;
my $alias = $self->{_sql_trattachalias};
@@ -823,7 +823,7 @@ sub _TransContentLimit {
$self->_SQLLimit(
%rest,
ALIAS => $alias,
- FIELD => $field,
+ FIELD => $index,
OPERATOR => '@@',
VALUE => 'plainto_tsquery('. $dbh->quote($value) .')',
QUOTEVALUE => 0,
@@ -833,7 +833,7 @@ sub _TransContentLimit {
$self->_SQLLimit(
%rest,
ALIAS => $alias,
- FIELD => $field,
+ FIELD => $index,
OPERATOR => $op,
VALUE => $value,
);
commit 4a6338c7eefeed5b60137ae2a0ab1330fd7c7313
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 11:37:04 2011 -0400
Needing to handle negative searches is for all databases, not just Pg
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index d876b3c..4fdb0ee 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -795,6 +795,7 @@ sub _TransContentLimit {
$alias = $self->{'_sql_trattachalias'};
}
+ #XXX: handle negative searches
my $index = $config->{'Column'};
if ( $db_type eq 'Oracle' ) {
my $dbh = $RT::Handle->dbh;
@@ -819,7 +820,6 @@ sub _TransContentLimit {
}
elsif ( $db_type eq 'Pg' ) {
my $dbh = $RT::Handle->dbh;
- #XXX: handle negative searches
$self->_SQLLimit(
%rest,
ALIAS => $alias,
commit 7b651f2b26b67634a7a7c45c6bafd62cfebbe54d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 11:38:37 2011 -0400
Disallow configuring the query column in the Sphinx table
Sphinx assumes that the third column in the table is used for issuing
queries; its name does not matter. However, as it is an entirely new
table, there is no reason to allow configuration of the name of the
column; it simply increases complexity and gives the illusion of
control. Hard-code it to the suggested 'query' column.
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 4fdb0ee..f320d18 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -833,7 +833,7 @@ sub _TransContentLimit {
$self->_SQLLimit(
%rest,
ALIAS => $alias,
- FIELD => $index,
+ FIELD => 'query',
OPERATOR => $op,
VALUE => $value,
);
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 28bea92..db738bc 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -104,7 +104,6 @@ if ( $DB{'type'} eq 'Pg' ) {
elsif ( $DB{'type'} eq 'mysql' ) {
%DEFAULT = (
table => 'AttachmentsIndex',
- column => 'Content',
);
}
elsif ( $DB{'type'} eq 'Oracle' ) {
@@ -153,14 +152,14 @@ if ( $DB{'type'} eq 'mysql' ) {
CREATE TABLE $table (
id INTEGER UNSIGNED NOT NULL,
weight INTEGER NOT NULL,
- $DEFAULT{'column'} VARCHAR(3072) NOT NULL,
- INDEX($DEFAULT{'column'})
+ query VARCHAR(3072) NOT NULL,
+ INDEX(query)
) ENGINE=SPHINX CONNECTION="$url"
END
insert_schema( $schema );
- print_rt_config( Table => $table, Column => $DEFAULT{'column'} );
+ print_rt_config( Table => $table );
require URI;
my $urlo = URI->new( $url );
commit 8aad388284e8c0c8eb57cfbcd6713e09ece69ea1
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 11:41:06 2011 -0400
Catch common FTS configuration errors and disable it
This allows less error-checking at runtime, as FTS will have been
disabled if the parameters are non-sensical.
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index aa41045..304f17f 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -482,6 +482,42 @@ our %META = (
},
# Internal config options
+ FullTextSearch => {
+ Type => 'HASH',
+ PostLoadCheck => sub {
+ my $self = shift;
+ my $v = $self->Get('FullTextSearch');
+ return unless $v->{Enable} and $v->{Indexed};
+ my $dbtype = $self->Get('DatabaseType');
+ if ($dbtype eq 'Oracle') {
+ if (not $v->{IndexName}) {
+ $RT::Logger->error("No IndexName set for full-text index; disabling");
+ $v->{Enable} = $v->{Indexed} = 0;
+ }
+ } elsif ($dbtype eq 'Pg') {
+ my $bad = 0;
+ if (not $v->{'Column'}) {
+ $RT::Logger->error("No Column set for full-text index; disabling");
+ $v->{Enable} = $v->{Indexed} = 0;
+ } elsif ($v->{'Column'} eq "Content"
+ and (not $v->{'Table'} or $v->{'Table'} eq "Attachments")) {
+ $RT::Logger->error("Column for full-text index is set to Content, not tsvector column; disabling");
+ $v->{Enable} = $v->{Indexed} = 0;
+ }
+ } elsif ($dbtype eq 'mysql') {
+ if (not $v->{'Table'}) {
+ $RT::Logger->error("No Table set for full-text index; disabling");
+ $v->{Enable} = $v->{Indexed} = 0;
+ } elsif ($v->{'Table'} eq "Attachments") {
+ $RT::Logger->error("Table for full-text index is set to Attachments, not SphinxSE table; disabling");
+ $v->{Enable} = $v->{Indexed} = 0;
+ }
+ } else {
+ $RT::Logger->error("Indexed full-text-search not supported for $dbtype");
+ $v->{Indexed} = 0;
+ }
+ },
+ },
DisableGraphViz => {
Type => 'SCALAR',
PostLoadCheck => sub {
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index f320d18..ff4c3f1 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -838,11 +838,6 @@ sub _TransContentLimit {
VALUE => $value,
);
}
- else {
- $RT::Logger->error( "Indexed full text search is not supported for $db_type" );
- $self->_SQLLimit( %rest, FIELD => 'id', VALUE => 0 );
- return;
- }
} else {
$self->_SQLLimit(
%rest,
commit ad0c132a903321b9e79a686afd1b2804b520420e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 11:44:15 2011 -0400
Sphinx only works with the "=" operator, not the "LIKE" operator
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index ff4c3f1..bbfa900 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -834,7 +834,7 @@ sub _TransContentLimit {
%rest,
ALIAS => $alias,
FIELD => 'query',
- OPERATOR => $op,
+ OPERATOR => '=',
VALUE => $value,
);
}
commit a8bdbc76bf180f13995e87b39bb828e5af35209d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 11:44:36 2011 -0400
Configure the number of attachment results to return from Sphinx
The default is to only return the first 20 matches; this can be
increased by raising the 'limit' parameter, but only up to the system
max_matches value, which defaults to 1,000. At FTS setup time, prompt
for the value to use, and default to the higher value of 10,000. This
can still cause problems wherein the first 10,000 results from Sphinx do
no overlap with the other query restrictions (queue, ticket status,
etc), and thus RT will incorrectly return no results.
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 304f17f..139098c 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -511,6 +511,9 @@ our %META = (
} elsif ($v->{'Table'} eq "Attachments") {
$RT::Logger->error("Table for full-text index is set to Attachments, not SphinxSE table; disabling");
$v->{Enable} = $v->{Indexed} = 0;
+ } elsif (not $v->{'MaxMatches'}) {
+ $RT::Logger->warn("No MaxMatches set for full-text index; defaulting to 10000");
+ $v->{MaxMatches} = 10_000;
}
} else {
$RT::Logger->error("Indexed full-text-search not supported for $dbtype");
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index bbfa900..44c6e2d 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -830,12 +830,13 @@ sub _TransContentLimit {
);
}
elsif ( $db_type eq 'mysql' ) {
+ my $max = $config->{'MaxMatches'};
$self->_SQLLimit(
%rest,
ALIAS => $alias,
FIELD => 'query',
OPERATOR => '=',
- VALUE => $value,
+ VALUE => "$value;limit=$max;maxmatches=$max",
);
}
} else {
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index db738bc..1ddda63 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -147,6 +147,15 @@ if ( $DB{'type'} eq 'mysql' ) {
default => 'sphinx://localhost:3312/rt',
silent => !$OPT{'ask'},
);
+ my $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"
+ . "agree on this value. Larger values cause your Sphinx server to\n"
+ . "consume more memory and CPU time per query.",
+ default => 10000,
+ silent => !$OPT{'ask'},
+ );
my $schema = <<END;
CREATE TABLE $table (
@@ -159,7 +168,7 @@ END
insert_schema( $schema );
- print_rt_config( Table => $table );
+ print_rt_config( Table => $table, MaxMatches => $maxmatches );
require URI;
my $urlo = URI->new( $url );
@@ -217,7 +226,7 @@ searchd {
read_timeout = 5
max_children = 30
pid_file = $var_path/sphinx/searchd.pid
- max_matches = 1000
+ max_matches = $maxmatches
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
@@ -627,11 +636,11 @@ You can now configure RT to use the newly-created full-text index by
adding the following to your RT_SiteConfig.pm:
Set( %FullTextSearch,
- Enable => 1,
- Indexed => 1,
+ Enable => 1,
+ Indexed => 1,
END
- $config .= sprintf(" %-9s => '$args{$_}',\n",$_)
+ $config .= sprintf(" %-10s => '$args{$_}',\n",$_)
foreach grep defined $args{$_}, keys %args;
$config .= ");\n";
commit 49eef0687344df57168b3458dc9bf6a57560d1f4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 13:45:22 2011 -0400
Escape ;-as-special-delimiter in Sphinx searches
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 44c6e2d..af6e9f7 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -830,6 +830,13 @@ sub _TransContentLimit {
);
}
elsif ( $db_type eq 'mysql' ) {
+ # This is a special character. Note that \ does not escape
+ # itself (in Sphinx 2.1.0, at least), so 'foo\;bar' becoming
+ # 'foo\\;bar' is not a vulnerability, and is still parsed as
+ # "foo, \, ;, then bar". Happily, the default mode is
+ # "all", meaning that boolean operators are not special.
+ $value =~ s/;/\\;/g;
+
my $max = $config->{'MaxMatches'};
$self->_SQLLimit(
%rest,
commit af9c935ff986de58ff6e80bf119d4d81498789dd
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 13:45:49 2011 -0400
Note possible optimization which would skip Attachment and Transaction joins
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index af6e9f7..adf7c1c 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -830,6 +830,12 @@ sub _TransContentLimit {
);
}
elsif ( $db_type eq 'mysql' ) {
+ # XXX: We could theoretically skip the join to Attachments,
+ # and have Sphinx simply index and group by the TicketId,
+ # and join Ticket.id to that attribute, which would be much
+ # more efficient -- however, this is only a possibility if
+ # there are no other transaction limits.
+
# This is a special character. Note that \ does not escape
# itself (in Sphinx 2.1.0, at least), so 'foo\;bar' becoming
# 'foo\\;bar' is not a vulnerability, and is still parsed as
commit 7ec3ef1677d732ad5c8f62462a001b226aaf8611
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 15:16:22 2011 -0400
Don't die with "Illegal mix of collations" when searching for unicode
Note this does not itself allow searching for most unicode characters,
as those are not in Sphinx's default charset_table, meaning that the
tokenizer does not parse them as characters to index. However, there is
no general-purpose sphinx charset_table available beyond the default
english and russian set.
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 1ddda63..96d4dd1 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -163,7 +163,7 @@ CREATE TABLE $table (
weight INTEGER NOT NULL,
query VARCHAR(3072) NOT NULL,
INDEX(query)
-) ENGINE=SPHINX CONNECTION="$url"
+) ENGINE=SPHINX CONNECTION="$url" CHARACTER SET utf8
END
insert_schema( $schema );
@@ -199,6 +199,7 @@ source rt {
sql_user = $sphinx_conf{'user'}
sql_pass = $sphinx_conf{'pass'}
+ sql_query_pre = SET NAMES utf8
sql_query = \\
SELECT a.id, a.content FROM Attachments a \\
JOIN Transactions txn ON a.TransactionId = txn.id AND txn.ObjectType = 'RT::Ticket' \\
commit dbfe8313247f15735503118cea65b9d2e3685d8f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 16:12:18 2011 -0400
Check that the Postgres version supports full-text searching
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 96d4dd1..815b7fa 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -239,6 +239,7 @@ END
elsif ( $DB{'type'} eq 'Pg' ) {
my $dbh = $RT::Handle->dbh;
+ check_tsvalue();
my $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"
@@ -349,6 +350,22 @@ else {
die "Full-text indexes on $DB{type} are not yet supported";
}
+sub check_tsvalue {
+ my $dbh = $RT::Handle->dbh;
+ my $fts = ($dbh->selectrow_array(<<EOQ))[0];
+SELECT 1 FROM information_schema.routines WHERE routine_name = 'plainto_tsquery'
+EOQ
+ unless ($fts) {
+ print STDERR <<EOT;
+
+Your Postgres server does not include full-text support. You will need
+to upgrade to Postgres version 8.3 or higher to use full-text indexing.
+
+EOT
+ exit 1;
+ }
+}
+
sub check_sphinx {
my $dbh = $RT::Handle->dbh;
my $sphinx = ($dbh->selectrow_array("show variables like 'have_sphinx'"))[1];
commit d15c50306b4bdd99ee3d20da515c4162b6d4d2a9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 16:13:32 2011 -0400
Always insert schemas as dba
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 815b7fa..903cea0 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -272,8 +272,8 @@ elsif ( $DB{'type'} eq 'Pg' ) {
);
} while ( $index_type ne 'gist' && $index_type ne 'gin' );
- insert_schema_as_dba( $schema );
- insert_schema_as_dba("CREATE INDEX ${column}_idx ON $table USING $index_type($column)");
+ insert_schema( $schema );
+ insert_schema("CREATE INDEX ${column}_idx ON $table USING $index_type($column)");
print_rt_config( Table => $table, Column => $column );
}
@@ -666,16 +666,8 @@ END
}
sub insert_schema {
- return _insert_schema( $dbh, "Going to run the following in the DB:", @_);
-}
-
-sub insert_schema_as_dba {
- return _insert_schema( dba_handle(), "Going to run the following in the DB:", @_);
-}
-
-sub _insert_schema {
- my $dbh = shift;
- my $message = shift;
+ my $dbh = dba_handle();
+ my $message = "Going to run the following in the DB:";
my $schema = shift;
print "$message\n";
print " $schema\n\n";
commit 8869a17145154928226362e2cae608ad427dfe51
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 16:25:23 2011 -0400
Be consistent with Oracle and drop the table/column if it exists already
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 903cea0..8fc3cae 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -132,8 +132,6 @@ $dbh->{'RaiseError'} = 1;
$dbh->{'PrintError'} = 1;
if ( $DB{'type'} eq 'mysql' ) {
- my $dbh = $RT::Handle->dbh;
-
check_sphinx();
my $table = prompt(
message => "Enter name of a new Mysql table that will be used to connect to the\n"
@@ -166,6 +164,8 @@ CREATE TABLE $table (
) ENGINE=SPHINX CONNECTION="$url" CHARACTER SET utf8
END
+ do_error_is_ok( dba_handle() => "DROP TABLE $table" )
+ unless $OPT{'dryrun'};
insert_schema( $schema );
print_rt_config( Table => $table, MaxMatches => $maxmatches );
@@ -237,8 +237,6 @@ END
}
elsif ( $DB{'type'} eq 'Pg' ) {
- my $dbh = $RT::Handle->dbh;
-
check_tsvalue();
my $table = prompt(
message => "Enter the name of a DB table that will be used to store the Pg tsvector.\n"
@@ -254,9 +252,12 @@ elsif ( $DB{'type'} eq 'Pg' ) {
);
my $schema;
+ my $drop;
if ( lc($table) eq 'attachments' ) {
+ $drop = "ALTER TABLE $table DROP COLUMN $column";
$schema = "ALTER TABLE $table ADD COLUMN $column tsvector";
} else {
+ $drop = "DROP TABLE $table";
$schema = "CREATE TABLE $table ( "
."id INTEGER NOT NULL,"
."$column tsvector )";
@@ -272,6 +273,8 @@ elsif ( $DB{'type'} eq 'Pg' ) {
);
} while ( $index_type ne 'gist' && $index_type ne 'gin' );
+ do_error_is_ok( dba_handle() => $drop )
+ unless $OPT{'dryrun'};
insert_schema( $schema );
insert_schema("CREATE INDEX ${column}_idx ON $table USING $index_type($column)");
commit 21c99c80ea60623e2497fd94eadc3889cdd355db
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 16:43:21 2011 -0400
Respect dryrun in more places
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 8fc3cae..651b0c1 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -339,13 +339,14 @@ elsif ( $DB{'type'} eq 'Oracle' ) {
my $index_params = join "\n", @params;
my $index_name = $DEFAULT{prefix} .'index';
- do_error_is_ok( $dbh => "DROP INDEX $index_name" );
+ do_error_is_ok( $dbh => "DROP INDEX $index_name" )
+ unless $OPT{'dryrun'};
$dbh->do(
"CREATE INDEX $index_name ON Attachments(Content)
indextype is ctxsys.context parameters('
$index_params
')",
- );
+ ) unless $OPT{'dryrun'};
print_rt_config( IndexName => $index_name );
}
@@ -429,34 +430,38 @@ sub ora_create_stop_list {
return '' unless -e $file;
my $name = $DEFAULT{'prefix'} .'stop_list';
- do_error_is_ok( $dbh => 'begin ctx_ddl.drop_stoplist(?); end;', $name );
-
- $dbh->do(
- 'begin ctx_ddl.create_stoplist(?, ?); end;',
- undef, $name, 'BASIC_STOPLIST'
- );
+ unless ($OPT{'dryrun'}) {
+ do_error_is_ok( $dbh => 'begin ctx_ddl.drop_stoplist(?); end;', $name );
- open( my $fh, '<:utf8', $file )
- or die "couldn't open file '$file': $!";
- while ( my $word = <$fh> ) {
- chomp $word;
$dbh->do(
- 'begin ctx_ddl.add_stopword(?, ?); end;',
- undef, $name, $word
+ 'begin ctx_ddl.create_stoplist(?, ?); end;',
+ undef, $name, 'BASIC_STOPLIST'
);
+
+ open( my $fh, '<:utf8', $file )
+ or die "couldn't open file '$file': $!";
+ while ( my $word = <$fh> ) {
+ chomp $word;
+ $dbh->do(
+ 'begin ctx_ddl.add_stopword(?, ?); end;',
+ undef, $name, $word
+ );
+ }
+ close $fh;
}
- close $fh;
return sprintf 'stoplist %s', $name;
}
sub ora_create_section_group {
my %args = @_;
my $name = $DEFAULT{'prefix'} .'section_group';
- do_error_is_ok( $dbh => 'begin ctx_ddl.drop_section_group(?); end;', $name );
- $dbh->do(
- 'begin ctx_ddl.create_section_group(?, ?); end;',
- undef, $name, $args{'type'}
- );
+ unless ($OPT{'dryrun'}) {
+ do_error_is_ok( $dbh => 'begin ctx_ddl.drop_section_group(?); end;', $name );
+ $dbh->do(
+ 'begin ctx_ddl.create_section_group(?, ?); end;',
+ undef, $name, $args{'type'}
+ );
+ }
return sprintf 'section group %s', $name;
}
@@ -469,6 +474,7 @@ sub ora_create_storage {
sub ora_create_format_column {
my $column_name = 'ContentOracleFormat';
+ return $column_name if $OPT{'dryrun'};
unless (
$dbh->column_info(
undef, undef, uc('Attachments'), uc( $column_name )
@@ -548,6 +554,7 @@ sub ora_create_format_column {
sub ora_create_preference {
my %info = @_;
my $name = $DEFAULT{'prefix'} . $info{'name'};
+ return $name if $OPT{'dryrun'};
do_error_is_ok( $dbh => 'begin ctx_ddl.drop_preference(?); end;', $name );
$dbh->do(
'begin ctx_ddl.create_preference(?, ?); end;',
@@ -568,6 +575,7 @@ sub ora_create_preference {
sub ora_create_procedure {
my $text = shift;
+ return if $OPT{'dryrun'};
my $status = $dbh->do($text, { RaiseError => 0 });
# Statement succeeded
commit a3fc4ec3c8992098473ec5ad4a6cd3ad6f35a4ad
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 5 16:45:08 2011 -0400
Minor formatting cleanup
diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 651b0c1..3c0edbf 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -681,7 +681,9 @@ sub insert_schema {
my $message = "Going to run the following in the DB:";
my $schema = shift;
print "$message\n";
- print " $schema\n\n";
+ my $disp = $schema;
+ $disp =~ s/^/ /mg;
+ print "$disp\n\n";
return if $OPT{'dryrun'};
my $res = $dbh->do( $schema );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list