Derby
  1. Derby
  2. DERBY-129

Derby should throw a truncation error or warning when CASTing a parameter/constant to char or char for bit datatypes and the data is too large for the datatype.

    Details

    • Urgency:
      Low
    • Issue & fix info:
      Newcomer

      Description

      Derby doesn't throw a truncation exception/warning when data is too large during casting of constants or parameters to character string or bit string data types.

      Following is ij example for constants which is too big for the datatype it is getting cast to
      ij> values (cast ('hello' as char(3)));
      1


      hel

      1 row selected
      ij> values (cast (X'0102' as char(1) for bit data));
      1


      01

      1 row selected

      Following code snippet is when using parameters through a JDBC program
      s.executeUpdate("create table ct (c CLOB(100K))");
      //the following Formatters just loads cData with 32700 'c' characters
      String cData = org.apache.derbyTesting.functionTests.util.Formatters.repeatChar("c",32700);
      //notice that ? in the preared statement below is bound to length 32672
      pSt = con.prepareStatement("insert into ct values (cast (? as varchar(32672)))");
      pSt.setString(1, cData);
      //Derby doesn't throw an exception at ps.execute time for 32700 characters into 32672 parameter. It silently
      truncates it to 32672
      pSt.execute();

      1. d129-1a.diff
        3.02 MB
        Knut Anders Hatlen
      2. d129-1b.diff
        3.02 MB
        Knut Anders Hatlen
      3. delta-1a-1b.diff
        5 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Mamta A. Satoor created issue -
          Kathey Marsden made changes -
          Field Original Value New Value
          Issue & fix info [Newcomer]
          Rick Hillegas made changes -
          Labels derby_triage10_8
          Rick Hillegas made changes -
          Urgency Low
          Dag H. Wanvik made changes -
          Link This issue relates to DERBY-5537 [ DERBY-5537 ]
          Knut Anders Hatlen made changes -
          Link This issue is duplicated by DERBY-5537 [ DERBY-5537 ]
          Knut Anders Hatlen made changes -
          Link This issue relates to DERBY-5537 [ DERBY-5537 ]
          Knut Anders Hatlen made changes -
          Assignee Knut Anders Hatlen [ knutanders ]
          Knut Anders Hatlen made changes -
          Attachment d129-1a.diff [ 12528050 ]
          Knut Anders Hatlen made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Knut Anders Hatlen made changes -
          Attachment d129-1b.diff [ 12528417 ]
          Attachment delta-1a-1b.diff [ 12528418 ]
          Knut Anders Hatlen made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Fix Version/s 10.9.0.0 [ 12316344 ]
          Resolution Fixed [ 1 ]
          Kathey Marsden made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Kathey Marsden made changes -
          Labels derby_triage10_8 derby_backport_reject_10_8 derby_triage10_8
          Kathey Marsden made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Gavin made changes -
          Workflow jira [ 39598 ] Default workflow, editable Closed status [ 12801908 ]
          Knut Anders Hatlen made changes -
          Link This issue is related to DERBY-6373 [ DERBY-6373 ]
          Myrna van Lunteren made changes -
          Status Resolved [ 5 ] Closed [ 6 ]

            People

            • Assignee:
              Knut Anders Hatlen
              Reporter:
              Mamta A. Satoor
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development