Closed billy1624 closed 1 year ago
- parse the
EXTRA
column; if it containsDEFAULT_GENERATED
, then theCOLUMN_DEFAULT
should be regarded as an expression
Hmmm... no. This logic doesn't work on every MySQL / Mariadb version
May be we simply regard CURRENT_TIMESTAMP
as special, but only if the column type is timestamp or datatime.
Note that, CURRENT_DATE
is not special.
Before MariaDB 10.2.1 you couldn't usually provide an expression or function to evaluate at insertion time. You had to provide a constant default value instead. The one exception is that you may use CURRENT_TIMESTAMP as the default value for a TIMESTAMP column to use the current timestamp at insertion time. CURRENT_TIMESTAMP may also be used as the default value for a DATETIME From MariaDB 10.2.1 you can use most functions in DEFAULT. Expressions should have parentheses around them
and this https://mariadb.com/kb/en/information-schema-columns-table/ https://jira.mariadb.org/browse/MDEV-13132 apparently MariaDB would sometimes quote the literal
Default value for the column. From MariaDB 10.2.7, literals are quoted to distinguish them from expressions. NULL means that the column has no default. In MariaDB 10.2.6 and earlier, no quotes were used for any type of default and NULL can either mean that there is no default, or that the default column value is NULL.
Sadly to implement this correctly we have to perform some version check:
MySQL 5: Only literal is supported, so:
TIMESTAMP
or DATETIME
and value is CURRENT_TIMESTAMP
, regard it as DefaultExpr::CurrentTimestamp
MySQL 8:
MariaDB < 10.2.1: Same as MySQL 5
MariaDB >= 10.2.1:
'
it must be a StringHey @tyt2y3, was a success. Please proofread the db specific parsing part for me :)
Done
I just checked on my machine, MySQL 8 default (NULL)
is valid and is different from default null
Wait... I am re-reading this
From MariaDB 10.2.7, literals are quoted to distinguish them from expressions. NULL means that the column has no default
It means for the versions >= 10.2.1 and < 10.2.7 is a void, and there is no way to properly parse the default.
Thank you everyone for the contribution! This feature is now available in the latest release. Now is a good time to upgrade! Your participation is what makes us unique; your adoption is what drives us forward. You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.
PR Info
Bug Fixes