[Rt-commit] rt branch 5.0/improve-text-indexes created. rt-5.0.3-129-g37aa8a66ee

BPS Git Server git at git.bestpractical.com
Fri Sep 30 20:51:30 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  37aa8a66ee04bafdae812a76d946e0a3cc93a0e2 (commit)

- Log -----------------------------------------------------------------
commit 37aa8a66ee04bafdae812a76d946e0a3cc93a0e2
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 7a39cd65f9..075d317925 100644
--- a/t/api/sql.t
+++ b/t/api/sql.t
@@ -8,7 +8,7 @@ my $users = RT::Users->new( RT->SystemUser );
 $users->WhoHaveGroupRight( Right => 'OwnTicket', Object => RT->System, IncludeSuperusers => 1 );
 like(
     $users->BuildSelectQuery(PreferBind => 0),
-    qr{RightName IN \('SuperUser', 'OwnTicket'\)},
+    qr{LOWER\(\w+.RightName\) IN \('superuser', 'ownticket'\)},
     'RightName check in WhoHaveGroupRight uses IN'
 );
 
@@ -18,14 +18,14 @@ my $general_id = RT::Test->load_or_create_queue( Name => 'General' )->id;
 my $support_id = RT::Test->load_or_create_queue( Name => 'Support' )->id;
 
 my %ticketsql = (
-    q{Status = 'new' OR Status = 'open'}                => qr{Status IN \('new', 'open'\)},
-    q{Status = '__Active__'}                            => qr{Status IN \('new', 'open', 'stalled'\)},
+    q{Status = 'new' OR Status = 'open'}                => qr{LOWER\(main.Status\) IN \('new', 'open'\)},
+    q{Status = '__Active__'}                            => qr{LOWER\(main.Status\) 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 IN \('new', 'open'\)},
+        qr{Queue IN \('$general_id', '$support_id'\).+LOWER\(main.Status\) IN \('new', 'open'\)},
 );
 
 my $tickets = RT::Tickets->new( RT->SystemUser );

commit 9afcabdd7c93d0587b4df3b9a0ab908081f60b5c
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 046a834e9e..0e282380d2 100644
--- a/lib/RT/Assets.pm
+++ b/lib/RT/Assets.pm
@@ -695,10 +695,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 6e827ffe28..95a5866e67 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -4258,10 +4258,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..3bcd88976a 100644
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -993,6 +993,21 @@ sub Limit {
         $ARGS{'CASESENSITIVE'} //= 1;
     }
 
