[MDEV-9677] Error in counting in sequence engine Created: 2016-03-02  Updated: 2016-03-03  Resolved: 2016-03-03

Status: Closed
Project: MariaDB Server
Component/s: Documentation, Storage Engine - Sequence
Affects Version/s: 10.1.12
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Bernd Buffen Assignee: Ian Gilfillan
Resolution: Fixed Votes: 0
Labels: None


 Description   

When you count from high to low the Values starts not from "from" Value every time. see sample

MariaDB [mysql]> select Version();
+-----------------------+
| Version()             |
+-----------------------+
| 10.1.12-MariaDB-debug |
+-----------------------+
1 row in set (0.00 sec)

MariaDB [mysql]> SELECT * FROM seq_15_to_1_step_2;
+-----+
| seq |
+-----+
|  15 |
|  13 |
|  11 |
|   9 |
|   7 |
|   5 |
|   3 |
|   1 |
+-----+
8 rows in set (0.00 sec)

MariaDB [mysql]> SELECT * FROM seq_15_to_1_step_3;
+-----+
| seq |
+-----+
|  13 |
|  10 |
|   7 |
|   4 |
|   1 |
+-----+
5 rows in set (0.01 sec)



 Comments   
Comment by Elena Stepanova [ 2016-03-03 ]

It has actually been documented, although wording could be clearer:
https://mariadb.com/kb/en/mariadb/sequence/

To use a sequence in a statement, you select from the table named by a pattern seq_FROM_to_TO or seq_FROM_to_TO_step_STEP.

A sequence can go backward too. In this case the final value will always be 1, so that a descending sequence has the same values as an ascending sequence:

In fact, of course, it should be not "will always be 1", but "will always be the TO value"; but anyway, it works so by design.

greenman, do you think it makes sense to put it better and maybe add a more generic example?

Comment by Ian Gilfillan [ 2016-03-03 ]

Clarified wording and added further examples to demonstrate descending order and from/to.

Generated at Thu Feb 08 07:36:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.