1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-17553 Enable setting start datetime for interval partitioned history of system versioned tables

* Explicit STARTS syntax
* SHOW CREATE
* Default STARTS rounding depending on INTERVAL type
* Warn when STARTS timestamp is later than query time
* Fix uninitialized Lex->create_last_non_select_table under
  mysql_unpack_partition()

Default STARTS rounding depending on INTERVAL type

If STARTS clause is omitted, default one is assigned with value
derived from query timestamp. The rounding is done on STARTS value
depending on INTERVAL type:

SECOND: no rounding is done;
MINUTE: timestamp seconds is set to 0;
HOUR: timestamp seconds and minutes are set to 0;
DAY, WEEK, MONTH and YEAR: timestamp seconds, minutes and hours are
set to 0 (the date of rotation is kept as current date).
This commit is contained in:
Aleksey Midenkov
2019-11-07 19:21:42 +03:00
parent 77e8a311e1
commit 1e73d7d6c6
11 changed files with 563 additions and 87 deletions

View File

@ -2569,11 +2569,21 @@ char *generate_partition_syntax(THD *thd, partition_info *part_info,
err+= str.append(STRING_WITH_LEN("INTERVAL "));
err+= append_interval(&str, vers_info->interval.type,
vers_info->interval.step);
err+= str.append(STRING_WITH_LEN(" STARTS "));
if (create_info) // not SHOW CREATE
{
err+= str.append(STRING_WITH_LEN(" STARTS "));
err+= str.append_ulonglong(vers_info->interval.start);
}
else
{
MYSQL_TIME ltime;
char ctime[MAX_DATETIME_WIDTH + 1];
thd->variables.time_zone->gmt_sec_to_TIME(&ltime, vers_info->interval.start);
uint ctime_len= my_datetime_to_str(&ltime, ctime, 0);
err+= str.append(STRING_WITH_LEN("TIMESTAMP'"));
err+= str.append(ctime, ctime_len);
err+= str.append('\'');
}
}
if (vers_info->limit)
{