+    # Convert IN searches like "Status IN ( 'new', 'open' )" to "LOWER(Status) IN ( 'new', 'open' )"
+    if (
+           !$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 1278f3b000..118adead45 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -2793,10 +2793,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 8f859e831f5bd7d1e795a50f04b5f5a4298c7a00
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
    
    With it, these indexes will be used by default, so we can get better
    performance.

diff --git a/lib/RT/ACE.pm b/lib/RT/ACE.pm
index 86bd562655..c5b498d19b 100644
--- a/lib/RT/ACE.pm
+++ b/lib/RT/ACE.pm
@@ -773,13 +773,13 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         PrincipalType =>
-                {read => 1, write => 1, sql_type => 12, length => 25,  is_blob => 0,  is_numeric => 0,  type => 'varchar(25)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 25,  is_blob => 0,  is_numeric => 0,  type => 'varchar(25)', default => '', is_case_sensitive => 0},
         PrincipalId =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         RightName =>
-                {read => 1, write => 1, sql_type => 12, length => 25,  is_blob => 0,  is_numeric => 0,  type => 'varchar(25)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 25,  is_blob => 0,  is_numeric => 0,  type => 'varchar(25)', default => '', is_case_sensitive => 0},
         ObjectType =>
-                {read => 1, write => 1, sql_type => 12, length => 25,  is_blob => 0,  is_numeric => 0,  type => 'varchar(25)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 25,  is_blob => 0,  is_numeric => 0,  type => 'varchar(25)', default => '', is_case_sensitive => 0},
         ObjectId =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Creator =>
diff --git a/lib/RT/Asset.pm b/lib/RT/Asset.pm
index e313db5d63..5847ff7e84 100644
--- a/lib/RT/Asset.pm
+++ b/lib/RT/Asset.pm
@@ -647,8 +647,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 8b6dc5ea0f..b62d5fe47c 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/Attribute.pm b/lib/RT/Attribute.pm
index d8d2db1434..1e87ba79d8 100644
--- a/lib/RT/Attribute.pm
+++ b/lib/RT/Attribute.pm
@@ -774,7 +774,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 => 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},
         Description =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         Content =>
@@ -782,7 +782,7 @@ sub _CoreAccessible {
         ContentType =>
                 {read => 1, write => 1, sql_type => 12, length => 16,  is_blob => 0,  is_numeric => 0,  type => 'varchar(16)', default => ''},
         ObjectType =>
-                {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},
         ObjectId =>
                 {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/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 7f9854a204..1eabb8be42 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/Link.pm b/lib/RT/Link.pm
index 1505fe817a..690b8adad8 100644
--- a/lib/RT/Link.pm
+++ b/lib/RT/Link.pm
@@ -462,11 +462,11 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
         Base =>
-                {read => 1, write => 1, sql_type => 12, length => 240,  is_blob => 0,  is_numeric => 0,  type => 'varchar(240)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 240,  is_blob => 0,  is_numeric => 0,  type => 'varchar(240)', default => '', is_case_sensitive => 0},
         Target =>
-                {read => 1, write => 1, sql_type => 12, length => 240,  is_blob => 0,  is_numeric => 0,  type => 'varchar(240)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 240,  is_blob => 0,  is_numeric => 0,  type => 'varchar(240)', default => '', is_case_sensitive => 0},
         Type =>
-                {read => 1, write => 1, sql_type => 12, length => 20,  is_blob => 0,  is_numeric => 0,  type => 'varchar(20)', default => ''},
+                {read => 1, write => 1, sql_type => 12, length => 20,  is_blob => 0,  is_numeric => 0,  type => 'varchar(20)', default => '', is_case_sensitive => 0},
         LocalTarget =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         LocalBase =>
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 8aba033035..d50b4fb171 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -994,7 +994,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 d63881f79e..53944b7b84 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -3659,7 +3659,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/Transaction.pm b/lib/RT/Transaction.pm
index 4f1286bf1b..425b504835 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -2050,7 +2050,7 @@ sub _CoreAccessible {
         id =>
                 {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => ''},
         ObjectType =>
-                {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},
         ObjectId =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         TimeTaken =>
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index f7d28b09eb..d13847a899 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 939d6d05db156c04731cd42ec9f41d1dcb304551
Author: Brian Conry <bconry at bestpractical.com>
Date:   Wed Mar 30 14:03:10 2022 -0500

    Oracle: Update indexes on char columns to use LOWER(column)
    
    Now that we're searching char columns with LOWER(), if the indexes in
    Oracle aren't built using LOWER() then they won't be used.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 324f790d19..09f0edc103 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;
@@ -56,10 +56,10 @@ CREATE TABLE Links (
         Creator         NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created         DATE
 );
-CREATE UNIQUE INDEX Links1 ON Links (Base, Target, Type);
-CREATE INDEX Links2 ON Links (Base, Type);
-CREATE INDEX Links3 ON Links (Target, Type);
-CREATE INDEX Links4 ON Links(Type,LocalBase);
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+CREATE INDEX Links2 ON Links (LOWER(Base), LOWER(Type));
+CREATE INDEX Links3 ON Links (LOWER(Target), LOWER(Type));
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
 
 
 CREATE SEQUENCE PRINCIPALS_seq;
@@ -122,7 +122,7 @@ CREATE TABLE Transactions (
         Creator                 NUMBER(11,0) DEFAULT 0 NOT NULL,
         Created                 DATE
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);
 
 
 CREATE SEQUENCE SCRIPS_seq;
@@ -172,7 +172,7 @@ CREATE TABLE ACL (
         LastUpdatedBy   NUMBER(11,0) DEFAULT 0 NOT NULL,
         LastUpdated     DATE
 );
-CREATE INDEX ACL1 ON ACL(RightName, ObjectType, ObjectId, PrincipalType, PrincipalId);
+CREATE INDEX ACL1 ON ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
 
 
 CREATE SEQUENCE GROUPMEMBERS_seq;
@@ -271,9 +271,9 @@ 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);
+CREATE INDEX Tickets6 ON Tickets (EffectiveId, LOWER(Type));
 
 
 CREATE SEQUENCE SCRIPACTIONS_seq;
@@ -342,8 +342,8 @@ CREATE TABLE ObjectCustomFieldValues (
         Disabled        NUMBER(11,0) DEFAULT 0 NOT NULL
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (Content); 
-CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content)); 
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,LOWER(ObjectType),ObjectId); 
 
 CREATE SEQUENCE CUSTOMFIELDS_seq;
 CREATE TABLE CustomFields (
@@ -402,8 +402,8 @@ CREATE TABLE Attributes (
         LastUpdated             DATE
 );
 
-CREATE INDEX Attributes1 on Attributes(Name);
-CREATE INDEX Attributes2 on Attributes(ObjectType, ObjectId);
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
 
 
 CREATE TABLE sessions (
@@ -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
new file mode 100644
index 0000000000..1838cc8959
--- /dev/null
+++ b/etc/upgrade/5.0.4/schema.Oracle
@@ -0,0 +1,28 @@
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX ACL1;
+CREATE INDEX ACL1 ON ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX Attributes1;
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+DROP INDEX Attributes2;
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
+DROP INDEX Links1;
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+DROP INDEX Links2;
+CREATE INDEX Links2 ON Links (LOWER(Base), LOWER(Type));
+DROP INDEX Links3;
+CREATE INDEX Links3 ON Links (LOWER(Target), LOWER(Type));
+DROP INDEX Links4;
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
+DROP INDEX ObjectCustomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (LOWER(Content));
+DROP INDEX ObjectCustomFieldValues2;
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId);
+DROP INDEX Tickets6;
+CREATE INDEX Tickets6 ON Tickets (EffectiveId, LOWER(Type));
+DROP INDEX Transactions1;
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);

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

    Pg: Update indexes on char columns to use LOWER(column)
    
    Now that we're searching char columns with LOWER(), if the indexes in
    PostgreSQL aren't built using LOWER() then they won't be used.

diff --git a/etc/schema.Pg b/etc/schema.Pg
index 9f34ec4b0a..fe69bfd9f3 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));
 
 
 
@@ -91,8 +91,8 @@ CREATE TABLE Links (
   PRIMARY KEY (id)
 
 );
-CREATE UNIQUE INDEX Links1 ON Links (Base, Target, Type) ;
-CREATE INDEX Links4 ON Links(Type,LocalBase);
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
 
 
 
@@ -202,7 +202,7 @@ CREATE TABLE Transactions (
   PRIMARY KEY (id)
 
 );
-CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);
 
 
 
@@ -278,7 +278,7 @@ CREATE TABLE ACL (
 
 );
 
-CREATE INDEX  ACL1 on ACL(RightName, ObjectType, ObjectId,PrincipalType,PrincipalId);
+CREATE INDEX ACL1 on ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
 
 
 
@@ -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,8 +514,8 @@ CREATE TABLE ObjectCustomFieldValues (
 
 );
 
-CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content); 
-CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId, LOWER(Content));
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId);
 
 
 
