• patg@krsna.patg.net's avatar
    item_strfunc.cc: · 6128521b
    patg@krsna.patg.net authored
      BUG #11104 
          Took out the offset-=delimiter_length-1 out of the for loop. It was causing
          basically this: 
          select substring_index('the king of the the hill', 'the', -2) to not work.
          The first iteration, offset would be initialised to 24, then strstr would 
          point at 'the king of the the* hill' ('*'means right before the 
          character following), returning a offset of 16. The for loop would then 
          decrement offset by two (3 - 1), to 14, now pointing at 
          "the king of th*e the hill", _skipping_ past the 'e' in the second to last
          'the', and therefore strstr would never have a chance of matching the 
          second to last 'the', then moving on to the 'the' at the begginning of the 
          string!
          In a nutshell, offset was being decremented by too great a value, preventing
          the second to last 'the' from being ever found, hence the result of 
          'king of the the hill' from the query that is reported in the bug report
    func_str.test:
      BUG #11104
      Added tests to make sure fix addresses issues in original bug report
    func_str.result:
      BUG #11104 
      New results for new tests
    6128521b
func_str.test 25.3 KB