提交 d5269307 编写于 作者: W wangzelin.wzl

move test folder

上级 29e0cb74
Subproject commit 4f9e63f635e841e457cd1d6f28d80ef2e196ebea
Subproject commit 509d86f9ea7afa6a5e6a577e95d20633f6c584b7
#--disable_query_log
#--disable_result_log
#
#let $index_status_expect = 2;
#let $result = 2;
#
#connect (obsys_caio,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
#connection obsys_caio;
#let $i=210;
#while($i>0)
#{
# sleep 1;
# #--echo $index_name
# ## let $result = query_get_value(select count(*) from oceanbase.__all_virtual_table where table_name like '__idx_%' and index_status!=2,count(*),1);
# let $result = query_get_value(select count(*) from oceanbase.__all_virtual_table as t join oceanbase.__all_virtual_database as d where t.tenant_id = d.tenant_id and t.database_id = d.database_id and d.in_recyclebin = false and d.database_name != "__recyclebin" and t.table_name like '__idx_%' and t.index_status!=2,count(*),1);
# if($result == 0)
# {
# let $i = -4;
# }
# dec $i;
#}
#sleep 2;
#if($i != -5)
#{
# let $table_id = query_get_value(select table_id from oceanbase.__all_virtual_table as t join oceanbase.__all_virtual_database as d where t.tenant_id = d.tenant_id and t.database_id = d.database_id and d.in_recyclebin = false and d.database_name != "__recyclebin" and t.table_name like '__idx_%' and t.index_status!=2 limit 1,table_id,1);
# --echo $result idx is build failed, first table id is $table_id
#}
#disconnect obsys_caio;
#connection default;
#--enable_query_log
#--enable_result_log
let $cluster_is_ob = 1;
let $cluster_is_mysql = 0;
let $collation_count = query_get_value(select count(1) as cnt from information_schema.COLLATIONS, cnt, 1);
if ($collation_count > 100) {
let $cluster_is_ob = 0;
let $cluster_is_mysql = 1;
}
connect (ob_sys_check_schema,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection ob_sys_check_schema;
let $i = 10;
while($i > 0)
{
sleep 1;
let $cnt = query_get_value(select count(*) as cnt from oceanbase.__all_virtual_server_schema_info as a join oceanbase.__all_virtual_server_schema_info as b on a.tenant_id = b.tenant_id where a.refreshed_schema_version != b.refreshed_schema_version, cnt, 1);
dec $i;
if ($cnt == 0)
{
let $i = -4;
}
}
if ($i != -4)
{
--echo check schema sync timeout
eval select * from oceanbase.__all_virtual_server_schema_info;
}
disconnect ob_sys_check_schema;
--disable_query_log
--disable_result_log
connection default;
let $tenant_id = query_get_value(select effective_tenant_id() as ID from dual, ID, 1);
connect (obsys_ydm,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_ydm;
let $__i__= 100;
while($__i__ > 0)
{
sleep 1;
dec $__i__;
## 检查有没有分区的列级统计信息还没有汇报上来
let $__num__ = query_get_value(select count(*) as num from oceanbase.__all_virtual_meta_table a where a.tenant_id = $tenant_id and not exists (select 1 from oceanbase.__all_virtual_column_statistic b where a.table_id = b.table_id and a.partition_id = b.partition_id and b.tenant_id = $tenant_id), num, 1);
if($__num__ == 0)
{
let $__i__ = -5;
}
}
connection default;
disconnect obsys_ydm;
--enable_query_log
--enable_result_log
let $server_cnt = query_get_value(select count(*) as cnt from oceanbase.__all_server, cnt, 1);
let $schema_version = query_get_value(select max(schema_version) as max_schema_version from oceanbase.__all_tenant_history, max_schema_version, 1);
let $sync_cnt = 0;
let $i = 10;
while($i > 0)
{
sleep 1;
dec $i;
let $sync_cnt = query_get_value(select count(*) as cnt from oceanbase.__all_virtual_server_schema_info where refreshed_schema_version >= $schema_version and tenant_id = 1, cnt, 1);
if ($sync_cnt == $server_cnt)
{
let $i = -4;
}
}
if ($i != -4)
{
--echo check tenant sync timeout, sync_cnt:$sync_cnt, server_cnt:$server_cnt
eval select * from oceanbase.__all_virtual_server_schema_info where refreshed_schema_version >= $schema_version and tenant_id = 1;
}
## 功能: 获取指定租户的ip&port
# 1.最好使用前sleep下,否则tenant_schema有可能还未刷到server上导致连接不上
# 2.如果分布于多个server,取unit_id最小的
## 用法:
# 1.设置待连接的tenant_name
# 2.source本文件
# 3.connect
## 模板:
# sleep 3;
# let $__tenant_name__ = 'tt1';
# --source mysql_test/include/get_tenant_server.inc
# connect (conn1,$TE_SERVER_IP,root@tt1,,*NO-ONE*,$TE_SERVER_PORT);
--disable_query_log
--disable_result_log
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
let $__tenant_id__ = `select tenant_id from oceanbase.__all_tenant where tenant_name = $__tenant_name__ limit 1`;
let $__resource_pool_id__ = `select resource_pool_id from oceanbase.__all_resource_pool where tenant_id = $__tenant_id__ limit 1`;
let $__svr_ip__ = `select svr_ip from oceanbase.__all_unit where resource_pool_id = $__resource_pool_id__ limit 1`;
let $__svr_port__ = `select svr_port from oceanbase.__all_unit where resource_pool_id = $__resource_pool_id__ limit 1`;
let $__inner_port__ = `select inner_port from oceanbase.__all_server where svr_ip = '$__svr_ip__' and svr_port = $__svr_port__ limit 1`;
let $TE_SERVER_IP = $__svr_ip__;
let $TE_SERVER_PORT = $__inner_port__;
disconnect obsys;
connection default;
--enable_query_log
--enable_result_log
connect (obsys_idm,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_idm;
set ob_enable_index_direct_select=1;
alter system set merger_check_interval = '10s';
disconnect obsys_idm;
connection default;
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
alter system major freeze;
disconnect obsys;
connection default;
-- require mysql_test/r/not_embedded.require
disable_query_log;
select version() like '%embedded%' as 'have_embedded';
enable_query_log;
connection default;
--disable_query_log
--disable_result_log
select * from proxy_mock_table_for_pc;
--enable_query_log
--enable_result_log
--replace_regex /REPLICA_NUM = [0-9]*/REPLICA_NUM = 1/g /ROW_FORMAT = (DYNAMIC|COMPRESSED|COMPACT|REDUNDANT)[ ]*//g /(NOCOMPRESS|COMPRESS) (FOR)*[ ]*(BASIC|OLTP|QUERY|ARCHIVE)*[ ]*//g /zstd_1\.3\.8/lz4_1.0/g /OBFK_[0-9]*/OBFK_1234/g /OBPK_[0-9]*/OBPK_1234/g /OBUNIQUE_[0-9]*/OBUNIQUE_1234/g /RECYCLE_\$_[0-9]*_[0-9]*_OBCHECK_[0-9]*/RECYCLE_$_1_2_OBCHECK_3/g /PCTFREE = [0-9]*/PCTFREE = 10/g
--replace_regex /REPLICA_NUM = [0-9]*/REPLICA_NUM = NUM/g /ROW_FORMAT = (DYNAMIC|COMPRESSED|COMPACT|REDUNDANT)[ ]*//g /(NOCOMPRESS|COMPRESS) (FOR)*[ ]*(BASIC|OLTP|QUERY|ARCHIVE)*[ ]*//g /zstd_1\.3\.8/lz4_1.0/g /OBFK_[0-9]*/OBFK_1234/g /OBIDX_[0-9]*/OBIDX_1234/g /OBCHECK_[0-9]*/OBCHECK_1234/g /OBPK_[0-9]*/OBPK_1234/g /OBUNIQUE_[0-9]*/OBUNIQUE_1234/g /zone1;zone2/zone1/g /BLOCK_SIZE = [0-9]*/BLOCK_SIZE = SIZE/g /TABLET_SIZE = [0-9]*/TABLET_SIZE = SIZE/g /ZONE_LIST = \(.*\)/ZONE_LIST = (test)/g /PRIMARY_ZONE = .*/PRIMARY_ZONE = /g /PCTFREE = [0-9]*/PCTFREE = 10/g
#--disable_query_log
#--disable_result_log
connect (obsys_ydm,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys_ydm;
let $__i__= 600;
while($__i__ > 0)
{
sleep 1;
dec $__i__;
let $__forzen_version__ = query_get_value(select value from oceanbase.__all_zone where name = 'frozen_version', value, 1);
let $__merged_version__ = query_get_value(select value from oceanbase.__all_zone where name = 'last_merged_version' and zone = '', value, 1);
if($__forzen_version__ == $__merged_version__)
{
let $__i__ = -5;
}
}
###判断集群状态,先注释掉
#let $__j__= 180;
#while($__j__ > 0)
#{
# sleep 1;
# dec $__j__;
# let $__global_stat__ = query_get_value(select comment from oceanbase.__all_cluster_stat where name='global_stat',comment, 1);
# if($__global_stat__ == NORMAL)
# {
# let $__j__ = -5;
# }
#}
#if($__j__ != -5)
#{
# --echo major freeze failed
#}
if($__i__ != -5)
{
--echo major freeze failed
}
sleep 2;
disconnect obsys_ydm;
connection default;
--enable_query_log
--enable_result_log
--disable_warnings
drop table if exists t_h3_01_20;
drop table if exists t_h3_05_24;
drop table if exists t_h3_09_28;
drop table if exists t_h5_01_20;
drop table if exists t_h5_05_24;
drop table if exists t_h5_09_28;
drop table if exists t_r4_01_20;
drop table if exists t_r4_05_24;
drop table if exists t_r4_09_28;
drop table if exists t_r5_01_20;
drop table if exists t_r5_05_24;
drop table if exists t_r5_09_28;
drop table if exists t_h3_r4_01_20;
drop table if exists t_h3_r5_09_28;
drop table if exists t_h5_r4_01_20;
drop table if exists t_h5_r5_09_28;
drop table if exists t_refered;
drop table if exists t_h5_int;
drop table if exists t_r4_int;
drop table if exists t_r4_date;
drop table if exists t_r4_datetime;
drop table if exists t_r4_timestamp;
drop table if exists t_h5_r4_int_int;
drop table if exists t_h5_r4_int_int_datetime;
drop table if exists t_r4_h2_date_int;
drop table if exists t_r4_h3_date_int;
drop table if exists t_r4_h3_date_bigint;
drop table if exists tt;
drop table if exists t_many_range_part;
--enable_warnings
================ expression convert_tz ================
SELECT CONVERT_TZ('2021-01-01 12:00:00','+00:00','+08:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','+00:00','+08:00') |
+-----------------------------------------------------+
| 2021-01-01 20:00:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+08:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','+01:00','+08:00') |
+-----------------------------------------------------+
| 2021-01-01 19:00:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+06:30');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','+01:00','+06:30') |
+-----------------------------------------------------+
| 2021-01-01 17:30:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:00','+10:10');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','+01:00','+10:10') |
+-----------------------------------------------------+
| 2021-01-01 21:10:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:00:00','+01:30','+13:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','+01:30','+13:00') |
+-----------------------------------------------------+
| 2021-01-01 23:30:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:00:00','-11:30','+13:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','-11:30','+13:00') |
+-----------------------------------------------------+
| 2021-01-02 12:30:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:00:00','-12:00','+13:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:00:00','-12:00','+13:00') |
+-----------------------------------------------------+
| 2021-01-02 13:00:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 00:00:00','-12:00','+13:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 00:00:00','-12:00','+13:00') |
+-----------------------------------------------------+
| 2021-01-02 01:00:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 23:59:59','-12:00','+13:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 23:59:59','-12:00','+13:00') |
+-----------------------------------------------------+
| 2021-01-03 00:59:59 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 13:19:38','-10:38','+10:12');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 13:19:38','-10:38','+10:12') |
+-----------------------------------------------------+
| 2021-01-02 10:09:38 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 12:23:35','-09:23','-11:11');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 12:23:35','-09:23','-11:11') |
+-----------------------------------------------------+
| 2021-01-01 10:35:35 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 00:01:00','+10:00','-11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 00:01:00','+10:00','-11:00') |
+-----------------------------------------------------+
| 2020-12-31 03:01:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 00:11:00','+00:00','-11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 00:11:00','+00:00','-11:00') |
+-----------------------------------------------------+
| 2020-12-31 13:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-03-01 00:11:00','+00:00','-11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-03-01 00:11:00','+00:00','-11:00') |
+-----------------------------------------------------+
| 2021-02-28 13:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-06-01 00:11:00','+00:00','-11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2021-06-01 00:11:00','+00:00','-11:00') |
+-----------------------------------------------------+
| 2021-05-31 13:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2020-03-01 00:11:00','+00:00','-11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2020-03-01 00:11:00','+00:00','-11:00') |
+-----------------------------------------------------+
| 2020-02-29 13:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2020-02-28 23:11:00','-00:00','+11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2020-02-28 23:11:00','-00:00','+11:00') |
+-----------------------------------------------------+
| 2020-02-29 10:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2020-12-31 23:11:00','-05:00','+11:00');
+-----------------------------------------------------+
| CONVERT_TZ('2020-12-31 23:11:00','-05:00','+11:00') |
+-----------------------------------------------------+
| 2021-01-01 15:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2020-12-31 23:11:00',null,'+11:00');
+-------------------------------------------------+
| CONVERT_TZ('2020-12-31 23:11:00',null,'+11:00') |
+-------------------------------------------------+
| NULL |
+-------------------------------------------------+
SELECT CONVERT_TZ('2020-12-31 23:11:00','+11:00', null);
+--------------------------------------------------+
| CONVERT_TZ('2020-12-31 23:11:00','+11:00', null) |
+--------------------------------------------------+
| NULL |
+--------------------------------------------------+
SELECT CONVERT_TZ(null,'-13:00','+11:00');
+------------------------------------+
| CONVERT_TZ(null,'-13:00','+11:00') |
+------------------------------------+
| NULL |
+------------------------------------+
SELECT CONVERT_TZ(null, null,'+11:00');
+---------------------------------+
| CONVERT_TZ(null, null,'+11:00') |
+---------------------------------+
| NULL |
+---------------------------------+
SELECT CONVERT_TZ(null, null, null);
+------------------------------+
| CONVERT_TZ(null, null, null) |
+------------------------------+
| NULL |
+------------------------------+
SELECT CONVERT_TZ('2020-12-31 23:11:00','America/Merida','Asia/Tokyo');
+-----------------------------------------------------------------+
| CONVERT_TZ('2020-12-31 23:11:00','America/Merida','Asia/Tokyo') |
+-----------------------------------------------------------------+
| 2021-01-01 14:11:00 |
+-----------------------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Australia/Darwin');
+-----------------------------------------------------------------------+
| CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Australia/Darwin') |
+-----------------------------------------------------------------------+
| 2021-01-01 15:41:00 |
+-----------------------------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Europe/Amsterdam');
+-----------------------------------------------------------------------+
| CONVERT_TZ('2021-01-01 00:11:00','America/Merida','Europe/Amsterdam') |
+-----------------------------------------------------------------------+
| 2021-01-01 07:11:00 |
+-----------------------------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','America/Merida');
+-----------------------------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','America/Merida') |
+-----------------------------------------------------------------------+
| 2021-01-01 00:11:00 |
+-----------------------------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','Libya');
+--------------------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','Europe/Amsterdam','Libya') |
+--------------------------------------------------------------+
| 2021-01-01 08:11:00 |
+--------------------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','MET','Libya');
+-------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','MET','Libya') |
+-------------------------------------------------+
| 2021-01-01 08:11:00 |
+-------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','MET','MST');
+-----------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','MET','MST') |
+-----------------------------------------------+
| 2020-12-31 23:11:00 |
+-----------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','PRC','MST');
+-----------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','PRC','MST') |
+-----------------------------------------------+
| 2020-12-31 16:11:00 |
+-----------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','PRC','ROC');
+-----------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','PRC','ROC') |
+-----------------------------------------------+
| 2021-01-01 07:11:00 |
+-----------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','UCT','ROC');
+-----------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','UCT','ROC') |
+-----------------------------------------------+
| 2021-01-01 15:11:00 |
+-----------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','Universal','ROC');
+-----------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','Universal','ROC') |
+-----------------------------------------------------+
| 2021-01-01 15:11:00 |
+-----------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00','Pacific/Marquesas','ROC');
+-------------------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00','Pacific/Marquesas','ROC') |
+-------------------------------------------------------------+
| 2021-01-02 00:41:00 |
+-------------------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00','GMT+0','ROC');
+-------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00','GMT+0','ROC') |
+-------------------------------------------------+
| 2021-03-01 01:11:00 |
+-------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00','GMT+0','Singapore');
+-------------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00','GMT+0','Singapore') |
+-------------------------------------------------------+
| 2021-03-01 01:11:00 |
+-------------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan','ROC');
+-------------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00','US/Michigan','ROC') |
+-------------------------------------------------------+
| 2021-03-01 06:11:00 |
+-------------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00', null,'ROC');
+-----------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00', null,'ROC') |
+-----------------------------------------------+
| NULL |
+-----------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', null);
+-------------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', null) |
+-------------------------------------------------------+
| NULL |
+-------------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00', null, null);
+-----------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00', null, null) |
+-----------------------------------------------+
| NULL |
+-----------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00', '+00:00','ROC');
+---------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00', '+00:00','ROC') |
+---------------------------------------------------+
| 2021-03-01 01:11:00 |
+---------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00', '+00:00','US/Michigan');
+-----------------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00', '+00:00','US/Michigan') |
+-----------------------------------------------------------+
| 2021-02-28 12:11:00 |
+-----------------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+00:00');
+---------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+00:00') |
+---------------------------------------------------+
| 2021-02-28 09:11:00 |
+---------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', '+00:00');
+-----------------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00','US/Michigan', '+00:00') |
+-----------------------------------------------------------+
| 2021-02-28 22:11:00 |
+-----------------------------------------------------------+
SELECT CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+12:58');
+---------------------------------------------------+
| CONVERT_TZ('2021-02-28 17:11:00', 'ROC','+12:58') |
+---------------------------------------------------+
| 2021-02-28 22:09:00 |
+---------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00', '-12:58','UCT');
+---------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00', '-12:58','UCT') |
+---------------------------------------------------+
| 2021-01-01 20:09:00 |
+---------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00', '-12:58','US/Michigan');
+-----------------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00', '-12:58','US/Michigan') |
+-----------------------------------------------------------+
| 2021-01-01 15:09:00 |
+-----------------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+05:12','MET');
+---------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00', '+05:12','MET') |
+---------------------------------------------------+
| 2021-01-01 02:59:00 |
+---------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+03:32','PRC');
+---------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00', '+03:32','PRC') |
+---------------------------------------------------+
| 2021-01-01 11:39:00 |
+---------------------------------------------------+
SELECT CONVERT_TZ('2021-01-01 07:11:00', '+11:32','PRC');
+---------------------------------------------------+
| CONVERT_TZ('2021-01-01 07:11:00', '+11:32','PRC') |
+---------------------------------------------------+
| 2021-01-01 03:39:00 |
+---------------------------------------------------+
\ No newline at end of file
drop database if exists xiaofeng_db;
create database xiaofeng_db;
use xiaofeng_db;
create table t1(c1 int primary key);
create table t2(c1 int unique, c2 int, c3 varchar(10), c4 varchar(10), constraint test_for_table_constraints_check_name check(c3 = substr(c4, 1, 1)),
constraint test_for_table_constraints_fk_name_1 foreign key (c1) references t1(c1),
constraint test_for_table_constraints_fk_name_2 foreign key (c2) references t2(c1));
select * from information_schema.table_constraints where CONSTRAINT_SCHEMA = 'xiaofeng_db';
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
def xiaofeng_db PRIMARY xiaofeng_db t1 PRIMARY KEY
def xiaofeng_db c1 xiaofeng_db t2 UNIQUE
def xiaofeng_db test_for_table_constraints_check_name xiaofeng_db t2 CHECK
def xiaofeng_db test_for_table_constraints_fk_name_2 xiaofeng_db t2 FOREIGN KEY
def xiaofeng_db test_for_table_constraints_fk_name_1 xiaofeng_db t2 FOREIGN KEY
drop database xiaofeng_db;
drop table if exists t1,t2;
create table t1 (id int primary key, i2 int);
create table t2 (id int primary key, i2 int);
insert/*trace*/ into t1(id) values (75);
insert/*trace*/ into t1(id) values (79);
insert/*trace*/ into t1(id) values (78);
insert/*trace*/ into t1(id) values (77);
insert/*trace*/ into t1(id) values (104);
insert/*trace*/ into t1(id) values (103);
insert/*trace*/ into t1(id) values (102);
insert/*trace*/ into t1(id) values (101);
insert/*trace*/ into t1(id) values (105);
insert/*trace*/ into t1(id) values (106);
insert/*trace*/ into t1(id) values (107);
insert/*trace*/ into t2(id) values (107),(75),(1000);
select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id>200;
id id
select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id>200 and t1.id<200;
id id
select a.id , b.id from t1 a, t2 b where a.id = b.id and a.id>200 and a.id<200;
id id
select a.id, b.id from t1 a, t2 b where a.id = a.id and a.id>200 and a.id<200;
id id
drop table t1, t2;
drop table if exists t1,t2;
create table t1 (id int primary key, i2 int);
create table t2 (id int primary key, i2 int);
insert/*trace*/ into t1(id) values (75);
insert/*trace*/ into t1(id) values (79);
insert/*trace*/ into t1(id) values (78);
insert/*trace*/ into t1(id) values (77);
insert/*trace*/ into t1(id) values (104);
insert/*trace*/ into t1(id) values (103);
insert/*trace*/ into t1(id) values (102);
insert/*trace*/ into t1(id) values (101);
insert/*trace*/ into t1(id) values (105);
insert/*trace*/ into t1(id) values (106);
insert/*trace*/ into t1(id) values (107);
insert/*trace*/ into t2(id) values (107),(75),(1000);
select t1.id, t2.id from t1 join t2 on t2.id = t1.id and t1.id>200;
id id
select t1.id, t2.id from t1 join t2 on t2.id = t1.id and t1.id>200 and t1.id<200;
id id
select a.id , b.id from t1 a join t2 b on a.id = b.id and a.id>200 and a.id<200;
id id
select a.id, b.id from t1 a join t2 b on a.id = a.id and a.id>200 and a.id<200;
id id
drop table t1, t2;
drop table if exists t1,t2;
create table t1 (id int primary key, i2 int);
create table t2 (id int primary key, i2 int);
insert/*trace*/ into t1(id) values (75);
insert/*trace*/ into t1(id) values (79);
insert/*trace*/ into t1(id) values (78);
insert/*trace*/ into t1(id) values (77);
insert/*trace*/ into t1(id) values (104);
insert/*trace*/ into t1(id) values (103);
insert/*trace*/ into t1(id) values (102);
insert/*trace*/ into t1(id) values (101);
insert/*trace*/ into t1(id) values (105);
insert/*trace*/ into t1(id) values (106);
insert/*trace*/ into t1(id) values (107);
insert/*trace*/ into t2(id) values (107),(75),(1000);
select t1.id, t2.id from t1 join t2 on t2.id = t1.id where t1.id>200;
id id
select t1.id, t2.id from t1 join t2 on t2.id = t1.id where t1.id>200 and t1.id<200;
id id
select a.id , b.id from t1 a join t2 b on a.id = b.id where a.id>200 and a.id<200;
id id
select a.id , b.id from t1 a join t2 b on a.id = a.id where a.id>200 and a.id<200;
id id
drop table t1, t2;
drop database if exists union_sort_opt_db;
create database union_sort_opt_db;
use union_sort_opt_db;
create table t4(c1 int primary key, c2 int, c3 int);
insert into t4 values(10,12,3),(4,5,6),(2,13,4),(3,4,25),(7,18,9);
commit;
create index idx_t4_c2c3 on t4(c2,c3);
### 1, 基本测试 表有PK ###
select* from (select * from t4 union select * from t4) as x order by 1,2,3;
c1 c2 c3
2 13 4
3 4 25
4 5 6
7 18 9
10 12 3
select * from t4 union select * from t4;
c1 c2 c3
2 13 4
3 4 25
4 5 6
7 18 9
10 12 3
#1.2 使用索引c2c3也ok
select /*+ index(t4 idx_t4_c2c3) */ * from t4 union
select /*+ index(t4 idx_t4_c2c3) */ * from t4 order by 1,2,3;
c1 c2 c3
2 13 4
3 4 25
4 5 6
7 18 9
10 12 3
#1.3 顺序一致, 原本就支持
select /*+ index(t4 idx_t4_c2c3) */ c2,c3 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c2,c3 from t4 order by 2,1;
c2 c3
12 3
13 4
5 6
18 9
4 25
#1.4 顺序不一致, 修改后支持, 5
select /*+ index(t4 idx_t4_c2c3) */ c3,c2 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c3,c2 from t4 order by 1,2;
c3 c2
3 12
4 13
6 5
9 18
25 4
#1.5 完全一致
select /*+ index(t4 idx_t4_c2c3) */ c2,c3,c1 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c2,c3,c1 from t4 order by 1,2,3;
c2 c3 c1
4 25 3
5 6 4
12 3 10
13 4 2
18 9 7
#1.5.2 左匹配, 原本就支持
select /*+ index(t4 idx_t4_c2c3) */ c2 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c2 from t4 order by 1;
c2
4
5
12
13
18
#1.5.3 不能优化
select /*+ index(t4 idx_t4_c2c3) */ c3 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c3 from t4 order by 1;
c3
3
4
6
9
25
#1.5.4 不支持
select /*+ index(t4 idx_t4_c2c3) */ c1 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c1 from t4 order by 1;
c1
2
3
4
7
10
#1.6 两侧不匹配不能优化, 都加sort 10
select /*+ index(x idx_t4_c2c3) */ c3,c1,c2 from t4 x union
select /*+ index(y idx_t4_c2c3) */ c3,c2,c1 from t4 y order by 1,2,3;
c3 c1 c2
3 10 12
3 12 10
4 2 13
4 13 2
6 4 5
6 5 4
9 7 18
9 18 7
25 3 4
25 4 3
#1.7 两侧不匹配不能优化, 单侧加sort
select /*+ index(t4 idx_t4_c2c3) */ c2,c3,c1 from t4 union
select /*+ index(t4 idx_t4_c2c3) */ c3,c2,c1 from t4 order by 1,2,3;
c2 c3 c1
3 12 10
4 13 2
4 25 3
5 6 4
6 5 4
9 18 7
12 3 10
13 4 2
18 9 7
25 4 3
### 2, 不包含PK的简单测试, 单key索引 ###
create table t5(c int, c2 int, c3 int);
insert into t5 values(1,2,3),(2,3,4),(0,1,2),(3,4,5),(0,2,3),(2,4,5);
create index idx_t5_c2 on t5(c2);
#2.1 不能优化
select /*+ index(t5 idx_t5_c2) */ c2,c3 from t5 union
select /*+ index(t5 idx_t5_c2) */ c2,c3 from t5 order by 1,2;
c2 c3
1 2
2 3
3 4
4 5
#2.2 原本就可优化
select /*+ index(t5 idx_t5_c2) */ c2 from t5 union
select /*+ index(t5 idx_t5_c2) */ c2 from t5 order by 1;
c2
1
2
3
4
### 3, 无PK, 数据有重复, 结果正确性验证1
create table t6(c1 int, c2 int);
create index idx_t6_c1c2 on t6(c1,c2);
insert into t6 values(10,20),(10,30),(20,10),(20,5),(10,30),(40,5),(10,8),(10,20),(1,0),(0,1),(20,80),(10,5),(10,5),(30,20),(30,1),(30,5),
(10,20),(10,30),(20,10),(20,5),(10,30),(40,5),(10,8),(20,80),(10,5),(10,5),(30,20),(30,1),(1,0),(0,1),(0,0),(30,5);
#3.1 可以优化, 14 rows
select c1,c2 from t6 union select c1,c2 from t6 order by 1,2;
c1 c2
0 0
0 1
1 0
10 5
10 8
10 20
10 30
20 5
20 10
20 80
30 1
30 5
30 20
40 5
#3.2 可以优化, 14 rows
select c2,c1 from t6 union select c2,c1 from t6 order by 1,2;
c2 c1
0 0
0 1
1 0
1 30
5 10
5 20
5 30
5 40
8 10
10 20
20 10
20 30
30 10
80 20
#3.3 不能优化 23 rows
select c2,c1 from t6 union select c1,c2 from t6 order by 1,2;
c2 c1
0 0
0 1
1 0
1 30
5 10
5 20
5 30
5 40
8 10
10 5
10 8
10 20
10 30
20 5
20 10
20 30
20 80
30 1
30 5
30 10
30 20
40 5
80 20
#3.4 不能优化, 有计算列的情况, 23 rows, 14
select c2,c1 from t6 union select 0+c1,c2 from t6 order by 1,2;
c2 c1
0 0
0 1
1 0
1 30
5 10
5 20
5 30
5 40
8 10
10 5
10 8
10 20
10 30
20 5
20 10
20 30
20 80
30 1
30 5
30 10
30 20
40 5
80 20
select c1,c2,c1,c2 from t6 union select 0+c1,c2,c1,c2 from t6 order by 1,2,3,4;
c1 c2 c1 c2
0 0 0 0
0 1 0 1
1 0 1 0
10 5 10 5
10 8 10 8
10 20 10 20
10 30 10 30
20 5 20 5
20 10 20 10
20 80 20 80
30 1 30 1
30 5 30 5
30 20 30 20
40 5 40 5
#4 分区表的测试
create table t7(c1 varchar(10), c2 decimal(10,2), c3 int, c4 int) partition by hash(c4) partitions 5;
insert into t7 values('11', 1.2, 1, 7),('22', 2.3, 2, 6),('33', 3.4, 3, 2), ('44', 4.5, 4, 10), ('55', 5.6, 5, 6),
('12', 1.244, 4, 22),('22', 2.3, 3, 13),('3', 3.4, 2, 0), ('44', 4.5, 4, 1), ('56', 56, 1, 6),('44', 4.5, 4, 10);
create index idx_t7_c2c1 on t7(c2,c1,c3) local;
#4.1 可以优化, 完全匹配, 9 rows
select /*+ index(t7 idx_t7_c2c1) */ c2,c1,c3 from t7 union
select /*+ index(t7 idx_t7_c2c1) */ c2,c1,c3 from t7 where c2 < 10 order by 1,2,3;
c2 c1 c3
1.20 11 1
1.24 12 4
2.30 22 2
2.30 22 3
3.40 3 2
3.40 33 3
4.50 44 4
5.60 55 5
56.00 56 1
#4.2 可以优化, 后续有连接, 15 rows
select xx.c2,xx.c1 from
(select /*+ index(t7 idx_t7_c2c1) */ c2,c1,c3 from t7 union
select /*+ index(t7 idx_t7_c2c1) */ c2,c1,c3 from t7 where c2 < 10) xx,
t7 yy where xx.c2 = yy.c2 order by 1,2;
c2 c1
1.20 11
1.24 12
2.30 22
2.30 22
2.30 22
2.30 22
3.40 3
3.40 3
3.40 33
3.40 33
4.50 44
4.50 44
4.50 44
5.60 55
56.00 56
#4.3 可以优化, 9 rows
select /*+ index(t7 idx_t7_c2c1) */ c2,c1,c3 from t7 union
select /*+ index(t7 idx_t7_c2c1) */ c2,c1,c3 from t7 order by 1,2,3;
c2 c1 c3
1.20 11 1
1.24 12 4
2.30 22 2
2.30 22 3
3.40 3 2
3.40 33 3
4.50 44 4
5.60 55 5
56.00 56 1
select c1 from t7 union select c1 from t7 order by 1;
c1
11
12
22
3
33
44
55
56
select /*+ index(t7 idx_t7_c2c1) */ c1,c2,c3 from t7 union
select /*+ index(t7 idx_t7_c2c1) */ c1,c2,c3 from t7 order by 1,2,3;
c1 c2 c3
11 1.20 1
12 1.24 4
22 2.30 2
22 2.30 3
3 3.40 2
33 3.40 3
44 4.50 4
55 5.60 5
56 56.00 1
#4.4 索引KEY升降序的测试, 目前此功能并不支持, 实际都是ASC
drop index idx_t7_c2c1 on t7;
create index idx_t7_c3c2c1 on t7(c3 asc,c2 asc,c1 asc) local;
create table t72(c1 varchar(10), c2 decimal(10,2), c3 int);
insert into t72 values('11', 1.2, 1),('22', 2.3, 2),('33', 3.4, 3), ('44', 4.5, 4), ('55', 5.6, 5),
('12', 1.244, 4),('22', 2.3, 3),('3', 3.4, 2), ('44', 4.5, 4), ('56', 56, 1),('44', 4.5, 4);
create index idx_t72_c3c2c1 on t72(c3 asc,c2 asc,c1 asc);
#4.4.1 两个表上索引升降序一致, 不一一对应但两侧分支匹配, 可以优化, 8 rows
select /*+ index(t7 idx_t7_c3c2c1) */ c1,c2,c3 from t7 where c3 < 5 union
select /*+ index(t72 idx_t72_c3c2c1) */ c1,c2,c3 from t72 where c3 < 5 order by 1,2,3;
c1 c2 c3
11 1.20 1
12 1.24 4
22 2.30 2
22 2.30 3
3 3.40 2
33 3.40 3
44 4.50 4
56 56.00 1
#4.4.2 可以优化, 同上
select /*+ index(t7 idx_t7_c3c2c1) */ c3,c2,c1 from t7 where c3 < 5 union
select /*+ index(t72 idx_t72_c3c2c1) */ c3,c2,c1 from t72 where c3 < 5 order by 1,2,3;
c3 c2 c1
1 1.20 11
1 56.00 56
2 2.30 22
2 3.40 3
3 2.30 22
3 3.40 33
4 1.24 12
4 4.50 44
drop index idx_t72_c3c2c1 on t72;
create index idx_t72_c3c2c1 on t72(c3 asc,c2 asc,c1 asc);
#4.4.3 A,D不同, 但是实际存储一样, 所以也能优化, 8 rows
select /*+ index(t7 idx_t7_c3c2c1) */ c1,c2,c3 from t7 where c3 < 5 union
select /*+ index(t72 idx_t72_c3c2c1) */ c1,c2,c3 from t72 where c3 < 5 order by 1,2,3;
c1 c2 c3
11 1.20 1
12 1.24 4
22 2.30 2
22 2.30 3
3 3.40 2
33 3.40 3
44 4.50 4
56 56.00 1
#4.4.4 同上, 也能优化
select /*+ index(t7 idx_t7_c3c2c1) */ c3,c2,c1 from t7 where c3 < 5 union
select /*+ index(t72 idx_t72_c3c2c1) */ c3,c2,c1 from t72 where c3 < 5 order by 1,2,3;
c3 c2 c1
1 1.20 11
1 56.00 56
2 2.30 22
2 3.40 3
3 2.30 22
3 3.40 33
4 1.24 12
4 4.50 44
#5 结果正确性测试2
create table test1(c1 int, c2 int);
create table test2(d1 int, d2 int);
insert into test1 values(1,1),(1,2),(2,1),(2,2),(2,0),(1,3),(1,0),(3,0),(3,2),(3,1),(2,1);
insert into test2 values(1,1),(1,2),(2,1),(2,2),(2,0),(1,3),(1,0),(3,0),(3,2),(3,1),(2,1);
commit;
create index idx_test1_c1c2 on test1(c1 asc, c2 asc);
create index idx_test2_d1d2 on test2(d1 asc, d2 asc);
#5.1 最后加了排序, which can't be optimized...
select c2, c1 from test1 union select d2,d1 from test2 order by c2,c1;
c2 c1
0 1
0 2
0 3
1 1
1 2
1 3
2 1
2 2
2 3
3 1
#5.2 最后的排序可以被优化
select c2, c1 from test1 union select d2,d1 from test2 order by c1,c2;
c2 c1
0 1
1 1
2 1
3 1
0 2
1 2
2 2
0 3
1 3
2 3
#5.3 最后的排序由于是逆序不能被优化掉
select c2, c1 from test1 union select d2,d1 from test2 order by c1 desc,c2 desc;
c2 c1
2 3
1 3
0 3
2 2
1 2
0 2
3 1
2 1
1 1
0 1
#5.4 整数的查询项, 6 rows, 10, 4 rows
select 1, c1 from test1 union select 2,d1 from test2 order by 1,2;
1 c1
1 1
1 2
1 3
2 1
2 2
2 3
select 1, c2 from test1 union select d1,d2 from test2 order by 1,2;
1 c2
1 0
1 1
1 2
1 3
2 0
2 1
2 2
3 0
3 1
3 2
select mod(c1,2),mod(c2,2) from test1 union select mod(d1,2),mod(d2,2) from test2 order by 1,2;
mod(c1,2) mod(c2,2)
0 0
0 1
1 0
1 1
#6 from mysqltest union1, simply recreate
create table x1(c1 int, c2 char(10), c3 int);
create table x2(d1 int, d2 char(10), d3 int, index ix2(d2, d3));
insert into x1 values(1,'xx2',3),(2,'xxx3',4),(3,'aaa4',5);
insert into x2 values(11,'xx2',3),(2,'xx3',4),(3,'aaa4',5);
select c2, c3 from x1 union select /*+ index(x2 ix2) */ d2, d3 from x2 order by 1,2;
c2 c3
aaa4 5
xx2 3
xx3 4
xxx3 4
select c3, c2 from x1 union select /*+ index(x2 ix2) */ d3, d2 from x2 order by 1,2;
c3 c2
3 xx2
4 xx3
4 xxx3
5 aaa4
CREATE TABLE ts1 (c1 VARCHAR(10) NOT NULL, c2 INT NOT NULL);
CREATE TABLE ts2 (c1 VARCHAR(10) NOT NULL, c2 INT NOT NULL);
INSERT INTO ts1 (c1, c2) VALUES ('t1a', 1), ('t1a', 2), ('t1a', 3), ('t1b', 2), ('t1b', 1);
INSERT INTO ts2 (c1, c2) VALUES ('t2a', 1), ('t2a', 2), ('t2a', 3), ('t2b', 2), ('t2b', 1);
SELECT c1, c2 FROM (
SELECT c1, c2 FROM ts1
UNION
(SELECT c1, c2 FROM ts2 ORDER BY c2 DESC, c1 LIMIT 1)
) AS res order by 1,2;
c1 c2
t1a 1
t1a 2
t1a 3
t1b 1
t1b 2
t2a 3
DROP TABLE IF EXISTS T1, T2, T3;
CREATE TABLE T1 (PK INT PRIMARY KEY, C1 INT, C2 INT);
CREATE TABLE T2 (PK INT PRIMARY KEY, C1 INT, C2 INT);
CREATE TABLE T3 (PK INT PRIMARY KEY, C1 INT, C2 INT);
SELECT C1, C2, PK FROM T1 ORDER BY PK DESC LIMIT 1 UNION (SELECT C1, C2, PK FROM T2 UNION SELECT C1, C2 ,PK FROM T3);
C1 C2 PK
5 4 2
1 1 1
1 1 2
CREATE TABLE table2_bigint (
col_decimal_20_0_signed decimal(20,0) signed,
col_decimal_20_0_unsigned decimal(20,0) unsigned,
col_char_20 char(20),
col_decimal_20_0 decimal(20,0),
pk bigint,
col_bigint bigint,
col_timestamp_6 timestamp(6) NULL DEFAULT NULL,
col_bigint_unsigned bigint unsigned,
col_bigint_signed bigint signed,
primary key (pk));
CREATE TABLE table100_bigint (
col_bigint_unsigned bigint unsigned,
col_decimal_20_0_unsigned decimal(20,0) unsigned,
col_bigint_signed bigint signed,
col_bigint bigint,
pk bigint,
col_decimal_20_0_signed decimal(20,0) signed,
col_timestamp_6 timestamp(6) NULL DEFAULT NULL,
col_char_20 char(20),
col_decimal_20_0 decimal(20,0),
/*Indices*/
primary key (pk)) ;
SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk
FROM
(
(SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk
FROM table2_bigint
WHERE col_decimal_20_0_unsigned <> 99999
ORDER BY pk DESC , 6 DESC , pk
LIMIT 1,
5)
UNION DISTINCT SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk
FROM (
(SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk
FROM table100_bigint
WHERE col_decimal_20_0_signed = ROUND(SIGN(col_decimal_20_0))
ORDER BY col_bigint_signed , 6 , col_decimal_20_0 , pk DESC LIMIT 7)
UNION DISTINCT
(SELECT col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk
FROM table2_bigint
WHERE SUBSTR('g', 1, LEAST(58, 20)) <> INSERT('lgeswk', 99, 8, TRIM(SUBSTRING(CONVERT(TRIM(SUBSTR(TRIM(SUBSTR(SUBSTRING('nlge', 1, LEAST(58, 20)), 1, 2)
FROM SUBSTRING('', 1, LEAST(58, 20))), 1, LEAST(58, 20))), CHAR(50)), 1, LEAST(58, 20))))
ORDER BY 3 ,
col_bigint_unsigned ,
pk DESC)) TUT
ORDER BY col_bigint,
col_bigint_signed,
col_bigint_unsigned,
col_char_20,
col_decimal_20_0,
col_decimal_20_0_signed,
col_decimal_20_0_unsigned,
col_timestamp_6,
pk) TUT WHERE pk in (9727744 ,7826688 ,1657856 , 55039 , 50631)
ORDER BY col_bigint, col_bigint_signed, col_bigint_unsigned, col_char_20, col_decimal_20_0, col_decimal_20_0_signed, col_decimal_20_0_unsigned, col_timestamp_6, pk;
col_bigint col_bigint_signed col_bigint_unsigned col_char_20 col_decimal_20_0 col_decimal_20_0_signed col_decimal_20_0_unsigned col_timestamp_6 pk
NULL NULL NULL NULL NULL NULL 0 NULL 7826688
NULL NULL NULL NULL NULL NULL 1 NULL 1657856
NULL NULL NULL NULL NULL NULL 11753728 NULL 9727744
NULL NULL NULL 0 NULL NULL 999999999 NULL 50631
NULL NULL NULL nf NULL NULL 22222222 NULL 55039
drop database union_sort_opt_db;
set ob_query_timeout=1000000000;
--disable_warnings
drop database if exists px_test;
--enable_warnings
create database px_test;
use px_test;
# 场景:一个年级 6 个班,修了2门课,英语和数学
create table stu (
sid int,
name varchar(32),
cls int,
primary key (cls, sid)
) partition by hash(sid) partitions 6;
create table teacher (
tid int,
name varchar(32),
subject varchar(4),
primary key (tid)
) partition by hash(tid) partitions 8;
create table score (
sid int,
subject varchar(4),
score int,
primary key (sid, subject)
) partition by hash(sid) partitions 6;
insert into stu values
(11, 'a1', 1),
(12, 'b1', 1),
(13, 'c1', 1),
(21, 'a2', 2),
(22, 'b2', 2),
(31, 'a3', 3),
(41, 'a4', 4),
(42, 'b4', 4),
(51, 'a5', 5),
(52, 'b5', 5),
(61, 'a6', 6),
(62, 'b6', 6),
(63, 'c6', 6),
(64, 'd6', 6);
insert into teacher values
(1, 'Miss Zhang', 'EN'),
(2, 'Mr Wang', 'MA');
insert into score values
(11, 'EN', 60),
(12, 'EN', 70),
(13, 'EN', 80),
(21, 'EN', 58),
(22, 'EN', 90),
(31, 'EN', 80),
(41, 'EN', 80),
(42, 'EN', 90),
(51, 'EN', 89),
(52, 'EN', 99),
(61, 'EN', 100),
(62, 'EN', 90),
(63, 'EN', 99),
(64, 'EN', 87);
insert into score values
(11, 'MA', 60),
(12, 'MA', 70),
(13, 'MA', 80),
(21, 'MA', 58),
(22, 'MA', 90),
(31, 'MA', 80),
(41, 'MA', 80),
(42, 'MA', 90),
(51, 'MA', 89),
(52, 'MA', 99),
(61, 'MA', 100),
(62, 'MA', 90),
(63, 'MA', 99),
(64, 'MA', 87);
--disable_query_log
--disable_result_log
select * from stu;
select * from teacher;
select * from score;
--enable_query_log
--enable_result_log
connect conn_admin, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,oceanbase,$OBMYSQL_PORT;
connection conn_admin;
alter system flush plan cache global;
set ob_enable_plan_cache = 0;
select char_length(1234);
char_length(1234)
4
select char_length(1);
char_length(1)
1
select char_length(null);
char_length(null)
NULL
select char_length('');
char_length('')
0
select char_length('a');
char_length('a')
1
select char_length(' a ');
char_length(' a ')
3
select char_length(' a b');
char_length(' a b')
4
drop table if exists t1;
create table t1 (c1 int, c2 char(10), c3 varchar(10), c4 timestamp, c5 decimal);
insert into t1 values(1, 'a ', 'a ', '2010-01-01 11:11:11', 10.1);
select char_length(c1) from t1;
char_length(c1)
1
select char_length(c2) from t1;
char_length(c2)
1
select char_length(c3) from t1;
char_length(c3)
2
select char_length(c4) from t1;
char_length(c4)
19
select char_length(c5) from t1;
char_length(c5)
2
connect sys, $OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT;
connection default;
set @@ob_enable_plan_cache = 0;
select conv('a',16,2) from dual;
conv('a',16,2)
1010
select conv('6E',18,8) from dual;
conv('6E',18,8)
172
select conv(-17,10,-18) from dual;
conv(-17,10,-18)
-H
select conv(10+'10'+'10'+X'0a',10,10) from dual;
conv(10+'10'+'10'+X'0a',10,10)
40
select conv(null, 16, 2) from dual;
conv(null, 16, 2)
NULL
select conv('6E',null,8) from dual;
conv('6E',null,8)
NULL
select conv('6E',18, null) from dual;
conv('6E',18, null)
NULL
connection sys;
此差异已折叠。
connect obsys1,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT;
connection obsys1;
alter system set backup_log_archive_option='MANDATORY';
alter system set backup_log_archive_option='MANDATORY compression=disable';
alter system set backup_log_archive_option='MANDATORY compression =enable';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册