@@ -629,8 +629,8 @@ CREATE TABLE Attributes (
 
 );
 
-CREATE INDEX Attributes1 on Attributes(Name);
-CREATE INDEX Attributes2 on Attributes(ObjectType, ObjectId);
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+CREATE INDEX Attributes2 on Attributes(LOWER(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
new file mode 100644
index 0000000000..19bbc0f9aa
--- /dev/null
+++ b/etc/upgrade/5.0.4/schema.Pg
@@ -0,0 +1,22 @@
+DROP INDEX Tickets1;
+CREATE INDEX Tickets1 ON Tickets (Queue, LOWER(Status));
+DROP INDEX AssetsStatus;
+CREATE INDEX AssetsStatus ON Assets (LOWER(Status));
+DROP INDEX ACL1;
+CREATE INDEX ACL1 on ACL(LOWER(RightName), LOWER(ObjectType), ObjectId, LOWER(PrincipalType), PrincipalId);
+DROP INDEX Attachments4;
+CREATE INDEX Attachments4 ON Attachments (LOWER(Filename));
+DROP INDEX Attributes1;
+CREATE INDEX Attributes1 on Attributes(LOWER(Name));
+DROP INDEX Attributes2;
+CREATE INDEX Attributes2 on Attributes(LOWER(ObjectType), ObjectId);
+DROP INDEX Links1;
+CREATE UNIQUE INDEX Links1 ON Links (LOWER(Base), LOWER(Target), LOWER(Type));
+DROP INDEX Links4;
+CREATE INDEX Links4 ON Links(LOWER(Type), LocalBase);
+DROP INDEX ObjectCUstomFieldValues1;
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId, LOWER(Content));
+DROP INDEX ObjectCUstomFieldValues2;
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField, LOWER(ObjectType), ObjectId);
+DROP INDEX Transactions1;
+CREATE INDEX Transactions1 ON Transactions (LOWER(ObjectType), ObjectId);

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


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list