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

Forbid ALTER TABLE ... SET CYCLE on identity columns in pre-10.11 databases

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.14.1.0
    • 10.14.1.0
    • SQL
    • None
    • Blocker

    Description

      The

      ALTER TABLE ALTER COLUMN $columnName SET CYCLE

      command does not raise an error even on identity columns in pre-10.12 databases. Those identity columns are not backed by sequence generators. Afterwards, the columns do not cycle, even though the ALTER TABLE command appeared to run successfully. This should be easy to fix. The parser just needs to forbid the ALTER TABLE...SET CYCLE command in pre-10.12 databases. The following scripts show this behavior:

      -- run the following script with version 10.10.1.1:
      connect 'jdbc:derby:db;create=true';
      
      create table t1(a int generated always as identity (start with 2147483646), b int);
      insert into t1(b) values (1);
      insert into t1(b) values (2);
      -- fails as expected
      insert into t1(b) values (3);
      
      select * from t1 order by b;
      
      create table t2(a int generated always as identity (start with 2147483646), b int);
      
      -- now run the following script with 10.14
      connect 'jdbc:derby:db';
      
      -- succeeds but should not
      alter table t2 alter column a set cycle;
      
      insert into t2(b) values (1);
      insert into t2(b) values (2);
      -- fails because the cycling behavior did not change
      insert into t2(b) values (3);
      
      select * from t2 order by b;
      

      Attachments

        1. derby-6962-01-aa-forbidSetCycleOn10_10.diff
          6 kB
          Richard N. Hillegas
        2. derby-6962-01-ab-forbidSetCycleOn10_10.diff
          11 kB
          Richard N. Hillegas

        Issue Links

          Activity

            People

              rhillegas Richard N. Hillegas
              rhillegas Richard N. Hillegas
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: