Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
8d332655
Commit
8d332655
authored
Jun 12, 2006
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into moonbone.local:/home/evgen/bk-trees/mysql-4.1-opt
parents
ce8b60b4
e815f93b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
86 additions
and
8 deletions
+86
-8
mysql-test/r/func_group.result
mysql-test/r/func_group.result
+24
-0
mysql-test/r/select.result
mysql-test/r/select.result
+14
-0
mysql-test/t/func_group.test
mysql-test/t/func_group.test
+19
-0
mysql-test/t/select.test
mysql-test/t/select.test
+14
-0
sql/opt_range.cc
sql/opt_range.cc
+1
-1
sql/opt_sum.cc
sql/opt_sum.cc
+10
-3
sql/sql_select.cc
sql/sql_select.cc
+3
-3
sql/sql_select.h
sql/sql_select.h
+1
-1
No files found.
mysql-test/r/func_group.result
View file @
8d332655
...
...
@@ -916,3 +916,27 @@ select count(*), min(7), max(7) from t2m, t1i;
count(*) min(7) max(7)
0 NULL NULL
drop table t1m, t1i, t2m, t2i;
CREATE TABLE t1 (id int PRIMARY KEY, b char(3), INDEX(b));
INSERT INTO t1 VALUES (1,'xx'), (2,'aa');
SELECT * FROM t1;
id b
1 xx
2 aa
SELECT MAX(b) FROM t1 WHERE b < 'ppppp';
MAX(b)
aa
SHOW WARNINGS;
Level Code Message
SELECT MAX(b) FROM t1 WHERE b < 'pp';
MAX(b)
aa
DROP TABLE t1;
CREATE TABLE t1 (id int PRIMARY KEY, b char(16), INDEX(b(4)));
INSERT INTO t1 VALUES (1, 'xxxxbbbb'), (2, 'xxxxaaaa');
SELECT MAX(b) FROM t1;
MAX(b)
xxxxbbbb
EXPLAIN SELECT MAX(b) FROM t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2
DROP TABLE t1;
mysql-test/r/select.result
View file @
8d332655
...
...
@@ -2714,3 +2714,17 @@ select * from t1 where f1 in (select f3 from t2 where (f3,f4)= (select f3,f4 fro
f1 f2
1 1
drop table t1,t2;
CREATE TABLE t1(a int, b int, c int, KEY b(b), KEY c(c));
insert into t1 values (1,0,0),(2,0,0);
CREATE TABLE t2 (a int, b varchar(2), c varchar(2), PRIMARY KEY(a));
insert into t2 values (1,'',''), (2,'','');
CREATE TABLE t3 (a int, b int, PRIMARY KEY (a,b), KEY a (a), KEY b (b));
insert into t3 values (1,1),(1,2);
explain select straight_join DISTINCT t2.a,t2.b, t1.c from t1, t3, t2
where (t1.c=t2.a or (t1.c=t3.a and t2.a=t3.b)) and t1.b=556476786 and
t2.b like '%%' order by t2.b limit 0,1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref b,c b 5 const 1 Using where; Using temporary; Using filesort
1 SIMPLE t3 index PRIMARY,a,b PRIMARY 8 NULL 2 Using index
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Range checked for each record (index map: 0x1)
DROP TABLE t1,t2,t3;
mysql-test/t/func_group.test
View file @
8d332655
...
...
@@ -598,4 +598,23 @@ select count(*), min(7), max(7) from t2m, t1i;
drop
table
t1m
,
t1i
,
t2m
,
t2i
;
#
# Bug #18206: min/max optimization cannot be applied to partial index
#
CREATE
TABLE
t1
(
id
int
PRIMARY
KEY
,
b
char
(
3
),
INDEX
(
b
));
INSERT
INTO
t1
VALUES
(
1
,
'xx'
),
(
2
,
'aa'
);
SELECT
*
FROM
t1
;
SELECT
MAX
(
b
)
FROM
t1
WHERE
b
<
'ppppp'
;
SHOW
WARNINGS
;
SELECT
MAX
(
b
)
FROM
t1
WHERE
b
<
'pp'
;
DROP
TABLE
t1
;
CREATE
TABLE
t1
(
id
int
PRIMARY
KEY
,
b
char
(
16
),
INDEX
(
b
(
4
)));
INSERT
INTO
t1
VALUES
(
1
,
'xxxxbbbb'
),
(
2
,
'xxxxaaaa'
);
SELECT
MAX
(
b
)
FROM
t1
;
EXPLAIN
SELECT
MAX
(
b
)
FROM
t1
;
DROP
TABLE
t1
;
# End of 4.1 tests
mysql-test/t/select.test
View file @
8d332655
...
...
@@ -2248,4 +2248,18 @@ insert into t2 values(1,1);
select
*
from
t1
where
f1
in
(
select
f3
from
t2
where
(
f3
,
f4
)
=
(
select
f3
,
f4
from
t2
));
drop
table
t1
,
t2
;
#
# Bug #4981: 4.x and 5.x produce non-optimal execution path, 3.23 regression test failure
#
CREATE
TABLE
t1
(
a
int
,
b
int
,
c
int
,
KEY
b
(
b
),
KEY
c
(
c
));
insert
into
t1
values
(
1
,
0
,
0
),(
2
,
0
,
0
);
CREATE
TABLE
t2
(
a
int
,
b
varchar
(
2
),
c
varchar
(
2
),
PRIMARY
KEY
(
a
));
insert
into
t2
values
(
1
,
''
,
''
),
(
2
,
''
,
''
);
CREATE
TABLE
t3
(
a
int
,
b
int
,
PRIMARY
KEY
(
a
,
b
),
KEY
a
(
a
),
KEY
b
(
b
));
insert
into
t3
values
(
1
,
1
),(
1
,
2
);
# must have "range checked" for t2
explain
select
straight_join
DISTINCT
t2
.
a
,
t2
.
b
,
t1
.
c
from
t1
,
t3
,
t2
where
(
t1
.
c
=
t2
.
a
or
(
t1
.
c
=
t3
.
a
and
t2
.
a
=
t3
.
b
))
and
t1
.
b
=
556476786
and
t2
.
b
like
'%%'
order
by
t2
.
b
limit
0
,
1
;
DROP
TABLE
t1
,
t2
,
t3
;
# End of 4.1 tests
sql/opt_range.cc
View file @
8d332655
...
...
@@ -64,7 +64,7 @@ class SEL_ARG :public Sql_alloc
uint8
min_flag
,
uint8
max_flag
,
uint8
maybe_flag
);
SEL_ARG
(
enum
Type
type_arg
)
:
elements
(
1
),
use_count
(
1
),
left
(
0
),
next_key_part
(
0
),
color
(
BLACK
),
type
(
type_arg
)
type
(
type_arg
)
,
min_flag
(
0
)
{}
inline
bool
is_same
(
SEL_ARG
*
arg
)
{
...
...
sql/opt_sum.cc
View file @
8d332655
...
...
@@ -582,7 +582,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
}
else
{
store_val_in_field
(
part
->
field
,
args
[
between
&&
max_fl
?
2
:
1
]);
store_val_in_field
(
part
->
field
,
args
[
between
&&
max_fl
?
2
:
1
],
CHECK_FIELD_IGNORE
);
if
(
part
->
null_bit
)
*
key_ptr
++=
(
byte
)
test
(
part
->
field
->
is_null
());
part
->
field
->
get_key_image
((
char
*
)
key_ptr
,
part
->
length
,
...
...
@@ -638,6 +639,8 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
field BETWEEN const1 AND const2
3. all references to the columns from the same table as column field
occur only in conjucts mentioned above.
4. each of k first components the index is not partial, i.e. is not
defined on a fixed length proper prefix of the field.
If such an index exists the function through the ref parameter
returns the key value to find max/min for the field using the index,
...
...
@@ -682,6 +685,10 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
if
(
!
(
table
->
file
->
index_flags
(
idx
,
jdx
,
0
)
&
HA_READ_ORDER
))
return
0
;
/* Check whether the index component is partial */
if
(
part
->
length
<
table
->
field
[
part
->
fieldnr
-
1
]
->
pack_length
())
break
;
if
(
field
->
eq
(
part
->
field
))
{
ref
->
key
=
idx
;
...
...
sql/sql_select.cc
View file @
8d332655
...
...
@@ -3434,7 +3434,7 @@ get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables,
*/
bool
store_val_in_field
(
Field
*
field
,
Item
*
item
)
store_val_in_field
(
Field
*
field
,
Item
*
item
,
enum_check_fields
check_flag
)
{
bool
error
;
THD
*
thd
=
current_thd
;
...
...
@@ -3445,7 +3445,7 @@ store_val_in_field(Field *field,Item *item)
with select_insert, which make count_cuted_fields= 1
*/
enum_check_fields
old_count_cuted_fields
=
thd
->
count_cuted_fields
;
thd
->
count_cuted_fields
=
CHECK_FIELD_WARN
;
thd
->
count_cuted_fields
=
check_flag
;
error
=
item
->
save_in_field
(
field
,
1
);
thd
->
count_cuted_fields
=
old_count_cuted_fields
;
return
error
||
cuted_fields
!=
thd
->
cuted_fields
;
...
...
@@ -7097,7 +7097,7 @@ static bool test_if_ref(Item_field *left_item,Item *right_item)
field
->
real_type
()
!=
FIELD_TYPE_VAR_STRING
&&
(
field
->
type
()
!=
FIELD_TYPE_FLOAT
||
field
->
decimals
()
==
0
))
{
return
!
store_val_in_field
(
field
,
right_item
);
return
!
store_val_in_field
(
field
,
right_item
,
CHECK_FIELD_WARN
);
}
}
}
...
...
sql/sql_select.h
View file @
8d332655
...
...
@@ -335,7 +335,7 @@ extern const char *join_type_str[];
void
TEST_join
(
JOIN
*
join
);
/* Extern functions in sql_select.cc */
bool
store_val_in_field
(
Field
*
field
,
Item
*
val
);
bool
store_val_in_field
(
Field
*
field
,
Item
*
val
,
enum_check_fields
check_flag
);
TABLE
*
create_tmp_table
(
THD
*
thd
,
TMP_TABLE_PARAM
*
param
,
List
<
Item
>
&
fields
,
ORDER
*
group
,
bool
distinct
,
bool
save_sum_fields
,
ulong
select_options
,
ha_rows
rows_limit
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment