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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
d2c585df
Commit
d2c585df
authored
Jun 13, 2004
by
bell@sanja.is.com.ua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed field resolving mode fo INSERT/REPLACE and CRETE with SELECT (BUG#4090)
parent
2f76413e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
3 deletions
+64
-3
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+26
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+14
-0
sql/sql_parse.cc
sql/sql_parse.cc
+13
-1
sql/sql_prepare.cc
sql/sql_prepare.cc
+11
-2
No files found.
mysql-test/r/subselect.result
View file @
d2c585df
...
@@ -1831,3 +1831,29 @@ Warnings:
...
@@ -1831,3 +1831,29 @@ Warnings:
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select test.up.a AS `a`,test.up.b AS `b` from test.t1 up where exists(select 1 AS `Not_used` from test.t1 where (test.t1.a = test.up.a))
Note 1003 select test.up.a AS `a`,test.up.b AS `b` from test.t1 up where exists(select 1 AS `Not_used` from test.t1 where (test.t1.a = test.up.a))
drop table t1;
drop table t1;
DROP TABLE IF EXISTS t1, t2, t3;
Warnings:
Note 1051 Unknown table 't1'
Note 1051 Unknown table 't2'
Note 1051 Unknown table 't3'
CREATE TABLE t1 ( a int, b int );
CREATE TABLE t2 ( c int, d int );
INSERT INTO t1 VALUES (1,2), (2,3), (3,4);
SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
abc b
1 2
2 3
3 4
INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
select * from t2;
c d
1 2
2 3
3 4
CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);
select * from t3;
abc b
1 2
2 3
3 4
DROP TABLE t1, t2, t3;
mysql-test/t/subselect.test
View file @
d2c585df
...
@@ -1167,3 +1167,17 @@ insert into t1 values (1,2),(3,4);
...
@@ -1167,3 +1167,17 @@ insert into t1 values (1,2),(3,4);
select
*
from
t1
up
where
exists
(
select
*
from
t1
where
t1
.
a
=
up
.
a
);
select
*
from
t1
up
where
exists
(
select
*
from
t1
where
t1
.
a
=
up
.
a
);
explain
extended
select
*
from
t1
up
where
exists
(
select
*
from
t1
where
t1
.
a
=
up
.
a
);
explain
extended
select
*
from
t1
up
where
exists
(
select
*
from
t1
where
t1
.
a
=
up
.
a
);
drop
table
t1
;
drop
table
t1
;
#
# outer fields resolving in INSERT/REPLACE and CRETE with SELECT
#
DROP
TABLE
IF
EXISTS
t1
,
t2
,
t3
;
CREATE
TABLE
t1
(
a
int
,
b
int
);
CREATE
TABLE
t2
(
c
int
,
d
int
);
INSERT
INTO
t1
VALUES
(
1
,
2
),
(
2
,
3
),
(
3
,
4
);
SELECT
a
AS
abc
,
b
FROM
t1
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t1
WHERE
a
=
abc
);
INSERT
INTO
t2
SELECT
a
AS
abc
,
b
FROM
t1
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t1
WHERE
a
=
abc
);
select
*
from
t2
;
CREATE
TABLE
t3
SELECT
a
AS
abc
,
b
FROM
t1
WHERE
b
=
(
SELECT
MIN
(
b
)
FROM
t1
WHERE
a
=
abc
);
select
*
from
t3
;
DROP
TABLE
t1
,
t2
,
t3
;
sql/sql_parse.cc
View file @
d2c585df
...
@@ -2334,7 +2334,15 @@ mysql_execute_command(THD *thd)
...
@@ -2334,7 +2334,15 @@ mysql_execute_command(THD *thd)
lex
->
create_list
,
lex
->
create_list
,
lex
->
key_list
,
lex
->
key_list
,
select_lex
->
item_list
,
lex
->
duplicates
)))
select_lex
->
item_list
,
lex
->
duplicates
)))
{
/*
CREATE from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
select_lex
->
resolve_mode
=
SELECT_LEX
::
SELECT_MODE
;
res
=
handle_select
(
thd
,
lex
,
result
);
res
=
handle_select
(
thd
,
lex
,
result
);
select_lex
->
resolve_mode
=
SELECT_LEX
::
NOMATTER_MODE
;
}
//reset for PS
//reset for PS
lex
->
create_list
.
empty
();
lex
->
create_list
.
empty
();
lex
->
key_list
.
empty
();
lex
->
key_list
.
empty
();
...
@@ -2685,7 +2693,11 @@ unsent_create_error:
...
@@ -2685,7 +2693,11 @@ unsent_create_error:
lex
->
duplicates
)))
lex
->
duplicates
)))
/* Skip first table, which is the table we are inserting in */
/* Skip first table, which is the table we are inserting in */
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
->
next
;
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
->
next
;
lex
->
select_lex
.
resolve_mode
=
SELECT_LEX
::
NOMATTER_MODE
;
/*
insert/replace from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
lex
->
select_lex
.
resolve_mode
=
SELECT_LEX
::
SELECT_MODE
;
res
=
handle_select
(
thd
,
lex
,
result
);
res
=
handle_select
(
thd
,
lex
,
result
);
/* revert changes for SP */
/* revert changes for SP */
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
;
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
;
...
...
sql/sql_prepare.cc
View file @
d2c585df
...
@@ -1308,6 +1308,7 @@ static int mysql_test_create_table(Prepared_statement *stmt,
...
@@ -1308,6 +1308,7 @@ static int mysql_test_create_table(Prepared_statement *stmt,
DBUG_ENTER
(
"mysql_test_create_table"
);
DBUG_ENTER
(
"mysql_test_create_table"
);
THD
*
thd
=
stmt
->
thd
;
THD
*
thd
=
stmt
->
thd
;
LEX
*
lex
=
stmt
->
lex
;
LEX
*
lex
=
stmt
->
lex
;
SELECT_LEX
*
select_lex
=
&
lex
->
select_lex
;
int
res
=
0
;
int
res
=
0
;
/* Skip first table, which is the table we are creating */
/* Skip first table, which is the table we are creating */
...
@@ -1316,8 +1317,12 @@ static int mysql_test_create_table(Prepared_statement *stmt,
...
@@ -1316,8 +1317,12 @@ static int mysql_test_create_table(Prepared_statement *stmt,
&
create_table_local
);
&
create_table_local
);
if
(
!
(
res
=
create_table_precheck
(
thd
,
tables
,
create_table
))
&&
if
(
!
(
res
=
create_table_precheck
(
thd
,
tables
,
create_table
))
&&
lex
->
select_lex
.
item_list
.
elements
)
select_lex
->
item_list
.
elements
)
{
select_lex
->
resolve_mode
=
SELECT_LEX
::
SELECT_MODE
;
res
=
select_like_statement_test
(
stmt
,
tables
);
res
=
select_like_statement_test
(
stmt
,
tables
);
select_lex
->
resolve_mode
=
SELECT_LEX
::
NOMATTER_MODE
;
}
/* put tables back for PS rexecuting */
/* put tables back for PS rexecuting */
tables
=
lex
->
link_first_table_back
(
tables
,
create_table
,
tables
=
lex
->
link_first_table_back
(
tables
,
create_table
,
...
@@ -1401,7 +1406,11 @@ static int mysql_test_insert_select(Prepared_statement *stmt,
...
@@ -1401,7 +1406,11 @@ static int mysql_test_insert_select(Prepared_statement *stmt,
(
TABLE_LIST
*
)
lex
->
select_lex
.
table_list
.
first
;
(
TABLE_LIST
*
)
lex
->
select_lex
.
table_list
.
first
;
/* Skip first table, which is the table we are inserting in */
/* Skip first table, which is the table we are inserting in */
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
->
next
;
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
->
next
;
lex
->
select_lex
.
resolve_mode
=
SELECT_LEX
::
NOMATTER_MODE
;
/*
insert/replace from SELECT give its SELECT_LEX for SELECT,
and item_list belong to SELECT
*/
lex
->
select_lex
.
resolve_mode
=
SELECT_LEX
::
SELECT_MODE
;
res
=
select_like_statement_test
(
stmt
,
tables
);
res
=
select_like_statement_test
(
stmt
,
tables
);
/* revert changes*/
/* revert changes*/
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
;
lex
->
select_lex
.
table_list
.
first
=
(
byte
*
)
first_local_table
;
...
...
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