Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4544

Referencing streaming CLOBs in (some) generated column clauses fails

    XMLWordPrintableJSON

Details

    • Low
    • Patch Available, Repro attached
    • Data corruption

    Description

      Referencing a CLOB represented as a stream in generated columns can lead to data corruption or that the query fails.

      For instance, with 10.5:
      create table t (id int, myclob clob, clen generated always as (length(myclob)));

      1. Insert CLOB using the streaming APIs (setCharacterStream).
        The exception 'java.lang.ClassCastException: org.apache.derby.iapi.types.ReaderToUTF8Stream cannot be cast to org.apache.derby.iapi.types.Resetable'

      On trunk the same query results in data corruption, and this isn't detected before the value is read back from store.

      Workaround:
      Don't use the streaming APIs when using CLOBs in generated columns. This increases the memory footprint, and may not feasible for large CLOBs.

      FYI, BLOB deals with this by materializing the value, which effectively equals to using the workaround mentioned above.

      Attachments

        1. derby-4544-01-ab-shortCircuitLengthOptimization.diff
          5 kB
          Richard N. Hillegas
        2. derby-4544-01-ac-shortCircuitLengthOptimization.diff
          9 kB
          Richard N. Hillegas
        3. Test_4544.java
          8 kB
          Richard N. Hillegas
        4. Test_4544.java
          4 kB
          Richard N. Hillegas
        5. Test_4544.java
          3 kB
          Richard N. Hillegas

        Issue Links

          Activity

            People

              rhillegas Richard N. Hillegas
              kristwaa Kristian Waagan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: