Derby
  1. Derby
  2. DERBY-4693

column rename looses 'identity' attribute.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.3.1.4, 10.6.1.0
    • Fix Version/s: 10.6.2.1, 10.7.1.1
    • Component/s: SQL
    • Labels:
      None
    • Environment:
      ubuntu, java 1.5
    • Urgency:
      Normal
    • Issue & fix info:
      Newcomer, Repro attached

      Description

      renaming an identity column causes the column to loose its 'identity' attribute.

      you can reproduce the problem as follows:

      CREATE TABLE njr_version ( id INTEGER generated always as identity, databaseVersion INTEGER);

      insert into njr_version (databaseVersion) values (10);
      – column inserted successfully.
      rename column njr_version.id to idVersion;

      insert into njr_version (databaseVersion) values (10);
      Error: Column 'IDVERSION' cannot accept a NULL value.

      To compound this problem there is no way to restore the renamed column's identity attribute as the alter command doesn't let you set an identity attribute. The only work around is to create a new table and copy the data across.

      1. patch.diff
        5 kB
        Bryan Pendleton

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        [bulk update] Close all resolved issues that haven't been updated for more than one year.

        Show
        Knut Anders Hatlen added a comment - [bulk update] Close all resolved issues that haven't been updated for more than one year.
        Hide
        Bryan Pendleton added a comment -

        Merged the fix to the 10.6 branch as revision 954684, and marked as resolved.

        Show
        Bryan Pendleton added a comment - Merged the fix to the 10.6 branch as revision 954684, and marked as resolved.
        Hide
        Bryan Pendleton added a comment -

        Committed to the trunk as revision 954344.

        I'll investigate merging this fix back to the 10.6 branch.

        Show
        Bryan Pendleton added a comment - Committed to the trunk as revision 954344. I'll investigate merging this fix back to the 10.6 branch.
        Hide
        Bryan Pendleton added a comment -

        Attached 'patch.diff' contains a proposed fix to the problem,
        and a handful of regression tests. The essence of the fix
        is to observe that, since RENAME COLUMN more-or-less
        drops and re-adds the column, we need to ensure that when
        the column is re-added, if it is an Autoincrement column,
        we set the CREATE_AUTOINCREMENT flag that the parser
        sets when initially creating the table.

        Regression tests completed successfully. Comments or
        suggestions about the patch are welcome.

        Show
        Bryan Pendleton added a comment - Attached 'patch.diff' contains a proposed fix to the problem, and a handful of regression tests. The essence of the fix is to observe that, since RENAME COLUMN more-or-less drops and re-adds the column, we need to ensure that when the column is re-added, if it is an Autoincrement column, we set the CREATE_AUTOINCREMENT flag that the parser sets when initially creating the table. Regression tests completed successfully. Comments or suggestions about the patch are welcome.
        Hide
        Bryan Pendleton added a comment -

        Thanks for tracking this problem down, Brett. It certainly appears
        that RENAME COLUMN isn't maintaining the autoincrement
        information properly. I'll see if I can fix it.

        Show
        Bryan Pendleton added a comment - Thanks for tracking this problem down, Brett. It certainly appears that RENAME COLUMN isn't maintaining the autoincrement information properly. I'll see if I can fix it.
        Hide
        Knut Anders Hatlen added a comment -

        This bug is present all the way back to the introduction of rename column in Derby 10.3, so I'm updating affects versions to reflect that.

        Cleared the fix version field since it is unknown when the bug will be fixed. Added the repro attached flag to indicate that the steps to reproduce are provided in the bug description.

        Show
        Knut Anders Hatlen added a comment - This bug is present all the way back to the introduction of rename column in Derby 10.3, so I'm updating affects versions to reflect that. Cleared the fix version field since it is unknown when the bug will be fixed. Added the repro attached flag to indicate that the steps to reproduce are provided in the bug description.

          People

          • Assignee:
            Bryan Pendleton
            Reporter:
            Brett Sutton
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development