Bug #118547 | SET DEFAULT (expr) on PK column requires issuing command twice | ||
---|---|---|---|
Submitted: | 27 Jun 17:26 | Modified: | 30 Jun 6:36 |
Reporter: | Duke Lee | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Information schema | Severity: | S3 (Non-critical) |
Version: | 8.0, 8.4, 8.0.42 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[27 Jun 17:26]
Duke Lee
[27 Jun 17:33]
Duke Lee
Ah, some clarification from further testing: Issuing the first ALTER will set the DDL's default to NULL w/ Extra DEFAULT_GENERATED, so SHOW CREATE TABLE and DESCRIBE will not show the default expression. HOWEVER, inserting a row will actually run the default expression even though it's not reflected in the DDL: CREATE TABLE test ( id INT NOT NULL PRIMARY KEY ); ALTER TABLE test ALTER id SET DEFAULT (1+1); DESCRIBE test; +-------+------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra | +-------+------+------+-----+---------+-------------------+ | id | int | NO | PRI | NULL | DEFAULT_GENERATED | +-------+------+------+-----+---------+-------------------+ INSERT INTO test VALUES (); SELECT * FROM test; +----+ | id | +----+ | 2 | +----+ DESCRIBE test; -- Still NULL +-------+------+------+-----+---------+-------------------+ | Field | Type | Null | Key | Default | Extra | +-------+------+------+-----+---------+-------------------+ | id | int | NO | PRI | NULL | DEFAULT_GENERATED | +-------+------+------+-----+---------+-------------------+ Needless to say, "something's not right." :)
[30 Jun 6:36]
MySQL Verification Team
Hello Duke Lee, Thank you for the report and test case. regards, Umesh