[MDEV-29270] ALTER TABLE PARTITION for RANGE UNIX_TIMESTAMP(COLUMN_NAME) doesn't work Created: 2022-08-08 Updated: 2022-08-23 Resolved: 2022-08-08 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Pramod Mahto | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Currently MariaDB don't support ALTER TABLE PARTITION for RANGE UNIX_TIMESTAMP(COLUMN_NAME) Reference :- https://mariadb.com/kb/en/unix_timestamp/ For Example :-
During create table UNIX_TIMESTAMP('2022-09-02 00:00:00') will be converted into int, before the int check will be done. Maybe in the alter statement it is different.... so using the int in alter is a workaround.
Using the above value in below alter command ...
|
| Comments |
| Comment by Alice Sherepa [ 2022-08-08 ] | ||||||||||||||||||||||
|
KB says: "As you can see in the examples above, UNIX_TIMESTAMP(constant-date-string) returns a timestamp with 6 decimals while MariaDB 5.2 and before returns it without decimals. This can cause a problem if you are using UNIX_TIMESTAMP() as a partitioning function. You can fix this by using FLOOR(UNIX_TIMESTAMP(..)) or changing the date string to a date number, like 20080101000000."
| ||||||||||||||||||||||
| Comment by Pramod Mahto [ 2022-08-08 ] | ||||||||||||||||||||||
|
alice I don't see any difference using floor(UNIX_TIMESTAMP('2022-09-02 00:00:00')) and UNIX_TIMESTAMP('2022-09-02 00:00:00') , its value remain same so I believe both workaround are fine. But is this what we need to do that while using a UNIX_TIMESTAMP ? not a bug ?
| ||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-08-08 ] | ||||||||||||||||||||||
|
Indeed, you can use
The server would see that the datetime literal has no fractional second part and will return an integer. Can be verified with
But it only works in case of a valid datetime literal. Your test case from the bug description uses not ascii dash 0x2d - character, but an EN DASH, Unicode U+2013 character:
|