Merge remote-tracking branch 'origin/10.4' into 10.5

This commit is contained in:
Alexander Barkov 2019-09-11 11:46:31 +04:00
commit 0636645e7e
56 changed files with 2549 additions and 623 deletions

View file

@ -39,6 +39,7 @@ ELSE()
SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
OPTION(CPACK_RPM_DEBUGINFO_PACKAGE "" ON)
MARK_AS_ADVANCED(CPACK_RPM_DEBUGINFO_PACKAGE)
SET(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_RPM_PACKAGE_NAME}-${VERSION}")
ENDIF()
SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}")
@ -270,7 +271,6 @@ IF(CMAKE_VERSION VERSION_GREATER "3.9.99")
SET(CPACK_SOURCE_GENERATOR "RPM")
SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
"-DRPM=${RPM}"
"-DCPACK_RPM_BUILD_SOURCE_DIRS_PREFIX=/usr/src/debug/${CPACK_RPM_PACKAGE_NAME}-${VERSION}"
)
MACRO(ADDIF var)

View file

@ -24,8 +24,10 @@ use My::Platform;
my $handle_exe;
if (IS_WINDOWS){
sub import {
my $self = shift;
my $params = shift;
return if (!IS_WINDOWS || $handle_exe);
# Check if handle.exe is available
# Pass switch to accept the EULA to avoid hanging
# if the program hasn't been run before.
@ -35,7 +37,7 @@ if (IS_WINDOWS){
$handle_exe= "$2.$3"
if ($line =~ /(Nth|H)andle v([0-9]*)\.([0-9]*)/);
}
if ($handle_exe){
if ($handle_exe && (!$params || !$params->{suppress_init_messages})){
print "Found handle.exe version $handle_exe\n";
}
}

File diff suppressed because it is too large Load diff

View file

@ -207,18 +207,29 @@ explain select * from t1 where a=1 or b=1 {
"best_access_path": {
"considered_access_paths": [
{
"access_type": "range",
"access_type": "index_merge",
"resulting_rows": 2,
"cost": 4.1484,
"chosen": true
}
]
],
"chosen_access_method": {
"type": "index_merge",
"records": 2,
"cost": 4.1484,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 2,
"cost_for_plan": 4.5484
"cost_for_plan": 4.5484,
"estimated_join_cardinality": 2
}
]
},
{
"best_join_order": ["t1"]
},
{
"attaching_conditions_to_tables": {
"original_condition": "t1.a = 1 or t1.b = 1",

View file

@ -208,13 +208,24 @@ explain select * from t1 where pk1 != 0 and key1 = 1 {
"chosen": false,
"cause": "cost"
}
]
],
"chosen_access_method": {
"type": "ref",
"records": 1,
"cost": 2,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 1,
"cost_for_plan": 2.2
"cost_for_plan": 2.2,
"estimated_join_cardinality": 1
}
]
},
{
"best_join_order": ["t1"]
},
{
"attaching_conditions_to_tables": {
"original_condition": "t1.key1 = 1 and t1.pk1 <> 0",

View file

@ -98,13 +98,24 @@ select * from db1.t1 {
"cost": 2.0051,
"chosen": true
}
]
],
"chosen_access_method": {
"type": "scan",
"records": 3,
"cost": 2.0051,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 3,
"cost_for_plan": 2.6051
"cost_for_plan": 2.6051,
"estimated_join_cardinality": 3
}
]
},
{
"best_join_order": ["t1"]
},
{
"attaching_conditions_to_tables": {
"original_condition": null,
@ -211,13 +222,24 @@ select * from db1.v1 {
"cost": 2.0051,
"chosen": true
}
]
],
"chosen_access_method": {
"type": "scan",
"records": 3,
"cost": 2.0051,
"uses_join_buffering": false,
"filter_used": false
}
},
"rows_for_plan": 3,
"cost_for_plan": 2.6051
"cost_for_plan": 2.6051,
"estimated_join_cardinality": 3
}
]
},
{
"best_join_order": ["t1"]
},
{
"attaching_conditions_to_tables": {
"original_condition": null,

View file

@ -1634,8 +1634,6 @@ SELECT @cnt;
@cnt
2
alter table t1 force;
set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;
#

View file

@ -1102,8 +1102,6 @@ set @@optimizer_use_condition_selectivity=4;
SELECT * FROM t1 WHERE a = f1();
SELECT @cnt;
alter table t1 force;
set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;

View file

@ -1644,8 +1644,6 @@ SELECT @cnt;
@cnt
2
alter table t1 force;
set @@use_stat_tables= @save_use_stat_tables;
set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
drop table t1;
drop function f1;
#
@ -1661,19 +1659,19 @@ test.t1 analyze status OK
# Check what info the optimizer has about selectivities
explain extended select * from t1 use index () where a in (17,51,5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1091 3.83 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 3.90 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`a` in (17,51,5)
explain extended select * from t1 use index () where b=2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1091 5.47 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 5.47 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` USE INDEX () where `test`.`t1`.`b` = 2
# Now, the equality is used for ref access, while the range condition
# gives selectivity data
explain extended select * from t1 where a in (17,51,5) and b=2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 2.66 Using where; Using rowid filter
1 SIMPLE t1 ref|filter b,a b|a 5|5 const 59 (3%) 2.90 Using where; Using rowid filter
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5)
drop table t1;

View file

@ -127,3 +127,51 @@ Table Op Msg_type Msg_text
test.t1 check status OK
InnoDB 0 transactions not purged
DROP TABLE t1;
SET @save_algo = @@GLOBAL.innodb_compression_algorithm;
SET GLOBAL innodb_compression_algorithm=2;
CREATE TABLE t1(a SERIAL) PAGE_COMPRESSED=1 ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
FLUSH TABLE t1 FOR EXPORT;
# List before copying files
db.opt
t1.cfg
t1.frm
t1.ibd
backup: t1
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
db.opt
t1.frm
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(2);
SELECT * FROM t1;
a
1
2
SET GLOBAL innodb_compression_algorithm=3;
FLUSH TABLE t1 FOR EXPORT;
# List before copying files
db.opt
t1.cfg
t1.frm
t1.ibd
backup: t1
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
db.opt
t1.frm
restore: t1 .ibd and .cfg files
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
a
1
2
3
DROP TABLE t1;
SET GLOBAL innodb_compression_algorithm=@save_algo;

View file

@ -137,3 +137,64 @@ DELETE FROM t1;
CHECK TABLE t1;
--source include/wait_all_purged.inc
DROP TABLE t1;
SET @save_algo = @@GLOBAL.innodb_compression_algorithm;
SET GLOBAL innodb_compression_algorithm=2;
CREATE TABLE t1(a SERIAL) PAGE_COMPRESSED=1 ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
FLUSH TABLE t1 FOR EXPORT;
--echo # List before copying files
let MYSQLD_DATADIR =`SELECT @@datadir`;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(2);
SELECT * FROM t1;
SET GLOBAL innodb_compression_algorithm=3;
FLUSH TABLE t1 FOR EXPORT;
--echo # List before copying files
let MYSQLD_DATADIR =`SELECT @@datadir`;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_backup_tablespaces("test", "t1");
EOF
UNLOCK TABLES;
SET GLOBAL innodb_compression_algorithm=0;
ALTER TABLE t1 FORCE;
ALTER TABLE t1 DISCARD TABLESPACE;
--list_files $MYSQLD_DATADIR/test
perl;
do "$ENV{MTR_SUITE_DIR}/include/innodb-util.pl";
ib_discard_tablespaces("test", "t1");
ib_restore_tablespaces("test", "t1");
EOF
ALTER TABLE t1 IMPORT TABLESPACE;
INSERT INTO t1 VALUES(3);
SELECT * FROM t1;
DROP TABLE t1;
SET GLOBAL innodb_compression_algorithm=@save_algo;

View file

@ -76,6 +76,7 @@ rmdir $targetdir;
perl;
use lib "lib";
use My::Handles { suppress_init_messages => 1 };
use My::File::Path;
my $install_db_dir = ($ENV{MTR_PARALLEL} == 1) ?
"$ENV{'MYSQLTEST_VARDIR'}/install.db" :

View file

@ -1,12 +0,0 @@
##############################################################################
#
# List the test cases that are to be disabled temporarily.
#
# Separate the test case name and the comment with ':'.
#
# <testcasename> : BUG#<xxxx> <date disabled> <disabler> <comment>
#
# Do not use any TAB characters for whitespace.
#
##############################################################################
big_innodb_log : MDEV-20421 2019-08-26 wlad Always fails on Windows buildbot

View file

@ -0,0 +1,9 @@
--- encrypted_page_corruption,crc32.result
+++ encrypted_page_corruption,full_crc32.result
@@ -5,5 +5,5 @@
# Corrupt the table
# restart
# xtrabackup backup
-FOUND 1 /Database page corruption detected.*/ in backup.log
+NOT FOUND /Database page corruption detected.*/ in backup.log
drop table t1;

View file

@ -0,0 +1,5 @@
[crc32]
--innodb-checksum-algorithm=crc32
[full_crc32]
--innodb-checksum-algorithm=full_crc32

View file

@ -4,4 +4,3 @@
--loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key
--loose-file-key-management-filename=$MTR_SUITE_DIR/filekeys-data.enc
--loose-file-key-management-encryption-algorithm=aes_cbc
--innodb-checksum-algorithm=crc32

View file

@ -19,27 +19,36 @@ use warnings;
use Fcntl qw(:DEFAULT :seek);
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl";
my $page_size = $ENV{INNODB_PAGE_SIZE};
my $ps = $ENV{INNODB_PAGE_SIZE};
sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR
|| die "Cannot open t1.ibd\n";
sysread(IBD_FILE, $_, 38) || die "Cannot read t1.ibd\n";
sysread(IBD_FILE, $_, 58) || die "Cannot read t1.ibd\n";
my $space = unpack("x[34]N", $_);
sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
my $full_crc32 = unpack("N",substr($_,54,4)) & 0x10; # FIL_SPACE_FLAGS
sysseek(IBD_FILE, $ps * 3, SEEK_SET) || die "Cannot seek t1.ibd\n";
my $head = pack("Nx[18]", 3); # better to have a valid page number
my $body = chr(0) x ($page_size - 38 - 8);
# better to have a valid page number (3)
my $page = pack("x[4]Nx[18]Nx[4]N", 3, 1, $space) . chr(0) x ($ps - 38);
# Calculate innodb_checksum_algorithm=crc32 for the unencrypted page.
# The following bytes are excluded:
# bytes 0..3 (the checksum is stored there)
# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id)
# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN)
my $polynomial = 0x82f63b78; # CRC-32C
my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial);
if ($full_crc32)
{
# no possibility of bug here
my $ck = mycrc32(substr($page, 0, $ps - 4), 0, $polynomial);
substr($page, $ps - 4, 4) = pack("N", $ck);
}
else
{
my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
substr($page,0,4)=$ck;
substr($page,$ps-8,4)=$ck;
# trigger the bug by having the same "post-encryption" checksum!
substr($page,30,4)=$ck;
}
my $page= pack("N",$ck).$head.pack("NNN",1,$ck,$space).$body.pack("Nx[4]",$ck);
die unless syswrite(IBD_FILE, $page, $page_size) == $page_size;
die unless syswrite(IBD_FILE, $page, $ps) == $ps;
close IBD_FILE;
EOF
@ -49,8 +58,13 @@ echo # xtrabackup backup;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log;
let $expect_error= 1;
if (`select @@innodb_checksum_algorithm LIKE '%full_crc32'`)
{
let $expect_error= 0;
}
--disable_result_log
--error 1
--error $expect_error
exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extended-validation --target-dir=$targetdir --core-file > $backuplog;
--enable_result_log

View file

@ -28,29 +28,41 @@ DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v TIME AS (a) VIRTUAL, KEY(v));
DROP TABLE t1;
CREATE TABLE t1 (c CHAR(8), v BINARY(8) AS (c), KEY(v));
ERROR HY000: Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v BIT(64) AS (a) VIRTUAL, KEY(v));
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (a) VIRTUAL, KEY(v));
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v TEXT AS (a) VIRTUAL, KEY(v(100)));
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + TRIM resolving dependency
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RTRIM(a)) VIRTUAL, KEY(v));
SHOW CREATE TABLE t1;
@ -126,67 +138,94 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + TRIM not resolving dependency
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(LEADING ' ' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v TEXT AS (TRIM(LEADING ' ' FROM a)) VIRTUAL, KEY(v(100)));
ERROR HY000: Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(leading ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING '' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(trailing '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(trailing '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(trailing '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(trailing '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH '' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(both '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(both '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(both '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(both '' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING 'x' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(trailing 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(trailing 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(trailing 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(trailing 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH 'x' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(both 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(both 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(both 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(both 'x' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (
a CHAR(5),
v VARCHAR(5) AS (TRIM(TRAILING ' ' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(trailing ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(trailing ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(trailing ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(trailing ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (
a CHAR(5),
v VARCHAR(5) AS (TRIM(BOTH ' ' FROM a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'trim(both ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(both ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(both ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(both ' ' from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + TRIM(... non_constant FROM a)
CREATE TABLE t1 (
a CHAR(5),
b CHAR(5),
v TEXT AS (TRIM(TRAILING b FROM a)) VIRTUAL, KEY(v(100)));
ERROR HY000: Function or expression 'trim(trailing `b` from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'trim(trailing `b` from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'trim(trailing `b` from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'trim(trailing `b` from `a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + RPAD resolving dependency
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,5,' ')) VIRTUAL, KEY(v));
SHOW CREATE TABLE t1;
@ -226,22 +265,28 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + RPAD not resolving dependency
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,4,' ')) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'rpad(`a`,4,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'rpad(`a`,4,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'rpad(`a`,4,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'rpad(`a`,4,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (
a CHAR(5),
b CHAR(5),
v VARCHAR(5) AS (RPAD(a,NULL,b)) VIRTUAL,
KEY(v)
);
ERROR HY000: Function or expression 'rpad(`a`,NULL,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'rpad(`a`,NULL,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'rpad(`a`,NULL,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'rpad(`a`,NULL,`b`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + comparison
CREATE TABLE t1 (a CHAR(5), v INT AS (a='a') VIRTUAL, KEY(v));
SHOW CREATE TABLE t1;
@ -256,11 +301,14 @@ CREATE TABLE t1 (
a CHAR(5) CHARACTER SET latin1 COLLATE latin1_nopad_bin,
v INT AS (a='a') VIRTUAL, KEY(v)
);
ERROR HY000: Function or expression '`a` = 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a` = 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a` = 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a` = 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + LIKE
CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE 'a%') VIRTUAL, KEY(v));
SHOW CREATE TABLE t1;
@ -281,18 +329,24 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE 'a') VIRTUAL, KEY(v));
ERROR HY000: Function or expression '`a` like 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a` like 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a` like 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a` like 'a'' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# PAD_CHAR_TO_FULL_LENGTH + LENGTH(char_column) = hard dependency
CREATE TABLE t1 (a CHAR(5), v INT AS (LENGTH(a)) VIRTUAL, KEY(v));
ERROR HY000: Function or expression 'octet_length(`a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'octet_length(`a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'octet_length(`a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'octet_length(`a`)' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
#
# Testing NO_UNSIGNED_SUBTRACTION
#
@ -302,33 +356,42 @@ b INT UNSIGNED,
c INT GENERATED ALWAYS AS (a-b) VIRTUAL,
KEY (c)
);
ERROR HY000: Function or expression '`a` - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warnings:
Warning 1901 Function or expression '`a` - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a` - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1901 Function or expression '`a` - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
DROP TABLE t1;
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
c INT GENERATED ALWAYS AS (CAST(a AS SIGNED)-b) VIRTUAL,
KEY (c)
);
ERROR HY000: Function or expression 'cast(`a` as signed) - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warnings:
Warning 1901 Function or expression 'cast(`a` as signed) - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'cast(`a` as signed) - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1901 Function or expression 'cast(`a` as signed) - `b`' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
DROP TABLE t1;
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
c INT GENERATED ALWAYS AS (a-CAST(b AS SIGNED)) VIRTUAL,
KEY (c)
);
ERROR HY000: Function or expression '`a` - cast(`b` as signed)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warnings:
Warning 1901 Function or expression '`a` - cast(`b` as signed)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a` - cast(`b` as signed)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1901 Function or expression '`a` - cast(`b` as signed)' cannot be used in the GENERATED ALWAYS AS clause of `c`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
DROP TABLE t1;
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -369,12 +432,16 @@ c CHAR(5),
v VARCHAR(5) GENERATED ALWAYS AS (RPAD(c,a-b,' ')) VIRTUAL,
KEY (v)
);
ERROR HY000: Function or expression 'rpad(`c`,`a` - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'rpad(`c`,`a` - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'rpad(`c`,`a` - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Warning 1901 Function or expression 'rpad(`c`,`a` - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value NO_UNSIGNED_SUBTRACTION
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -382,11 +449,14 @@ c CHAR(5),
v VARCHAR(5) GENERATED ALWAYS AS (RPAD(c,CAST(a AS DECIMAL(20,1))-b,' ')) VIRTUAL,
KEY (v)
);
ERROR HY000: Function or expression 'rpad(`c`,cast(`a` as decimal(20,1)) - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression 'rpad(`c`,cast(`a` as decimal(20,1)) - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression 'rpad(`c`,cast(`a` as decimal(20,1)) - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression 'rpad(`c`,cast(`a` as decimal(20,1)) - `b`,' ')' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# ALTER TABLE ADD KEY(vcol_depending_on_sql_mode) --> error
CREATE TABLE t1 (
a INT UNSIGNED,
@ -395,32 +465,62 @@ c CHAR(5),
v VARCHAR(5) GENERATED ALWAYS AS (c) VIRTUAL
);
ALTER TABLE t1 ADD KEY(v);
ERROR HY000: Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
ALTER TABLE t1 DROP KEY v;
Warnings:
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
CREATE INDEX v ON t1 (v);
ERROR HY000: Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`c`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# A virtual column on the second position in an index - cannot depend on sql_mode
CREATE TABLE t1 (id int, a CHAR(5), v TEXT AS (a) VIRTUAL, KEY(id, v(100)));
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
# A persisten virtual column cannot depend on sql_mode
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (a) PERSISTENT);
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW WARNINGS;
Level Code Message
Error 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RTRIM(a)) PERSISTENT);
SHOW CREATE TABLE t1;
Table Create Table

