Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-18492

SQL: Inconsistent behavior of LENGTH limit for CHAR data type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0-beta1
    • None
    • sql
    • Docs Required, Release Notes Required

    Description

      When I create a table with CHAR(length) column, it's still possible to insert character values with length greater than given limit.

      sql-cli> create table xx (pk int primary key, f1 char(5));
      Updated 0 rows.
      sql-cli> insert into xx values (1, 'abcdefgh');
      Updated 1 rows.
      sql-cli> select * from xx;
      ╔════╤══════════╗
      ║ PK │ F1       ║
      ╠════╪══════════╣
      ║ 1  │ abcdefgh ║
      ╚════╧══════════╝
      

      In other hand, length limit is applied when I insert non-char value that's casted into CHAR implicitly. With the same table as above:

      sql-cli> insert into xx values (2, 1234567);
      Updated 1 rows.
      sql-cli> select * from xx;
      ╔════╤══════════╗
      ║ PK │ F1       ║
      ╠════╪══════════╣
      ║ 2  │ 12345    ║
      ╟────┼──────────╢
      ║ 1  │ abcdefgh ║
      ╚════╧══════════╝
      

      Behavior should be consistent: ether strip both values down to the given length limit, or deny to insert too long values in both cases (like it's done in other DBs, like postgresql).

       

      Dynamic params can be processed to, check IgniteSqlValidator#inferDynamicParamType

      NOTE

      VARCHAR is also affected
      (this note was added so that the ticket would be included in the search for the keyword VARCHAR)

      Attachments

        Issue Links

          Activity

            People

              zstan Evgeny Stanilovsky
              akhitrin Andrey Khitrin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 50m
                  3h 50m