Skip to content

Commit

Permalink
SQL: revisit error messages [closes #217]
Browse files Browse the repository at this point in the history
  • Loading branch information
midenok committed Jul 3, 2017
1 parent 177e477 commit 4b0f128
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 188 deletions.
1 change: 1 addition & 0 deletions include/my_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ extern int my_sync_dir(const char *dir_name, myf my_flags);
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
extern const char *my_get_err_msg(uint nr);
extern void my_error(uint nr,myf MyFlags, ...);
extern void my_error_as(uint nr1, uint nr2, myf MyFlags, ...);
extern void my_printf_error(uint my_err, const char *format,
myf MyFlags, ...)
ATTRIBUTE_FORMAT(printf, 2, 4);
Expand Down
8 changes: 4 additions & 4 deletions mysql-test/suite/versioning/r/alter.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ t CREATE TABLE `t` (
alter table t without system versioning;
ERROR HY000: Wrong parameters for `t`: table is not versioned
alter table t with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
alter table t with system versioning;
show create table t;
Table Create Table
Expand Down Expand Up @@ -224,11 +224,11 @@ t CREATE TABLE `t` (
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t modify a int with system versioning;
ERROR HY000: Wrong parameters for `t`: Can not change fields versioning mode in a non-versioned table
ERROR HY000: Wrong parameters for `t`: table is not versioned
alter table t modify a int with system versioning with system versioning;
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `a`
alter table t modify a int with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `a`
alter table t with system versioning;
alter table t modify a int without system versioning;
show create table t;
Expand Down
36 changes: 18 additions & 18 deletions mysql-test/suite/versioning/r/create.result
Original file line number Diff line number Diff line change
Expand Up @@ -103,56 +103,56 @@ Sys_start2 SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW START'
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW START' (`Sys_start2`, `Sys_start`)
create or replace table t1 (
x4 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW END' mismatch
ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW END'
create or replace table t1 (
x5 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW END' (`Sys_end2`, `Sys_end`)
create or replace table t1 (
x6 int unsigned,
period for system_time (Sys_start, Sys_end)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: 'GENERATED AS ROW START' column missing
ERROR HY000: Wrong parameters for `t1`: missing 'AS ROW START'
create or replace table t1 (
x7 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
Sys_end2 SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: multiple 'GENERATED ALWAYS AS ROW END'
ERROR HY000: Wrong parameters for `t1`: multiple 'AS ROW END' (`Sys_end2`, `Sys_end`)
create or replace table t1 (
x8 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (sys_insert, sys_remove)
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' and 'GENERATED AS ROW START' mismatch
ERROR HY000: Wrong parameters for `t1`: mismatch 'PERIOD FOR SYSTEM_TIME' and 'AS ROW START'
create or replace table t1 (
x9 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_end)
);
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
x10 int unsigned,
Sys_start SYS_TRX_TYPE generated always as row start,
Sys_end SYS_TRX_TYPE generated always as row end,
period for system_time (Sys_start, Sys_start)
);
ERROR HY000: Wrong parameters for `t1`: 'PERIOD FOR SYSTEM_TIME' columns must be different
ERROR HY000: Wrong parameters for `t1`: multiple `Sys_start` for 'PERIOD FOR SYSTEM_TIME'
create or replace table t1 (
x11 int unsigned,
Sys_start bigint unsigned generated always as row start,
Expand Down Expand Up @@ -211,7 +211,7 @@ create or replace table t1 (
A3 int,
B int without system versioning
);
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
A4 int,
B int without system versioning
Expand Down Expand Up @@ -254,39 +254,39 @@ t1 CREATE TABLE `t1` (
create or replace table t1 (
A7 int without system versioning
);
ERROR HY000: Wrong parameters for `t1`: 'WITH SYSTEM VERSIONING' missing
ERROR HY000: Wrong parameters for `t1`: missing 'WITH SYSTEM VERSIONING'
create or replace table t1 (
A8 int without system versioning
) with system versioning;
ERROR HY000: Wrong parameters for `t1`: no columns defined with system versioning!
ERROR HY000: Wrong parameters for `t1`: no columns defined 'WITH SYSTEM VERSIONING'
create or replace table t1 (
A9 int without system versioning with system versioning
);
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `A9`
create or replace table t1 (
A10 int with system versioning without system versioning
);
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same field
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING' for `A10`
create table t(
a11 int
) without system versioning;
ERROR HY000: Wrong parameters for `t`: 'WITHOUT SYSTEM VERSIONING' is not allowed
ERROR HY000: Wrong parameters for `t`: not allowed 'WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A12 int
) without system versioning with system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A13 int
) with system versioning without system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A14 int
) with system versioning with system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (
A15 int
) without system versioning without system versioning;
ERROR HY000: Wrong parameters for `t1`: Versioning specified more than once for the same table
ERROR HY000: Wrong parameters for `t1`: multiple 'WITH/WITHOUT SYSTEM VERSIONING'
create or replace table t1 (a int) with system versioning;
create temporary table tmp with system versioning select * from t1;
create or replace table t1 (a int) with system versioning;
Expand Down
28 changes: 21 additions & 7 deletions mysql-test/suite/versioning/r/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -104,33 +104,33 @@ create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 as of now);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: unexpected number of partitions (expected > 1)
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 as of now,
partition p1 as of now);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: multiple `AS OF NOW` partitions
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 versioning,
partition p1 versioning);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: no `AS OF NOW` partition defined
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition pn as of now,
partition p0 versioning);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: AS OF NOW partition is not last
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 versioning,
partition pn as of now);
alter table t1 add partition (
partition p1 as of now);
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: AS OF NOW partition can not be added
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
alter table t1 add partition (
partition p1 versioning);
Warnings:
Expand All @@ -148,10 +148,10 @@ t1 CREATE TABLE `t1` (
PARTITION p1 VERSIONING ENGINE = ${INNODB_OR_MYISAM},
PARTITION pn AS OF NOW ENGINE = ${INNODB_OR_MYISAM})
alter table t1 drop partition pn;
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: `AS OF NOW` partition can not be dropped
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
alter table t1 drop partition p1;
alter table t1 drop partition p0;
ERROR HY000: Wrong parameters for `BY SYSTEM_TIME`: one `AS OF NOW` and at least one `VERSIONING` partition required
ERROR HY000: Wrong partitions consistency for `t1`: must have at least one 'VERSIONING' and exactly one last 'AS OF NOW'
set @now= now(6);
insert into t1 values (1);
set @ts_start= sys_commit_ts('sys_trx_start');
Expand Down Expand Up @@ -226,6 +226,13 @@ select @ts2 = @ts3;
1
create or replace table t1 (x int)
with system versioning
partition by system_time limit 0 (
partition p0 versioning,
partition p1 versioning,
partition pn as of now);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'LIMIT'
create or replace table t1 (x int)
with system versioning
partition by system_time limit 1 (
partition p0 versioning,
partition p1 versioning,
Expand Down Expand Up @@ -268,6 +275,13 @@ x
3
create or replace table t1 (x int)
with system versioning
partition by system_time interval 0 second (
partition p0 versioning,
partition p1 versioning,
partition pn as of now);
ERROR HY000: Wrong parameters for partitioned `t1`: wrong value for 'INTERVAL'
create or replace table t1 (x int)
with system versioning
partition by system_time interval 1 second (
partition p0 versioning,
partition p1 versioning,
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/versioning/r/select.result
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ ERROR HY000: System Versioning required: `FOR SYSTEM_TIME` query
create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
select * from t1 for system_time all for update;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME query`: write-locking of historic rows
ERROR HY000: Versioned SELECT write-locking of history rows
create or replace table t1 (a int not null auto_increment primary key) with system versioning;
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
a
Expand Down Expand Up @@ -437,7 +437,7 @@ x y
2 1
3 1
select * from t1 for system_time all, t2 for system_time all query for system_time all;
ERROR HY000: Wrong versioned query: unused `QUERY FOR SYSTEM_TIME` clause!
ERROR HY000: Unused clause: 'QUERY FOR SYSTEM_TIME'
drop view v1;
drop table t1, t2;
call innodb_verify_vtq(27);
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/versioning/r/vtmd_show.result
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ ERROR 42S02: Table 'test.t_vtmd' doesn't exist
set versioning_ddl_survival=on;
create or replace table t (a int) with system versioning;
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
ERROR HY000: SYSTEM_TIME range selector is prohibited
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
ERROR HY000: SYSTEM_TIME range selector is prohibited
show create table t for system_time before timestamp @tm1;
ERROR HY000: Wrong parameters for `FOR SYSTEM_TIME`: only AS OF allowed here
ERROR HY000: SYSTEM_TIME range selector is prohibited
show create table t for system_time as of timestamp '01-01-1990';
ERROR HY000: VTMD error: failed to query VTMD table
show create table t for system_time as of timestamp '01-01-2020';
Expand Down
30 changes: 23 additions & 7 deletions mysql-test/suite/versioning/t/partition.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ partition by system_time (
partition p0 versioning,
partition pn as of now);

--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 as of now);

--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 as of now,
partition p1 as of now);

--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
partition p0 versioning,
partition p1 versioning);

--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
create or replace table t1 (x int)
with system versioning
partition by system_time (
Expand All @@ -69,7 +69,7 @@ partition by system_time (
partition pn as of now);

# alter table
--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
alter table t1 add partition (
partition p1 as of now);

Expand All @@ -79,10 +79,10 @@ alter table t1 add partition (
--replace_result InnoDB ${INNODB_OR_MYISAM} MyISAM ${INNODB_OR_MYISAM} "bigint(20) unsigned" ${SYS_TRX_TYPE} timestamp(6) ${SYS_TRX_TYPE}
show create table t1;

--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
alter table t1 drop partition pn;
alter table t1 drop partition p1;
--error ER_VERS_WRONG_PARAMS
--error ER_VERS_WRONG_PARTS
alter table t1 drop partition p0;

# insert, delete, update
Expand Down Expand Up @@ -138,6 +138,14 @@ select @ts0 = @ts1;
select @ts2 = @ts3;

# rotation by LIMIT
--error ER_VERS_WRONG_PARAMS
create or replace table t1 (x int)
with system versioning
partition by system_time limit 0 (
partition p0 versioning,
partition p1 versioning,
partition pn as of now);

create or replace table t1 (x int)
with system versioning
partition by system_time limit 1 (
Expand All @@ -162,6 +170,14 @@ delete from t1;
select * from t1 partition (p1) for system_time all;

# rotation by INTERVAL
--error ER_VERS_WRONG_PARAMS
create or replace table t1 (x int)
with system versioning
partition by system_time interval 0 second (
partition p0 versioning,
partition p1 versioning,
partition pn as of now);

create or replace table t1 (x int)
with system versioning
partition by system_time interval 1 second (
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/versioning/t/select.test
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ select * from t1 for system_time all;

create or replace table t1 (x int) with system versioning;
insert into t1 values (1);
--error ER_VERS_WRONG_PARAMS
--error ER_VERS_HISTORY_LOCK
select * from t1 for system_time all for update;

create or replace table t1 (a int not null auto_increment primary key) with system versioning;
Expand Down Expand Up @@ -197,7 +197,7 @@ delete from t1 where x = 3;
insert into t2 values (1);
select * from t1, t2 query for system_time all;

--error ER_VERS_WRONG_QUERY
--error ER_VERS_UNUSED_CLAUSE
select * from t1 for system_time all, t2 for system_time all query for system_time all;

drop view v1;
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/versioning/t/vtmd_show.test
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ show create table t for system_time as of now;
set versioning_ddl_survival=on;

create or replace table t (a int) with system versioning;
--error ER_VERS_WRONG_PARAMS
--error ER_VERS_RANGE_PROHIBITED
show create table t for system_time between timestamp @tm1 and timestamp @tm1;
--error ER_VERS_WRONG_PARAMS
--error ER_VERS_RANGE_PROHIBITED
show create table t for system_time from timestamp @tm1 to timestamp @tm1;
--error ER_VERS_WRONG_PARAMS
--error ER_VERS_RANGE_PROHIBITED
show create table t for system_time before timestamp @tm1;
--error ER_VERS_VTMD_ERROR
show create table t for system_time as of timestamp '01-01-1990';
Expand Down
Loading

0 comments on commit 4b0f128

Please sign in to comment.