View file

@ -52,40 +52,66 @@ Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
CREATE TABLE t2 LIKE t1;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t2;
FLUSH TABLES;
CREATE TABLE t2 LIKE t1;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(5) DEFAULT NULL,
`v` varchar(5) GENERATED ALWAYS AS (`a`) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1
ALTER TABLE t1 ADD b INT DEFAULT a;
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(5) DEFAULT NULL,
`v` varchar(5) GENERATED ALWAYS AS (`a`) STORED,
`b` int(11) DEFAULT `a`
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
ALTER TABLE t1 ADD b INT DEFAULT a;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` char(5) DEFAULT NULL,
`v` varchar(5) GENERATED ALWAYS AS (`a`) STORED
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SELECT * FROM t1;
a v
1 1
2 2
3 3
a v b
1 1 1
2 2 2
3 3 3
FLUSH TABLES;
ALTER TABLE t1 ADD c INT DEFAULT a;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SELECT * FROM t1;
a v
1 1
2 2
3 3
a v b c
1 1 1 1
2 2 2 2
3 3 3 3
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
#
# Fixing a Maria-10.2.26 table with a stored VARCHAR column
@ -177,10 +203,18 @@ Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
CREATE TABLE t2 LIKE t1;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t2;
FLUSH TABLES;
CREATE TABLE t2 LIKE t1;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t2;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@ -188,19 +222,33 @@ t1 CREATE TABLE `t1` (
`v` varchar(5) GENERATED ALWAYS AS (`a`) VIRTUAL,
KEY `v` (`v`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
ALTER TABLE t1 ADD b INT DEFAULT a;
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
ALTER TABLE t1 ADD b INT DEFAULT a;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
FLUSH TABLES;
ALTER TABLE t1 ADD c INT DEFAULT a;
ERROR HY000: Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
SELECT * FROM t1;
a v
1 1
2 2
3 3
a v b c
1 1 1 1
2 2 2 2
3 3 3 3
Warnings:
Warning 1901 Function or expression '`a`' cannot be used in the GENERATED ALWAYS AS clause of `v`
Warning 1105 Expression depends on the @@sql_mode value PAD_CHAR_TO_FULL_LENGTH
DROP TABLE t1;
#
# Fixing a Maria-10.2.26 table with a virtual VARCHAR column

View file

@ -21,21 +21,25 @@ DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v TIME AS (a) VIRTUAL, KEY(v));
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (c CHAR(8), v BINARY(8) AS (c), KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v BIT(64) AS (a) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (a) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v TEXT AS (a) VIRTUAL, KEY(v(100)));
SHOW WARNINGS;
DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + TRIM resolving dependency
@ -75,52 +79,61 @@ DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + TRIM not resolving dependency
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(LEADING ' ' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v TEXT AS (TRIM(LEADING ' ' FROM a)) VIRTUAL, KEY(v(100)));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING '' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH '' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(TRAILING 'x' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (TRIM(BOTH 'x' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
# more than one space
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a CHAR(5),
v VARCHAR(5) AS (TRIM(TRAILING ' ' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
# more than one space
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a CHAR(5),
v VARCHAR(5) AS (TRIM(BOTH ' ' FROM a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + TRIM(... non_constant FROM a)
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a CHAR(5),
b CHAR(5),
v TEXT AS (TRIM(TRAILING b FROM a)) VIRTUAL, KEY(v(100)));
SHOW WARNINGS;
DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + RPAD resolving dependency
@ -144,11 +157,12 @@ DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + RPAD not resolving dependency
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RPAD(a,4,' ')) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a CHAR(5),
b CHAR(5),
@ -156,6 +170,7 @@ CREATE TABLE t1 (
KEY(v)
);
SHOW WARNINGS;
DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + comparison
@ -164,12 +179,13 @@ CREATE TABLE t1 (a CHAR(5), v INT AS (a='a') VIRTUAL, KEY(v));
SHOW CREATE TABLE t1;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a CHAR(5) CHARACTER SET latin1 COLLATE latin1_nopad_bin,
v INT AS (a='a') VIRTUAL, KEY(v)
);
SHOW WARNINGS;
DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + LIKE
@ -182,23 +198,25 @@ CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE NULL) VIRTUAL, KEY(v));
SHOW CREATE TABLE t1;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v INT AS (a LIKE 'a') VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--echo # PAD_CHAR_TO_FULL_LENGTH + LENGTH(char_column) = hard dependency
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v INT AS (LENGTH(a)) VIRTUAL, KEY(v));
SHOW WARNINGS;
DROP TABLE t1;
--echo #
--echo # Testing NO_UNSIGNED_SUBTRACTION
--echo #
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -206,8 +224,9 @@ CREATE TABLE t1 (
KEY (c)
);
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -215,8 +234,9 @@ CREATE TABLE t1 (
KEY (c)
);
SHOW WARNINGS;
DROP TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -224,6 +244,7 @@ CREATE TABLE t1 (
KEY (c)
);
SHOW WARNINGS;
DROP TABLE t1;
CREATE TABLE t1 (
a INT UNSIGNED,
@ -250,7 +271,7 @@ DROP TABLE t1;
--echo # Comnination: PAD_CHAR_TO_FULL_LENGTH + NO_UNSIGNED_SUBTRACTION
--echo #
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -259,13 +280,14 @@ CREATE TABLE t1 (
KEY (v)
);
SHOW WARNINGS;
DROP TABLE t1;
# The below solves the dependency on NO_UNSIGNED_SUBTRACTION
# but does not solve the dependency on PAD_CHAR_TO_FULL_LENGTH,
# because the 'length' argument to RPAD() is not a constant.
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (
a INT UNSIGNED,
b INT UNSIGNED,
@ -274,6 +296,7 @@ CREATE TABLE t1 (
KEY (v)
);
SHOW WARNINGS;
DROP TABLE t1;
@ -291,10 +314,12 @@ CREATE TABLE t1 (
c CHAR(5),
v VARCHAR(5) GENERATED ALWAYS AS (c) VIRTUAL
);
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD KEY(v);
SHOW WARNINGS;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 DROP KEY v;
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE INDEX v ON t1 (v);
SHOW WARNINGS;
DROP TABLE t1;
@ -302,16 +327,18 @@ DROP TABLE t1;
--echo # A virtual column on the second position in an index - cannot depend on sql_mode
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (id int, a CHAR(5), v TEXT AS (a) VIRTUAL, KEY(id, v(100)));
SHOW WARNINGS;
DROP TABLE t1;
--echo # A persisten virtual column cannot depend on sql_mode
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (a) PERSISTENT);
SHOW WARNINGS;
DROP TABLE t1;
CREATE TABLE t1 (a CHAR(5), v VARCHAR(5) AS (RTRIM(a)) PERSISTENT);
SHOW CREATE TABLE t1;

View file

@ -25,19 +25,21 @@ SELECT * FROM t1;
FLUSH TABLES;
SELECT * FROM t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;
DROP TABLE t2;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;
DROP TABLE t2;
SHOW CREATE TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD b INT DEFAULT a;
SHOW CREATE TABLE t1;
SELECT * FROM t1;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD c INT DEFAULT a;
SELECT * FROM t1;
DROP TABLE t1;
@ -90,18 +92,20 @@ SELECT * FROM t1;
FLUSH TABLES;
SELECT * FROM t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;
DROP TABLE t2;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
CREATE TABLE t2 LIKE t1;
DROP TABLE t2;
SHOW CREATE TABLE t1;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD b INT DEFAULT a;
FLUSH TABLES;
--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
#--error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
ALTER TABLE t1 ADD c INT DEFAULT a;
SELECT * FROM t1;
DROP TABLE t1;

File diff suppressed because it is too large Load diff

View file

@ -562,6 +562,9 @@ public:
/*
RAII-based class to disable writing into the JSON document
The tracing is disabled as soon as the object is created.
The destuctor is called as soon as we exit the scope of the object
and the tracing is enabled back.
*/
class Json_writer_temp_disable

View file

@ -457,7 +457,6 @@ void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables, uint idx,
bool disable_jbuf, double record_count,
POSITION *pos, POSITION *loose_scan_pos);
void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables);
static Item *create_subq_in_equalities(THD *thd, SJ_MATERIALIZATION_INFO *sjm,
Item_in_subselect *subq_pred);
@ -3859,7 +3858,7 @@ void fix_semijoin_strategies_for_picked_join_order(JOIN *join)
join->cur_sj_inner_tables= 0;
Json_writer_object semijoin_strategy(thd);
semijoin_strategy.add("semi_join_strategy","LooseScan");
Json_writer_array semijoin_plan(thd, "join_order");
Json_writer_array semijoin_plan(thd, "join_order");
for (idx= first; idx <= tablenr; idx++)
{
if (unlikely(thd->trace_started()))

View file

@ -416,6 +416,12 @@ size_t Opt_trace_context::remaining_mem_size()
return max_mem_size;
}
/*
Disable tracing for children if the current trace is already present.
Currently only one trace is stored and there is no mechanism
to restore traces, so disabling tracing for children is the best option.
*/
bool Opt_trace_context::disable_tracing_if_required()
{
if (current_trace)
@ -633,6 +639,73 @@ void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab)
table_rec.add("rows", tab->found_records)
.add("cost", tab->read_time);
}
/*
@brief
Add the tables inside a partial join to the optimizer trace
@param join join handler
@param idx length of the partial QEP in 'join->positions'
@table_map map of all non-const tables of the join
@note
This function is used during best_access_path to print the tables
inside the partial join that were considered doing the cost based
analysis of the various join orders.
*/
void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables)
{
THD *const thd= join->thd;
Json_writer_array plan_prefix(thd, "plan_prefix");
for (uint i= 0; i < idx; i++)
{
TABLE_LIST *const tr= join->positions[i].table->tab_list;
if (!(tr->map & join_tables))
plan_prefix.add_table_name(join->positions[i].table);
}
}
/*
Print the join order of all the tables for top level select.
For example:
select * from ot1
where ot1.a IN (select it1.a from it1, it2 where it1.b=it2.a);
So this function would print
ot1, <subquery2> ----> For select #1
*/
void print_final_join_order(JOIN *join)
{
Json_writer_object join_order(join->thd);
Json_writer_array best_order(join->thd, "best_join_order");
JOIN_TAB *j;
uint i;
for (j= join->join_tab,i=0 ; i < join->top_join_tab_count;
i++, j++)
best_order.add_table_name(j);
}
void print_best_access_for_table(THD *thd, POSITION *pos,
enum join_type type)
{
Json_writer_object trace_best_access(thd, "chosen_access_method");
trace_best_access.add("type", type == JT_ALL ? "scan" :
join_type_str[type]);
trace_best_access.add("records", pos->records_read);
trace_best_access.add("cost", pos->read_time);
trace_best_access.add("uses_join_buffering", pos->use_join_buffer);
trace_best_access.add("filter_used",
pos->range_rowid_filter_info != NULL);
}
/*
Introduce enum_query_type flags parameter, maybe also allow
EXPLAIN also use this function.

View file

@ -105,6 +105,10 @@ void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex,
Json_writer_object *trace_object);
void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab);
void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables);
void print_final_join_order(JOIN *join);
void print_best_access_for_table(THD *thd, POSITION *pos,
enum join_type type);
/*
Security related (need to add a proper comment here)

View file

@ -121,7 +121,6 @@ static bool best_extension_by_limited_search(JOIN *join,
double read_time, uint depth,
uint prune_level,
uint use_cond_selectivity);
void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables);
static uint determine_search_depth(JOIN* join);
C_MODE_START
static int join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2);
@ -7218,6 +7217,7 @@ best_access_path(JOIN *join,
SplM_plan_info *spl_plan= 0;
Range_rowid_filter_cost_info *filter= 0;
const char* cause= NULL;
enum join_type best_type= JT_UNKNOWN, type= JT_UNKNOWN;
disable_jbuf= disable_jbuf || idx == join->const_tables;
@ -7357,7 +7357,8 @@ best_access_path(JOIN *join,
*/
tmp= prev_record_reads(join->positions, idx, found_ref);
records= 1.0;
trace_access_idx.add("access_type", "fulltext")
type= JT_FT;
trace_access_idx.add("access_type", join_type_str[type])
.add("index", keyinfo->name);
}
else
@ -7380,14 +7381,16 @@ best_access_path(JOIN *join,
(!(key_flags & HA_NULL_PART_KEY) || // (2)
all_key_parts == notnull_part)) // (3)
{
trace_access_idx.add("access_type", "eq_ref")
type= JT_EQ_REF;
trace_access_idx.add("access_type", join_type_str[type])
.add("index", keyinfo->name);
tmp = prev_record_reads(join->positions, idx, found_ref);
records=1.0;
}
else
{
trace_access_idx.add("access_type", "ref")
type= JT_REF;
trace_access_idx.add("access_type", join_type_str[type])
.add("index", keyinfo->name);
if (!found_ref)
{ /* We found a const key */
@ -7482,8 +7485,8 @@ best_access_path(JOIN *join,
}
else
{
trace_access_idx.add("access_type",
ref_or_null_part ? "ref_or_null" : "ref")
type = ref_or_null_part ? JT_REF_OR_NULL : JT_REF;
trace_access_idx.add("access_type", join_type_str[type])
.add("index", keyinfo->name);
/*
Use as much key-parts as possible and a uniq key is better
@ -7698,6 +7701,7 @@ best_access_path(JOIN *join,
best_max_key_part= max_key_part;
best_ref_depends_map= found_ref;
best_filter= filter;
best_type= type;
}
else
{
@ -7751,6 +7755,7 @@ best_access_path(JOIN *join,
best_ref_depends_map= 0;
best_uses_jbuf= TRUE;
best_filter= 0;
best_type= JT_HASH;
trace_access_hash.add("type", "hash");
trace_access_hash.add("index", "hj-key");
trace_access_hash.add("cost", rnd_records);
@ -7814,10 +7819,6 @@ best_access_path(JOIN *join,
filter= 0;
if (s->quick)
{
trace_access_scan.add("access_type", "range");
/*
should have some info about all the different QUICK_SELECT
*/
/*
For each record we:
- read record range through 'quick'
@ -7843,23 +7844,29 @@ best_access_path(JOIN *join,
{
tmp-= filter->get_adjusted_gain(rows);
DBUG_ASSERT(tmp >= 0);
}
}
type= JT_RANGE;
}
else
{
type= JT_INDEX_MERGE;
best_filter= 0;
}
loose_scan_opt.check_range_access(join, idx, s->quick);
}
else
{
trace_access_scan.add("access_type", "scan");
/* Estimate cost of reading table. */
if (s->table->force_index && !best_key) // index scan
{
type= JT_NEXT;
tmp= s->table->file->read_time(s->ref.key, 1, s->records);
}
else // table scan
{
tmp= s->scan_time();
type= JT_ALL;
}
if ((s->table->map & join->outer_join) || disable_jbuf) // Can't use join cache
{
@ -7889,6 +7896,9 @@ best_access_path(JOIN *join,
}
}
trace_access_scan.add("access_type", type == JT_ALL ?
"scan" :
join_type_str[type]);
/* Splitting technique cannot be used with join cache */
if (s->table->is_splittable())
tmp+= s->table->get_materialization_cost();
@ -7928,6 +7938,7 @@ best_access_path(JOIN *join,
best_uses_jbuf= MY_TEST(!disable_jbuf && !((s->table->map &
join->outer_join)));
spl_plan= 0;
best_type= type;
}
trace_access_scan.add("chosen", best_key == NULL);
}
@ -7959,6 +7970,11 @@ best_access_path(JOIN *join,
trace_access_scan.add("use_tmp_table", true);
join->sort_by_table= (TABLE*) 1; // Must use temporary table
}
trace_access_scan.end();
trace_paths.end();
if (unlikely(thd->trace_started()))
print_best_access_for_table(thd, pos, best_type);
DBUG_VOID_RETURN;
}
@ -9189,18 +9205,6 @@ double table_cond_selectivity(JOIN *join, uint idx, JOIN_TAB *s,
}
void trace_plan_prefix(JOIN *join, uint idx, table_map remaining_tables)
{
THD *const thd= join->thd;
Json_writer_array plan_prefix(thd, "plan_prefix");
for (uint i= 0; i < idx; i++)
{
TABLE_LIST *const tr= join->positions[i].table->tab_list;
if (!(tr->map & remaining_tables))
plan_prefix.add_table_name(join->positions[i].table);
}
}
/**
Find a good, possibly optimal, query execution plan (QEP) by a possibly
exhaustive search.
@ -9499,6 +9503,8 @@ best_extension_by_limited_search(JOIN *join,
Hence it may be wrong.
*/
current_read_time= COST_ADD(current_read_time, current_record_count);
trace_one_table.add("estimated_join_cardinality",
partial_join_cardinality);
if (current_read_time < join->best_read)
{
memcpy((uchar*) join->best_positions, (uchar*) join->positions,
@ -10320,6 +10326,9 @@ bool JOIN::get_best_combination()
top_join_tab_count= (uint)(join_tab_ranges.head()->end -
join_tab_ranges.head()->start);
if (unlikely(thd->trace_started()))
print_final_join_order(this);
update_depend_map(this);
DBUG_RETURN(0);
}

View file

@ -3866,6 +3866,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
outparam->check_constraints= check_constraint_ptr;
vcol_init_mode mode= VCOL_INIT_DEPENDENCY_FAILURE_IS_WARNING;
#if MYSQL_VERSION_ID > 100500
switch (thd->lex->sql_command)
{
case SQLCOM_CREATE_TABLE:
@ -3880,9 +3881,10 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
default:
break;
}
#endif
if (unlikely(parse_vcol_defs(thd, &outparam->mem_root, outparam,
&error_reported, mode)))
if (parse_vcol_defs(thd, &outparam->mem_root, outparam,
&error_reported, mode))
{
error= OPEN_FRM_CORRUPTED;
goto err;

View file

@ -2758,7 +2758,6 @@ fseg_free_page_low(
ulint state;
ib_id_t descr_id;
ib_id_t seg_id;
ulint i;
ut_ad(seg_inode != NULL);
ut_ad(mtr != NULL);
@ -2794,7 +2793,7 @@ fseg_free_page_low(
if (state != XDES_FSEG) {
/* The page is in the fragment pages of the segment */
for (i = 0;; i++) {
for (ulint i = 0;; i++) {
if (fseg_get_nth_frag_page_no(seg_inode, i, mtr)
== offset) {
@ -2954,7 +2953,6 @@ fseg_free_extent(
xdes_t* descr;
ulint not_full_n_used;
ulint descr_n_used;
ulint i;
ut_ad(mtr != NULL);
@ -2970,7 +2968,7 @@ fseg_free_extent(
#ifdef BTR_CUR_HASH_ADAPT
if (ahi) {
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
for (ulint i = 0; i < FSP_EXTENT_SIZE; i++) {
if (!xdes_mtr_get_bit(descr, XDES_FREE_BIT, i, mtr)) {
/* Drop search system page hash index
@ -3008,7 +3006,7 @@ fseg_free_extent(
fsp_free_extent(space, page, mtr);
#ifdef UNIV_DEBUG
for (i = 0; i < FSP_EXTENT_SIZE; i++) {
for (ulint i = 0; i < FSP_EXTENT_SIZE; i++) {
buf_page_set_file_page_was_freed(
page_id_t(space->id, first_page_in_extent + i));

View file

@ -398,13 +398,16 @@ struct fil_space_t {
static bool is_flags_full_crc32_equal(ulint flags, ulint expected)
{
ut_ad(full_crc32(flags));
ulint page_ssize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
if (full_crc32(expected)) {
return get_compression_algo(flags)
== get_compression_algo(expected);
/* The data file may have been created with a
different innodb_compression_algorithm. But
we only support one innodb_page_size for all files. */
return page_ssize
== FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(expected);
}
ulint page_ssize = FSP_FLAGS_FCRC32_GET_PAGE_SSIZE(flags);
ulint space_page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(expected);
if (page_ssize == 5) {
@ -415,7 +418,7 @@ struct fil_space_t {
return false;
}
return is_compressed(expected) == is_compressed(flags);
return true;
}
/** Whether old tablespace flags match full_crc32 flags.
@param[in] flags flags present
@ -441,7 +444,7 @@ struct fil_space_t {
return false;
}
return is_compressed(expected) == is_compressed(flags);
return true;
}
/** Whether both fsp flags are equivalent */
static bool is_flags_equal(ulint flags, ulint expected)

View file

@ -2306,6 +2306,8 @@ class Rdb_transaction {
bool m_is_delayed_snapshot = false;
bool m_is_two_phase = false;
std::unordered_set<Rdb_tbl_def*> modified_tables;
private:
/*
Number of write operations this transaction had when we took the last
@ -3001,6 +3003,25 @@ protected:
virtual void start_tx() = 0;
virtual void start_stmt() = 0;
protected:
// Non-virtual functions with actions to be done on transaction start and
// commit.
void on_commit() {
time_t tm;
tm = time(nullptr);
for (auto &it : modified_tables) {
it->update_time = tm;
}
modified_tables.clear();
}
void on_rollback() {
modified_tables.clear();
}
public:
void log_table_write_op(Rdb_tbl_def *tbl) {
modified_tables.insert(tbl);
}
void set_initial_savepoint() {
/*
Set the initial savepoint. If the first statement in the transaction
@ -3185,7 +3206,9 @@ class Rdb_transaction_impl : public Rdb_transaction {
goto error;
}
on_commit();
error:
on_rollback();
/* Save the transaction object to be reused */
release_tx();
@ -3201,6 +3224,7 @@ class Rdb_transaction_impl : public Rdb_transaction {
public:
void rollback() override {
on_rollback();
m_write_count = 0;
m_insert_count = 0;
m_update_count = 0;
@ -3522,7 +3546,9 @@ class Rdb_writebatch_impl : public Rdb_transaction {
res = true;
goto error;
}
on_commit();
error:
on_rollback();
reset();
m_write_count = 0;
@ -3555,6 +3581,7 @@ class Rdb_writebatch_impl : public Rdb_transaction {
}
void rollback() override {
on_rollback();
m_write_count = 0;
m_insert_count = 0;
m_update_count = 0;
@ -7698,6 +7725,8 @@ int ha_rocksdb::create_table(const std::string &table_name,
goto error;
}
m_tbl_def->put_creation_time(&dict_manager, batch, time(nullptr));
err = dict_manager.commit(batch);
if (err != HA_EXIT_SUCCESS) {
dict_manager.unlock();
@ -10334,6 +10363,8 @@ int ha_rocksdb::update_write_row(const uchar *const old_data,
row_info.tx->incr_insert_count();
}
row_info.tx->log_table_write_op(m_tbl_def);
if (do_bulk_commit(row_info.tx)) {
DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD);
}
@ -10813,6 +10844,7 @@ int ha_rocksdb::delete_row(const uchar *const buf) {
}
tx->incr_delete_count();
tx->log_table_write_op(m_tbl_def);
if (do_bulk_commit(tx)) {
DBUG_RETURN(HA_ERR_ROCKSDB_BULK_LOAD);
@ -11011,6 +11043,12 @@ int ha_rocksdb::info(uint flag) {
k->rec_per_key[j] = x;
}
}
stats.create_time = m_tbl_def->get_creation_time(&dict_manager);
}
if (flag & HA_STATUS_TIME) {
stats.update_time = m_tbl_def->update_time;
}
if (flag & HA_STATUS_ERRKEY) {

View file

@ -121,12 +121,12 @@ set rocksdb_bulk_load=0;
--remove_file $file
# Make sure row count index stats are correct
--replace_column 6 # 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
SHOW TABLE STATUS WHERE name LIKE 't%';
ANALYZE TABLE t1, t2, t3;
--replace_column 6 # 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
SHOW TABLE STATUS WHERE name LIKE 't%';
# Make sure all the data is there.

View file

@ -121,12 +121,12 @@ set rocksdb_bulk_load=0;
--remove_file $file
# Make sure row count index stats are correct
--replace_column 6 # 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
SHOW TABLE STATUS WHERE name LIKE 't%';
ANALYZE TABLE t1, t2, t3;
--replace_column 6 # 7 # 8 # 9 #
--replace_column 6 # 7 # 8 # 9 # 12 # 13 #
SHOW TABLE STATUS WHERE name LIKE 't%';
# Make sure all the data is there.

View file

@ -40,9 +40,9 @@ pk a b
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -53,9 +53,9 @@ test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
select count(pk),count(a) from t1;
count(pk) count(a)
2500000 2500000

View file

@ -40,9 +40,9 @@ pk a b
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -53,9 +53,9 @@ test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
select count(pk),count(a) from t1;
count(pk) count(a)
2500000 2500000

View file

@ -40,9 +40,9 @@ pk a b
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -53,9 +53,9 @@ test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
select count(pk),count(a) from t1;
count(pk) count(a)
2500000 2500000

View file

@ -40,9 +40,9 @@ pk a b
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -53,9 +53,9 @@ test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_bin NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_bin NULL partitioned 0 N
select count(pk),count(a) from t1;
count(pk) count(a)
2500000 2500000

View file

@ -72,9 +72,9 @@ LOAD DATA INFILE <input_file> INTO TABLE t3;
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -85,9 +85,9 @@ test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
select count(a),count(b) from t1;
count(a) count(b)
2500000 2500000

View file

@ -72,9 +72,9 @@ LOAD DATA INFILE <input_file> INTO TABLE t3;
set rocksdb_bulk_load=0;
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@ -85,9 +85,9 @@ test.t3 analyze status Engine-independent statistics collected
test.t3 analyze status OK
SHOW TABLE STATUS WHERE name LIKE 't%';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned 0 N
t1 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 2500000 # # # # 0 NULL # # NULL latin1_swedish_ci NULL partitioned 0 N
select count(a),count(b) from t1;
count(a) count(b)
2500000 2500000

View file

@ -2,7 +2,7 @@ CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5);
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 VALUES ('538647864786478647864');
Warnings:
Warning 1264 Out of range value for column 'pk' at row 1
@ -12,7 +12,7 @@ pk
9223372036854775807
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed 2 22 44 0 0 0 9223372036854775807 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
SELECT * FROM t1;
@ -21,7 +21,7 @@ pk
9223372036854775807
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '9223372036854775807' for key 'PRIMARY'
SELECT * FROM t1;
@ -30,13 +30,13 @@ pk
9223372036854775807
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 9223372036854775807 # # NULL latin1_swedish_ci NULL 0 N
DROP TABLE t1;
CREATE TABLE t1 (pk TINYINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5);
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 6 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 6 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 VALUES (1000);
Warnings:
Warning 1264 Out of range value for column 'pk' at row 1
@ -46,7 +46,7 @@ pk
127
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
SELECT * FROM t1;
@ -55,7 +55,7 @@ pk
127
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 VALUES ();
ERROR 23000: Duplicate entry '127' for key 'PRIMARY'
SELECT * FROM t1;
@ -64,5 +64,5 @@ pk
127
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB # Fixed # # # # # # 127 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB # Fixed # # # # # # 127 # # NULL latin1_swedish_ci NULL 0 N
DROP TABLE t1;

View file

@ -1422,7 +1422,7 @@ create table t1 (i int primary key auto_increment) engine=RocksDB;
insert into t1 values (null),(null);
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed 1000 0 # 0 0 0 3 # # NULL latin1_swedish_ci NULL 0 N
drop table t1;
#
# Fix Issue #4: Crash when using pseudo-unique keys
@ -2595,7 +2595,7 @@ CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
INSERT INTO t1 VALUES(0),(-1),(0);
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 3 # # NULL latin1_swedish_ci NULL 0 N
SELECT * FROM t1;
a
-1
@ -2606,7 +2606,7 @@ CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
INSERT INTO t1 VALUES(0),(10),(0);
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed 1000 0 0 0 0 0 12 # # NULL latin1_swedish_ci NULL 0 N
SELECT * FROM t1;
a
1

View file

@ -7,12 +7,12 @@ set global rocksdb_force_flush_memtable_now = true;
CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb CHARACTER SET utf8;
SHOW TABLE STATUS WHERE name IN ( 't1', 't2', 't3' );
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL utf8_general_ci NULL 0 N
t1 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL 0 N
t3 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL utf8_general_ci NULL 0 N
SHOW TABLE STATUS WHERE name LIKE 't2';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL 0 N
t2 ROCKSDB 10 Fixed 1000 # # 0 0 0 NULL # # NULL latin1_swedish_ci NULL 0 N
DROP TABLE t1, t2, t3;
CREATE DATABASE `db_new..............................................end`;
USE `db_new..............................................end`;
@ -22,3 +22,39 @@ SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE T
TABLE_SCHEMA db_new..............................................end
TABLE_NAME t1_new..............................................end
DROP DATABASE `db_new..............................................end`;
#
# MDEV-17171: Bug: RocksDB Tables do not have "Creation Date"
#
use test;
create table t1 (a int) engine=rocksdb;
select create_time is not null, update_time, check_time
from information_schema.tables where table_schema=database() and table_name='t1';
create_time is not null update_time check_time
1 NULL NULL
insert into t1 values (1);
select create_time is not null, update_time is not null, check_time
from information_schema.tables where table_schema=database() and table_name='t1';
create_time is not null update_time is not null check_time
1 1 NULL
flush tables;
select create_time is not null, update_time is not null, check_time
from information_schema.tables where table_schema=database() and table_name='t1';
create_time is not null update_time is not null check_time
1 1 NULL
select create_time, update_time into @create_tm, @update_tm
from information_schema.tables
where table_schema=database() and table_name='t1';
select sleep(3);
sleep(3)
0
insert into t1 values (2);
select
create_time=@create_tm /* should not change */ ,
timestampdiff(second, @update_tm, update_time) > 2,
check_time
from information_schema.tables
where table_schema=database() and table_name='t1';
create_time=@create_tm 1
timestampdiff(second, @update_tm, update_time) > 2 1
check_time NULL
drop table t1;

View file

@ -9,19 +9,19 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT KEY AUTO_INCREMENT, c CHAR(8)) ENGINE=rocksdb;
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed # # # 0 0 0 4 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed # # # 0 0 0 4 # # NULL latin1_swedish_ci NULL 0 N
TRUNCATE TABLE t1;
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed # # # 0 0 0 1 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed # # # 0 0 0 1 # # NULL latin1_swedish_ci NULL 0 N
INSERT INTO t1 (c) VALUES ('d');
SHOW TABLE STATUS LIKE 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 ROCKSDB 10 Fixed # # # 0 0 0 2 NULL NULL NULL latin1_swedish_ci NULL 0 N
t1 ROCKSDB 10 Fixed # # # 0 0 0 2 # # NULL latin1_swedish_ci NULL 0 N
SELECT a,c FROM t1;
a c
1 d

View file

@ -76,6 +76,7 @@ select variable_value-@a from information_schema.global_status where variable_na
variable_value-@a
4
DROP TABLE t1;
set global ROCKSDB_COMPACT_CF= 'default';
CREATE TABLE t1 (
a int,
b int,

View file

@ -11,7 +11,7 @@ use My::Find;
use File::Basename;
use strict;
sub is_default { not $::opt_embedded_server }
#sub is_default { not $::opt_embedded_server }
my $sst_dump=
::mtr_exe_maybe_exists(

View file

@ -3,24 +3,25 @@
CREATE TABLE t1 (pk BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5);
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
INSERT INTO t1 VALUES ('538647864786478647864');
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SELECT * FROM t1;
--replace_column 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
DROP TABLE t1;
@ -28,24 +29,24 @@ DROP TABLE t1;
CREATE TABLE t1 (pk TINYINT NOT NULL PRIMARY KEY AUTO_INCREMENT);
INSERT INTO t1 VALUES (5);
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
INSERT INTO t1 VALUES (1000);
SELECT * FROM t1;
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES ();
SELECT * FROM t1;
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 #
--replace_column 3 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
DROP TABLE t1;

View file

@ -1207,7 +1207,7 @@ drop table t1;
create table t1 (i int primary key auto_increment) engine=RocksDB;
insert into t1 values (null),(null);
--replace_column 7 #
--replace_column 7 # 12 # 13 #
show table status like 't1';
drop table t1;
@ -1914,11 +1914,13 @@ DROP TABLE t1;
# value is 4 while MyRocks will show it as 3.
CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
INSERT INTO t1 VALUES(0),(-1),(0);
--replace_column 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a INT AUTO_INCREMENT KEY);
INSERT INTO t1 VALUES(0),(10),(0);
--replace_column 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
SELECT * FROM t1;
DROP TABLE t1;

View file

@ -25,7 +25,7 @@ set global rocksdb_force_flush_memtable_now = true;
CREATE TABLE t3 (a INT, b CHAR(8), pk INT PRIMARY KEY) ENGINE=rocksdb CHARACTER SET utf8;
--replace_column 6 # 7 #
--replace_column 6 # 7 # 12 # 13 #
SHOW TABLE STATUS WHERE name IN ( 't1', 't2', 't3' );
# Some statistics don't get updated as quickly. The Data_length and
@ -49,7 +49,7 @@ set global rocksdb_force_flush_memtable_now = true;
# We expect the number of rows to be 10000. Data_len and Avg_row_len
# may vary, depending on built-in compression library.
--replace_column 6 # 7 #
--replace_column 6 # 7 # 12 # 13 #
SHOW TABLE STATUS WHERE name LIKE 't2';
DROP TABLE t1, t2, t3;
@ -63,3 +63,36 @@ CREATE TABLE `t1_new..............................................end`(a int) en
INSERT INTO `t1_new..............................................end` VALUES (1);
--query_vertical SELECT TABLE_SCHEMA, TABLE_NAME FROM information_schema.table_statistics WHERE TABLE_NAME = 't1_new..............................................end'
DROP DATABASE `db_new..............................................end`;
--echo #
--echo # MDEV-17171: Bug: RocksDB Tables do not have "Creation Date"
--echo #
use test;
create table t1 (a int) engine=rocksdb;
select create_time is not null, update_time, check_time
from information_schema.tables where table_schema=database() and table_name='t1';
insert into t1 values (1);
select create_time is not null, update_time is not null, check_time
from information_schema.tables where table_schema=database() and table_name='t1';
flush tables;
select create_time is not null, update_time is not null, check_time
from information_schema.tables where table_schema=database() and table_name='t1';
select create_time, update_time into @create_tm, @update_tm
from information_schema.tables
where table_schema=database() and table_name='t1';
select sleep(3);
insert into t1 values (2);
--vertical_results
select
create_time=@create_tm /* should not change */ ,
timestampdiff(second, @update_tm, update_time) > 2,
check_time
from information_schema.tables
where table_schema=database() and table_name='t1';
drop table t1;

View file

@ -29,22 +29,22 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT KEY AUTO_INCREMENT, c CHAR(8)) ENGINE=rocksdb;
#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
--replace_column 5 # 6 # 7 #
--replace_column 5 # 6 # 7 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
--replace_column 5 # 6 # 7 #
--replace_column 5 # 6 # 7 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
TRUNCATE TABLE t1;
#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
--replace_column 5 # 6 # 7 #
--replace_column 5 # 6 # 7 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
INSERT INTO t1 (c) VALUES ('d');
#--replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 #
--replace_column 5 # 6 # 7 #
--replace_column 5 # 6 # 7 # 12 # 13 #
SHOW TABLE STATUS LIKE 't1';
--sorted_result

View file

@ -102,6 +102,8 @@ SELECT * FROM t1;
select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered';
DROP TABLE t1;
# Compact away the dropped data
set global ROCKSDB_COMPACT_CF= 'default';
# Read filtering index scan tests (None of these queries should return any results)
CREATE TABLE t1 (

View file

@ -9,7 +9,7 @@ use My::Find;
use File::Basename;
use strict;
sub is_default { not $::opt_embedded_server }
#sub is_default { not $::opt_embedded_server }
my $sst_dump=
::mtr_exe_maybe_exists(

View file

@ -11,7 +11,7 @@ use My::Find;
use File::Basename;
use strict;
sub is_default { not $::opt_embedded_server }
#sub is_default { not $::opt_embedded_server }
my $sst_dump=
::mtr_exe_maybe_exists(

View file

@ -8,7 +8,7 @@ use My::Find;
use File::Basename;
use strict;
sub is_default { not $::opt_embedded_server }
#sub is_default { not $::opt_embedded_server }
my $sst_dump=
::mtr_exe_maybe_exists(

View file

@ -3517,6 +3517,27 @@ Rdb_tbl_def::~Rdb_tbl_def() {
}
}
void Rdb_tbl_def::put_creation_time(Rdb_dict_manager *dict_manager,
rocksdb::WriteBatchBase *batch,
time_t timeval) {
dict_manager->put_creation_time(batch,
m_key_descr_arr[0]->get_gl_index_id(),
timeval);
create_time = timeval;
}
time_t Rdb_tbl_def::get_creation_time(Rdb_dict_manager *dict_manager) {
time_t tm;
if (create_time == CREATE_TIME_UNKNOWN) {
if (dict_manager->get_creation_time(m_key_descr_arr[0]->get_gl_index_id(),
&tm))
create_time = tm;
else
create_time = 0; // Not available
}
return create_time;
}
/*
Put table definition DDL entry. Actual write is done at
Rdb_dict_manager::commit.
@ -5343,6 +5364,7 @@ rocksdb::Status Rdb_dict_manager::put_auto_incr_val(
value_writer.to_slice());
}
bool Rdb_dict_manager::get_auto_incr_val(const GL_INDEX_ID &gl_index_id,
ulonglong *new_val) const {
Rdb_buf_writer<Rdb_key_def::INDEX_NUMBER_SIZE * 3> key_writer;
@ -5362,6 +5384,51 @@ bool Rdb_dict_manager::get_auto_incr_val(const GL_INDEX_ID &gl_index_id,
return false;
}
rocksdb::Status
Rdb_dict_manager::put_creation_time(rocksdb::WriteBatchBase *batch,
const GL_INDEX_ID &gl_index_id,
time_t timeval) const {
uchar key_buf[Rdb_key_def::INDEX_NUMBER_SIZE * 3] = {0};
dump_index_id(key_buf, Rdb_key_def::TABLE_CREATION_TS, gl_index_id);
const rocksdb::Slice key =
rocksdb::Slice(reinterpret_cast<char *>(key_buf), sizeof(key_buf));
// Value is constructed by storing the version and the value.
uchar value_buf[RDB_SIZEOF_TABLE_CREATION_TS_VERSION +
ROCKSDB_SIZEOF_TABLE_CREATION_TS] = {0};
uchar *ptr = value_buf;
rdb_netbuf_store_uint16(ptr, Rdb_key_def::TABLE_CREATION_TS_VERSION);
ptr += RDB_SIZEOF_TABLE_CREATION_TS_VERSION;
rdb_netbuf_store_uint64(ptr, timeval);
ptr += ROCKSDB_SIZEOF_TABLE_CREATION_TS;
const rocksdb::Slice value =
rocksdb::Slice(reinterpret_cast<char *>(value_buf), ptr - value_buf);
return batch->Put(m_system_cfh, key, value);
}
bool Rdb_dict_manager::get_creation_time(const GL_INDEX_ID &gl_index_id,
time_t *new_val) const {
uchar key_buf[Rdb_key_def::INDEX_NUMBER_SIZE * 3] = {0};
dump_index_id(key_buf, Rdb_key_def::TABLE_CREATION_TS, gl_index_id);
std::string value;
const rocksdb::Status status = get_value(
rocksdb::Slice(reinterpret_cast<char *>(key_buf), sizeof(key_buf)),
&value);
if (status.ok() && value.size() >= RDB_SIZEOF_TABLE_CREATION_TS_VERSION) {
const uchar *const val = reinterpret_cast<const uchar *>(value.data());
if (rdb_netbuf_to_uint16(val) <= Rdb_key_def::TABLE_CREATION_TS_VERSION) {
*new_val = rdb_netbuf_to_uint64(val + RDB_SIZEOF_TABLE_CREATION_TS_VERSION);
return true;
}
}
return false;
}
uint Rdb_seq_generator::get_and_update_next_number(
Rdb_dict_manager *const dict) {
DBUG_ASSERT(dict != nullptr);

View file

@ -201,6 +201,7 @@ const size_t RDB_SIZEOF_INDEX_TYPE = sizeof(uchar);
const size_t RDB_SIZEOF_KV_VERSION = sizeof(uint16);
const size_t RDB_SIZEOF_INDEX_FLAGS = sizeof(uint32);
const size_t RDB_SIZEOF_AUTO_INCREMENT_VERSION = sizeof(uint16);
const size_t RDB_SIZEOF_TABLE_CREATION_TS_VERSION = sizeof(uint16);
// Possible return values for rdb_index_field_unpack_t functions.
enum {
@ -504,6 +505,7 @@ class Rdb_key_def {
MAX_INDEX_ID = 7,
DDL_CREATE_INDEX_ONGOING = 8,
AUTO_INC = 9,
TABLE_CREATION_TS = 10,
END_DICT_INDEX_ID = 255
};
@ -517,6 +519,7 @@ class Rdb_key_def {
MAX_INDEX_ID_VERSION = 1,
DDL_CREATE_INDEX_ONGOING_VERSION = 1,
AUTO_INCREMENT_VERSION = 1,
TABLE_CREATION_TS_VERSION = 1
// Version for index stats is stored in IndexStats struct
};
@ -1108,6 +1111,13 @@ class Rdb_tbl_def {
~Rdb_tbl_def();
// time values are shown in SHOW TABLE STATUS
void put_creation_time(Rdb_dict_manager *dict_manager,
rocksdb::WriteBatchBase *batch, time_t timeval);
time_t get_creation_time(Rdb_dict_manager *dict_manager);
time_t update_time = 0; // in-memory only value, maintained right here
void check_and_set_read_free_rpl_table();
/* Number of indexes */
@ -1133,6 +1143,12 @@ class Rdb_tbl_def {
const std::string &base_tablename() const { return m_tablename; }
const std::string &base_partition() const { return m_partition; }
GL_INDEX_ID get_autoincr_gl_index_id();
private:
const time_t CREATE_TIME_UNKNOWN= 1;
// CREATE_TIME_UNKNOWN means "didn't try to read, yet"
// 0 means "no data available" (and SQL layer shares this)
time_t create_time = CREATE_TIME_UNKNOWN;
};
/*
@ -1347,6 +1363,10 @@ class Rdb_binlog_manager {
value: version, {max auto_increment so far}
max auto_increment is 8 bytes
10. Table creation timestamp
key: Rdb_key_def::TABLE_CREATION_TIMESTAMP + cf_id + index_id
value: timestamp
Data dictionary operations are atomic inside RocksDB. For example,
when creating a table with two indexes, it is necessary to call Put
three times. They have to be atomic. Rdb_dict_manager has a wrapper function
@ -1505,6 +1525,11 @@ class Rdb_dict_manager {
bool overwrite = false) const;
bool get_auto_incr_val(const GL_INDEX_ID &gl_index_id,
ulonglong *new_val) const;
rocksdb::Status put_creation_time(rocksdb::WriteBatchBase *batch,
const GL_INDEX_ID &gl_index_id,
time_t timeval_arg) const;
bool get_creation_time(const GL_INDEX_ID &gl_index_id,
time_t *new_val) const;
};
struct Rdb_index_info {

View file

@ -228,6 +228,8 @@ const char *const RDB_TTL_COL_QUALIFIER = "ttl_col";
#define ROCKSDB_SIZEOF_AUTOINC_VALUE sizeof(longlong)
#define ROCKSDB_SIZEOF_TABLE_CREATION_TS sizeof(uint64_t)
/*
Maximum index prefix length in bytes.
*/