SQLite

Check-in [b2c89ef49c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Size reduction and performance improvement in the LIKE and GLOB operators.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b2c89ef49cd19b8031a8149a2dc47cea07dd04e0
User & Date: drh 2014-09-25 00:56:00.685
Context
2014-09-25
02:44
Change that might allow SQLite to build and work using the EBCDIC character set. (check-in: ef30e0352b user: drh tags: trunk)
00:56
Size reduction and performance improvement in the LIKE and GLOB operators. (check-in: b2c89ef49c user: drh tags: trunk)
2014-09-24
19:47
Have each open database allocate its pTmpSpace when the first write cursor is opened, rather than on each insert or delete, for a small space savings and performance boost. (check-in: 99323552c0 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/func.c.
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
  u32 c, c2;
  int invert;
  int seen;
  u8 matchOne = pInfo->matchOne;
  u8 matchAll = pInfo->matchAll;
  u8 matchSet = pInfo->matchSet;
  u8 noCase = pInfo->noCase; 
  int prevEscape = 0;     /* True if the previous character was 'escape' */

  while( (c = sqlite3Utf8Read(&zPattern))!=0 ){
    if( c==matchAll && !prevEscape ){
      while( (c=sqlite3Utf8Read(&zPattern)) == matchAll
               || c == matchOne ){
        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){
          return 0;
        }
      }
      if( c==0 ){







<


|







618
619
620
621
622
623
624

625
626
627
628
629
630
631
632
633
634
  u32 c, c2;
  int invert;
  int seen;
  u8 matchOne = pInfo->matchOne;
  u8 matchAll = pInfo->matchAll;
  u8 matchSet = pInfo->matchSet;
  u8 noCase = pInfo->noCase; 


  while( (c = sqlite3Utf8Read(&zPattern))!=0 ){
    if( c==matchAll ){
      while( (c=sqlite3Utf8Read(&zPattern)) == matchAll
               || c == matchOne ){
        if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){
          return 0;
        }
      }
      if( c==0 ){
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
            c2 = sqlite3Utf8Read(&zString);
          }
        }
        if( c2==0 ) return 0;
        if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;
      }
      return 0;
    }else if( c==matchOne && !prevEscape ){
      if( sqlite3Utf8Read(&zString)==0 ){
        return 0;
      }
    }else if( c==matchSet ){
      u32 prior_c = 0;
      assert( esc==0 );    /* This only occurs for GLOB, not LIKE */
      seen = 0;







|







659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
            c2 = sqlite3Utf8Read(&zString);
          }
        }
        if( c2==0 ) return 0;
        if( patternCompare(zPattern,zString,pInfo,esc) ) return 1;
      }
      return 0;
    }else if( c==matchOne ){
      if( sqlite3Utf8Read(&zString)==0 ){
        return 0;
      }
    }else if( c==matchSet ){
      u32 prior_c = 0;
      assert( esc==0 );    /* This only occurs for GLOB, not LIKE */
      seen = 0;
696
697
698
699
700
701
702
703
704
705
706



707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
          prior_c = c2;
        }
        c2 = sqlite3Utf8Read(&zPattern);
      }
      if( c2==0 || (seen ^ invert)==0 ){
        return 0;
      }
    }else if( esc==c && !prevEscape ){
      prevEscape = 1;
    }else{
      c2 = sqlite3Utf8Read(&zString);



      if( noCase ){
        GlobUpperToLower(c);
        GlobUpperToLower(c2);
      }
      if( c!=c2 ){
        return 0;
      }
      prevEscape = 0;
    }
  }
  return *zString==0;
}

/*
** The sqlite3_strglob() interface.







<
<


>
>
>







<







695
696
697
698
699
700
701


702
703
704
705
706
707
708
709
710
711
712
713

714
715
716
717
718
719
720
          prior_c = c2;
        }
        c2 = sqlite3Utf8Read(&zPattern);
      }
      if( c2==0 || (seen ^ invert)==0 ){
        return 0;
      }


    }else{
      c2 = sqlite3Utf8Read(&zString);
      if( c==esc ){
        c = sqlite3Utf8Read(&zPattern);
      }
      if( noCase ){
        GlobUpperToLower(c);
        GlobUpperToLower(c2);
      }
      if( c!=c2 ){
        return 0;
      }

    }
  }
  return *zString==0;
}

/*
** The sqlite3_strglob() interface.