[Rt-commit] rt branch 5.0/improve-text-indexes2 created. rt-5.0.3-328-gb10707a0a9

BPS Git Server git at git.bestpractical.com
Wed Mar 22 21:42:21 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/improve-text-indexes2 has been created
        at  b10707a0a9771f950da6a4a81449f58dc6fb3493 (commit)

- Log -----------------------------------------------------------------
commit b10707a0a9771f950da6a4a81449f58dc6fb3493
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 1 00:27:26 2022 +0800

    Update SQL tests for automatic LOWER conversion

diff --git a/t/api/sql.t b/t/api/sql.t
index 262a6c2d8b..8ee8d7b3f2 100644
--- a/t/api/sql.t
+++ b/t/api/sql.t
@@ -28,6 +28,17 @@ RT->Config->Set(
         defaults => { on_create => 'new', },
     },
 );
+my $status_key = RT->DatabaseHandle->CaseSensitive ? 'LOWER\(main.Status\)' : 'Status';
+my %ticketsql = (
+    q{Status = 'new' OR Status = 'open'}                => qr{$status_key IN \('new', 'open'\)},
+    q{Status = '__Active__'}                            => qr{$status_key IN \('new', 'open', 'stalled'\)},
+    q{id = 2 OR id = 3}                                 => qr{id IN \('2', '3'\)},
+    q{Creator = 'root' OR Creator = 'alice'}            => qr{Creator IN \('$alice_id', '$root_id'\)},
+    q{Queue = 'General' OR Queue = 'Support'}           => qr{Queue IN \('$general_id', '$support_id'\)},
+    q{Lifecycle = 'default' or Lifecycle = 'approvals'} => qr{Lifecycle IN \('approvals', 'default'\)},
+    q{(Queue = 'General' OR Queue = 'Support') AND (Status = 'new' OR Status = 'open')} =>
+        qr{Queue IN \('$general_id', '$support_id'\).+$status_key IN \('new', 'open'\)},
+);
 
 RT::Lifecycle->FillCache();
 

commit e7b789980cb5c07b1cba8fd67835789f9a0be716
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Oct 1 03:27:01 2022 +0800

    Support case insensitive "IN" searches for all fields
    
    Previously we implemented it only for specifiec fields like group names,
    this commit abstracts it so it could be used for all case insensitive
    fields.

diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index 8698cf00c0..bc9f942073 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -696,10 +696,8 @@ sub CurrentUserCanSee {
         $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Catalog-Role', CASESENSITIVE => 0 );
         $groups->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'IN',
-            VALUE         => [ map {lc $_} @tmp ],
-            CASESENSITIVE => 1,
+            VALUE         => \@tmp,
         );
         my $principal_alias = $groups->Join(
             ALIAS1 => 'main',
diff --git a/lib/RT/CustomFields.pm b/lib/RT/CustomFields.pm
index 7615799052..56d11cac44 100644
--- a/lib/RT/CustomFields.pm
+++ b/lib/RT/CustomFields.pm
@@ -151,10 +151,8 @@ sub LimitToGrouping {
         }
         $self->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'IN',
-            VALUE         => [map {lc $_} @{$list}],
-            CASESENSITIVE => 1,
+            VALUE         => $list,
         );
     } else {
         my @list = map {@$_} grep defined && ref($_) eq 'ARRAY',
@@ -164,10 +162,8 @@ sub LimitToGrouping {
 
         $self->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'NOT IN',
-            VALUE         => [ map {lc $_} @list ],
-            CASESENSITIVE => 1,
+            VALUE         => \@list,
         );
     }
     return;
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 17dfc131e2..1b02ba5da6 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -4259,10 +4259,8 @@ sub GetPrincipalsMap {
                     $roles->LimitToRolesForObject(RT->System);
                     $roles->Limit(
                         FIELD         => "Name",
-                        FUNCTION      => 'LOWER(?)',
                         OPERATOR      => "IN",
-                        VALUE         => [ map {lc $_} $class->Roles ],
-                        CASESENSITIVE => 1,
+                        VALUE         => [ $class->Roles ],
                     );
                 } else {
                     # No roles to show; so show nothing
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 86190ae46d..31585baf96 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -993,6 +993,22 @@ sub Limit {
         $ARGS{'CASESENSITIVE'} //= 1;
     }
 
+    # Convert IN searches like "Status IN ( 'new', 'open' )" to "LOWER(Status) IN ( 'new', 'open' )"
+    if (
+           $self->_Handle->CaseSensitive
+        && !$ARGS{CASESENSITIVE}
+        && !$ARGS{FUNCTION}
+        && $ARGS{OPERATOR} =~ /\bIN\b/i
+        && ( $ARGS{QUOTEVALUE} || !exists $ARGS{QUOTEVALUE} )    # QUOTEVALUE defaults to true in DBIx::SearchBuilder
+        && ref $ARGS{VALUE} eq 'ARRAY'
+        && grep( /\D/, @{ $ARGS{VALUE} } )
+        )
+    {
+        $ARGS{FUNCTION}      = 'LOWER(?)';
+        $ARGS{VALUE}         = [ map lc, @{ $ARGS{VALUE} } ];
+        $ARGS{CASESENSITIVE} = 1;
+    }
+
     # Oracle doesn't support to directly compare CLOB with VARCHAR/INTEGER.
     # DefaultDashboard search in RT::Dashboard::CurrentUserCanDelete needs this
     if (   $ARGS{OPERATOR} !~ /IS/i
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index e58ad24a28..bf2540efcc 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -2794,10 +2794,8 @@ sub CurrentUserCanSee {
         $groups->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
         $groups->Limit(
             FIELD         => 'Name',
-            FUNCTION      => 'LOWER(?)',
             OPERATOR      => 'IN',
-            VALUE         => [ map {lc $_} @tmp ],
-            CASESENSITIVE => 1,
+            VALUE         => \@tmp,
         );
         my $principal_alias = $groups->Join(
             ALIAS1 => 'main',

commit 21b4ddbb44b2fe3a169a43311c793402f7031fa7
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri Sep 30 23:08:49 2022 +0800

    Default searches to be case insensitive for fields with lower cased indexes
    
    Previously we had to manually pass CASESENSITIVE arg. We don't need to
    do so any more with this commit.

diff --git a/lib/RT/Asset.pm b/lib/RT/Asset.pm
index c29e58f67d..68bb48fb74 100644
--- a/lib/RT/Asset.pm
+++ b/lib/RT/Asset.pm
@@ -689,8 +689,8 @@ sub Table { "Assets" }
 sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
-        Name          => { read => 1, type => 'varchar(255)',   default => '',  write => 1 },
-        Status        => { read => 1, type => 'varchar(64)',    default => '',  write => 1 },
+        Name          => { read => 1, type => 'varchar(255)',   default => '',  write => 1, is_case_sensitive => 0 },
+        Status        => { read => 1, type => 'varchar(64)',    default => '',  write => 1, is_case_sensitive => 0 },
         Description   => { read => 1, type => 'varchar(255)',   default => '',  write => 1 },
         Catalog       => { read => 1, type => 'int(11)',        default => '0', write => 1 },
         Creator       => { read => 1, type => 'int(11)',        default => '0', auto => 1 },
diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 03af410a5b..5254c2c407 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1296,7 +1296,7 @@ sub _CoreAccessible {
         Subject =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Filename =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         ContentType =>
                 {read => 1, write => 1, sql_type => 12, length => 80,  is_blob => 0,  is_numeric => 0,  type => 'varchar(80)', default => ''},
         ContentEncoding =>
diff --git a/lib/RT/Catalog.pm b/lib/RT/Catalog.pm
index 415042330d..52b3102b1d 100644
--- a/lib/RT/Catalog.pm
+++ b/lib/RT/Catalog.pm
@@ -488,7 +488,7 @@ sub Table { "Catalogs" }
 sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
-        Name          => { read => 1, type => 'varchar(255)',   default => '',          write => 1 },
+        Name          => { read => 1, type => 'varchar(255)',   default => '',          write => 1, is_case_sensitive => 0 },
         Description   => { read => 1, type => 'varchar(255)',   default => '',          write => 1 },
         Lifecycle     => { read => 1, type => 'varchar(32)',    default => 'assets',    write => 1 },
         Disabled      => { read => 1, type => 'int(2)',         default => '0',         write => 1 },
diff --git a/lib/RT/Configuration.pm b/lib/RT/Configuration.pm
index 2952e251b4..9fd0e91c85 100644
--- a/lib/RT/Configuration.pm
+++ b/lib/RT/Configuration.pm
@@ -499,7 +499,7 @@ sub Table { "Configurations" }
 sub _CoreAccessible {
     {
         id            => { read => 1, type => 'int(11)',        default => '' },
-        Name          => { read => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+        Name          => { read => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         Content       => { read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'blob', default => ''},
         ContentType   => { read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
         Disabled      => { read => 1, write => 1, sql_type => 5, length => 6,  is_blob => 0,  is_numeric => 1,  type => 'smallint(6)', default => '0'},
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
index 9fc202d001..28d2452d9c 100644
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@ -1526,11 +1526,11 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name =>
-                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Description =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Domain =>
-                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         Instance =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Creator =>
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index e28c33765c..1f8eba5680 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -750,7 +750,7 @@ sub _CoreAccessible {
         SortOrder =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Content =>
-                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => '', is_case_sensitive => 0},
         LargeContent =>
                 {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'longblob', default => ''},
         ContentType =>
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index 1f3af9c9d0..08d45e89f4 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -995,7 +995,7 @@ sub _CoreAccessible {
         id =>
         {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0 },
         Description => 
         {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         CorrespondAddress => 
diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 4a740d73b5..86190ae46d 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -932,13 +932,6 @@ injection attacks when we pass through user specified values.
 
 =cut
 
-my %check_case_sensitivity = (
-    groups => { 'name' => 1, domain => 1 },
-    queues => { 'name' => 1 },
-    users => { 'name' => 1, emailaddress => 1 },
-    customfields => { 'name' => 1 },
-);
-
 my %deprecated = (
 );
 
@@ -988,15 +981,16 @@ sub Limit {
     }
 
     unless ( exists $ARGS{CASESENSITIVE} or (exists $ARGS{QUOTEVALUE} and not $ARGS{QUOTEVALUE}) ) {
-        if ( $ARGS{FIELD} and $ARGS{'OPERATOR'} !~ /IS/i
-            && $table && $check_case_sensitivity{ lc $table }{ lc $ARGS{'FIELD'} }
-        ) {
-            RT->Logger->warning(
-                "Case sensitive search by $table.$ARGS{'FIELD'}"
-                ." at ". (caller)[1] . " line ". (caller)[2]
-            );
+
+        # Set CASESENSITIVE from field declaration
+        my $class = "RT::$table";
+        if ( $class->can('RecordClass') && $class->RecordClass && $class->RecordClass->can('_CoreAccessible') ) {
+            if ( my $meta = $class->RecordClass->_CoreAccessible->{ $ARGS{FIELD} } ) {
+                $ARGS{'CASESENSITIVE'} = $meta->{is_case_sensitive};
+            }
         }
-        $ARGS{'CASESENSITIVE'} = 1;
+
+        $ARGS{'CASESENSITIVE'} //= 1;
     }
 
     # Oracle doesn't support to directly compare CLOB with VARCHAR/INTEGER.
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 5592929bb3..76af2da40d 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -3684,7 +3684,7 @@ sub _CoreAccessible {
         TimeWorked =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Status =>
-                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => '', is_case_sensitive => 0},
         SLA =>
                 {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
         TimeLeft =>
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 7134085a66..2d4986365a 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2863,7 +2863,7 @@ sub _CoreAccessible {
         id =>
         {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Name => 
-        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 200,  is_blob => 0,  is_numeric => 0,  type => 'varchar(200)', default => '', is_case_sensitive => 0},
         Password => 
         {read => 1, write => 1, sql_type => 12, length => 256,  is_blob => 0,  is_numeric => 0,  type => 'varchar(256)', default => ''},
         AuthToken => 
@@ -2873,7 +2873,7 @@ sub _CoreAccessible {
         Signature => 
         {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
         EmailAddress => 
-        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => ''},
+        {read => 1, write => 1, sql_type => 12, length => 120,  is_blob => 0,  is_numeric => 0,  type => 'varchar(120)', default => '', is_case_sensitive => 0},
         FreeformContactInfo => 
         {read => 1, write => 1, sql_type => -4, length => 0,  is_blob => 1,  is_numeric => 0,  type => 'text', default => ''},
         Organization => 

commit 0e87746b04be010bc488122aaeefbf9fc648b5d0
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 14:03:10 2022 -0500

    Make lower cased indexes on char columns that contain user inputs for Oracle
    
    Now that we're searching them with LOWER(), we need the lower cased
    indexes accordingly.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 7b7ac07475..1c2e205305 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -17,7 +17,7 @@ CREATE TABLE Attachments (
 );
 CREATE INDEX Attachments2 ON Attachments (TransactionId);
 CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId);
-CREATE INDEX Attachments4 ON Attachments (Filename);
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
 
 
 CREATE SEQUENCE QUEUES_seq;
@@ -271,7 +271,7 @@ CREATE TABLE Tickets (
         Creator                 NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created                 DATE
 );
-CREATE INDEX Tickets1 ON Tickets (Queue, Status);
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner);
 CREATE INDEX Tickets6 ON Tickets (EffectiveId, Type);
 
@@ -342,7 +342,7 @@ CREATE TABLE ObjectCustomFieldValues (
         Disabled        NUMBER(11,0) DEFAULT 0 NOT NULL
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (Content); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content)); 
 CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
 
 CREATE SEQUENCE CUSTOMFIELDS_seq;
@@ -493,7 +493,7 @@ CREATE TABLE Assets (
 );
 
 CREATE INDEX AssetsName ON Assets (LOWER(Name));
-CREATE INDEX AssetsStatus ON Assets (Status);
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
 CREATE INDEX AssetsCatalog ON Assets (Catalog);
 
 CREATE SEQUENCE Catalogs_seq;
diff --git a/etc/upgrade/5.0.4/schema.Oracle b/etc/upgrade/5.0.4/schema.Oracle
index 300bf8d8b6..67c43908b3 100644
--- a/etc/upgrade/5.0.4/schema.Oracle
+++ b/etc/upgrade/5.0.4/schema.Oracle
@@ -1,2 +1,10 @@
 ALTER TABLE CustomRoles ADD LookupType VARCHAR2(255);
 UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX ObjectCustomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content));

commit 8b312d02867650e65a892cd3ece8c87061e9fbfc
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 13:10:45 2022 -0500

    Make lower cased indexes on char columns that contain user inputs for Pg
    
    Now that we're searching them with LOWER(), we need the lower cased
    indexes accordingly.

diff --git a/etc/schema.Pg b/etc/schema.Pg
index 0c81859312..ba470daeb6 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -33,7 +33,7 @@ CREATE TABLE Attachments (
 CREATE INDEX Attachments1 ON Attachments (Parent) ;
 CREATE INDEX Attachments2 ON Attachments (TransactionId) ;
 CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId) ;
-CREATE INDEX Attachments4 ON Attachments (Filename) ;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
 
 
 
@@ -429,7 +429,7 @@ CREATE TABLE Tickets (
 
 );
 
-CREATE INDEX Tickets1 ON Tickets (Queue, Status) ;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
 CREATE INDEX Tickets2 ON Tickets (Owner) ;
 CREATE INDEX Tickets3 ON Tickets (EffectiveId) ;
 
@@ -514,7 +514,7 @@ CREATE TABLE ObjectCustomFieldValues (
 
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,LOWER(Content)); 
 CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
 
 
@@ -725,7 +725,7 @@ CREATE TABLE Assets (
 );
 
 CREATE INDEX AssetsName ON Assets (LOWER(Name));
-CREATE INDEX AssetsStatus ON Assets (Status);
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
 CREATE INDEX AssetsCatalog ON Assets (Catalog);
 
 CREATE SEQUENCE catalogs_id_seq;
diff --git a/etc/upgrade/5.0.4/schema.Pg b/etc/upgrade/5.0.4/schema.Pg
index 671d871f45..196e86bb44 100644
--- a/etc/upgrade/5.0.4/schema.Pg
+++ b/etc/upgrade/5.0.4/schema.Pg
@@ -1,2 +1,10 @@
 ALTER TABLE CustomRoles ADD COLUMN LookupType VARCHAR(255);
 UPDATE CustomRoles SET LookupType='RT::Queue-RT::Ticket';
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX ObjectCustomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField, ObjectType, ObjectId, LOWER(Content));

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list