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
90a69255
Commit
90a69255
authored
Feb 19, 2007
by
gkodinov/kgeorge@rakia.gmz
Browse files
Options
Browse Files
Download
Plain Diff
Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into rakia.gmz:/home/kgeorge/mysql/autopush/B19717-5.0-opt
parents
664f24d5
53d93fc3
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
295 additions
and
16 deletions
+295
-16
mysql-test/r/bdb.result
mysql-test/r/bdb.result
+1
-1
mysql-test/r/endspace.result
mysql-test/r/endspace.result
+1
-1
mysql-test/r/innodb.result
mysql-test/r/innodb.result
+1
-1
mysql-test/r/insert_select.result
mysql-test/r/insert_select.result
+13
-0
mysql-test/r/myisam.result
mysql-test/r/myisam.result
+1
-1
mysql-test/r/select.result
mysql-test/r/select.result
+148
-0
mysql-test/r/type_blob.result
mysql-test/r/type_blob.result
+2
-2
mysql-test/t/insert_select.test
mysql-test/t/insert_select.test
+15
-0
mysql-test/t/select.test
mysql-test/t/select.test
+46
-0
sql/item.cc
sql/item.cc
+45
-0
sql/item.h
sql/item.h
+2
-0
sql/sql_insert.cc
sql/sql_insert.cc
+16
-0
sql/sql_select.cc
sql/sql_select.cc
+4
-10
No files found.
mysql-test/r/bdb.result
View file @
90a69255
...
...
@@ -1442,7 +1442,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 r
ange t t 13 NULL
# Using where
1 SIMPLE t1 r
ef t t 13 const
# Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where
...
...
mysql-test/r/endspace.result
View file @
90a69255
...
...
@@ -98,7 +98,7 @@ concat('|', text1, '|')
|teststring |
explain select concat('|', text1, '|') from t1 where text1='teststring ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 r
ange key1 key1 22 NULL
2 Using where
1 SIMPLE t1 r
ef key1 key1 22 const
2 Using where
select concat('|', text1, '|') from t1 where text1 like 'teststring_%';
concat('|', text1, '|')
|teststring |
...
...
mysql-test/r/innodb.result
View file @
90a69255
...
...
@@ -1991,7 +1991,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where; Using index
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 r
ange t t 13 NULL
# Using where
1 SIMPLE t1 r
ef t t 13 const
# Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where; Using index
...
...
mysql-test/r/insert_select.result
View file @
90a69255
...
...
@@ -731,3 +731,16 @@ select @@identity;
@@identity
0
drop table t1;
CREATE TABLE t1 (f1 INT, f2 INT );
CREATE TABLE t2 (f1 INT PRIMARY KEY, f2 INT);
INSERT INTO t1 VALUES (1,1),(2,2),(10,10);
INSERT INTO t2 (f1, f2) SELECT f1, f2 FROM t1;
INSERT INTO t2 (f1, f2)
SELECT f1, f1 FROM t2 src WHERE f1 < 2
ON DUPLICATE KEY UPDATE f1 = 100 + src.f1;
SELECT * FROM t2;
f1 f2
101 1
2 2
10 10
DROP TABLE t1, t2;
mysql-test/r/myisam.result
View file @
90a69255
...
...
@@ -1071,7 +1071,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref c c 11 const # Using where; Using index
explain select count(*) from t1 where t='a ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 r
ange t t 13 NULL
# Using where
1 SIMPLE t1 r
ef t t 13 const
# Using where
explain select count(*) from t1 where v like 'a%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range v v 13 NULL # Using where; Using index
...
...
mysql-test/r/select.result
View file @
90a69255
...
...
@@ -3785,4 +3785,152 @@ case when 1 then cast(1111111111111111111 as unsigned) else 1 end c,
coalesce(cast(1111111111111111111 as unsigned), 1) co;
i c co
1111111111111111111 1111111111111111111 1111111111111111111
CREATE TABLE t1 (name varchar(255));
CREATE TABLE t2 (name varchar(255), n int, KEY (name(3)));
INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa');
INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3);
INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);
INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);
SELECT * FROM t2;
name n
bb 1
aa 2
cc 3
cc 4
cc 5
bb 6
cc 7
SELECT * FROM t2 ORDER BY name;
name n
aa 2
bb 1
bb 6
cc 4
cc 3
cc 5
cc 7
SELECT name, LENGTH(name), n FROM t2 ORDER BY name;
name LENGTH(name) n
aa 2 2
bb 2 1
bb 3 6
cc 4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref name name 6 const 3 Using where
SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
name LENGTH(name) n
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
name LENGTH(name) n
cc 5 3
cc 4 4
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
name LENGTH(name) n
cc 4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref name name 6 test.t1.name 2
SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
name name n
ccc NULL NULL
bb bb 1
bb bb 6
cc cc 3
cc cc 5
cc cc 7
aa aa 2
aa aa 2
DROP TABLE t1,t2;
CREATE TABLE t1 (name text);
CREATE TABLE t2 (name text, n int, KEY (name(3)));
INSERT INTO t1 VALUES ('ccc'), ('bb'), ('cc '), ('aa '), ('aa');
INSERT INTO t2 VALUES ('bb',1), ('aa',2), ('cc ',3);
INSERT INTO t2 VALUES (concat('cc ', 0x06), 4);
INSERT INTO t2 VALUES ('cc',5), ('bb ',6), ('cc ',7);
SELECT * FROM t2;
name n
bb 1
aa 2
cc 3
cc 4
cc 5
bb 6
cc 7
SELECT * FROM t2 ORDER BY name;
name n
aa 2
bb 1
bb 6
cc 4
cc 3
cc 5
cc 7
SELECT name, LENGTH(name), n FROM t2 ORDER BY name;
name LENGTH(name) n
aa 2 2
bb 2 1
bb 3 6
cc 4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref name name 6 const 3 Using where
SELECT name, LENGTH(name), n FROM t2 WHERE name='cc ';
name LENGTH(name) n
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%';
name LENGTH(name) n
cc 5 3
cc 4 4
cc 2 5
cc 3 7
EXPLAIN SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range name name 6 NULL 3 Using where; Using filesort
SELECT name , LENGTH(name), n FROM t2 WHERE name LIKE 'cc%' ORDER BY name;
name LENGTH(name) n
cc 4 4
cc 5 3
cc 2 5
cc 3 7
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref name name 6 test.t1.name 2
SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
name name n
ccc NULL NULL
bb bb 1
bb bb 6
cc cc 3
cc cc 5
cc cc 7
aa aa 2
aa aa 2
DROP TABLE t1,t2;
End of 5.0 tests
mysql-test/r/type_blob.result
View file @
90a69255
...
...
@@ -610,12 +610,12 @@ create table t1 (id integer primary key auto_increment, txt text, index txt_inde
insert into t1 (txt) values ('Chevy'), ('Chevy '), (NULL);
select * from t1 where txt='Chevy' or txt is NULL;
id txt
3 NULL
1 Chevy
2 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 r
ange txt_index txt_index 23 NULL
2 Using where
1 SIMPLE t1 r
ef_or_null txt_index txt_index 23 const
2 Using where
select * from t1 where txt='Chevy ';
id txt
1 Chevy
...
...
mysql-test/t/insert_select.test
View file @
90a69255
...
...
@@ -292,3 +292,18 @@ select @@identity;
insert
ignore
t1
(
f2
)
select
1
;
select
@@
identity
;
drop
table
t1
;
#
# Bug#16630: wrong result, when INSERT t1 SELECT ... FROM t1 ON DUPLICATE
#
CREATE
TABLE
t1
(
f1
INT
,
f2
INT
);
CREATE
TABLE
t2
(
f1
INT
PRIMARY
KEY
,
f2
INT
);
INSERT
INTO
t1
VALUES
(
1
,
1
),(
2
,
2
),(
10
,
10
);
INSERT
INTO
t2
(
f1
,
f2
)
SELECT
f1
,
f2
FROM
t1
;
INSERT
INTO
t2
(
f1
,
f2
)
SELECT
f1
,
f1
FROM
t2
src
WHERE
f1
<
2
ON
DUPLICATE
KEY
UPDATE
f1
=
100
+
src
.
f1
;
SELECT
*
FROM
t2
;
DROP
TABLE
t1
,
t2
;
mysql-test/t/select.test
View file @
90a69255
...
...
@@ -3253,4 +3253,50 @@ select
case
when
1
then
cast
(
1111111111111111111
as
unsigned
)
else
1
end
c
,
coalesce
(
cast
(
1111111111111111111
as
unsigned
),
1
)
co
;
#
# Bug #22971: indexes on text columns are ignored for ref accesses
#
CREATE
TABLE
t1
(
name
varchar
(
255
));
CREATE
TABLE
t2
(
name
varchar
(
255
),
n
int
,
KEY
(
name
(
3
)));
INSERT
INTO
t1
VALUES
(
'ccc'
),
(
'bb'
),
(
'cc '
),
(
'aa '
),
(
'aa'
);
INSERT
INTO
t2
VALUES
(
'bb'
,
1
),
(
'aa'
,
2
),
(
'cc '
,
3
);
INSERT
INTO
t2
VALUES
(
concat
(
'cc '
,
0x06
),
4
);
INSERT
INTO
t2
VALUES
(
'cc'
,
5
),
(
'bb '
,
6
),
(
'cc '
,
7
);
SELECT
*
FROM
t2
;
SELECT
*
FROM
t2
ORDER
BY
name
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
ORDER
BY
name
;
EXPLAIN
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
=
'cc '
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
=
'cc '
;
EXPLAIN
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
;
EXPLAIN
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
ORDER
BY
name
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
ORDER
BY
name
;
EXPLAIN
SELECT
*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
name
=
t2
.
name
;
SELECT
*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
name
=
t2
.
name
;
DROP
TABLE
t1
,
t2
;
CREATE
TABLE
t1
(
name
text
);
CREATE
TABLE
t2
(
name
text
,
n
int
,
KEY
(
name
(
3
)));
INSERT
INTO
t1
VALUES
(
'ccc'
),
(
'bb'
),
(
'cc '
),
(
'aa '
),
(
'aa'
);
INSERT
INTO
t2
VALUES
(
'bb'
,
1
),
(
'aa'
,
2
),
(
'cc '
,
3
);
INSERT
INTO
t2
VALUES
(
concat
(
'cc '
,
0x06
),
4
);
INSERT
INTO
t2
VALUES
(
'cc'
,
5
),
(
'bb '
,
6
),
(
'cc '
,
7
);
SELECT
*
FROM
t2
;
SELECT
*
FROM
t2
ORDER
BY
name
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
ORDER
BY
name
;
EXPLAIN
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
=
'cc '
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
=
'cc '
;
EXPLAIN
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
;
EXPLAIN
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
ORDER
BY
name
;
SELECT
name
,
LENGTH
(
name
),
n
FROM
t2
WHERE
name
LIKE
'cc%'
ORDER
BY
name
;
EXPLAIN
SELECT
*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
name
=
t2
.
name
;
SELECT
*
FROM
t1
LEFT
JOIN
t2
ON
t1
.
name
=
t2
.
name
;
DROP
TABLE
t1
,
t2
;
--
echo
End
of
5.0
tests
sql/item.cc
View file @
90a69255
...
...
@@ -4809,6 +4809,51 @@ void Item_field::update_null_value()
}
/*
Add the field to the select list and substitute it for the reference to
the field.
SYNOPSIS
Item_field::update_value_transformer()
select_arg current select
DESCRIPTION
If the field doesn't belong to the table being inserted into then it is
added to the select list, pointer to it is stored in the ref_pointer_array
of the select and the field itself is substituted for the Item_ref object.
This is done in order to get correct values from update fields that
belongs to the SELECT part in the INSERT .. SELECT .. ON DUPLICATE KEY
UPDATE statement.
RETURN
0 if error occured
ref if all conditions are met
this field otherwise
*/
Item
*
Item_field
::
update_value_transformer
(
byte
*
select_arg
)
{
SELECT_LEX
*
select
=
(
SELECT_LEX
*
)
select_arg
;
DBUG_ASSERT
(
fixed
);
if
(
field
->
table
!=
select
->
context
.
table_list
->
table
&&
type
()
!=
Item
::
TRIGGER_FIELD_ITEM
)
{
List
<
Item
>
*
all_fields
=
&
select
->
join
->
all_fields
;
Item
**
ref_pointer_array
=
select
->
ref_pointer_array
;
int
el
=
all_fields
->
elements
;
Item_ref
*
ref
;
ref_pointer_array
[
el
]
=
(
Item
*
)
this
;
all_fields
->
push_front
((
Item
*
)
this
);
ref
=
new
Item_ref
(
&
select
->
context
,
ref_pointer_array
+
el
,
table_name
,
field_name
);
return
ref
;
}
return
this
;
}
Item_ref
::
Item_ref
(
Name_resolution_context
*
context_arg
,
Item
**
item
,
const
char
*
table_name_arg
,
const
char
*
field_name_arg
)
...
...
sql/item.h
View file @
90a69255
...
...
@@ -817,6 +817,7 @@ class Item {
virtual
Item_field
*
filed_for_view_update
()
{
return
0
;
}
virtual
Item
*
neg_transformer
(
THD
*
thd
)
{
return
NULL
;
}
virtual
Item
*
update_value_transformer
(
byte
*
select_arg
)
{
return
this
;
}
virtual
Item
*
safe_charset_converter
(
CHARSET_INFO
*
tocs
);
void
delete_self
()
{
...
...
@@ -1295,6 +1296,7 @@ class Item_field :public Item_ident
Item_field
*
filed_for_view_update
()
{
return
this
;
}
Item
*
safe_charset_converter
(
CHARSET_INFO
*
tocs
);
int
fix_outer_field
(
THD
*
thd
,
Field
**
field
,
Item
**
reference
);
virtual
Item
*
update_value_transformer
(
byte
*
select_arg
);
friend
class
Item_default_value
;
friend
class
Item_insert_value
;
friend
class
st_select_lex_unit
;
...
...
sql/sql_insert.cc
View file @
90a69255
...
...
@@ -2388,7 +2388,23 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
next_name_resolution_table
=
ctx_state
.
save_next_local
;
}
res
=
res
||
setup_fields
(
thd
,
0
,
*
info
.
update_values
,
1
,
0
,
0
);
if
(
!
res
)
{
/*
Traverse the update values list and substitute fields from the
select for references (Item_ref objects) to them. This is done in
order to get correct values from those fields when the select
employs a temporary table.
*/
List_iterator
<
Item
>
li
(
*
info
.
update_values
);
Item
*
item
;
while
((
item
=
li
++
))
{
item
->
transform
(
&
Item
::
update_value_transformer
,
(
byte
*
)
lex
->
current_select
);
}
}
/* Restore the current context. */
ctx_state
.
restore_state
(
context
,
table_list
);
}
...
...
sql/sql_select.cc
View file @
90a69255
...
...
@@ -482,6 +482,9 @@ JOIN::prepare(Item ***rref_pointer_array,
}
}
if
(
!
procedure
&&
result
&&
result
->
prepare
(
fields_list
,
unit_arg
))
goto
err
;
/* purecov: inspected */
/* Init join struct */
count_field_types
(
&
tmp_table_param
,
all_fields
,
0
);
ref_pointer_array_size
=
all_fields
.
elements
*
sizeof
(
Item
*
);
...
...
@@ -495,9 +498,6 @@ JOIN::prepare(Item ***rref_pointer_array,
goto
err
;
}
#endif
if
(
!
procedure
&&
result
&&
result
->
prepare
(
fields_list
,
unit_arg
))
goto
err
;
/* purecov: inspected */
if
(
select_lex
->
olap
==
ROLLUP_TYPE
&&
rollup_init
())
goto
err
;
if
(
alloc_func_list
())
...
...
@@ -2854,15 +2854,9 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Item_func *cond,
/*
We can't use indexes if the effective collation
of the operation differ from the field collation.
We also cannot use index on a text column, as the column may
contain 'x' 'x\t' 'x ' and 'read_next_same' will stop after
'x' when searching for WHERE col='x '
*/
if
(
field
->
cmp_type
()
==
STRING_RESULT
&&
(((
Field_str
*
)
field
)
->
charset
()
!=
cond
->
compare_collation
()
||
((
*
value
)
->
type
()
!=
Item
::
NULL_ITEM
&&
(
field
->
flags
&
BLOB_FLAG
)
&&
!
field
->
binary
())))
((
Field_str
*
)
field
)
->
charset
()
!=
cond
->
compare_collation
())
return
;
}
}
...
...
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