Commit e8b7591e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20610 Assertion failed or btr_validate_index(..) in...

MDEV-20610 Assertion failed or btr_validate_index(..) in row_upd_sec_index_entry on a time_zone change
parent 37fd497c
......@@ -1794,8 +1794,18 @@ item_name varchar(32) primary key, -- A common attribute for all items
i int,
dynamic_cols blob -- Dynamic columns will be stored here
);
Warnings:
Warning 1901 Function or expression 'column_get(`dynamic_cols`,1 as char charset latin1)' cannot be used in the GENERATED ALWAYS AS clause of `color`
Warning 1105 Its intermediate result may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'column_get(column_add(column_create(1,'blue' AS char charset latin1 collate latin1_swedish_ci ),2,'ttt'),`i` as char charset latin1)' cannot be used in the GENERATED ALWAYS AS clause of `cl`
Warning 1105 Its intermediate result may be limited by @@max_allowed_packet
INSERT INTO t1(item_name, dynamic_cols, i) VALUES
('MariaDB T-shirt', COLUMN_CREATE(1, 'blue', 2, 'XL'), 1);
Warnings:
Warning 1901 Function or expression 'column_get(`dynamic_cols`,1 as char charset latin1)' cannot be used in the GENERATED ALWAYS AS clause of `color`
Warning 1105 Its intermediate result may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'column_get(column_add(column_create(1,'blue' AS char charset latin1 collate latin1_swedish_ci ),2,'ttt'),`i` as char charset latin1)' cannot be used in the GENERATED ALWAYS AS clause of `cl`
Warning 1105 Its intermediate result may be limited by @@max_allowed_packet
INSERT INTO t1(item_name, dynamic_cols, i) VALUES
('Thinkpad Laptop', COLUMN_CREATE(1, 'black', 3, 500), 2);
select item_name, color, cl from t1;
......
......@@ -1661,7 +1661,13 @@ CREATE TABLE arrNestTest (
id VARCHAR(80) AS (JSON_COMPACT(JSON_EXTRACT(doc, "$._id"))) UNIQUE KEY,
doc JSON,
CONSTRAINT id_not_null CHECK(id IS NOT NULL));
Warnings:
Warning 1901 Function or expression 'json_compact(json_extract(`doc`,'$._id'))' cannot be used in the GENERATED ALWAYS AS clause of `id`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
INSERT INTO test.arrNestTest (doc) VALUES ('{ "_id" : { "$oid" : "611c0a463b150154132f6636" }, "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : 1.0 } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }');
Warnings:
Warning 1901 Function or expression 'json_compact(json_extract(`doc`,'$._id'))' cannot be used in the GENERATED ALWAYS AS clause of `id`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
SELECT * FROM arrNestTest;
id doc
{"$oid":"611c0a463b150154132f6636"} { "_id" : { "$oid" : "611c0a463b150154132f6636" }, "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : 1.0 } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }
......@@ -1693,6 +1699,9 @@ json_arrayagg('ä') json_objectagg(1, 'ä')
# MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json
#
CREATE TABLE t (id CHAR AS (JSON_COMPACT (JSON_EXTRACT(doc,"$._id"))) UNIQUE KEY,doc JSON,CONSTRAINT notnu CHECK (id IS NOT NULL));
Warnings:
Warning 1901 Function or expression 'json_compact(json_extract(`doc`,'$._id'))' cannot be used in the GENERATED ALWAYS AS clause of `id`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" :0} ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }');
ERROR 22001: Data too long for column 'id' at row 1
DROP TABLE t;
......
#
# Start of 10.5 tests
#
#
# MDEV-20610 Assertion failed or btr_validate_index(..) in row_upd_sec_index_entry on a time_zone change
#
SET time_zone='+04:00';
CREATE TABLE t1 (a DATETIME);
SELECT TIMESTAMP_TZ(a, concat('unknown')) FROM t1;
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 'concat('unknown')) FROM t1' at line 1
SELECT TIMESTAMP_TZ(a, a) FROM t1;
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 'a) FROM t1' at line 1
SELECT TIMESTAMP_TZ(a, 'unknown') FROM t1;
ERROR HY000: Unknown or incorrect time zone: 'unknown'
DROP TABLE t1;
SET time_zone='+04:00';
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('2001-01-01 10:00:00');
CREATE VIEW v1 AS SELECT
TIMESTAMP_TZ(a, '-08:00') AS tstz_a_m0800,
TIMESTAMP_TZ(a, '-04:00') AS tstz_a_m0400,
TIMESTAMP_TZ(a, '-02:00') AS tstz_a_m0200,
TIMESTAMP_TZ(a, '-01:00') AS tstz_a_m0100,
TIMESTAMP_TZ(a, '+00:00') AS tstz_a_p0000,
TIMESTAMP_TZ(a, '+01:00') AS tstz_a_p0100,
TIMESTAMP_TZ(a, '+02:00') AS tstz_a_p0200,
TIMESTAMP_TZ(a, '+04:00') AS tstz_a_p0400,
TIMESTAMP_TZ(a, '+08:00') AS tstz_a_p0800
FROM t1;
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select timestamp_tz(`t1`.`a`,'-08:00') AS `tstz_a_m0800`,timestamp_tz(`t1`.`a`,'-04:00') AS `tstz_a_m0400`,timestamp_tz(`t1`.`a`,'-02:00') AS `tstz_a_m0200`,timestamp_tz(`t1`.`a`,'-01:00') AS `tstz_a_m0100`,timestamp_tz(`t1`.`a`,'+00:00') AS `tstz_a_p0000`,timestamp_tz(`t1`.`a`,'+01:00') AS `tstz_a_p0100`,timestamp_tz(`t1`.`a`,'+02:00') AS `tstz_a_p0200`,timestamp_tz(`t1`.`a`,'+04:00') AS `tstz_a_p0400`,timestamp_tz(`t1`.`a`,'+08:00') AS `tstz_a_p0800` from `t1` latin1 latin1_swedish_ci
CREATE VIEW v2 AS SELECT
UNIX_TIMESTAMP(tstz_a_m0800) AS uts_tstz_a_m0800,
UNIX_TIMESTAMP(tstz_a_m0400) AS uts_tstz_a_m0400,
UNIX_TIMESTAMP(tstz_a_m0200) AS uts_tstz_a_m0200,
UNIX_TIMESTAMP(tstz_a_m0100) AS uts_tstz_a_m0100,
UNIX_TIMESTAMP(tstz_a_p0000) AS uts_tstz_a_p0000,
UNIX_TIMESTAMP(tstz_a_p0100) AS uts_tstz_a_p0100,
UNIX_TIMESTAMP(tstz_a_p0200) AS uts_tstz_a_p0200,
UNIX_TIMESTAMP(tstz_a_p0400) AS uts_tstz_a_p0400,
UNIX_TIMESTAMP(tstz_a_p0800) AS uts_tstz_a_p0800
FROM v1;
SET time_zone='-04:00';
SELECT * FROM v1;
tstz_a_m0800 2001-01-01 10:00:00 -08:00
tstz_a_m0400 2001-01-01 10:00:00 -04:00
tstz_a_m0200 2001-01-01 10:00:00 -02:00
tstz_a_m0100 2001-01-01 10:00:00 -01:00
tstz_a_p0000 2001-01-01 10:00:00 +00:00
tstz_a_p0100 2001-01-01 10:00:00 +01:00
tstz_a_p0200 2001-01-01 10:00:00 +02:00
tstz_a_p0400 2001-01-01 10:00:00 +04:00
tstz_a_p0800 2001-01-01 10:00:00 +08:00
SELECT * FROM v2;
uts_tstz_a_m0800 978372000
uts_tstz_a_m0400 978357600
uts_tstz_a_m0200 978350400
uts_tstz_a_m0100 978346800
uts_tstz_a_p0000 978343200
uts_tstz_a_p0100 978339600
uts_tstz_a_p0200 978336000
uts_tstz_a_p0400 978328800
uts_tstz_a_p0800 978314400
SET time_zone='+00:00';
SELECT * FROM v1;
tstz_a_m0800 2001-01-01 10:00:00 -08:00
tstz_a_m0400 2001-01-01 10:00:00 -04:00
tstz_a_m0200 2001-01-01 10:00:00 -02:00
tstz_a_m0100 2001-01-01 10:00:00 -01:00
tstz_a_p0000 2001-01-01 10:00:00 +00:00
tstz_a_p0100 2001-01-01 10:00:00 +01:00
tstz_a_p0200 2001-01-01 10:00:00 +02:00
tstz_a_p0400 2001-01-01 10:00:00 +04:00
tstz_a_p0800 2001-01-01 10:00:00 +08:00
SELECT * FROM v2;
uts_tstz_a_m0800 978372000
uts_tstz_a_m0400 978357600
uts_tstz_a_m0200 978350400
uts_tstz_a_m0100 978346800
uts_tstz_a_p0000 978343200
uts_tstz_a_p0100 978339600
uts_tstz_a_p0200 978336000
uts_tstz_a_p0400 978328800
uts_tstz_a_p0800 978314400
SET time_zone='+04:00';
SELECT * FROM v1;
tstz_a_m0800 2001-01-01 10:00:00 -08:00
tstz_a_m0400 2001-01-01 10:00:00 -04:00
tstz_a_m0200 2001-01-01 10:00:00 -02:00
tstz_a_m0100 2001-01-01 10:00:00 -01:00
tstz_a_p0000 2001-01-01 10:00:00 +00:00
tstz_a_p0100 2001-01-01 10:00:00 +01:00
tstz_a_p0200 2001-01-01 10:00:00 +02:00
tstz_a_p0400 2001-01-01 10:00:00 +04:00
tstz_a_p0800 2001-01-01 10:00:00 +08:00
SELECT * FROM v2;
uts_tstz_a_m0800 978372000
uts_tstz_a_m0400 978357600
uts_tstz_a_m0200 978350400
uts_tstz_a_m0100 978346800
uts_tstz_a_p0000 978343200
uts_tstz_a_p0100 978339600
uts_tstz_a_p0200 978336000
uts_tstz_a_p0400 978328800
uts_tstz_a_p0800 978314400
ALTER TABLE t1 MODIFY a DATETIME(6);
UPDATE t1 SET a= a + INTERVAL 123456 MICROSECOND;
SET time_zone='-04:00';
SELECT * FROM v1;
tstz_a_m0800 2001-01-01 10:00:00.123456 -08:00
tstz_a_m0400 2001-01-01 10:00:00.123456 -04:00
tstz_a_m0200 2001-01-01 10:00:00.123456 -02:00
tstz_a_m0100 2001-01-01 10:00:00.123456 -01:00
tstz_a_p0000 2001-01-01 10:00:00.123456 +00:00
tstz_a_p0100 2001-01-01 10:00:00.123456 +01:00
tstz_a_p0200 2001-01-01 10:00:00.123456 +02:00
tstz_a_p0400 2001-01-01 10:00:00.123456 +04:00
tstz_a_p0800 2001-01-01 10:00:00.123456 +08:00
SELECT * FROM v2;
uts_tstz_a_m0800 978372000.123456
uts_tstz_a_m0400 978357600.123456
uts_tstz_a_m0200 978350400.123456
uts_tstz_a_m0100 978346800.123456
uts_tstz_a_p0000 978343200.123456
uts_tstz_a_p0100 978339600.123456
uts_tstz_a_p0200 978336000.123456
uts_tstz_a_p0400 978328800.123456
uts_tstz_a_p0800 978314400.123456
SET time_zone='+00:00';
SELECT * FROM v1;
tstz_a_m0800 2001-01-01 10:00:00.123456 -08:00
tstz_a_m0400 2001-01-01 10:00:00.123456 -04:00
tstz_a_m0200 2001-01-01 10:00:00.123456 -02:00
tstz_a_m0100 2001-01-01 10:00:00.123456 -01:00
tstz_a_p0000 2001-01-01 10:00:00.123456 +00:00
tstz_a_p0100 2001-01-01 10:00:00.123456 +01:00
tstz_a_p0200 2001-01-01 10:00:00.123456 +02:00
tstz_a_p0400 2001-01-01 10:00:00.123456 +04:00
tstz_a_p0800 2001-01-01 10:00:00.123456 +08:00
SELECT * FROM v2;
uts_tstz_a_m0800 978372000.123456
uts_tstz_a_m0400 978357600.123456
uts_tstz_a_m0200 978350400.123456
uts_tstz_a_m0100 978346800.123456
uts_tstz_a_p0000 978343200.123456
uts_tstz_a_p0100 978339600.123456
uts_tstz_a_p0200 978336000.123456
uts_tstz_a_p0400 978328800.123456
uts_tstz_a_p0800 978314400.123456
SET time_zone='+04:00';
SELECT * FROM v1;
tstz_a_m0800 2001-01-01 10:00:00.123456 -08:00
tstz_a_m0400 2001-01-01 10:00:00.123456 -04:00
tstz_a_m0200 2001-01-01 10:00:00.123456 -02:00
tstz_a_m0100 2001-01-01 10:00:00.123456 -01:00
tstz_a_p0000 2001-01-01 10:00:00.123456 +00:00
tstz_a_p0100 2001-01-01 10:00:00.123456 +01:00
tstz_a_p0200 2001-01-01 10:00:00.123456 +02:00
tstz_a_p0400 2001-01-01 10:00:00.123456 +04:00
tstz_a_p0800 2001-01-01 10:00:00.123456 +08:00
SELECT * FROM v2;
uts_tstz_a_m0800 978372000.123456
uts_tstz_a_m0400 978357600.123456
uts_tstz_a_m0200 978350400.123456
uts_tstz_a_m0100 978346800.123456
uts_tstz_a_p0000 978343200.123456
uts_tstz_a_p0100 978339600.123456
uts_tstz_a_p0200 978336000.123456
uts_tstz_a_p0400 978328800.123456
uts_tstz_a_p0800 978314400.123456
DROP VIEW v2;
DROP VIEW v1;
DROP TABLE t1;
SET time_zone=DEFAULT;
#
# End of 10.5 tests
#
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20610 Assertion failed or btr_validate_index(..) in row_upd_sec_index_entry on a time_zone change
--echo #
SET time_zone='+04:00';
CREATE TABLE t1 (a DATETIME);
--error ER_PARSE_ERROR
SELECT TIMESTAMP_TZ(a, concat('unknown')) FROM t1;
--error ER_PARSE_ERROR
SELECT TIMESTAMP_TZ(a, a) FROM t1;
--error ER_UNKNOWN_TIME_ZONE
SELECT TIMESTAMP_TZ(a, 'unknown') FROM t1;
DROP TABLE t1;
SET time_zone='+04:00';
CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('2001-01-01 10:00:00');
CREATE VIEW v1 AS SELECT
TIMESTAMP_TZ(a, '-08:00') AS tstz_a_m0800,
TIMESTAMP_TZ(a, '-04:00') AS tstz_a_m0400,
TIMESTAMP_TZ(a, '-02:00') AS tstz_a_m0200,
TIMESTAMP_TZ(a, '-01:00') AS tstz_a_m0100,
TIMESTAMP_TZ(a, '+00:00') AS tstz_a_p0000,
TIMESTAMP_TZ(a, '+01:00') AS tstz_a_p0100,
TIMESTAMP_TZ(a, '+02:00') AS tstz_a_p0200,
TIMESTAMP_TZ(a, '+04:00') AS tstz_a_p0400,
TIMESTAMP_TZ(a, '+08:00') AS tstz_a_p0800
FROM t1;
SHOW CREATE VIEW v1;
CREATE VIEW v2 AS SELECT
UNIX_TIMESTAMP(tstz_a_m0800) AS uts_tstz_a_m0800,
UNIX_TIMESTAMP(tstz_a_m0400) AS uts_tstz_a_m0400,
UNIX_TIMESTAMP(tstz_a_m0200) AS uts_tstz_a_m0200,
UNIX_TIMESTAMP(tstz_a_m0100) AS uts_tstz_a_m0100,
UNIX_TIMESTAMP(tstz_a_p0000) AS uts_tstz_a_p0000,
UNIX_TIMESTAMP(tstz_a_p0100) AS uts_tstz_a_p0100,
UNIX_TIMESTAMP(tstz_a_p0200) AS uts_tstz_a_p0200,
UNIX_TIMESTAMP(tstz_a_p0400) AS uts_tstz_a_p0400,
UNIX_TIMESTAMP(tstz_a_p0800) AS uts_tstz_a_p0800
FROM v1;
--vertical_results
SET time_zone='-04:00';
SELECT * FROM v1;
SELECT * FROM v2;
SET time_zone='+00:00';
SELECT * FROM v1;
SELECT * FROM v2;
SET time_zone='+04:00';
SELECT * FROM v1;
SELECT * FROM v2;
--horizontal_results
ALTER TABLE t1 MODIFY a DATETIME(6);
UPDATE t1 SET a= a + INTERVAL 123456 MICROSECOND;
--vertical_results
SET time_zone='-04:00';
SELECT * FROM v1;
SELECT * FROM v2;
SET time_zone='+00:00';
SELECT * FROM v1;
SELECT * FROM v2;
SET time_zone='+04:00';
SELECT * FROM v1;
SELECT * FROM v2;
--horizontal_results
DROP VIEW v2;
DROP VIEW v1;
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -224,7 +224,13 @@ insert into t1 values(1, default);
ERROR 23000: Duplicate entry '1' for key 'b'
drop table t1;
create table t1(a blob, b blob, c blob as (left(a, 5000)) virtual, d blob as (left(b, 5000)) persistent, unique(a,b(4000)));
Warnings:
Warning 1901 Function or expression 'left(`b`,5000)' cannot be used in the GENERATED ALWAYS AS clause of `d`
Warning 1105 The result octet length 5000 may be limited by @@max_allowed_packet
insert into t1(a,b) values(10,11);
Warnings:
Warning 1901 Function or expression 'left(`b`,5000)' cannot be used in the GENERATED ALWAYS AS clause of `d`
Warning 1105 The result octet length 5000 may be limited by @@max_allowed_packet
insert into t1(a,b) values(10,11);
ERROR 23000: Duplicate entry '10-11' for key 'a'
insert into t1(a,b) values(2,2);
......
This diff is collapsed.
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20610 Assertion failed or btr_validate_index(..) in row_upd_sec_index_entry on a time_zone change
--echo #
--echo #
--echo # timestamp_expr AT TIME ZONE
--echo #
CREATE TABLE t1 (a TIMESTAMP NULL);
CREATE VIEW v_a AS
SELECT
a,
a AT TIME ZONE '-08:00' AS a_at_m0800,
a AT TIME ZONE '-04:00' AS a_at_m0400,
a AT TIME ZONE '-02:00' AS a_at_m0200,
a AT TIME ZONE '-01:00' AS a_at_m0100,
a AT TIME ZONE '+00:00' AS a_at__0000,
a AT TIME ZONE '+01:00' AS a_at_p0100,
a AT TIME ZONE '+02:00' AS a_at_p0200,
a AT TIME ZONE '+04:00' AS a_at_p0400,
a AT TIME ZONE '+08:00' AS a_at_p0800
FROM t1;
CREATE VIEW v_concat AS
SELECT
a,
CONCAT(a AT TIME ZONE '-08:00') AS con_a_at_m0800,
CONCAT(a AT TIME ZONE '-04:00') AS con_a_at_m0400,
CONCAT(a AT TIME ZONE '-02:00') AS con_a_at_m0200,
CONCAT(a AT TIME ZONE '-01:00') AS con_a_at_m0100,
CONCAT(a AT TIME ZONE '+00:00') AS con_a_at__0000,
CONCAT(a AT TIME ZONE '+01:00') AS con_a_at_p0100,
CONCAT(a AT TIME ZONE '+02:00') AS con_a_at_p0200,
CONCAT(a AT TIME ZONE '+04:00') AS con_a_at_p0400,
CONCAT(a AT TIME ZONE '+08:00') AS con_a_at_p0800
FROM t1;
CREATE VIEW v_unix_time AS
SELECT
a,
UNIX_TIMESTAMP(a) AS uts_a_at__none,
UNIX_TIMESTAMP(a AT TIME ZONE '-08:00') AS uts_a_at_m0800,
UNIX_TIMESTAMP(a AT TIME ZONE '-04:00') AS uts_a_at_m0400,
UNIX_TIMESTAMP(a AT TIME ZONE '-02:00') AS uts_a_at_m0200,
UNIX_TIMESTAMP(a AT TIME ZONE '-01:00') AS uts_a_at_m0100,
UNIX_TIMESTAMP(a AT TIME ZONE '+00:00') AS uts_a_at__0000,
UNIX_TIMESTAMP(a AT TIME ZONE '+01:00') AS uts_a_at_p0100,
UNIX_TIMESTAMP(a AT TIME ZONE '+02:00') AS uts_a_at_p0200,
UNIX_TIMESTAMP(a AT TIME ZONE '+04:00') AS uts_a_at_p0400,
UNIX_TIMESTAMP(a AT TIME ZONE '+08:00') AS uts_a_at_p0800
FROM t1;
CREATE VIEW v_extract_ds AS
SELECT
a,
EXTRACT(DAY_SECOND FROM a ) AS eds_a_at__none,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '-08:00') AS eds_a_at_m0800,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '-04:00') AS eds_a_at_m0400,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '-02:00') AS eds_a_at_m0200,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '-01:00') AS eds_a_at_m0100,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '+00:00') AS eds_a_at__0000,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '+01:00') AS eds_a_at_p0100,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '+02:00') AS eds_a_at_p0200,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '+04:00') AS eds_a_at_p0400,
EXTRACT(DAY_SECOND FROM a AT TIME ZONE '+08:00') AS eds_a_at_p0800
FROM t1;
CREATE VIEW v_cast_as_datetime AS
SELECT
a,
CAST(a AS DATETIME) AS cdt_a_at__none,
CAST(a AT TIME ZONE '-08:00' AS DATETIME) AS cdt_a_at_m0800,
CAST(a AT TIME ZONE '-04:00' AS DATETIME) AS cdt_a_at_m0400,
CAST(a AT TIME ZONE '-02:00' AS DATETIME) AS cdt_a_at_m0200,
CAST(a AT TIME ZONE '-01:00' AS DATETIME) AS cdt_a_at_m0100,
CAST(a AT TIME ZONE '+00:00' AS DATETIME) AS cdt_a_at__0000,
CAST(a AT TIME ZONE '+01:00' AS DATETIME) AS cdt_a_at_p0100,
CAST(a AT TIME ZONE '+02:00' AS DATETIME) AS cdt_a_at_p0200,
CAST(a AT TIME ZONE '+04:00' AS DATETIME) AS cdt_a_at_p0400,
CAST(a AT TIME ZONE '+08:00' AS DATETIME) AS cdt_a_at_p0800
FROM t1;
CREATE VIEW v_cast_as_date AS
SELECT
a,
CAST(a AS DATE) AS cdd_a_at__none,
CAST(a AT TIME ZONE '-08:00' AS DATE) AS cdd_a_at_m0800,
CAST(a AT TIME ZONE '-04:00' AS DATE) AS cdd_a_at_m0400,
CAST(a AT TIME ZONE '-02:00' AS DATE) AS cdd_a_at_m0200,
CAST(a AT TIME ZONE '-01:00' AS DATE) AS cdd_a_at_m0100,
CAST(a AT TIME ZONE '+00:00' AS DATE) AS cdd_a_at__0000,
CAST(a AT TIME ZONE '+01:00' AS DATE) AS cdd_a_at_p0100,
CAST(a AT TIME ZONE '+02:00' AS DATE) AS cdd_a_at_p0200,
CAST(a AT TIME ZONE '+04:00' AS DATE) AS cdd_a_at_p0400,
CAST(a AT TIME ZONE '+08:00' AS DATE) AS cdd_a_at_p0800
FROM t1;
CREATE VIEW v_cast_as_time AS
SELECT
a,
CAST(a AS TIME) AS ctm_a_at__none,
CAST(a AT TIME ZONE '-08:00' AS TIME) AS ctm_a_at_m0800,
CAST(a AT TIME ZONE '-04:00' AS TIME) AS ctm_a_at_m0400,
CAST(a AT TIME ZONE '-02:00' AS TIME) AS ctm_a_at_m0200,
CAST(a AT TIME ZONE '-01:00' AS TIME) AS ctm_a_at_m0100,
CAST(a AT TIME ZONE '+00:00' AS TIME) AS ctm_a_at__0000,
CAST(a AT TIME ZONE '+01:00' AS TIME) AS ctm_a_at_p0100,
CAST(a AT TIME ZONE '+02:00' AS TIME) AS ctm_a_at_p0200,
CAST(a AT TIME ZONE '+04:00' AS TIME) AS ctm_a_at_p0400,
CAST(a AT TIME ZONE '+08:00' AS TIME) AS ctm_a_at_p0800
FROM t1;
CREATE VIEW v_cast_as_unsigned AS
SELECT
a,
CAST(a AS UNSIGNED) AS cui_a_at__none,
CAST(a AT TIME ZONE '-08:00' AS UNSIGNED) AS cui_a_at_m0800,
CAST(a AT TIME ZONE '-04:00' AS UNSIGNED) AS cui_a_at_m0400,
CAST(a AT TIME ZONE '-02:00' AS UNSIGNED) AS cui_a_at_m0200,
CAST(a AT TIME ZONE '-01:00' AS UNSIGNED) AS cui_a_at_m0100,
CAST(a AT TIME ZONE '+00:00' AS UNSIGNED) AS cui_a_at__0000,
CAST(a AT TIME ZONE '+01:00' AS UNSIGNED) AS cui_a_at_p0100,
CAST(a AT TIME ZONE '+02:00' AS UNSIGNED) AS cui_a_at_p0200,
CAST(a AT TIME ZONE '+04:00' AS UNSIGNED) AS cui_a_at_p0400,
CAST(a AT TIME ZONE '+08:00' AS UNSIGNED) AS cui_a_at_p0800
FROM t1;
CREATE VIEW v_cast_as_decimal_14_0 AS
SELECT
a,
CAST(a AS DECIMAL(14,0)) AS cdc_a_at__none,
CAST(a AT TIME ZONE '-08:00' AS DECIMAL(14,0)) AS cdc_a_at_m0800,
CAST(a AT TIME ZONE '-04:00' AS DECIMAL(14,0)) AS cdc_a_at_m0400,
CAST(a AT TIME ZONE '-02:00' AS DECIMAL(14,0)) AS cdc_a_at_m0200,
CAST(a AT TIME ZONE '-01:00' AS DECIMAL(14,0)) AS cdc_a_at_m0100,
CAST(a AT TIME ZONE '+00:00' AS DECIMAL(14,0)) AS cdc_a_at__0000,
CAST(a AT TIME ZONE '+01:00' AS DECIMAL(14,0)) AS cdc_a_at_p0100,
CAST(a AT TIME ZONE '+02:00' AS DECIMAL(14,0)) AS cdc_a_at_p0200,
CAST(a AT TIME ZONE '+04:00' AS DECIMAL(14,0)) AS cdc_a_at_p0400,
CAST(a AT TIME ZONE '+08:00' AS DECIMAL(14,0)) AS cdc_a_at_p0800
FROM t1;
CREATE VIEW v_cast_as_double AS
SELECT
a,
CAST(a AS DOUBLE) AS cdb_a_at__none,
CAST(a AT TIME ZONE '-08:00' AS DOUBLE) AS cdb_a_at_m0800,
CAST(a AT TIME ZONE '-04:00' AS DOUBLE) AS cdb_a_at_m0400,
CAST(a AT TIME ZONE '-02:00' AS DOUBLE) AS cdb_a_at_m0200,
CAST(a AT TIME ZONE '-01:00' AS DOUBLE) AS cdb_a_at_m0100,
CAST(a AT TIME ZONE '+00:00' AS DOUBLE) AS cdb_a_at__0000,
CAST(a AT TIME ZONE '+01:00' AS DOUBLE) AS cdb_a_at_p0100,
CAST(a AT TIME ZONE '+02:00' AS DOUBLE) AS cdb_a_at_p0200,
CAST(a AT TIME ZONE '+04:00' AS DOUBLE) AS cdb_a_at_p0400,
CAST(a AT TIME ZONE '+08:00' AS DOUBLE) AS cdb_a_at_p0800
FROM t1;
DELIMITER $$;
CREATE PROCEDURE exec(query TEXT)
BEGIN
SELECT query AS `Query`;
EXECUTE IMMEDIATE query;
END;
$$
CREATE PROCEDURE query_all_views()
BEGIN
CALL exec('SELECT * FROM v_a');
CALL exec('SELECT * FROM v_concat');
CALL exec('SELECT * FROM v_unix_time');
CALL exec('SELECT * FROM v_extract_ds');
CALL exec('SELECT * FROM v_cast_as_datetime');
CALL exec('SELECT * FROM v_cast_as_date');
CALL exec('SELECT * FROM v_cast_as_time');
CALL exec('SELECT * FROM v_cast_as_unsigned');
CALL exec('SELECT * FROM v_cast_as_decimal_14_0');
CALL exec('SELECT * FROM v_cast_as_double');
END;
$$
DELIMITER ;$$
SET time_zone='+04:00';
INSERT INTO t1 VALUES (NULL);
--vertical_results
SET time_zone='+04:00';
CALL query_all_views();
DELETE FROM t1;
--horizontal_results
SET time_zone='+04:00';
INSERT INTO t1 VALUES (TIMESTAMP'2001-01-01 10:00:00');
--vertical_results
SET time_zone='+03:00';
CALL query_all_views();
SET time_zone='+04:00';
CALL query_all_views();
SET time_zone='+05:00';
CALL query_all_views();
DELETE FROM t1;
--horizontal_results
DROP TABLE t1;
--echo #
--echo # datetime_expr AT TIME ZONE
--echo #
CREATE TABLE t1 (a DATETIME);
SET time_zone='+04:00';
INSERT INTO t1 VALUES (NULL);
--vertical_results
SET time_zone='+04:00';
CALL query_all_views();
DELETE FROM t1;
--horizontal_results
SET time_zone='+04:00';
INSERT INTO t1 VALUES (TIMESTAMP'2001-01-01 10:00:00');
--vertical_results
SET time_zone='+03:00';
CALL query_all_views();
SET time_zone='+04:00';
CALL query_all_views();
SET time_zone='+05:00';
CALL query_all_views();
DELETE FROM t1;
--horizontal_results
DROP PROCEDURE query_all_views;
DROP PROCEDURE exec;
DROP VIEW v_a;
DROP VIEW v_concat;
DROP VIEW v_unix_time;
DROP VIEW v_extract_ds;
DROP VIEW v_cast_as_datetime;
DROP VIEW v_cast_as_date;
DROP VIEW v_cast_as_time;
DROP VIEW v_cast_as_unsigned;
DROP VIEW v_cast_as_decimal_14_0;
DROP VIEW v_cast_as_double;
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # Hybrid functions
--echo #
# TODO: fix this to mix as follows:
# TIMESTAMP WITH TIME ZONE + TIMESTAMP -> return TIMESTAMP WITH TIME ZONE???
# ???
SET time_zone='+04:00';
CREATE TABLE t1 (a TIMESTAMP NULL);
INSERT INTO t1 VALUES (NULL),('2001-01-01 10:00:00');
--vertical_results
SELECT
a,
a AT TIME ZONE '+04:00' AS a1,
COALESCE(a AT TIME ZONE '+04:00',
'2002-01-01 10:00:00' AT TIME ZONE '+00:00') AS a2
FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # End of 10.5 tests
--echo #
This diff is collapsed.
This diff is collapsed.
......@@ -8,12 +8,19 @@ a date not null,
b mediumtext generated always as ((a not in (a,a))) virtual,
c timestamp generated always as ((a not in (b,b))) stored
);
Warnings:
Warning 1901 Function or expression '`a` not in (`b`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
insert t1(a) values(7777777777);
Warnings:
Warning 1901 Function or expression '`a` not in (`b`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
Warning 1265 Data truncated for column 'a' at row 1
Warning 1292 Truncated incorrect datetime value: '0'
show warnings;
Level Code Message
Warning 1901 Function or expression '`a` not in (`b`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
Warning 1265 Data truncated for column 'a' at row 1
Warning 1292 Truncated incorrect datetime value: '0'
disconnect con1;
......
......@@ -52,7 +52,13 @@ c_blob BLOB,
c_blob_key BLOB GENERATED ALWAYS AS (REPEAT(c_blob,15)) STORED,
KEY (c_blob_key(200))
);
Warnings:
Warning 1901 Function or expression 'repeat(`c_blob`,15)' cannot be used in the GENERATED ALWAYS AS clause of `c_blob_key`
Warning 1105 The result octet length 983025 may be limited by @@max_allowed_packet
INSERT INTO t1 (c_blob) VALUES ('xceks');
Warnings:
Warning 1901 Function or expression 'repeat(`c_blob`,15)' cannot be used in the GENERATED ALWAYS AS clause of `c_blob_key`
Warning 1105 The result octet length 983025 may be limited by @@max_allowed_packet
DROP TABLE t1;
#
# Bug#21345972 WL8149:JOIN_CACHE::FILTER_VIRTUAL_GCOL_BASE_COLS(): ASSERTION `FALSE' FAILED.
......@@ -279,6 +285,15 @@ KEY (col_int_key, col_longblob_key(100)),
KEY (col_longtext_key(10), col_longblob_key(100)),
KEY (col_int_key, col_text_key(10), col_blob_key(100), col_longtext_key(50), col_longblob_key(50))
) engine=innodb;
Warnings:
Warning 1901 Function or expression 'repeat(`col_blob_nokey`,15)' cannot be used in the GENERATED ALWAYS AS clause of `col_blob_key`
Warning 1105 The result octet length 983025 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_longblob_nokey`,20)' cannot be used in the GENERATED ALWAYS AS clause of `col_longblob_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_longblob_nokey`,18)' cannot be used in the GENERATED ALWAYS AS clause of `col_longtext_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_text_nokey`,30)' cannot be used in the GENERATED ALWAYS AS clause of `col_text_key`
Warning 1105 The result octet length 1966050 may be limited by @@max_allowed_packet
INSERT INTO t1 (col_int_nokey,col_blob_nokey,col_longtext_nokey,col_longblob_nokey,col_text_nokey)
VALUES
(0, 'ijcszxw', 'ijcszxw', 'ijcszxw', 'ijcszxw'),
......@@ -291,6 +306,15 @@ VALUES
(5, 'bjjv', 'bjjv', 'bjjv', 'bjjv'),
(0, 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu', 'jjvvkymalu'),
(3, 'j', 'j', 'j', 'j');
Warnings:
Warning 1901 Function or expression 'repeat(`col_blob_nokey`,15)' cannot be used in the GENERATED ALWAYS AS clause of `col_blob_key`
Warning 1105 The result octet length 983025 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_longblob_nokey`,20)' cannot be used in the GENERATED ALWAYS AS clause of `col_longblob_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_longblob_nokey`,18)' cannot be used in the GENERATED ALWAYS AS clause of `col_longtext_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_text_nokey`,30)' cannot be used in the GENERATED ALWAYS AS clause of `col_text_key`
Warning 1105 The result octet length 1966050 may be limited by @@max_allowed_packet
SELECT alias1.pk AS field1
FROM t1 AS alias1 LEFT OUTER JOIN t1 AS alias2
ON alias1.col_int_key = alias2.col_int_key
......@@ -308,6 +332,15 @@ field1
3
8
8
Warnings:
Warning 1901 Function or expression 'repeat(`col_blob_nokey`,15)' cannot be used in the GENERATED ALWAYS AS clause of `col_blob_key`
Warning 1105 The result octet length 983025 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_longblob_nokey`,20)' cannot be used in the GENERATED ALWAYS AS clause of `col_longblob_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_longblob_nokey`,18)' cannot be used in the GENERATED ALWAYS AS clause of `col_longtext_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_text_nokey`,30)' cannot be used in the GENERATED ALWAYS AS clause of `col_text_key`
Warning 1105 The result octet length 1966050 may be limited by @@max_allowed_packet
DROP TABLE t1;
# bug#21487651: gcols: memory leak after failed alter table
CREATE TABLE t(a int);
......@@ -544,7 +577,15 @@ b BLOB,
c TIMESTAMP GENERATED ALWAYS AS (GREATEST(a, '2000-01-01 00:00:00')) VIRTUAL,
UNIQUE KEY(c)
);
Warnings:
Warning 1901 Function or expression 'greatest(`a`,'2000-01-01 00:00:00')' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
INSERT INTO t(b) VALUES ('');
Warnings:
Warning 1901 Function or expression 'greatest(`a`,'2000-01-01 00:00:00')' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
UPDATE t SET a='2001-01-01 00:00:00';
SELECT c FROM t;
c
......
......@@ -551,12 +551,28 @@ col1 col2 col3 col4 vgc1 sgc1
1 10 100 NULL 1000 -90
2 20 200 NULL 4000 -180
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
SELECT * FROM t1 order by col1;
col1 col2 col3 col4 vgc1 sgc1
1 10 100 NULL 1000 0
2 20 200 NULL 4000 0
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD INDEX vgc1 (vgc1);
ALTER TABLE t1 ADD INDEX sgc1 (sgc1);
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
......@@ -569,19 +585,50 @@ vgc1
1000
4000
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
SELECT * FROM t1 order by col1;
col1 col2 col3 col4 vgc1 sgc1
1 10 100 NULL 1000 0
2 20 200 NULL 4000 0
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
SELECT sgc1 FROM t1 order by sgc1;
sgc1
0
0
ALTER TABLE t1 DROP INDEX vgc1;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 DROP INDEX sgc1;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD UNIQUE INDEX vgc1 (vgc1);
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD UNIQUE INDEX sgc1 (sgc1);
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 / col3) VIRTUAL;
ERROR 23000: Duplicate entry '0' for key 'vgc1'
......
......@@ -551,12 +551,28 @@ col1 col2 col3 col4 vgc1 sgc1
1 10 100 NULL 1000 -90
2 20 200 NULL 4000 -180
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
SELECT * FROM t1 order by col1;
col1 col2 col3 col4 vgc1 sgc1
1 10 100 NULL 1000 0
2 20 200 NULL 4000 0
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD INDEX vgc1 (vgc1);
ALTER TABLE t1 ADD INDEX sgc1 (sgc1);
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 * col3) VIRTUAL;
......@@ -569,19 +585,62 @@ vgc1
1000
4000
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 / col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
SELECT * FROM t1 order by col1;
col1 col2 col3 col4 vgc1 sgc1
1 10 100 NULL 1000 0
2 20 200 NULL 4000 0
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
SELECT sgc1 FROM t1 order by sgc1;
sgc1
0
0
ALTER TABLE t1 DROP INDEX vgc1;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 DROP INDEX sgc1;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 + col3) VIRTUAL;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD UNIQUE INDEX vgc1 (vgc1);
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 MODIFY COLUMN sgc1 INTEGER AS (col2 - col3) STORED;
Warnings:
Warning 1901 Function or expression '`col2` / `col3`' cannot be used in the GENERATED ALWAYS AS clause of `sgc1`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD UNIQUE INDEX sgc1 (sgc1);
ALTER TABLE t1 MODIFY COLUMN vgc1 INTEGER AS (col2 / col3) VIRTUAL;
ERROR 23000: Duplicate entry '0' for key 'vgc1'
......
......@@ -426,11 +426,17 @@ CREATE TABLE t1 (col1 INT, col2 INT, col3 INT, col4 INT, col5
INT GENERATED ALWAYS AS (col3 * col2) VIRTUAL, col6 INT GENERATED ALWAYS AS
(col4 * col1) STORED, col7 INT GENERATED ALWAYS AS (col6 + col6) VIRTUAL,
col8 INT GENERATED ALWAYS AS (col6 / col5) STORED, col9 TEXT);
Warnings:
Warning 1901 Function or expression '`col6` / `col5`' cannot be used in the GENERATED ALWAYS AS clause of `col8`
Warning 1105 Expression depends on @@div_precision_increment
SET @fill_amount = (@@innodb_page_size / 2 ) + 1;
INSERT INTO t1 (col1,col2,col3,col4,col5,col6,col7,col8,col9) VALUES /* 3 */
(3, 3 / 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT, DEFAULT ,REPEAT(CAST(3 AS
CHAR(1)),@fill_amount)) , (3, 3 * 3, 3 + 3, 3 / 3, DEFAULT, DEFAULT, DEFAULT,
DEFAULT ,REPEAT(CAST(3 AS CHAR(1)),@fill_amount));
Warnings:
Warning 1901 Function or expression '`col6` / `col5`' cannot be used in the GENERATED ALWAYS AS clause of `col8`
Warning 1105 Expression depends on @@div_precision_increment
UPDATE t1 SET col1 = 2;
UPDATE t1 SET col7 = DEFAULT;
UPDATE t1 SET col8 = DEFAULT;
......@@ -443,7 +449,13 @@ c blob GENERATED ALWAYS AS (concat(a,b)) VIRTUAL,
d blob GENERATED ALWAYS AS (b) VIRTUAL,
e int(11) GENERATED ALWAYS AS (10) VIRTUAL,
h int(11) NOT NULL, PRIMARY KEY (h), key(c(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65635 may be limited by @@max_allowed_packet
INSERT INTO t(a,b,h) VALUES('aaaaaaa','1111111', 11);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65635 may be limited by @@max_allowed_packet
INSERT INTO t(a,b,h) VALUES('bbbbbbb','2222222', 22);
SELECT c FROM t;
c
......
......@@ -365,7 +365,13 @@ c blob GENERATED ALWAYS AS (concat(a,b)) VIRTUAL,
d blob GENERATED ALWAYS AS (b) VIRTUAL,
e int(11) GENERATED ALWAYS AS (10) VIRTUAL,
h int(11) NOT NULL, PRIMARY KEY (h), key(c(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65635 may be limited by @@max_allowed_packet
INSERT INTO t(a,b,h) VALUES('aaaaaaa','1111111', 11);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65635 may be limited by @@max_allowed_packet
INSERT INTO t(a,b,h) VALUES('bbbbbbb','2222222', 22);
SELECT c FROM t;
c
......
......@@ -224,7 +224,13 @@ col_varchar_nokey TEXT ,
col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)),
KEY (col_varchar_key(50))
);
Warnings:
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
INSERT INTO A (col_varchar_nokey) VALUES ('');
Warnings:
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
CREATE TABLE D (
pk INTEGER AUTO_INCREMENT,
col_date_nokey BLOB,
......@@ -242,12 +248,30 @@ KEY (col_time_key(20)),
KEY (col_datetime_key(20)),
KEY (col_varchar_key(10), col_date_key(10), col_time_key(5), col_datetime_key(5))
);
Warnings:
Warning 1901 Function or expression 'repeat(`col_date_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_date_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_datetime_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_time_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
INSERT INTO D (
col_date_nokey,
col_time_nokey,
col_datetime_nokey,
col_varchar_nokey
) VALUES ('', '', '', ''),('', '', '', '');
Warnings:
Warning 1901 Function or expression 'repeat(`col_date_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_date_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_datetime_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_time_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
DELETE FROM OUTR1.* USING D AS OUTR1 RIGHT JOIN A AS OUTR2 ON
( OUTR1 . `col_varchar_nokey` = OUTR2 . `col_varchar_nokey` );
DROP TABLE IF EXISTS A,D;
......@@ -269,9 +293,18 @@ PRIMARY KEY (`col3`),
UNIQUE KEY uidx (`col2`),
KEY idx (`col5`)
);
Warnings:
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
INSERT INTO t1(col1,col2,col3,col4,col9,col6)
VALUES(1,1,0,1,REPEAT(col1,1000),0), (3,2,1,1,REPEAT(col1,1000),NULL);
Warnings:
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD COLUMN extra INT;
Warnings:
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
DROP TABLE t1;
#
# Bug#21316860: WL8149:INNODB: FAILING ASSERTION:
......@@ -671,9 +704,18 @@ col65 INTEGER DEFAULT NULL,
gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL,
KEY idx1 (gcol2)
);
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
INSERT INTO t1 (col1, col2, col3, col4)
VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5);
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD COLUMN extra INTEGER;
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
SELECT gcol2 FROM t1 FORCE INDEX(idx1);
gcol2
1
......@@ -681,6 +723,9 @@ gcol2
1
1
1
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
DROP TABLE t1;
#
# Bug#21628161 CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN
......
......@@ -224,7 +224,13 @@ col_varchar_nokey TEXT ,
col_varchar_key TEXT GENERATED ALWAYS AS (REPEAT(col_varchar_nokey, 1000)),
KEY (col_varchar_key(50))
);
Warnings:
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
INSERT INTO A (col_varchar_nokey) VALUES ('');
Warnings:
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
CREATE TABLE D (
pk INTEGER AUTO_INCREMENT,
col_date_nokey BLOB,
......@@ -242,12 +248,30 @@ KEY (col_time_key(20)),
KEY (col_datetime_key(20)),
KEY (col_varchar_key(10), col_date_key(10), col_time_key(5), col_datetime_key(5))
);
Warnings:
Warning 1901 Function or expression 'repeat(`col_date_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_date_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_datetime_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_time_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
INSERT INTO D (
col_date_nokey,
col_time_nokey,
col_datetime_nokey,
col_varchar_nokey
) VALUES ('', '', '', ''),('', '', '', '');
Warnings:
Warning 1901 Function or expression 'repeat(`col_date_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_date_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_datetime_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_datetime_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_time_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'repeat(`col_varchar_nokey`,1000)' cannot be used in the GENERATED ALWAYS AS clause of `col_varchar_key`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
DELETE FROM OUTR1.* USING D AS OUTR1 RIGHT JOIN A AS OUTR2 ON
( OUTR1 . `col_varchar_nokey` = OUTR2 . `col_varchar_nokey` );
DROP TABLE IF EXISTS A,D;
......@@ -269,9 +293,22 @@ PRIMARY KEY (`col3`),
UNIQUE KEY uidx (`col2`),
KEY idx (`col5`)
);
Warnings:
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
INSERT INTO t1(col1,col2,col3,col4,col9,col6)
VALUES(1,1,0,1,REPEAT(col1,1000),0), (3,2,1,1,REPEAT(col1,1000),NULL);
Warnings:
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD COLUMN extra INT;
Warnings:
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col2` / `col2`' cannot be used in the GENERATED ALWAYS AS clause of `col5`
Warning 1105 Expression depends on @@div_precision_increment
DROP TABLE t1;
#
# Bug#21316860: WL8149:INNODB: FAILING ASSERTION:
......@@ -671,9 +708,22 @@ col65 INTEGER DEFAULT NULL,
gcol2 INTEGER GENERATED ALWAYS AS (col3 / col4) VIRTUAL,
KEY idx1 (gcol2)
);
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
INSERT INTO t1 (col1, col2, col3, col4)
VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), (5,5,5,5);
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
ALTER TABLE t1 ADD COLUMN extra INTEGER;
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
SELECT gcol2 FROM t1 FORCE INDEX(idx1);
gcol2
1
......@@ -681,6 +731,9 @@ gcol2
1
1
1
Warnings:
Warning 1901 Function or expression '`col3` / `col4`' cannot be used in the GENERATED ALWAYS AS clause of `gcol2`
Warning 1105 Expression depends on @@div_precision_increment
DROP TABLE t1;
#
# Bug#21628161 CRASH/MEMORY CORRUPTION ADDING INDEXES TO VIRTUAL COLUMN
......
......@@ -2,6 +2,9 @@ SET @@session.default_storage_engine = 'InnoDB';
create table t1 (a int,
b int generated always as (a/10) virtual,
c int generated always as (a/10) stored);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create table t2 (a timestamp);
create trigger trg1 before insert on t1 for each row
begin
......@@ -14,12 +17,18 @@ if (new.c > 50) then
set new.a:= 500;
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create trigger trg2 after insert on t1 for each row
begin
if (new.b >= 60) then
insert into t2 values (now());
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create function f1()
returns int
begin
......@@ -32,6 +41,9 @@ return sum1;
end|
set sql_warnings = 1;
insert into t1 (a) values (200);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
select * from t1;
a b c
200 20 20
......@@ -58,6 +70,9 @@ f1()
set sql_warnings = 0;
drop trigger trg1;
drop trigger trg2;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
drop table t2;
create procedure p1()
begin
......@@ -75,6 +90,9 @@ end if;
end;
end|
delete from t1;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
call p1();
select * from t2;
a b c
......
......@@ -2,6 +2,9 @@ SET @@session.default_storage_engine = 'MyISAM';
create table t1 (a int,
b int generated always as (a/10) virtual,
c int generated always as (a/10) stored);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create table t2 (a timestamp);
create trigger trg1 before insert on t1 for each row
begin
......@@ -14,12 +17,18 @@ if (new.c > 50) then
set new.a:= 500;
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create trigger trg2 after insert on t1 for each row
begin
if (new.b >= 60) then
insert into t2 values (now());
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create function f1()
returns int
begin
......@@ -32,6 +41,9 @@ return sum1;
end|
set sql_warnings = 1;
insert into t1 (a) values (200);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
select * from t1;
a b c
200 20 20
......@@ -58,6 +70,9 @@ f1()
set sql_warnings = 0;
drop trigger trg1;
drop trigger trg2;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
drop table t2;
create procedure p1()
begin
......@@ -75,6 +90,9 @@ end if;
end;
end|
delete from t1;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
call p1();
select * from t2;
a b c
......
......@@ -12,8 +12,14 @@ CREATE TABLE `t` (
INSERT INTO t VALUES (REPEAT('g', 16000), REPEAT('x', 16000), DEFAULT, "kk", 1);
INSERT INTO t VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, "mm", 2);
CREATE INDEX idx ON t(c(100));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
SET global debug_dbug="d,ib_purge_virtual_index_callback";
UPDATE t SET a = REPEAT('m', 16000) WHERE a like "aaa%";
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
InnoDB 0 transactions not purged
SET global debug_dbug=@old_dbug;
DROP TABLE t;
......@@ -136,7 +142,13 @@ a b c
8 8 16
DROP TABLE t0, t1;
create table t (a blob, b blob, c blob as (concat(a,b)), h varchar(10), index (c(100)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
insert t(a,b,h) values (repeat('g', 16000), repeat('x', 16000), "kk");
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
insert t(a,b,h) values (repeat('a', 16000), repeat('b', 16000), "mm");
set global debug_dbug="d,ib_purge_virtual_index_callback";
connect prevent_purge, localhost, root;
......
......@@ -320,8 +320,14 @@ DROP TABLE t1;
CREATE TABLE t(fld1 INT NOT NULL,
fld2 INT AS (100/fld1) VIRTUAL,
KEY(fld1), KEY(fld2));
Warnings:
Warning 1901 Function or expression '100 / `fld1`' cannot be used in the GENERATED ALWAYS AS clause of `fld2`
Warning 1105 Expression depends on @@div_precision_increment
CREATE TABLE t_odd(id int);
INSERT INTO t(fld1) VALUES(1), (2);
Warnings:
Warning 1901 Function or expression '100 / `fld1`' cannot be used in the GENERATED ALWAYS AS clause of `fld2`
Warning 1105 Expression depends on @@div_precision_increment
connect stop_purge,localhost,root;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
INSERT INTO t_odd VALUES(10000);
......@@ -351,8 +357,13 @@ CREATE TABLE t(pk INT PRIMARY KEY,
fld1 INT NOT NULL,
fld2 INT AS (100/fld1) VIRTUAL,
KEY(fld1), KEY(fld2));
Warnings:
Warning 1901 Function or expression '100 / `fld1`' cannot be used in the GENERATED ALWAYS AS clause of `fld2`
Warning 1105 Expression depends on @@div_precision_increment
INSERT IGNORE t(pk, fld1) VALUES(1, 0);
Warnings:
Warning 1901 Function or expression '100 / `fld1`' cannot be used in the GENERATED ALWAYS AS clause of `fld2`
Warning 1105 Expression depends on @@div_precision_increment
Warning 1365 Division by 0
SELECT * FROM t;
pk fld1 fld2
......
......@@ -45,6 +45,9 @@ h VARCHAR(10) DEFAULT NULL
INSERT INTO t2 VALUES (REPEAT('g', 16000), REPEAT('x', 16000), DEFAULT, 'kk');
INSERT INTO t2 VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, 'mm');
CREATE INDEX idx ON t2(c(100));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
INSERT INTO t1 (a, b) VALUES(1,1);
connection con1;
BEGIN;
......@@ -85,7 +88,10 @@ affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
ALTER TABLE t2 DROP COLUMN c;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
info: Records: 0 Duplicates: 0 Warnings: 2
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
UPDATE t2 SET a = REPEAT('s', 6000) WHERE a like 'aaa%';
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
......@@ -93,13 +99,23 @@ ALTER TABLE t2 ADD COLUMN x1 BLOB GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL,
ADD COLUMN x2 BLOB GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL,
ADD INDEX(x1(100), x2(120)), ADD INDEX (x1(20));
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
info: Records: 0 Duplicates: 0 Warnings: 4
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `x1`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `x2`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
UPDATE t1 SET a=5;
affected rows: 2
info: Rows matched: 2 Changed: 2 Warnings: 0
UPDATE t2 SET a = REPEAT('m', 16000) WHERE a like 'sss%';
affected rows: 1
info: Rows matched: 1 Changed: 1 Warnings: 0
info: Rows matched: 1 Changed: 1 Warnings: 4
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `x1`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `x2`
Warning 1105 The result octet length 131070 may be limited by @@max_allowed_packet
ALTER TABLE t1 DROP COLUMN b2, ALGORITHM=INPLACE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
......
......@@ -10,18 +10,36 @@ CREATE TABLE t0(a INT NOT NULL) ENGINE=INNODB;
ALTER TABLE t0 ADD UNIQUE INDEX (a);
# Case a: Create table with virtual unique not null column
CREATE TABLE t1(a POINT GENERATED ALWAYS AS (POINT(1,1)) VIRTUAL UNIQUE) ENGINE=INNODB;
Warnings:
Warning 1901 Function or expression 'point(1,1)' cannot be used in the GENERATED ALWAYS AS clause of `a`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
SELECT * FROM t1;
a
Warnings:
Warning 1901 Function or expression 'point(1,1)' cannot be used in the GENERATED ALWAYS AS clause of `a`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
# Case b: Create table with index on virtual point column
CREATE TABLE t2(a POINT GENERATED ALWAYS AS (POINT(1,1)) VIRTUAL, UNIQUE INDEX no_pk(a(1))) ENGINE=INNODB;
Warnings:
Warning 1901 Function or expression 'point(1,1)' cannot be used in the GENERATED ALWAYS AS clause of `a`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
SELECT * FROM t2;
a
Warnings:
Warning 1901 Function or expression 'point(1,1)' cannot be used in the GENERATED ALWAYS AS clause of `a`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
# Case c: Add unique index on virtual point column
CREATE TABLE t3(a POINT GENERATED ALWAYS AS (POINT(1,1)) VIRTUAL)
ENGINE=INNODB;
ALTER TABLE t3 ADD UNIQUE INDEX (a(1));
Warnings:
Warning 1901 Function or expression 'point(1,1)' cannot be used in the GENERATED ALWAYS AS clause of `a`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
SELECT * FROM t3;
a
Warnings:
Warning 1901 Function or expression 'point(1,1)' cannot be used in the GENERATED ALWAYS AS clause of `a`
Warning 1105 The result octet length 4294967295 may be limited by @@max_allowed_packet
# Case d: Add unique index on virtual blob column
CREATE TABLE t4 (a BLOB, b BLOB GENERATED ALWAYS AS (a) VIRTUAL) ENGINE=INNODB;
ALTER TABLE t4 ADD UNIQUE INDEX (b(1));
......
......@@ -191,17 +191,17 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
FROM performance_schema.events_statements_summary_by_digest
ORDER BY DIGEST_TEXT;
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR
test eae5046a9d01df1163966c0bfeaebe2f EXPLAIN SELECT * FROM `test` . `v1` 1
test f1894d73004034fde99d25abd8416ffa EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test b1ddddcfd89c9c5e1326e0c520d03d87 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test 4dd37d9265144f5232d4d4f52ba2191c EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1
test 38faf7d85ad1e905a0da57f4806cea9d EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1
test 927ed567fda67d2c992421529099860a SELECT * FROM `test` . `v1` 1
test ca236012aba4eb3ffdaf69abec7e9366 SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test 525ea4996ecb5a00ee0e61f331a08305 SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test 499aba5b6baca6e30c5d13efc9e616ba SELECT `a` , `b` FROM `test` . `v1` 1
test 3b6fbf35b223db3b2651f2accf6424d2 SELECT `b` , `a` FROM `test` . `v1` 1
test c552920371a4c5745ba299a89382e036 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
test 37dea8f84aac346903b2a7458f5a205c EXPLAIN SELECT * FROM `test` . `v1` 1
test a315952945621324a6bfcf1f6661bc1f EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test 1330b191a5d215acdf8d0b735ec6f336 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test a337bc71da7c8fbc66b6de7512427352 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1
test 0b41d635fa372446c43c91e2aff21566 EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1
test 2bc3eac48624171b6b2fb16df6a5bbea SELECT * FROM `test` . `v1` 1
test 71eee1f484086701a377431beee4964f SELECT * FROM `test` . `v1` WHERE `a` = ? 1
test f9fc1d70334997a0d84ae02de912fc3b SELECT * FROM `test` . `v1` WHERE `b` > ? 1
test 51eb6f80b8fc7e42278d2ef05338f9c6 SELECT `a` , `b` FROM `test` . `v1` 1
test ba48024b5bd0a5bf03ae8e2593f7a8b3 SELECT `b` , `a` FROM `test` . `v1` 1
test ce479a0a1fd4bd47717f1c9082833700 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
DROP TABLE test.v1;
CREATE VIEW test.v1 AS SELECT * FROM test.t1;
EXPLAIN SELECT * from test.v1;
......@@ -248,19 +248,19 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR
FROM performance_schema.events_statements_summary_by_digest
ORDER BY DIGEST_TEXT;
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR
test 93b87bd4ebcbb5ae9bf2dba94c509fb9 CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1
test 57cb0a39892c46938cd83aafa3908811 DROP TABLE `test` . `v1` 1
test eae5046a9d01df1163966c0bfeaebe2f EXPLAIN SELECT * FROM `test` . `v1` 2
test f1894d73004034fde99d25abd8416ffa EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test b1ddddcfd89c9c5e1326e0c520d03d87 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test 4dd37d9265144f5232d4d4f52ba2191c EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2
test 38faf7d85ad1e905a0da57f4806cea9d EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2
test 927ed567fda67d2c992421529099860a SELECT * FROM `test` . `v1` 2
test ca236012aba4eb3ffdaf69abec7e9366 SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test 525ea4996ecb5a00ee0e61f331a08305 SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test 3bc8d25c6199783091cf96f3908727ca SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1
test 499aba5b6baca6e30c5d13efc9e616ba SELECT `a` , `b` FROM `test` . `v1` 2
test 3b6fbf35b223db3b2651f2accf6424d2 SELECT `b` , `a` FROM `test` . `v1` 2
test c552920371a4c5745ba299a89382e036 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
test 441b9375dc36ec4fe7044966d0bf1c1b CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1
test c14613cf8c7cb5f85c64f82e45ae95d6 DROP TABLE `test` . `v1` 1
test 37dea8f84aac346903b2a7458f5a205c EXPLAIN SELECT * FROM `test` . `v1` 2
test a315952945621324a6bfcf1f6661bc1f EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test 1330b191a5d215acdf8d0b735ec6f336 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test a337bc71da7c8fbc66b6de7512427352 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2
test 0b41d635fa372446c43c91e2aff21566 EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2
test 2bc3eac48624171b6b2fb16df6a5bbea SELECT * FROM `test` . `v1` 2
test 71eee1f484086701a377431beee4964f SELECT * FROM `test` . `v1` WHERE `a` = ? 2
test f9fc1d70334997a0d84ae02de912fc3b SELECT * FROM `test` . `v1` WHERE `b` > ? 2
test eab51423dad879a222899a47e35e8390 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1
test 51eb6f80b8fc7e42278d2ef05338f9c6 SELECT `a` , `b` FROM `test` . `v1` 2
test ba48024b5bd0a5bf03ae8e2593f7a8b3 SELECT `b` , `a` FROM `test` . `v1` 2
test ce479a0a1fd4bd47717f1c9082833700 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1
DROP VIEW test.v1;
DROP TABLE test.t1;
......@@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
####################################
SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long;
event_name digest digest_text sql_text
statement/sql/select 230fd11f009a87fecbb87c9fc7361475 SELECT ? + ? + SELECT ...
statement/sql/truncate 19da7becacbb87bb3794bf9f77138fb5 TRUNCATE TABLE truncat...
statement/sql/select d2246116093fecdd0c2fa9a15a9aa724 SELECT ? + ? + SELECT ...
statement/sql/truncate ac81cac1e4b9fd679e83b21b5e88dfa6 TRUNCATE TABLE truncat...
......@@ -32,7 +32,13 @@ d varchar(5000) generated always as (b) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1 (
......@@ -44,7 +50,13 @@ d varchar(5000) generated always as (i) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1(a blob not null, b int, c varbinary (10) generated always as (a) virtual, unique (c(9)));
......
......@@ -34,7 +34,13 @@ d varchar(5000) generated always as (b) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1 (
......@@ -46,7 +52,13 @@ d varchar(5000) generated always as (i) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1(a blob not null, b int, c varbinary (10) generated always as (a) virtual, unique (c(9)));
......@@ -214,7 +226,13 @@ d varchar(5000) generated always as (b) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1 (
......@@ -226,7 +244,13 @@ d varchar(5000) generated always as (i) virtual,
e int(11) generated always as (10) virtual,
h int(11) not null primary key,
index(c(100), d(20)));
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
insert t1 (a,b,h) values (repeat('g', 10000), repeat('x', 2800), 1);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 13000 may be limited by @@max_allowed_packet
update t1 set a = repeat(cast(1 as char), 2000);
drop table t1;
create table t1(a blob not null, b int, c varbinary (10) generated always as (a) virtual, unique (c(9)));
......
......@@ -212,8 +212,14 @@ ERROR HY000: Function or expression 'variance()' cannot be used in the GENERATED
#
# ExtractValue()
create or replace table t1 (a varchar(1024), b varchar(1024) as (ExtractValue(a,'//b[$@j]')) PERSISTENT);
Warnings:
Warning 1901 Function or expression 'extractvalue(`a`,'//b[$@j]')' cannot be used in the GENERATED ALWAYS AS clause of `b`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
# UpdateXML()
create or replace table t1 (a varchar(1024), b varchar(1024) as (UpdateXML(a,'/a','<e>fff</e>')) PERSISTENT);
Warnings:
Warning 1901 Function or expression 'updatexml(`a`,'/a','<e>fff</e>')' cannot be used in the GENERATED ALWAYS AS clause of `b`
Warning 1105 The result octet length 16777216 may be limited by @@max_allowed_packet
#
# Sub-selects
#
......
......@@ -429,11 +429,30 @@ Warnings:
Warning 1286 Unknown storage engine 'innodb'
Warning 1266 Using storage engine MyISAM for table 't'
Note 1071 Specified key was too long; max key length is 1000 bytes
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
insert into t values (0,0,default,0);
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
create table ti like t;
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
alter table ti engine=myisam;
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
insert into ti select * from t;
Warnings:
Warning 1901 Function or expression 'concat(`a`,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 The result octet length 65536 may be limited by @@max_allowed_packet
Warning 1906 The value specified for generated column 'c' in table 'ti' has been ignored
drop tables ti, t;
create table t (id int,a varchar(1),b varchar(1),c varchar(1) generated always as (concat (a,b)),key(c)) engine=myisam;
......
......@@ -19,6 +19,9 @@ d DATETIME,
v TIMESTAMP(4) AS ('2001-01-01 10:20:30.1234') VIRTUAL,
KEY(v,d)
);
Warnings:
Warning 1901 Function or expression ''2001-01-01 10:20:30.1234'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
DROP TABLE t1;
# OK: lower FSP + no virtual index
CREATE TABLE t1 (
......@@ -63,7 +66,15 @@ d DATETIME,
v TIMESTAMP(3) AS (ROUND(t,3)) VIRTUAL,
KEY(v,d)
);
Warnings:
Warning 1901 Function or expression 'round(`t`,3)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
INSERT IGNORE INTO t1 (t,d) VALUES ('2006-03-01 12:44:34.0496','2029-10-10 21:27:53');
Warnings:
Warning 1901 Function or expression 'round(`t`,3)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
SELECT * FROM t1;
t d v
2006-03-01 12:44:34.0496 2029-10-10 21:27:53 2006-03-01 12:44:34.050
......@@ -79,7 +90,15 @@ d DATETIME,
v TIMESTAMP(3) AS (TRUNCATE(t,3)) VIRTUAL,
KEY(v,d)
);
Warnings:
Warning 1901 Function or expression 'truncate(`t`,3)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
INSERT IGNORE INTO t1 (t,d) VALUES ('2006-03-01 12:44:34.0496','2029-10-10 21:27:53');
Warnings:
Warning 1901 Function or expression 'truncate(`t`,3)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
SELECT * FROM t1;
t d v
2006-03-01 12:44:34.0496 2029-10-10 21:27:53 2006-03-01 12:44:34.049
......
This diff is collapsed.
......@@ -2,6 +2,9 @@ SET @@session.default_storage_engine = 'InnoDB';
create table t1 (a int,
b int as (a/10),
c int as (a/10) persistent);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create table t2 (a timestamp);
create trigger trg1 before insert on t1 for each row
begin
......@@ -14,12 +17,18 @@ if (new.c > 50) then
set new.a:= 500;
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create trigger trg2 after insert on t1 for each row
begin
if (new.b >= 60) then
insert into t2 values (now());
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create function f1()
returns int
begin
......@@ -32,6 +41,9 @@ return sum1;
end|
set sql_warnings = 1;
insert into t1 (a) values (200);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
select * from t1;
a b c
200 20 20
......@@ -58,6 +70,9 @@ f1()
set sql_warnings = 0;
drop trigger trg1;
drop trigger trg2;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
drop table t2;
create procedure p1()
begin
......@@ -75,6 +90,9 @@ end if;
end;
end|
delete from t1;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
call p1();
select * from t2;
a b c
......
......@@ -2,6 +2,9 @@ SET @@session.default_storage_engine = 'MyISAM';
create table t1 (a int,
b int as (a/10),
c int as (a/10) persistent);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create table t2 (a timestamp);
create trigger trg1 before insert on t1 for each row
begin
......@@ -14,12 +17,18 @@ if (new.c > 50) then
set new.a:= 500;
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create trigger trg2 after insert on t1 for each row
begin
if (new.b >= 60) then
insert into t2 values (now());
end if;
end|
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
create function f1()
returns int
begin
......@@ -32,6 +41,9 @@ return sum1;
end|
set sql_warnings = 1;
insert into t1 (a) values (200);
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
select * from t1;
a b c
200 20 20
......@@ -58,6 +70,9 @@ f1()
set sql_warnings = 0;
drop trigger trg1;
drop trigger trg2;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
drop table t2;
create procedure p1()
begin
......@@ -75,6 +90,9 @@ end if;
end;
end|
delete from t1;
Warnings:
Warning 1901 Function or expression '`a` / 10' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on @@div_precision_increment
call p1();
select * from t2;
a b c
......
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20610 Assertion failed or btr_validate_index(..) in row_upd_sec_index_entry on a time_zone change
--echo #
--echo # Without indexed the conversion to TIMESTAMP and from TIMESTAMP
--echo # works without errors or wanings
CREATE TABLE t1
(
a DATETIME,
v TIMESTAMP GENERATED ALWAYS AS (a)
);
DROP TABLE t1;
CREATE TABLE t1
(
a TIMESTAMP,
v DATETIME GENERATED ALWAYS AS (a)
);
DROP TABLE t1;
CREATE TABLE t1
(
a DECIMAL(32,0),
v TIMESTAMP GENERATED ALWAYS AS (a)
);
DROP TABLE t1;
CREATE TABLE t1
(
a TIMESTAMP,
v DECIMAL(32,0) GENERATED ALWAYS AS (a)
);
DROP TABLE t1;
--echo #
--echo # TIMESTAMP -> not-TIMESTAMP depends on @@time_zone.
--echo #
CREATE TABLE t1
(
a TIMESTAMP,
v DATETIME GENERATED ALWAYS AS (a),
KEY(v)
);
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (
a TIMESTAMP,
v DECIMAL(32,0) GENERATED ALWAYS AS (a),
KEY(v)
);
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (
a TIMESTAMP,
v VARCHAR(64) GENERATED ALWAYS AS (a),
KEY(v)
);
DROP TABLE t1;
--echo #
--echo # Conversion not-TIMESTAMP -> TIMESTAMP depends on @@time_zone.
--echo #
CREATE OR REPLACE TABLE t1 (
a DECIMAL(32,0),
v TIMESTAMP GENERATED ALWAYS AS (a),
KEY(v)
);
DROP TABLE t1;
CREATE TABLE t1
(
a DATETIME,
v TIMESTAMP GENERATED ALWAYS AS (a),
KEY(v)
);
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1
(
a VARCHAR(64),
v TIMESTAMP GENERATED ALWAYS AS (a),
KEY(v)
);
SHOW WARNINGS;
CREATE TABLE t1
(
a VARCHAR(64),
v TIMESTAMP GENERATED ALWAYS AS (ROUND(a)),
KEY(v)
);
DROP TABLE t1;
CREATE TABLE t1 (
a DECIMAL(32,0),
v TIMESTAMP GENERATED ALWAYS AS (a AT TIME ZONE '+04:00'),
KEY(v)
);
DROP TABLE t1;
CREATE TABLE t1
(
a DATETIME,
v TIMESTAMP GENERATED ALWAYS AS (a AT TIME ZONE '+04:00'),
KEY(v)
);
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1
(
a VARCHAR(64),
v TIMESTAMP GENERATED ALWAYS AS (a AT TIME ZONE '+04:00'),
KEY(v)
);
SHOW WARNINGS;
CREATE TABLE t1
(
a VARCHAR(64),
v TIMESTAMP GENERATED ALWAYS AS (ROUND(a) AT TIME ZONE '+04:00'),
KEY(v)
);
SHOW WARNINGS;
DROP TABLE t1;
--echo #
--echo # LEFT(ts AT TIME ZONE ..) can remove dependency on @@time_zone
--echo #
SET time_zone='+04:00';
CREATE TABLE t1
(
a TIMESTAMP,
v_________at_p0400 VARCHAR(32) GENERATED ALWAYS AS (a AT TIME ZONE '+04:00'),
v_left_19_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (LEFT(a AT TIME ZONE '+04:00',19))
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00');
--vertical_results
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+03:00';
SELECT * FROM t1;
SET time_zone='+05:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # EXTRACT(... FROM ts AT TIME ZONE ..) can remove dependency on @@time_zone
--echo #
SET time_zone='+04:00';
CREATE TABLE t1
(
a TIMESTAMP,
v___________a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (a AT TIME ZONE '+04:00'),
v_e_year____a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(YEAR FROM a AT TIME ZONE '+04:00')),
v_e_month___a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(MONTH FROM a AT TIME ZONE '+04:00')),
v_e_day_____a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(DAY FROM a AT TIME ZONE '+04:00')),
v_e_hour____a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(HOUR FROM a AT TIME ZONE '+04:00')),
v_e_minute__a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(MINUTE FROM a AT TIME ZONE '+04:00')),
v_e_second__a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(SECOND FROM a AT TIME ZONE '+04:00')),
v_e_usecond_a_at_p0400 VARCHAR(32) GENERATED ALWAYS AS (EXTRACT(MICROSECOND FROM a AT TIME ZONE '+04:00'))
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00');
--vertical_results
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+03:00';
SELECT * FROM t1;
SET time_zone='+05:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # Implicit and explicit CAST(... FROM ts AT TIME ZONE ..) can remove dependency on @@time_zone
--echo #
SET time_zone='+04:00';
CREATE TABLE t1
(
a TIMESTAMP,
v_i_cast_as_td_a_________ DATETIME GENERATED ALWAYS AS (a),
v_e_cast_as_td_a_________ DATETIME GENERATED ALWAYS AS (CAST(a AS DATETIME)),
v_i_cast_as_td_a_at_p0400 DATETIME GENERATED ALWAYS AS (a AT TIME ZONE '+04:00'),
v_e_cast_as_td_a_at_p0400 DATETIME GENERATED ALWAYS AS (CAST(a AT TIME ZONE '+04:00' AS DATETIME))
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00');
--vertical_results
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+03:00';
SELECT * FROM t1;
SET time_zone='+05:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # (timestamp_expr AT TIME ZONE 'TZ') removes the dependency on @@time_zone
--echo # and allows the conversion from TIMESTAMP to DATETIME.
--echo #
SET time_zone='+04:00';
CREATE TABLE t1
(
a TIMESTAMP,
vd DATETIME GENERATED ALWAYS AS (a AT TIME ZONE '+01:00'),
KEY(vd)
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00');
--vertical_results
SET time_zone='+08:00';
SELECT * FROM t1;
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+02:00';
SELECT * FROM t1;
SET time_zone='+01:00';
SELECT * FROM t1;
SET time_zone='+00:00';
SELECT * FROM t1;
SET time_zone='-01:00';
SELECT * FROM t1;
SET time_zone='-02:00';
SELECT * FROM t1;
SET time_zone='-04:00';
SELECT * FROM t1;
SET time_zone='-08:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
SET time_zone='+04:00';
CREATE TABLE t1
(
a TIMESTAMP(6),
vd DECIMAL(32,6) GENERATED ALWAYS AS (a AT TIME ZONE '+01:00'),
KEY(vd)
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00.123456');
--vertical_results
SET time_zone='+08:00';
SELECT * FROM t1;
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+02:00';
SELECT * FROM t1;
SET time_zone='+01:00';
SELECT * FROM t1;
SET time_zone='+00:00';
SELECT * FROM t1;
SET time_zone='-01:00';
SELECT * FROM t1;
SET time_zone='-02:00';
SELECT * FROM t1;
SET time_zone='-04:00';
SELECT * FROM t1;
SET time_zone='-08:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # but (datetime_expr AT TIME ZONE 'TZ') still depends on @@time_zone
--echo #
CREATE TABLE t1
(
a DATETIME,
vd DATETIME GENERATED ALWAYS AS (a AT TIME ZONE '+01:00'),
KEY(vd)
);
DROP TABLE t1;
CREATE TABLE t1
(
a DATETIME,
vd TIMESTAMP GENERATED ALWAYS AS (a AT TIME ZONE '+01:00'),
KEY(vd)
);
DROP TABLE t1;
--echo #
--echo # TIMESTAMP_TZ(datetime_expr,'TZ') removes the dependency on @@time_zone
--echo # and allows the conversion from DATETIME to TIMESTAMP.
--echo #
SET time_zone='+04:00';
CREATE TABLE t1
(
a DATETIME,
v TIMESTAMP GENERATED ALWAYS AS (TIMESTAMP_TZ(a, '+01:00')),
u BIGINT GENERATED ALWAYS AS (UNIX_TIMESTAMP(v)),
KEY(v)
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES ('2001-01-01 00:00:00');
--vertical_results
SET time_zone='+08:00';
SELECT * FROM t1;
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+02:00';
SELECT * FROM t1;
SET time_zone='+01:00';
SELECT * FROM t1;
SET time_zone='+00:00';
SELECT * FROM t1;
SET time_zone='-01:00';
SELECT * FROM t1;
SET time_zone='-02:00';
SELECT * FROM t1;
SET time_zone='-04:00';
SELECT * FROM t1;
SET time_zone='-08:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
SET time_zone='+04:00';
CREATE TABLE t1
(
a DECIMAL(32,6),
v TIMESTAMP(6) GENERATED ALWAYS AS (TIMESTAMP_TZ(a, '+01:00')),
u DECIMAL(32,6) GENERATED ALWAYS AS (UNIX_TIMESTAMP(v)),
KEY(v)
);
SHOW CREATE TABLE t1;
INSERT INTO t1 (a) VALUES (20010101000000.123456);
--vertical_results
SET time_zone='+08:00';
SELECT * FROM t1;
SET time_zone='+04:00';
SELECT * FROM t1;
SET time_zone='+02:00';
SELECT * FROM t1;
SET time_zone='+01:00';
SELECT * FROM t1;
SET time_zone='+00:00';
SELECT * FROM t1;
SET time_zone='-01:00';
SELECT * FROM t1;
SET time_zone='-02:00';
SELECT * FROM t1;
SET time_zone='-04:00';
SELECT * FROM t1;
SET time_zone='-08:00';
SELECT * FROM t1;
--horizontal_results
DROP TABLE t1;
SET time_zone=DEFAULT;
--echo #
--echo # but TIMESTAMP_TZ(timestamp_expr, 'tz') still depends on @@time_zone
--echo #
CREATE TABLE t1
(
a TIMESTAMP,
v TIMESTAMP GENERATED ALWAYS AS (TIMESTAMP_TZ(a, '+01:00')),
KEY(v)
);
DROP TABLE t1;
CREATE TABLE t1
(
a TIMESTAMP,
v DATETIME GENERATED ALWAYS AS (TIMESTAMP_TZ(a, '+01:00')),
KEY(v)
);
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -79,6 +79,10 @@ d timestamp(6) generated always as row start,
e timestamp(6) generated always as row end,
period for system_time(d,e)
) with system versioning;
Warnings:
Warning 1901 Function or expression '`a` + interval 1 month' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
show columns from t1;
Field Type Null Key Default Extra
a timestamp(6) NO current_timestamp(6) on update current_timestamp(6)
......@@ -86,6 +90,10 @@ b timestamp(6) YES NULL VIRTUAL GENERATED
c timestamp(6) YES NULL STORED GENERATED
d timestamp(6) NO NULL STORED GENERATED
e timestamp(6) NO NULL STORED GENERATED
Warnings:
Warning 1901 Function or expression '`a` + interval 1 month' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 TIMESTAMP to DATETIME conversion depends on @@time_zone
Warning 1105 DATETIME to TIMESTAMP conversion depends on @@time_zone
select table_catalog,table_schema,table_name,column_name,ordinal_position,column_default,is_nullable,data_type,character_maximum_length,character_octet_length,numeric_precision,numeric_scale,datetime_precision,character_set_name,collation_name,column_type,column_key,extra,column_comment,is_generated,generation_expression,'---' from information_schema.columns where table_name='t1';
table_catalog def
table_schema test
......@@ -197,4 +205,14 @@ column_comment
is_generated ALWAYS
generation_expression ROW END
--- ---
Warnings:
Level Warning
Code 1901
Message Function or expression '`a` + interval 1 month' cannot be used in the GENERATED ALWAYS AS clause of `c`
Level Warning
Code 1105
Message TIMESTAMP to DATETIME conversion depends on @@time_zone
Level Warning
Code 1105
Message DATETIME to TIMESTAMP conversion depends on @@time_zone
drop table t1;
......@@ -287,6 +287,8 @@ drop table t1;
--echo # MDEV-20661 Virtual fields are not recalculated on system fields value assignment
--echo #
# With SYS_DATATYPE=TIMESTAMP expressions (a^row_start) and (a^row_end) depend on @@time_zone
--disable_warnings
replace_result $sys_datatype_expl SYS_DATATYPE;
eval create table t1 (
a int,
......@@ -300,6 +302,7 @@ eval create table t1 (
insert into t1 (a) values (1), (2);
update ignore t1 set a= 3;
delete history from t1;
--enable_warnings
# cleanup
drop table t1;
......
......@@ -161,6 +161,7 @@ SET (SQL_SOURCE
sql_type.cc sql_mode.cc sql_type_json.cc
sql_type_string.cc
sql_type_geom.cc
sql_type_timestamp_with_tz.cc
item_windowfunc.cc sql_window.cc
sql_cte.cc
item_vers.cc
......
......@@ -1499,6 +1499,21 @@ bool Field::check_vcol_sql_mode_dependency(THD *thd, vcol_init_mode mode) const
dep.push_dependency_warnings(thd);
return error;
}
Session_env_dependency env_dep_value=
vcol_info->expr->value_depends_on_session_env();
Session_env_dependency env_dep_cnv(0,
type_handler()->
type_conversion_dependency_from(
vcol_info->expr->type_handler()));
Session_env_dependency env_dep= env_dep_value | env_dep_cnv;
if (env_dep)
{
// Will be changed to error in 11.6
bool error= false;//(mode & VCOL_INIT_DEPENDENCY_FAILURE_IS_ERROR) != 0;
error_generated_column_function_is_not_allowed(thd, error);
env_dep.push_dependency_warnings(thd, vcol_info->expr);
return error;
}
}
return false;
}
......
......@@ -1566,6 +1566,10 @@ class Item: public Value_source,
{
return Sql_mode_dependency();
}
virtual Session_env_dependency value_depends_on_session_env() const
{
return Session_env_dependency();
}
int save_time_in_field(Field *field, bool no_conversions);
int save_date_in_field(Field *field, bool no_conversions);
......@@ -2757,6 +2761,9 @@ class Item_args
inline uint argument_count() const { return arg_count; }
inline void remove_arguments() { arg_count=0; }
Sql_mode_dependency value_depends_on_sql_mode_bit_or() const;
Session_env_dependency value_depends_on_session_env_bit_or() const;
Session_env_dependency::Param conversion_depends_on_session_env_bit_or(
const Type_handler *to) const;
};
......@@ -5360,6 +5367,20 @@ class Item_func_or_sum: public Item_result_field,
{
return Item_args::value_depends_on_sql_mode_bit_or().soft_to_hard();
}
Session_env_dependency value_depends_on_session_env() const override
{
/*
Collect dependencies from all arguments, with soft_to_hard() escalation.
Add data type conversion soft dependencies. This assumes that by default
a function:
- does not remove a dependency on the session environment
- thinks that all arguments will be converted from their data types
to the result data type
*/
return Item_args::value_depends_on_session_env_bit_or().soft_to_hard() |
Session_env_dependency(0,
Item_args::conversion_depends_on_session_env_bit_or(type_handler()));
}
};
class sp_head;
......
......@@ -613,6 +613,29 @@ Sql_mode_dependency Item_args::value_depends_on_sql_mode_bit_or() const
}
Session_env_dependency Item_args::value_depends_on_session_env_bit_or() const
{
Session_env_dependency res;
for (uint i= 0; i < arg_count; i++)
res|= args[i]->value_depends_on_session_env();
return res;
}
Session_env_dependency::Param
Item_args::conversion_depends_on_session_env_bit_or(const Type_handler *to)
const
{
ulonglong dep= Session_env_dependency::NONE;
for (uint i= 0; i < arg_count; i++)
{
dep|= to->type_conversion_dependency_from(args[i]->type_handler());
}
return (Session_env_dependency::Param) dep;
}
/**
See comments in Item_cond::split_sum_func()
*/
......
......@@ -1645,6 +1645,12 @@ class Item_func_div :public Item_num_op
double real_op();
my_decimal *decimal_op(my_decimal *);
const char *func_name() const { return "/"; }
Session_env_dependency value_depends_on_session_env() const override
{
return args[0]->value_depends_on_session_env().soft_to_hard() |
Session_env_dependency(0,
Session_env_dependency::SYS_VAR_DIV_PRECISION_INCREMENT);
}
enum precedence precedence() const { return MUL_PRECEDENCE; }
bool fix_length_and_dec();
void fix_length_and_dec_double();
......
......@@ -72,6 +72,16 @@ class Item_str_func :public Item_func
const Type_handler *type_handler() const { return string_type_handler(); }
void left_right_max_length();
bool fix_fields(THD *thd, Item **ref);
Session_env_dependency value_depends_on_session_env() const override
{
DBUG_ASSERT(fixed);
Session_env_dependency dep= Item_func::value_depends_on_session_env();
return dep | Session_env_dependency(0,
max_length > 1024 ?
Session_env_dependency::SYS_VAR_MAX_ALLOWED_PACKET :
Session_env_dependency::NONE);
}
};
......
......@@ -1960,6 +1960,129 @@ bool Item_func_from_unixtime::get_date(THD *thd, MYSQL_TIME *ltime,
}
bool Item_func_at_tz::check_arguments() const
{
if (args[0]->check_type_can_return_date(func_name()))
return true;
const Type_handler *handler= args[0]->type_handler();
if (dynamic_cast<const Type_handler_time_common*>(handler) ||
dynamic_cast<const Type_handler_date_common*>(handler))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
handler->name().ptr(), func_name());
return true;
}
return false;
}
bool Item_func_at_tz::fix_length_and_dec()
{
fix_attributes_datetime(args[0]->datetime_precision(current_thd));
max_length+= 1 + m_tz->get_name()->length();
maybe_null= true;
return false;
}
void Item_func_at_tz::print(String *str, enum_query_type query_type)
{
args[0]->print_parenthesised(str, query_type, precedence());
str->append(STRING_WITH_LEN(" at time zone "));
str->append("'");
str->append(m_tz->get_name()[0]);
str->append("'");
}
bool Item_func_at_tz::val_native(THD *thd, Native *to)
{
/*
The SQL standard about:
datetime_expr AT TIME ZONE 'TZ'
says:
a) If the argument is a datetime type with time zone,
then the UTC component of the result is just taken the argument.
b) If the argument is a datetime type without time zone),
then the UTC component of the result is DV-STZD, where:
- DV is the UTC component of the argument
- STZD is the current default time zone displacement of
the SQL-session (which is @@time_zone in MariaDB)
*/
const Type_handler *fmt=
args[0]->type_handler()->type_handler_for_native_format();
if (fmt == &type_handler_timestamp2 ||
fmt == &type_handler_timestamp2_with_tz)
{
Timestamp_with_tz_null ts= TH::item_value_null(thd, args[0]);
return (null_value= ts.is_null()) ? true :
ts.set_tz(m_tz).to_native(to, decimals);
}
/*
Treat other argument data types (e.g. DATETIME) as
"TIMESTAMP WITHOUT TIME ZONE".
*/
Datetime dt(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
Timestamp_with_tz_null ts(thd, dt, thd->variables.time_zone);
thd->time_zone_used|= !ts.is_null();
return null_value= ts.set_tz(m_tz).to_native(to, decimals);
}
bool Item_func_timestamp_tz::check_arguments() const
{
if (args[0]->check_type_can_return_date(func_name()))
return true;
const Type_handler *handler= args[0]->type_handler();
if (dynamic_cast<const Type_handler_time_common*>(handler) ||
dynamic_cast<const Type_handler_date_common*>(handler))
{
my_error(ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION, MYF(0),
handler->name().ptr(), func_name());
return true;
}
return false;
}
bool Item_func_timestamp_tz::fix_length_and_dec()
{
fix_attributes_datetime(args[0]->datetime_precision(current_thd));
max_length+= 1 + m_tz->get_name()->length();
maybe_null= true;
return false;
}
void Item_func_timestamp_tz::print(String *str, enum_query_type query_type)
{
str->append(func_name());
str->append('(');
args[0]->print(str, query_type);
str->append(STRING_WITH_LEN(",'"));
str->append(m_tz->get_name()[0]);
str->append(STRING_WITH_LEN("')"));
}
bool Item_func_timestamp_tz::val_native(THD *thd, Native *to)
{
const Type_handler *fmt=
args[0]->type_handler()->type_handler_for_native_format();
if (fmt == &type_handler_timestamp2 ||
fmt == &type_handler_timestamp2_with_tz)
{
Timestamp_with_tz_null ts= TH::item_value_null(thd, args[0]);
return (null_value= ts.is_null()) ? true :
ts.set_tz(m_tz).to_native(to, decimals);
}
Datetime dt(thd, args[0], Datetime::Options(TIME_NO_ZEROS, thd));
return null_value= Timestamp_with_tz_null(thd, dt, m_tz).
to_native(to, decimals);
}
bool Item_func_convert_tz::get_date(THD *thd, MYSQL_TIME *ltime,
date_mode_t fuzzydate __attribute__((unused)))
{
......
This diff is collapsed.
......@@ -731,6 +731,7 @@ SYMBOL symbols[] = {
{ "YEAR", SYM(YEAR_SYM)},
{ "YEAR_MONTH", SYM(YEAR_MONTH_SYM)},
{ "ZEROFILL", SYM(ZEROFILL)},
{ "ZONE", SYM(ZONE_SYM)},
{ "||", SYM(OR2_SYM)}
};
......@@ -780,6 +781,7 @@ SYMBOL sql_functions[] = {
{ "SUM", SYM(SUM_SYM)},
{ "SYSDATE", SYM(SYSDATE)},
{ "SYSTEM_USER", SYM(USER_SYM)},
{ "TIMESTAMP_TZ", SYM(TIMESTAMP_TZ_SYM)},
{ "TRIM", SYM(TRIM)},
{ "TRIM_ORACLE", SYM(TRIM_ORACLE)},
{ "VARIANCE", SYM(VARIANCE_SYM)},
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment