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
ae6842fd
Commit
ae6842fd
authored
Jul 25, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rurik.mysql.com:/home/igor/mysql-5.0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
parents
c15cab96
1c3f8cc2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
30 deletions
+79
-30
mysql-test/r/view.result
mysql-test/r/view.result
+23
-0
mysql-test/t/view.test
mysql-test/t/view.test
+25
-1
sql/item.h
sql/item.h
+5
-2
sql/item_buff.cc
sql/item_buff.cc
+3
-3
sql/sql_select.cc
sql/sql_select.cc
+23
-24
No files found.
mysql-test/r/view.result
View file @
ae6842fd
...
@@ -2024,3 +2024,26 @@ f1 sb
...
@@ -2024,3 +2024,26 @@ f1 sb
2005-01-01 12:00:00 2005-01-01 10:58:59
2005-01-01 12:00:00 2005-01-01 10:58:59
drop view v1;
drop view v1;
drop table t1;
drop table t1;
CREATE TABLE t1 (
aid int PRIMARY KEY,
fn varchar(20) NOT NULL,
ln varchar(20) NOT NULL
);
CREATE TABLE t2 (
aid int NOT NULL,
pid int NOT NULL
);
INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d');
INSERT INTO t2 values (1,1), (2,1), (2,2);
CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;
SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2
WHERE t1.aid = t2.aid GROUP BY pid;
pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1)
1 a b,c d
2 c d
SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;
pid GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1)
1 a b,c d
2 c d
DROP VIEW v1;
DROP TABLE t1,t2;
mysql-test/t/view.test
View file @
ae6842fd
...
@@ -1862,4 +1862,28 @@ insert into t1 values('2005.01.01 12:0:0');
...
@@ -1862,4 +1862,28 @@ insert into t1 values('2005.01.01 12:0:0');
create
view
v1
as
select
f1
,
subtime
(
f1
,
'1:1:1'
)
as
sb
from
t1
;
create
view
v1
as
select
f1
,
subtime
(
f1
,
'1:1:1'
)
as
sb
from
t1
;
select
*
from
v1
;
select
*
from
v1
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
;
drop
table
t1
;
#
# Test for bug #11412: query over a multitable view with GROUP_CONCAT
#
CREATE
TABLE
t1
(
aid
int
PRIMARY
KEY
,
fn
varchar
(
20
)
NOT
NULL
,
ln
varchar
(
20
)
NOT
NULL
);
CREATE
TABLE
t2
(
aid
int
NOT
NULL
,
pid
int
NOT
NULL
);
INSERT
INTO
t1
VALUES
(
1
,
'a'
,
'b'
),
(
2
,
'c'
,
'd'
);
INSERT
INTO
t2
values
(
1
,
1
),
(
2
,
1
),
(
2
,
2
);
CREATE
VIEW
v1
AS
SELECT
t1
.*
,
t2
.
pid
FROM
t1
,
t2
WHERE
t1
.
aid
=
t2
.
aid
;
SELECT
pid
,
GROUP_CONCAT
(
CONCAT
(
fn
,
' '
,
ln
)
ORDER
BY
1
)
FROM
t1
,
t2
WHERE
t1
.
aid
=
t2
.
aid
GROUP
BY
pid
;
SELECT
pid
,
GROUP_CONCAT
(
CONCAT
(
fn
,
' '
,
ln
)
ORDER
BY
1
)
FROM
v1
GROUP
BY
pid
;
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
;
sql/item.h
View file @
ae6842fd
...
@@ -1464,7 +1464,10 @@ class Item_ref :public Item_ident
...
@@ -1464,7 +1464,10 @@ class Item_ref :public Item_ident
void
save_org_in_field
(
Field
*
field
)
{
(
*
ref
)
->
save_org_in_field
(
field
);
}
void
save_org_in_field
(
Field
*
field
)
{
(
*
ref
)
->
save_org_in_field
(
field
);
}
enum
Item_result
result_type
()
const
{
return
(
*
ref
)
->
result_type
();
}
enum
Item_result
result_type
()
const
{
return
(
*
ref
)
->
result_type
();
}
enum_field_types
field_type
()
const
{
return
(
*
ref
)
->
field_type
();
}
enum_field_types
field_type
()
const
{
return
(
*
ref
)
->
field_type
();
}
Field
*
get_tmp_table_field
()
{
return
result_field
;
}
Field
*
get_tmp_table_field
()
{
return
result_field
?
result_field
:
(
*
ref
)
->
get_tmp_table_field
();
}
Item
*
get_tmp_table_item
(
THD
*
thd
)
{
return
(
*
ref
)
->
get_tmp_table_item
(
thd
);
}
table_map
used_tables
()
const
table_map
used_tables
()
const
{
{
return
depended_from
?
OUTER_REF_TABLE_BIT
:
(
*
ref
)
->
used_tables
();
return
depended_from
?
OUTER_REF_TABLE_BIT
:
(
*
ref
)
->
used_tables
();
...
@@ -1702,7 +1705,7 @@ class Cached_item_field :public Cached_item
...
@@ -1702,7 +1705,7 @@ class Cached_item_field :public Cached_item
public:
public:
Cached_item_field
(
Item_field
*
item
)
Cached_item_field
(
Item_field
*
item
)
{
{
field
=
item
->
field
;
field
=
item
->
field
;
buff
=
(
char
*
)
sql_calloc
(
length
=
field
->
pack_length
());
buff
=
(
char
*
)
sql_calloc
(
length
=
field
->
pack_length
());
}
}
bool
cmp
(
void
);
bool
cmp
(
void
);
...
...
sql/item_buff.cc
View file @
ae6842fd
...
@@ -25,9 +25,9 @@
...
@@ -25,9 +25,9 @@
Cached_item
*
new_Cached_item
(
THD
*
thd
,
Item
*
item
)
Cached_item
*
new_Cached_item
(
THD
*
thd
,
Item
*
item
)
{
{
if
(
item
->
type
()
==
Item
::
FIELD_ITEM
&&
if
(
item
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
&&
!
(((
Item_field
*
)
item
)
->
field
->
flags
&
BLOB_FLAG
))
!
(((
Item_field
*
)
(
item
->
real_item
())
)
->
field
->
flags
&
BLOB_FLAG
))
return
new
Cached_item_field
((
Item_field
*
)
item
);
return
new
Cached_item_field
((
Item_field
*
)
(
item
->
real_item
())
);
switch
(
item
->
result_type
())
{
switch
(
item
->
result_type
())
{
case
STRING_RESULT
:
case
STRING_RESULT
:
return
new
Cached_item_str
(
thd
,
(
Item_field
*
)
item
);
return
new
Cached_item_str
(
thd
,
(
Item_field
*
)
item
);
...
...
sql/sql_select.cc
View file @
ae6842fd
...
@@ -8026,6 +8026,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
...
@@ -8026,6 +8026,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
bool
table_cant_handle_bit_fields
,
bool
table_cant_handle_bit_fields
,
uint
convert_blob_length
)
uint
convert_blob_length
)
{
{
Item
*
org_item
=
item
;
if
(
item
->
real_item
()
->
type
()
==
Item
::
FIELD_ITEM
)
{
item
=
item
->
real_item
();
type
=
item
->
type
();
}
switch
(
type
)
{
switch
(
type
)
{
case
Item
:
:
SUM_FUNC_ITEM
:
case
Item
:
:
SUM_FUNC_ITEM
:
{
{
...
@@ -8038,30 +8044,22 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
...
@@ -8038,30 +8044,22 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case
Item
:
:
FIELD_ITEM
:
case
Item
:
:
FIELD_ITEM
:
case
Item
:
:
DEFAULT_VALUE_ITEM
:
case
Item
:
:
DEFAULT_VALUE_ITEM
:
{
{
Item_field
*
field
=
(
Item_field
*
)
item
;
if
(
org_item
->
type
()
!=
Item
::
REF_ITEM
||
if
(
table_cant_handle_bit_fields
&&
field
->
field
->
type
()
==
FIELD_TYPE_BIT
)
!
((
Item_ref
*
)
org_item
)
->
depended_from
)
return
create_tmp_field_from_item
(
thd
,
item
,
table
,
copy_func
,
modify_item
,
convert_blob_length
);
return
create_tmp_field_from_field
(
thd
,
(
*
from_field
=
field
->
field
),
item
->
name
,
table
,
modify_item
?
(
Item_field
*
)
item
:
NULL
,
convert_blob_length
);
}
case
Item
:
:
REF_ITEM
:
{
Item
*
tmp_item
;
if
((
tmp_item
=
item
->
real_item
())
->
type
()
==
Item
::
FIELD_ITEM
)
{
{
Item_field
*
field
=
(
Item_field
*
)
tmp_item
;
Item_field
*
field
=
(
Item_field
*
)
item
;
Field
*
new_field
=
create_tmp_field_from_field
(
thd
,
if
(
table_cant_handle_bit_fields
&&
(
*
from_field
=
field
->
field
),
field
->
field
->
type
()
==
FIELD_TYPE_BIT
)
item
->
name
,
table
,
return
create_tmp_field_from_item
(
thd
,
item
,
table
,
copy_func
,
NULL
,
modify_item
,
convert_blob_length
);
convert_blob_length
);
return
create_tmp_field_from_field
(
thd
,
(
*
from_field
=
field
->
field
),
if
(
modify_item
)
item
->
name
,
table
,
item
->
set_result_field
(
new_field
);
modify_item
?
(
Item_field
*
)
item
:
return
new_field
;
NULL
,
convert_blob_length
);
}
}
else
item
=
org_item
;
}
}
case
Item
:
:
FUNC_ITEM
:
case
Item
:
:
FUNC_ITEM
:
case
Item
:
:
COND_ITEM
:
case
Item
:
:
COND_ITEM
:
...
@@ -8074,6 +8072,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
...
@@ -8074,6 +8072,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
case
Item
:
:
REAL_ITEM
:
case
Item
:
:
REAL_ITEM
:
case
Item
:
:
DECIMAL_ITEM
:
case
Item
:
:
DECIMAL_ITEM
:
case
Item
:
:
STRING_ITEM
:
case
Item
:
:
STRING_ITEM
:
case
Item
:
:
REF_ITEM
:
case
Item
:
:
NULL_ITEM
:
case
Item
:
:
NULL_ITEM
:
case
Item
:
:
VARBIN_ITEM
:
case
Item
:
:
VARBIN_ITEM
:
return
create_tmp_field_from_item
(
thd
,
item
,
table
,
copy_func
,
modify_item
,
return
create_tmp_field_from_item
(
thd
,
item
,
table
,
copy_func
,
modify_item
,
...
@@ -10904,12 +10903,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
...
@@ -10904,12 +10903,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
usable_keys
.
set_all
();
usable_keys
.
set_all
();
for
(
ORDER
*
tmp_order
=
order
;
tmp_order
;
tmp_order
=
tmp_order
->
next
)
for
(
ORDER
*
tmp_order
=
order
;
tmp_order
;
tmp_order
=
tmp_order
->
next
)
{
{
if
((
*
tmp_order
->
item
)
->
type
()
!=
Item
::
FIELD_ITEM
)
if
((
*
tmp_order
->
item
)
->
real_item
()
->
type
()
!=
Item
::
FIELD_ITEM
)
{
{
usable_keys
.
clear_all
();
usable_keys
.
clear_all
();
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
}
}
usable_keys
.
intersect
(((
Item_field
*
)
(
*
tmp_order
->
item
))
->
usable_keys
.
intersect
(((
Item_field
*
)
(
*
tmp_order
->
item
)
->
real_item
()
)
->
field
->
part_of_sortkey
);
field
->
part_of_sortkey
);
if
(
usable_keys
.
is_clear_all
())
if
(
usable_keys
.
is_clear_all
())
DBUG_RETURN
(
0
);
// No usable keys
DBUG_RETURN
(
0
);
// No usable keys
...
...
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