Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions include/my_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,41 @@ enum interval_type
INTERVAL_MINUTE_MICROSECOND, INTERVAL_SECOND_MICROSECOND, INTERVAL_LAST
};

typedef struct my_timespec
{
my_time_t sec;
ulong usec;
} my_timespec_t;

static inline
int cmp(my_timespec_t a, my_timespec_t b)
{
return ((a.sec > b.sec || (a.sec == b.sec && a.usec > b.usec)) ? 1 :
((a.sec < b.sec || (a.sec == b.sec && a.usec < b.usec)) ? -1 : 0));
}

C_MODE_END

#ifdef __cplusplus
constexpr my_timespec_t MY_TIMESPEC_MIN= {MY_TIME_T_MIN, 0};
constexpr my_timespec_t MY_TIMESPEC_MAX= {TIMESTAMP_MAX_VALUE, TIME_MAX_SECOND_PART};

inline
bool operator< (my_timespec_t a, my_timespec_t b)
{
return cmp(a, b) < 0;
}

inline
bool operator> (my_timespec_t a, my_timespec_t b)
{
return cmp(a, b) > 0;
}

inline
bool operator== (my_timespec_t a, my_timespec_t b)
{
return (a.sec == b.sec) && (a.usec == b.usec);
}
#endif
#endif /* _my_time_h_ */
15 changes: 15 additions & 0 deletions mysql-test/main/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -2921,3 +2921,18 @@ DROP TABLE mdev20498;
#
# End of 10.6 tests
#
#
# MDEV-25529 ALTER TABLE FORCE syntax improved
#
create table t1 (id int primary key);
alter table t1 force partition by hash(id) partitions 2;
alter table t1 force remove partitioning;
alter table t1 partition by hash(id) partitions 2 force;
alter table t1 remove partitioning force;
alter table t1 force partition by hash(id) partitions 2 force;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'force' at line 1
alter table t1 force remove partitioning force;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'force' at line 1
alter table t1 add column x int partition by hash(id) partitions 2;
alter table t1 remove partitioning add column y int;
drop table t1;
17 changes: 17 additions & 0 deletions mysql-test/main/partition.test
Original file line number Diff line number Diff line change
Expand Up @@ -3144,3 +3144,20 @@ DROP TABLE mdev20498;
--echo #
--echo # End of 10.6 tests
--echo #

--echo #
--echo # MDEV-25529 ALTER TABLE FORCE syntax improved
--echo #
create table t1 (id int primary key);
alter table t1 force partition by hash(id) partitions 2;
alter table t1 force remove partitioning;
alter table t1 partition by hash(id) partitions 2 force;
alter table t1 remove partitioning force;
--error ER_PARSE_ERROR
alter table t1 force partition by hash(id) partitions 2 force;
--error ER_PARSE_ERROR
alter table t1 force remove partitioning force;
# Strange syntax, but it exists since 2005 (cd483c55)
alter table t1 add column x int partition by hash(id) partitions 2;
alter table t1 remove partitioning add column y int;
drop table t1;
6 changes: 3 additions & 3 deletions mysql-test/suite/versioning/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ PARTITIONS 2
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-01 00:00:01';
Warnings:
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
Warning 4164 `t1`: STARTS timestamp 2000-01-01 00:00:01 is later than query timestamp 2000-01-01 00:00:00, first history partition may exceed INTERVAL value
# Test default STARTS rounding
set timestamp= unix_timestamp('1999-12-15 13:33:33');
create or replace table t1 (i int) with system versioning
Expand Down Expand Up @@ -556,7 +556,7 @@ set time_zone="+03:00";
create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-01 00:00:00';
Warnings:
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
Warning 4164 `t1`: STARTS timestamp 2000-01-01 00:00:00 is later than query timestamp 1999-12-15 16:33:33, first history partition may exceed INTERVAL value
set timestamp= unix_timestamp('2000-01-01 00:00:00');
create or replace table t2 (i int) with system versioning
partition by system_time interval 1 day;
Expand Down Expand Up @@ -616,7 +616,7 @@ create or replace table t1 (i int) with system versioning
partition by system_time interval 1 day starts '2000-01-03 00:00:00'
partitions 3;
Warnings:
Warning 4164 `t1`: STARTS is later than query time, first history partition may exceed INTERVAL value
Warning 4164 `t1`: STARTS timestamp 2000-01-03 00:00:00 is later than query timestamp 2000-01-01 00:00:00, first history partition may exceed INTERVAL value
insert into t1 values (0);
set timestamp= unix_timestamp('2000-01-01 00:00:01');
update t1 set i= i + 1;
Expand Down
Loading