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
9bf63b14
Commit
9bf63b14
authored
Jan 20, 2005
by
ingo@mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql.com:/home/mydev/mysql-5.0
into mysql.com:/home/mydev/mysql-5.0-5000
parents
d959e2ab
bd24018f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
5 deletions
+75
-5
mysql-test/r/insert_select.result
mysql-test/r/insert_select.result
+12
-0
mysql-test/t/insert_select.test
mysql-test/t/insert_select.test
+15
-0
sql/sql_class.h
sql/sql_class.h
+2
-0
sql/sql_insert.cc
sql/sql_insert.cc
+43
-4
sql/sql_select.cc
sql/sql_select.cc
+3
-1
No files found.
mysql-test/r/insert_select.result
View file @
9bf63b14
...
...
@@ -638,3 +638,15 @@ No Field Count
0 1 100
0 2 100
drop table t1, t2;
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
NO int(11) NOT NULL default '0',
SEQ int(11) NOT NULL default '0',
PRIMARY KEY (ID),
KEY t1$NO (SEQ,NO)
) ENGINE=MyISAM;
INSERT INTO t1 (SEQ, NO) SELECT "1" AS SEQ, IF(MAX(NO) IS NULL, 0, MAX(NO)) + 1 AS NO FROM t1 WHERE (SEQ = 1);
select SQL_BUFFER_RESULT * from t1 WHERE (SEQ = 1);
ID NO SEQ
1 1 1
drop table t1;
mysql-test/t/insert_select.test
View file @
9bf63b14
...
...
@@ -180,3 +180,18 @@ insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2
select
*
from
t2
;
drop
table
t1
,
t2
;
#
# BUG#6034 - Error code 124: Wrong medium type
#
CREATE
TABLE
t1
(
ID
int
(
11
)
NOT
NULL
auto_increment
,
NO
int
(
11
)
NOT
NULL
default
'0'
,
SEQ
int
(
11
)
NOT
NULL
default
'0'
,
PRIMARY
KEY
(
ID
),
KEY
t1
$NO
(
SEQ
,
NO
)
)
ENGINE
=
MyISAM
;
INSERT
INTO
t1
(
SEQ
,
NO
)
SELECT
"1"
AS
SEQ
,
IF
(
MAX
(
NO
)
IS
NULL
,
0
,
MAX
(
NO
))
+
1
AS
NO
FROM
t1
WHERE
(
SEQ
=
1
);
select
SQL_BUFFER_RESULT
*
from
t1
WHERE
(
SEQ
=
1
);
drop
table
t1
;
sql/sql_class.h
View file @
9bf63b14
...
...
@@ -1280,6 +1280,7 @@ class select_result :public Sql_alloc {
unit
=
u
;
return
0
;
}
virtual
int
prepare2
(
void
)
{
return
0
;
}
/*
Because of peculiarities of prepared statements protocol
we need to know number of columns in the result set (if
...
...
@@ -1379,6 +1380,7 @@ class select_insert :public select_result_interceptor {
enum_duplicates
duplic
,
bool
ignore
);
~
select_insert
();
int
prepare
(
List
<
Item
>
&
list
,
SELECT_LEX_UNIT
*
u
);
int
prepare2
(
void
);
bool
send_data
(
List
<
Item
>
&
items
);
virtual
void
store_values
(
List
<
Item
>
&
values
);
void
send_error
(
uint
errcode
,
const
char
*
err
);
...
...
sql/sql_insert.cc
View file @
9bf63b14
...
...
@@ -1802,13 +1802,22 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
thd
->
lex
->
current_select
->
options
|=
OPTION_BUFFER_RESULT
;
thd
->
lex
->
current_select
->
join
->
select_options
|=
OPTION_BUFFER_RESULT
;
}
restore_record
(
table
,
s
->
default_values
);
// Get empty record
table
->
next_number_field
=
table
->
found_next_number_field
;
thd
->
cuted_fields
=
0
;
else
{
/*
We must not yet prepare the result table if it is the same as one of the
source tables (INSERT SELECT). The preparation may disable
indexes on the result table, which may be used during the select, if it
is the same table (Bug #6034). Do the preparation after the select phase
in select_insert::prepare2().
*/
if
(
info
.
ignore
||
info
.
handle_duplicates
!=
DUP_ERROR
)
table
->
file
->
extra
(
HA_EXTRA_IGNORE_DUP_KEY
);
table
->
file
->
start_bulk_insert
((
ha_rows
)
0
);
}
restore_record
(
table
,
s
->
default_values
);
// Get empty record
table
->
next_number_field
=
table
->
found_next_number_field
;
thd
->
cuted_fields
=
0
;
thd
->
no_trans_update
=
0
;
thd
->
abort_on_warning
=
(
!
info
.
ignore
&&
(
thd
->
variables
.
sql_mode
&
...
...
@@ -1819,6 +1828,36 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
}
/*
Finish the preparation of the result table.
SYNOPSIS
select_insert::prepare2()
void
DESCRIPTION
If the result table is the same as one of the source tables (INSERT SELECT),
the result table is not finally prepared at the join prepair phase.
Do the final preparation now.
RETURN
0 OK
*/
int
select_insert
::
prepare2
(
void
)
{
DBUG_ENTER
(
"select_insert::prepare2"
);
if
(
thd
->
lex
->
current_select
->
options
&
OPTION_BUFFER_RESULT
)
{
if
(
info
.
ignore
||
info
.
handle_duplicates
!=
DUP_ERROR
)
table
->
file
->
extra
(
HA_EXTRA_IGNORE_DUP_KEY
);
table
->
file
->
start_bulk_insert
((
ha_rows
)
0
);
}
return
0
;
}
void
select_insert
::
cleanup
()
{
/* select_insert/select_create are never re-used in prepared statement */
...
...
sql/sql_select.cc
View file @
9bf63b14
...
...
@@ -1164,6 +1164,7 @@ JOIN::exec()
DBUG_VOID_RETURN
;
}
}
(
void
)
result
->
prepare2
();
// Currently, this cannot fail.
if
(
!
tables_list
)
{
// Only test of functions
...
...
@@ -13149,7 +13150,8 @@ bool JOIN::change_result(select_result *res)
{
DBUG_ENTER
(
"JOIN::change_result"
);
result
=
res
;
if
(
!
procedure
&&
result
->
prepare
(
fields_list
,
select_lex
->
master_unit
()))
if
(
!
procedure
&&
(
result
->
prepare
(
fields_list
,
select_lex
->
master_unit
())
||
result
->
prepare2
()))
{
DBUG_RETURN
(
TRUE
);
}
...
...
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