Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2.7, 10.2(EOL)
-
None
-
openSUSE 42.2
Description
The following create statement fails on 10.2.7:
CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB; |
Giving the error:
#1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id`
The same create statement works fine on 10.1.22
Attachments
Issue Links
- relates to
-
MDEV-12936 upgrade to 10.2.6 failed upon tables with virtual columns
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue relates to |
Description |
The following create statement fails on 10.2.7:
{{CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT, v INT AS (i) VIRTUAL, PRIMARY KEY (i) ) ENGINE=InnoDB;}} Giving the error: {{#1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `i`}} The same create statement works fine on 10.1.22 |
The following create statement fails on 10.2.7:
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT, v INT AS (i) VIRTUAL, PRIMARY KEY (i) ) ENGINE=InnoDB; Giving the error: #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `i` The same create statement works fine on 10.1.22 |
Description |
The following create statement fails on 10.2.7:
CREATE TABLE t1 ( i INT NOT NULL AUTO_INCREMENT, v INT AS (i) VIRTUAL, PRIMARY KEY (i) ) ENGINE=InnoDB; Giving the error: #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `i` The same create statement works fine on 10.1.22 |
The following create statement fails on 10.2.7:
CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB; Giving the error: #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id` The same create statement works fine on 10.1.22 |
Fix Version/s | N/A [ 14700 ] | |
Assignee | Sergei Golubchik [ serg ] | |
Resolution | Not a Bug [ 6 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Description |
The following create statement fails on 10.2.7:
CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB; Giving the error: #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id` The same create statement works fine on 10.1.22 |
The following create statement fails on 10.2.7:
{code:sql} CREATE TABLE t1 ( id INT NOT NULL AUTO_INCREMENT, v INT AS (id) VIRTUAL, PRIMARY KEY (id) ) ENGINE=InnoDB; {code} Giving the error: #1901 - Function or expression 'AUTO_INCREMENT' cannot be used in the GENERATED ALWAYS AS clause of `id` The same create statement works fine on 10.1.22 |
Assignee | Sergei Golubchik [ serg ] | Ian Gilfillan [ greenman ] |
Resolution | Not a Bug [ 6 ] | |
Status | Closed [ 6 ] | Stalled [ 10000 ] |
Component/s | Documentation [ 10903 ] |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Comment |
[ Should also be documented on the *CREATE TABLE* page, under the *DEFAULT Column Option* heading. The text currently says:
From MariaDB 10.2.1 you can use most functions in DEFAULT. Expressions should have parentheses around them. If you use a non deterministic function in DEFAULT then all inserts to the table will be replicated in row mode. *You can even refer to earlier columns in the DEFAULT expression*: ... But there's no indication that the "earlier columns" cannot be AUTO_INCREMENT. ] |
Workflow | MariaDB v3 [ 81665 ] | MariaDB v4 [ 152485 ] |
This is intentional. Generated columns do not work with auto-incremented columns, they won't see the value. We've introduced the limitation in
MDEV-11117. It's the same in MySQL 5.7.In 10.1 (and earlier version) this was allowed, but it did not work correctly.
To let generated columns work with auto-increment would need a rather big internal refactoring. We want to do that, but it's not a change for 10.2.