Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-113

The Sequence class lacks last value / start value

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1
    • Component/s: Schema Managers
    • Labels:
      None
    • Environment:
      Linux / Postgresql

      Description

      The Sequence class only has _initalValue which means that when a sequence is altered (by DROP and CREATE) the existing last_value, aka existing sequence ID is lost and the first attempt on flushing a new record results in a pkey exception.

      This result in the sequence counter starting all over.

      This can be handled by setting _initalValue to whatever is the last sequence value but since it is also used for setting MINVALUE this may not be a good idea. They should be split.

      Not sure what name to use, last_value is from postgresql but I'm sure others use different names.

        Activity

        Hide
        Denis added a comment -

        Not sure if this is entirely relevant to the question, but you can get the full details on a sequence by selecting * from it:

        test=# select * from test_id_seq;
        sequence_name | last_value | start_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
        ------------------------------------------------------------------------------------------------------+----------
        test_id_seq | 1 | 1 | 1 | 9223372036854775807 | 1 | 1 | 0 | f | t
        (1 row)

        Show
        Denis added a comment - Not sure if this is entirely relevant to the question, but you can get the full details on a sequence by selecting * from it: test=# select * from test_id_seq; sequence_name | last_value | start_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called -------------- ---------- ----------- ------------ ------------------- --------- ----------- ------- --------- + ---------- test_id_seq | 1 | 1 | 1 | 9223372036854775807 | 1 | 1 | 0 | f | t (1 row)
        Hide
        Benjamin Eberlei added a comment -

        Fixed by using ALTER SEQUENCE which only changes the increment.

        Show
        Benjamin Eberlei added a comment - Fixed by using ALTER SEQUENCE which only changes the increment.

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Thomas Lundquist
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: