[Rt-commit] rt branch 5.0/improve-text-indexes created. rt-5.0.2-113-g9c33e2574d

BPS Git Server git at git.bestpractical.com
Wed Apr 13 18:50:59 UTC 2022


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-indexes has been created
        at  9c33e2574d23616e5a18d5bf74756bcfa2cda20b (commit)

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

    Tickets/Assets Status always use case-insensitive
    
    The code previously  sometimes searched these columns case-sensitive and
    sometimes case-insensitive.  Both Oracle and Pg have case-sensitive
    semantics, so sometimes the indexes were usable and sometimes they
    weren't.
    
    This change standardizes all searches using these columns to be
    explicitly case-insensitive.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 57fbae685d..b5d314ef92 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -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);
 
@@ -491,7 +491,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/schema.Pg b/etc/schema.Pg
index 5f6c3d85fb..2d38332e70 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -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) ;
 
@@ -723,7 +723,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.3/schema.Oracle b/etc/upgrade/5.0.3/schema.Oracle
new file mode 100644
index 0000000000..2d76c9de8b
--- /dev/null
+++ b/etc/upgrade/5.0.3/schema.Oracle
@@ -0,0 +1,4 @@
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
diff --git a/etc/upgrade/5.0.3/schema.Pg b/etc/upgrade/5.0.3/schema.Pg
new file mode 100644
index 0000000000..2d76c9de8b
--- /dev/null
+++ b/etc/upgrade/5.0.3/schema.Pg
@@ -0,0 +1,4 @@
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
diff --git a/lib/RT/Assets.pm b/lib/RT/Assets.pm
index dad7d054ca..7ffa5afb64 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -317,6 +317,9 @@ sub Limit {
     $self->{_sql_looking_at}{ lc $args{FIELD} } = 1
         if $args{FIELD} and (not $args{ALIAS} or $args{ALIAS} eq "main");
 
+    $args{CASESENSITIVE} = 0
+        if $args{FIELD} and lc $args{FIELD} eq 'status' and (not $args{ALIAS} or $args{ALIAS} eq 'main');
+
     $self->SUPER::Limit(%args);
 }
 
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 4ffbd6ab61..0a870df762 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -1649,6 +1649,9 @@ sub Limit {
     $self->{_sql_looking_at}{ lc $args{FIELD} } = 1
         if $args{FIELD} and (not $args{ALIAS} or $args{ALIAS} eq "main");
 
+    $args{CASESENSITIVE} = 0
+        if $args{FIELD} and lc $args{FIELD} eq 'status' and (not $args{ALIAS} or $args{ALIAS} eq 'main');
+
     $self->SUPER::Limit(%args);
 }
 
@@ -1757,10 +1760,11 @@ sub LimitStatus {
         @_
     );
     $self->LimitField(
-        FIELD       => 'Status',
-        VALUE       => $args{'VALUE'},
-        OPERATOR    => $args{'OPERATOR'},
-        DESCRIPTION => join( ' ',
+        FIELD         => 'Status',
+        VALUE         => $args{'VALUE'},
+        OPERATOR      => $args{'OPERATOR'},
+        CASESENSITIVE => 0,
+        DESCRIPTION   => join( ' ',
             $self->loc('Status'), $args{'OPERATOR'},
             $self->loc( $args{'VALUE'} ) ),
     );

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list