Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-6267

View Index PK Fixed Width Field Truncation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 5.0.0, 4.15.0, 4.14.3
    • 5.1.0, 4.16.0
    • None
    • None

    Description

      1. Create a table T
      2. Create a view V that extends the PK of T, where the last field of the view's PK is a fixed width column C such as an INTEGER or BIGINT
      3. Create a view index VI on V that does NOT contain C in its index key
      4. Select C from the view with a query that runs against the view index

      You will get the following error:

       java.sql.SQLException: ERROR 201 (22000): Illegal data. Expected length of at least 8 bytes, but had 7
      

      giskender, kadir, tkhurana and I investigated. It appears the problem comes from
      IndexMaintainer.buildRowKey:707-713

                  int length = stream.size();
                  int minLength = length - maxTrailingNulls;
                  byte[] indexRowKey = stream.getBuffer();
                  // Remove trailing nulls
                  while (length > minLength && indexRowKey[length-1] == QueryConstants.SEPARATOR_BYTE) {
                      length--;
                  }
      

      The logic to remove trailing separator bytes shouldn't run if the end of the index key (i.e the end of the base PK) is a fixed width column. Otherwise, we'll truncate whenever the last byte of the fixed width field happens to be \x00

       

      This only happens for view indexes (mutitenant or not)

      Attachments

        1. PHOENIX-6267.master.005.patch
          12 kB
          Gokcen Iskender
        2. PHOENIX-6267.4.x.003.patch
          11 kB
          Gokcen Iskender
        3. PHOENIX-6267.master.004.patch
          11 kB
          Gokcen Iskender
        4. PHOENIX-6267.4.x.002.patch
          11 kB
          Gokcen Iskender
        5. PHOENIX-6267.4.x.001.patch
          10 kB
          Gokcen Iskender
        6. PHOENIX-6267.master.003.patch
          11 kB
          Gokcen Iskender
        7. PHOENIX-6267.master.002.patch
          10 kB
          Gokcen Iskender
        8. PHOENIX-6267.master.001.patch
          10 kB
          Gokcen Iskender

        Issue Links

          Activity

            People

              giskender Gokcen Iskender
              gjacoby Geoffrey Jacoby
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: