• Nikita Malyavin's avatar
    MDEV-25370 Update for portion changes autoincrement key in bi-temp table · 68c1fbfc
    Nikita Malyavin authored
    According to the standard, the autoincrement column (i.e. *identity
    column*) should be advanced each insert implicitly made by
    UPDATE/DELETE ... FOR PORTION.
    
    This is very unconvenient use in several notable cases. Concider a
    WITHOUT OVERLAPS key with an autoinc column:
    id int auto_increment, unique(id, p without overlaps)
    
    An update or delete with FOR PORTION creates a sense that id will remain
    unchanged in such case.
    
    The standard's IDENTITY reminds MariaDB's AUTO_INCREMENT, however
    the generation rules differ in many ways. For example, there's also a
    notion autoincrement index, which is bound to the autoincrement field.
    
    We will define our own generation rule for the PORTION OF operations
    involving AUTO_INCREMENT:
    * If an autoincrement index contains WITHOUT OVERLAPS specification, then
    a new value should not be generated, otherwise it should.
    
    Apart from WITHOUT OVERLAPS there is also another notable case, referred
    by the reporter - a unique key that has an autoincrement column and a field
    from the period specification:
      id int auto_increment, unique(id, s), period for p(s, e)
    
    for this case, no exception is made, and the autoincrementing rules will be
    proceeded accordung to the standard (i.e. the value will be advanced on
    implicit inserts).
    68c1fbfc
table.cc 309 KB