[MDEV-19906] Show internal type for TIMESTAMP, DATETIME, and TIME columns Created: 2019-06-28 Updated: 2023-09-01 Resolved: 2020-01-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data types, Variables |
| Fix Version/s: | 10.5.1 |
| Type: | Task | Priority: | Critical |
| Reporter: | Geoff Montee (Inactive) | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
MySQL 5.6 and later supports the show_old_temporals system variable that configures the server to show internal type for TIMESTAMP, DATETIME, and TIME columns:
https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_show_old_temporals Mixing old temporal types and new temporal types can cause a lot of issues with replication and with importing InnoDB tablespaces. It would be useful to have some easy way tell if a temporal column uses the MariaDB 5.3 format or the MySQL 5.6 format or the pre-MySQL 5.6 format. We should probably port this feature from MySQL, or re-implement a similar feature. |
| Comments |
| Comment by Geoff Montee (Inactive) [ 2019-11-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For InnoDB tables, there is currently a hacky way that you can tell the difference between the MariaDB 5.3 `DATETIME` and `TIMESTAMP` columns and MySQL 5.6 `DATETIME` and `TIMESTAMP` columns. For example, let's say that we create two tables:
We can query information_schema.COLUMNS:
We can also query information_schema.INNODB_SYS_COLUMNS:
That does show some useful information:
So we can see that for MariaDB 5.3 temporals, the `MTYPE` is 6, and for MySQL 5.6 temporals, the `MTYPE` is 3. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2019-11-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is a query that can be used to check InnoDB tables:
For example:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2019-11-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
GeoffMontee, good catch. Thanks for your findings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-01-17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It's been implemented this way: Unlike MySQL, we don't implement the show_old_temporals variable. Instead, old temporal data types (created with a pre-10.0 version of MariaDB)
For example:
Note, new temporal data types are displayed without a format comment. These manual articles have been updated accordingly: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Geoff Montee (Inactive) [ 2020-01-17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi bar, Thanks for implementing this! The comments are only for informational purposes, right? I assume that if a user executes the CREATE TABLE statement that is output by SHOW CREATE TABLE, then MariaDB does not parse the comment to determine whether it needs to use the old datetime format. The user would still need to manually set mysql56_temporal_format if they want to recreate the table with the old datetime format. i.e.:
Is that a correct understanding? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-01-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Geoff, This is correct. The comment is only for informational purpose, it does not get parsed. |