Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(tianmu):improve the code quality and refactoring derived table optimize for tianmu(#1277, #1276, #1258) #1281

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions mysql-test/suite/tianmu/r/issue1258.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
DROP DATABASE IF EXISTS issue1258_test;
CREATE DATABASE issue1258_test;
USE issue1258_test;
set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Warnings:
Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
CREATE TABLE `t_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(10) NOT NULL,
`last_name` varchar(10) NOT NULL,
`sex` varchar(5) NOT NULL,
`score` int(11) NOT NULL,
`copy_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
insert into t_test values(1,"syz1","stonedb1","nan",99,21);
insert into t_test values(2,"syz2","stonedb2","nan",99,22);
insert into t_test values(3,"syz3","stonedb3","nan",99,23);
insert into t_test values(4,"syz4","stonedb4","nan",99,24);
insert into t_test values(5,"syz5","stonedb5","nan",99,25);
SELECT
bb.first_name,
bb.last_name
FROM
(
SELECT
count(a.first_name ) AS first_name,
SUBSTR( a.last_name, 1, 10 ) AS last_name
FROM
t_test a,
t_test b
WHERE
a.id = b.id
GROUP BY
SUBSTR( a.last_name, 1, 10 )
) bb;
first_name last_name
1 stonedb1
1 stonedb2
1 stonedb3
1 stonedb4
1 stonedb5
DROP DATABASE issue1258_test;
46 changes: 46 additions & 0 deletions mysql-test/suite/tianmu/t/issue1258.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
--source include/have_tianmu.inc

--disable_warnings
DROP DATABASE IF EXISTS issue1258_test;
--enable_warnings

CREATE DATABASE issue1258_test;

USE issue1258_test;

set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

CREATE TABLE `t_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(10) NOT NULL,
`last_name` varchar(10) NOT NULL,
`sex` varchar(5) NOT NULL,
`score` int(11) NOT NULL,
`copy_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;

insert into t_test values(1,"syz1","stonedb1","nan",99,21);
insert into t_test values(2,"syz2","stonedb2","nan",99,22);
insert into t_test values(3,"syz3","stonedb3","nan",99,23);
insert into t_test values(4,"syz4","stonedb4","nan",99,24);
insert into t_test values(5,"syz5","stonedb5","nan",99,25);

SELECT
bb.first_name,
bb.last_name
FROM
(
SELECT
count(a.first_name ) AS first_name,
SUBSTR( a.last_name, 1, 10 ) AS last_name
FROM
t_test a,
t_test b
WHERE
a.id = b.id
GROUP BY
SUBSTR( a.last_name, 1, 10 )
) bb;

DROP DATABASE issue1258_test;
1 change: 0 additions & 1 deletion sql/sql_derived.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ bool TABLE_LIST::optimize_derived(THD *thd)
DBUG_RETURN(false);
}


/**
Create result table for a materialized derived table/view.
Expand Down
5 changes: 3 additions & 2 deletions sql/sql_lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,10 @@ class st_select_lex_unit: public Sql_alloc
bool prepare(THD *thd, Query_result *result, ulonglong added_options,
ulonglong removed_options);
bool optimize(THD *thd);
//TIANMU UPGRADE END

int optimize_for_tianmu();
int optimize_after_tianmu();
//END

bool execute(THD *thd);
bool explain(THD *ethd);
bool cleanup(bool full);
Expand Down Expand Up @@ -1416,6 +1416,7 @@ class st_select_lex: public Sql_alloc
bool setup_conds(THD *thd);
bool prepare(THD *thd);
bool optimize(THD *thd);
bool optimize_select_for_tianmu(THD *thd);
void reset_nj_counters(List<TABLE_LIST> *join_list= NULL);
bool check_only_full_group_by(THD *thd);

Expand Down
Loading