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
035b5404
Commit
035b5404
authored
Oct 03, 2006
by
msvensson@neptunus.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal:/home/bk/mysql-4.1-runtime
into neptunus.(none):/home/msvensson/mysql/mysql-4.1-maint
parents
2ef628bf
c30b6eaf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
22 deletions
+91
-22
mysql-test/r/temp_table.result
mysql-test/r/temp_table.result
+17
-0
mysql-test/t/temp_table.test
mysql-test/t/temp_table.test
+47
-1
sql/sql_select.cc
sql/sql_select.cc
+24
-19
sql/sql_table.cc
sql/sql_table.cc
+3
-2
No files found.
mysql-test/r/temp_table.result
View file @
035b5404
...
@@ -108,3 +108,20 @@ d c
...
@@ -108,3 +108,20 @@ d c
bar 2
bar 2
foo 1
foo 1
drop table t1, t2;
drop table t1, t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (i INT);
LOCK TABLE t1 WRITE;
CREATE TEMPORARY TABLE t1 (i INT);
The following command should not block
DROP TEMPORARY TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (i INT);
CREATE TEMPORARY TABLE t2 (i INT);
DROP TEMPORARY TABLE t2, t1;
ERROR 42S02: Unknown table 't1'
SELECT * FROM t2;
ERROR 42S02: Table 'test.t2' doesn't exist
SELECT * FROM t1;
i
DROP TABLE t1;
End of 4.1 tests.
mysql-test/t/temp_table.test
View file @
035b5404
...
@@ -99,4 +99,50 @@ insert into t2 values (NULL, 'foo'), (NULL, 'bar');
...
@@ -99,4 +99,50 @@ insert into t2 values (NULL, 'foo'), (NULL, 'bar');
select
d
,
c
from
t1
left
join
t2
on
b
=
c
where
a
=
3
order
by
d
;
select
d
,
c
from
t1
left
join
t2
on
b
=
c
where
a
=
3
order
by
d
;
drop
table
t1
,
t2
;
drop
table
t1
,
t2
;
# End of 4.1 tests
#
# BUG#21096: locking issue ; temporary table conflicts.
#
# The problem was that on DROP TEMPORARY table name lock was acquired,
# which should not be done.
#
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
--
enable_warnings
CREATE
TABLE
t1
(
i
INT
);
LOCK
TABLE
t1
WRITE
;
connect
(
conn1
,
localhost
,
root
,,);
CREATE
TEMPORARY
TABLE
t1
(
i
INT
);
--
echo
The
following
command
should
not
block
DROP
TEMPORARY
TABLE
t1
;
disconnect
conn1
;
connection
default
;
DROP
TABLE
t1
;
#
# Check that it's not possible to drop a base table with
# DROP TEMPORARY statement.
#
CREATE
TABLE
t1
(
i
INT
);
CREATE
TEMPORARY
TABLE
t2
(
i
INT
);
--
error
1051
DROP
TEMPORARY
TABLE
t2
,
t1
;
# Table t2 should have been dropped.
--
error
1146
SELECT
*
FROM
t2
;
# But table t1 should still be there.
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
--
echo
End
of
4.1
tests
.
sql/sql_select.cc
View file @
035b5404
...
@@ -933,17 +933,28 @@ JOIN::optimize()
...
@@ -933,17 +933,28 @@ JOIN::optimize()
tmp_table_param
.
hidden_field_count
=
(
all_fields
.
elements
-
tmp_table_param
.
hidden_field_count
=
(
all_fields
.
elements
-
fields_list
.
elements
);
fields_list
.
elements
);
ORDER
*
tmp_group
=
((
!
simple_group
&&
!
procedure
&&
!
(
test_flags
&
TEST_NO_KEY_GROUP
))
?
group_list
:
(
ORDER
*
)
0
);
/*
Pushing LIMIT to the temporary table creation is not applicable
when there is ORDER BY or GROUP BY or there is no GROUP BY, but
there are aggregate functions, because in all these cases we need
all result rows.
*/
ha_rows
tmp_rows_limit
=
((
order
==
0
||
skip_sort_order
||
test
(
select_options
&
OPTION_BUFFER_RESULT
))
&&
!
tmp_group
&&
!
thd
->
lex
->
current_select
->
with_sum_func
)
?
select_limit
:
HA_POS_ERROR
;
if
(
!
(
exec_tmp_table1
=
if
(
!
(
exec_tmp_table1
=
create_tmp_table
(
thd
,
&
tmp_table_param
,
all_fields
,
create_tmp_table
(
thd
,
&
tmp_table_param
,
all_fields
,
((
!
simple_group
&&
!
procedure
&&
tmp_group
,
!
(
test_flags
&
TEST_NO_KEY_GROUP
))
?
group_list
:
(
ORDER
*
)
0
),
group_list
?
0
:
select_distinct
,
group_list
?
0
:
select_distinct
,
group_list
&&
simple_group
,
group_list
&&
simple_group
,
select_options
,
select_options
,
(
order
==
0
||
skip_sort_order
||
tmp_rows_limit
,
test
(
select_options
&
OPTION_BUFFER_RESULT
))
?
select_limit
:
HA_POS_ERROR
,
(
char
*
)
""
)))
(
char
*
)
""
)))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
...
@@ -5567,6 +5578,13 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
...
@@ -5567,6 +5578,13 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
thd
->
variables
.
max_heap_table_size
)
:
thd
->
variables
.
max_heap_table_size
)
:
thd
->
variables
.
tmp_table_size
)
/
table
->
reclength
);
thd
->
variables
.
tmp_table_size
)
/
table
->
reclength
);
set_if_bigger
(
table
->
max_rows
,
1
);
// For dummy start options
set_if_bigger
(
table
->
max_rows
,
1
);
// For dummy start options
/*
Push the LIMIT clause to the temporary table creation, so that we
materialize only up to 'rows_limit' records instead of all result records.
*/
set_if_smaller
(
table
->
max_rows
,
rows_limit
);
param
->
end_write_records
=
rows_limit
;
keyinfo
=
param
->
keyinfo
;
keyinfo
=
param
->
keyinfo
;
if
(
group
)
if
(
group
)
...
@@ -5687,19 +5705,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
...
@@ -5687,19 +5705,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
}
}
}
}
/*
Push the LIMIT clause to the temporary table creation, so that we
materialize only up to 'rows_limit' records instead of all result records.
This optimization is not applicable when there is GROUP BY or there is
no GROUP BY, but there are aggregate functions, because both must be
computed for all result rows.
*/
if
(
!
group
&&
!
thd
->
lex
->
current_select
->
with_sum_func
)
{
set_if_smaller
(
table
->
max_rows
,
rows_limit
);
param
->
end_write_records
=
rows_limit
;
}
if
(
thd
->
is_fatal_error
)
// If end of memory
if
(
thd
->
is_fatal_error
)
// If end of memory
goto
err
;
/* purecov: inspected */
goto
err
;
/* purecov: inspected */
table
->
db_record_offset
=
1
;
table
->
db_record_offset
=
1
;
...
...
sql/sql_table.cc
View file @
035b5404
...
@@ -214,7 +214,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
...
@@ -214,7 +214,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
bool
some_tables_deleted
=
0
,
tmp_table_deleted
=
0
,
foreign_key_error
=
0
;
bool
some_tables_deleted
=
0
,
tmp_table_deleted
=
0
,
foreign_key_error
=
0
;
DBUG_ENTER
(
"mysql_rm_table_part2"
);
DBUG_ENTER
(
"mysql_rm_table_part2"
);
if
(
lock_table_names
(
thd
,
tables
))
if
(
!
drop_temporary
&&
lock_table_names
(
thd
,
tables
))
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
for
(
table
=
tables
;
table
;
table
=
table
->
next
)
for
(
table
=
tables
;
table
;
table
=
table
->
next
)
...
@@ -311,7 +311,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
...
@@ -311,7 +311,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
}
}
}
}
unlock_table_names
(
thd
,
tables
);
if
(
!
drop_temporary
)
unlock_table_names
(
thd
,
tables
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
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