DETAIL:  Valid values are between "1" and "2024".
 create index trgm_idx on test_trgm using gist (t gist_trgm_ops(siglen=2024));
 set enable_seqscan=off;
+-- check index compatibility handling when opclass option is specified
+alter table test_trgm alter column t type varchar(768);
+alter table test_trgm alter column t type text;
 select t,similarity(t,'qwertyu0988') as sml from test_trgm where t % 'qwertyu0988' order by sml desc, t;
       t      |   sml    
 -------------+----------
 
 create index trgm_idx on test_trgm using gist (t gist_trgm_ops(siglen=2024));
 set enable_seqscan=off;
 
+-- check index compatibility handling when opclass option is specified
+alter table test_trgm alter column t type varchar(768);
+alter table test_trgm alter column t type text;
+
 select t,similarity(t,'qwertyu0988') as sml from test_trgm where t % 'qwertyu0988' order by sml desc, t;
 select t,similarity(t,'gwertyu0988') as sml from test_trgm where t % 'gwertyu0988' order by sml desc, t;
 select t,similarity(t,'gwertyu1988') as sml from test_trgm where t % 'gwertyu1988' order by sml desc, t;
 
 #include "catalog/index.h"
 #include "catalog/indexing.h"
 #include "catalog/pg_am.h"
+#include "catalog/pg_collation.h"
 #include "catalog/pg_constraint.h"
 #include "catalog/pg_inherits.h"
 #include "catalog/pg_opclass.h"
 CompareOpclassOptions(Datum *opts1, Datum *opts2, int natts)
 {
    int         i;
+   FmgrInfo    fm;
 
    if (!opts1 && !opts2)
        return true;
 
+   fmgr_info(F_ARRAY_EQ, &fm);
    for (i = 0; i < natts; i++)
    {
        Datum       opt1 = opts1 ? opts1[i] : (Datum) 0;
        else if (opt2 == (Datum) 0)
            return false;
 
-       /* Compare non-NULL text[] datums. */
-       if (!DatumGetBool(DirectFunctionCall2(array_eq, opt1, opt2)))
+       /*
+        * Compare non-NULL text[] datums.  Use C collation to enforce binary
+        * equivalence of texts, because we don't know anything about the
+        * semantics of opclass options.
+        */
+       if (!DatumGetBool(FunctionCall2Coll(&fm, C_COLLATION_OID, opt1, opt2)))
            return false;
    }