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
e6c2cba5
Commit
e6c2cba5
authored
Feb 09, 2007
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge trift2.:/MySQL/M41/mysql-4.1
into trift2.:/MySQL/M41/push-4.1
parents
1a289151
7c08621c
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
247 additions
and
27 deletions
+247
-27
mysql-test/r/ndb_index_unique.result
mysql-test/r/ndb_index_unique.result
+15
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+74
-0
mysql-test/t/ndb_index_unique.test
mysql-test/t/ndb_index_unique.test
+8
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+59
-0
ndb/src/common/util/File.cpp
ndb/src/common/util/File.cpp
+15
-3
ndb/src/kernel/vm/SimulatedBlock.cpp
ndb/src/kernel/vm/SimulatedBlock.cpp
+8
-6
ndb/src/mgmclient/CommandInterpreter.cpp
ndb/src/mgmclient/CommandInterpreter.cpp
+12
-0
sql/filesort.cc
sql/filesort.cc
+5
-1
sql/item.cc
sql/item.cc
+1
-0
sql/item.h
sql/item.h
+3
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+4
-3
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+2
-1
sql/item_func.cc
sql/item_func.cc
+1
-0
sql/item_subselect.cc
sql/item_subselect.cc
+4
-0
sql/opt_sum.cc
sql/opt_sum.cc
+5
-5
sql/sql_select.cc
sql/sql_select.cc
+31
-8
No files found.
mysql-test/r/ndb_index_unique.result
View file @
e6c2cba5
...
@@ -133,6 +133,21 @@ a b c
...
@@ -133,6 +133,21 @@ a b c
6 7 2
6 7 2
7 8 3
7 8 3
8 2 3
8 2 3
create unique index bi using hash on t2(b);
insert into t2 values(9, 3, 1);
ERROR 23000: Duplicate entry '' for key 0
alter table t2 drop index bi;
insert into t2 values(9, 3, 1);
select * from t2 order by a;
a b c
2 3 5
3 4 6
4 5 8
5 6 2
6 7 2
7 8 3
8 2 3
9 3 1
drop table t2;
drop table t2;
CREATE TABLE t2 (
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
a int unsigned NOT NULL PRIMARY KEY,
...
...
mysql-test/r/subselect.result
View file @
e6c2cba5
...
@@ -3026,3 +3026,77 @@ id select_type table type possible_keys key key_len ref rows Extra
...
@@ -3026,3 +3026,77 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
DROP TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (2), (4), (1), (3);
CREATE TABLE t2 (b int, c int);
INSERT INTO t2 VALUES
(2,1), (1,3), (2,1), (4,4), (2,2), (1,4);
SELECT a FROM t1 ORDER BY (SELECT c FROM t2 WHERE b > 2 );
a
2
4
1
3
SELECT a FROM t1 ORDER BY (SELECT c FROM t2 WHERE b > 1);
ERROR 21000: Subquery returns more than 1 row
SELECT a FROM t1 ORDER BY (SELECT c FROM t2 WHERE b > 2), a;
a
1
2
3
4
SELECT a FROM t1 ORDER BY (SELECT c FROM t2 WHERE b > 1), a;
ERROR 21000: Subquery returns more than 1 row
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 2);
b MAX(c)
1 4
2 2
4 4
SELECT b, MAX(c) FROM t2 GROUP BY b, (SELECT c FROM t2 WHERE b > 1);
ERROR 21000: Subquery returns more than 1 row
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
a
1
2
3
4
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
ERROR 21000: Subquery returns more than 1 row
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b)) > 3;
a
4
SELECT a FROM t1 GROUP BY a
HAVING IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b)) > 3;
ERROR 21000: Subquery returns more than 1 row
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 2),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
2
4
1
3
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 1),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
ERROR 21000: Subquery returns more than 1 row
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 2 ORDER BY b));
a
2
1
3
4
SELECT a FROM t1
ORDER BY IFNULL((SELECT b FROM t2 WHERE b > 4),
(SELECT c FROM t2 WHERE c=a AND b > 1 ORDER BY b));
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1,t2;
mysql-test/t/ndb_index_unique.test
View file @
e6c2cba5
...
@@ -83,6 +83,14 @@ delete from t2 where a = 1;
...
@@ -83,6 +83,14 @@ delete from t2 where a = 1;
insert
into
t2
values
(
8
,
2
,
3
);
insert
into
t2
values
(
8
,
2
,
3
);
select
*
from
t2
order
by
a
;
select
*
from
t2
order
by
a
;
# Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld
create
unique
index
bi
using
hash
on
t2
(
b
);
--
error
1062
insert
into
t2
values
(
9
,
3
,
1
);
alter
table
t2
drop
index
bi
;
insert
into
t2
values
(
9
,
3
,
1
);
select
*
from
t2
order
by
a
;
drop
table
t2
;
drop
table
t2
;
--
error
1121
--
error
1121
...
...
mysql-test/t/subselect.test
View file @
e6c2cba5
...
@@ -1993,4 +1993,63 @@ SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
...
@@ -1993,4 +1993,63 @@ SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
EXPLAIN
SELECT
a
FROM
t1
WHERE
(
SELECT
1
FROM
DUAL
WHERE
1
=
0
)
IS
NULL
;
EXPLAIN
SELECT
a
FROM
t1
WHERE
(
SELECT
1
FROM
DUAL
WHERE
1
=
0
)
IS
NULL
;
DROP
TABLE
t1
;
DROP
TABLE
t1
;
#
# Bug 24653: sorting by expressions containing subselects
# that return more than one row
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
2
),
(
4
),
(
1
),
(
3
);
CREATE
TABLE
t2
(
b
int
,
c
int
);
INSERT
INTO
t2
VALUES
(
2
,
1
),
(
1
,
3
),
(
2
,
1
),
(
4
,
4
),
(
2
,
2
),
(
1
,
4
);
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
2
);
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
1
);
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
2
),
a
;
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
1
),
a
;
SELECT
b
,
MAX
(
c
)
FROM
t2
GROUP
BY
b
,
(
SELECT
c
FROM
t2
WHERE
b
>
2
);
--
error
1242
SELECT
b
,
MAX
(
c
)
FROM
t2
GROUP
BY
b
,
(
SELECT
c
FROM
t2
WHERE
b
>
1
);
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
2
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
))
>
3
;
--
error
1242
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
1
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
))
>
3
;
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
))
>
3
;
--
error
1242
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
1
ORDER
BY
b
))
>
3
;
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
2
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
));
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
1
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
1
ORDER
BY
b
));
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
));
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
1
ORDER
BY
b
));
DROP
TABLE
t1
,
t2
;
# End of 4.1 tests
# End of 4.1 tests
ndb/src/common/util/File.cpp
View file @
e6c2cba5
...
@@ -123,13 +123,25 @@ bool
...
@@ -123,13 +123,25 @@ bool
File_class
::
close
()
File_class
::
close
()
{
{
bool
rc
=
true
;
bool
rc
=
true
;
int
retval
=
0
;
if
(
m_file
!=
NULL
)
if
(
m_file
!=
NULL
)
{
{
::
fflush
(
m_file
);
::
fflush
(
m_file
);
rc
=
(
::
fclose
(
m_file
)
==
0
?
true
:
false
);
retval
=
::
fclose
(
m_file
);
m_file
=
NULL
;
// Try again?
while
(
(
retval
!=
0
)
&&
(
errno
==
EINTR
)
){
retval
=
::
fclose
(
m_file
);
}
if
(
retval
==
0
){
rc
=
true
;
}
else
{
rc
=
false
;
ndbout_c
(
"ERROR: Close file error in File.cpp for %s"
,
strerror
(
errno
));
}
}
}
m_file
=
NULL
;
return
rc
;
return
rc
;
}
}
...
...
ndb/src/kernel/vm/SimulatedBlock.cpp
View file @
e6c2cba5
...
@@ -658,24 +658,26 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear)
...
@@ -658,24 +658,26 @@ SimulatedBlock::allocRecord(const char * type, size_t s, size_t n, bool clear)
void
*
p
=
NULL
;
void
*
p
=
NULL
;
size_t
size
=
n
*
s
;
size_t
size
=
n
*
s
;
Uint64
real_size
=
(
Uint64
)((
Uint64
)
n
)
*
((
Uint64
)
s
);
refresh_watch_dog
();
refresh_watch_dog
();
if
(
size
>
0
){
if
(
real_
size
>
0
){
#ifdef VM_TRACE_MEM
#ifdef VM_TRACE_MEM
ndbout_c
(
"%s::allocRecord(%s, %u, %u) = %u bytes"
,
ndbout_c
(
"%s::allocRecord(%s, %u, %u) = %
ll
u bytes"
,
getBlockName
(
number
()),
getBlockName
(
number
()),
type
,
type
,
s
,
s
,
n
,
n
,
size
);
real_
size
);
#endif
#endif
p
=
NdbMem_Allocate
(
size
);
if
(
real_size
==
(
Uint64
)
size
)
p
=
NdbMem_Allocate
(
size
);
if
(
p
==
NULL
){
if
(
p
==
NULL
){
char
buf1
[
255
];
char
buf1
[
255
];
char
buf2
[
255
];
char
buf2
[
255
];
BaseString
::
snprintf
(
buf1
,
sizeof
(
buf1
),
"%s could not allocate memory for %s"
,
BaseString
::
snprintf
(
buf1
,
sizeof
(
buf1
),
"%s could not allocate memory for %s"
,
getBlockName
(
number
()),
type
);
getBlockName
(
number
()),
type
);
BaseString
::
snprintf
(
buf2
,
sizeof
(
buf2
),
"Requested: %ux%u = %u bytes"
,
BaseString
::
snprintf
(
buf2
,
sizeof
(
buf2
),
"Requested: %ux%u = %
ll
u bytes"
,
(
Uint32
)
s
,
(
Uint32
)
n
,
(
Uint
32
)
size
);
(
Uint32
)
s
,
(
Uint32
)
n
,
(
Uint
64
)
real_
size
);
ERROR_SET
(
fatal
,
ERR_MEMALLOC
,
buf1
,
buf2
);
ERROR_SET
(
fatal
,
ERR_MEMALLOC
,
buf1
,
buf2
);
}
}
...
...
ndb/src/mgmclient/CommandInterpreter.cpp
View file @
e6c2cba5
...
@@ -1627,6 +1627,18 @@ CommandInterpreter::executeStatus(int processId,
...
@@ -1627,6 +1627,18 @@ CommandInterpreter::executeStatus(int processId,
ndbout
<<
processId
<<
": Node not found"
<<
endl
;
ndbout
<<
processId
<<
": Node not found"
<<
endl
;
return
-
1
;
return
-
1
;
}
}
if
(
cl
->
node_states
[
i
].
node_type
!=
NDB_MGM_NODE_TYPE_NDB
){
if
(
cl
->
node_states
[
i
].
version
!=
0
){
ndbout
<<
"Node "
<<
cl
->
node_states
[
i
].
node_id
<<
": connected"
;
ndbout_c
(
" (Version %d.%d.%d)"
,
getMajor
(
version
)
,
getMinor
(
version
),
getBuild
(
version
));
}
else
ndbout
<<
"Node "
<<
cl
->
node_states
[
i
].
node_id
<<
": not connected"
<<
endl
;
return
0
;
}
status
=
cl
->
node_states
[
i
].
node_status
;
status
=
cl
->
node_states
[
i
].
node_status
;
startPhase
=
cl
->
node_states
[
i
].
start_phase
;
startPhase
=
cl
->
node_states
[
i
].
start_phase
;
version
=
cl
->
node_states
[
i
].
version
;
version
=
cl
->
node_states
[
i
].
version
;
...
...
sql/filesort.cc
View file @
e6c2cba5
...
@@ -387,7 +387,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
...
@@ -387,7 +387,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
byte
*
ref_pos
,
*
next_pos
,
ref_buff
[
MAX_REFLENGTH
];
byte
*
ref_pos
,
*
next_pos
,
ref_buff
[
MAX_REFLENGTH
];
my_off_t
record
;
my_off_t
record
;
TABLE
*
sort_form
;
TABLE
*
sort_form
;
volatile
my_bool
*
killed
=
&
current_thd
->
killed
;
THD
*
thd
=
current_thd
;
volatile
my_bool
*
killed
=
&
thd
->
killed
;
handler
*
file
;
handler
*
file
;
DBUG_ENTER
(
"find_all_keys"
);
DBUG_ENTER
(
"find_all_keys"
);
DBUG_PRINT
(
"info"
,(
"using: %s"
,(
select
?
select
->
quick
?
"ranges"
:
"where"
:
"every row"
)));
DBUG_PRINT
(
"info"
,(
"using: %s"
,(
select
?
select
->
quick
?
"ranges"
:
"where"
:
"every row"
)));
...
@@ -474,6 +475,9 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
...
@@ -474,6 +475,9 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
}
}
else
else
file
->
unlock_row
();
file
->
unlock_row
();
/* It does not make sense to read more keys in case of a fatal error */
if
(
thd
->
net
.
report_error
)
DBUG_RETURN
(
HA_POS_ERROR
);
}
}
(
void
)
file
->
extra
(
HA_EXTRA_NO_CACHE
);
/* End cacheing of records */
(
void
)
file
->
extra
(
HA_EXTRA_NO_CACHE
);
/* End cacheing of records */
if
(
!
next_pos
)
if
(
!
next_pos
)
...
...
sql/item.cc
View file @
e6c2cba5
...
@@ -47,6 +47,7 @@ Item::Item():
...
@@ -47,6 +47,7 @@ Item::Item():
collation
.
set
(
&
my_charset_bin
,
DERIVATION_COERCIBLE
);
collation
.
set
(
&
my_charset_bin
,
DERIVATION_COERCIBLE
);
name
=
0
;
name
=
0
;
decimals
=
0
;
max_length
=
0
;
decimals
=
0
;
max_length
=
0
;
with_subselect
=
0
;
/* Put item in free list so that we can free all items at end */
/* Put item in free list so that we can free all items at end */
THD
*
thd
=
current_thd
;
THD
*
thd
=
current_thd
;
...
...
sql/item.h
View file @
e6c2cba5
...
@@ -142,6 +142,9 @@ class Item {
...
@@ -142,6 +142,9 @@ class Item {
my_bool
with_sum_func
;
my_bool
with_sum_func
;
my_bool
fixed
;
/* If item fixed with fix_fields */
my_bool
fixed
;
/* If item fixed with fix_fields */
DTCollation
collation
;
DTCollation
collation
;
my_bool
with_subselect
;
/* If this item is a subselect or some
of its arguments is or contains a
subselect */
// alloc & destruct is done as start of select using sql_alloc
// alloc & destruct is done as start of select using sql_alloc
Item
();
Item
();
...
...
sql/item_cmpfunc.cc
View file @
e6c2cba5
...
@@ -2139,6 +2139,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -2139,6 +2139,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
and_tables_cache
&=
tmp_table_map
;
and_tables_cache
&=
tmp_table_map
;
const_item_cache
&=
item
->
const_item
();
const_item_cache
&=
item
->
const_item
();
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
with_sum_func
=
with_sum_func
||
item
->
with_sum_func
;
with_subselect
|=
item
->
with_subselect
;
if
(
item
->
maybe_null
)
if
(
item
->
maybe_null
)
maybe_null
=
1
;
maybe_null
=
1
;
}
}
...
@@ -2351,7 +2352,7 @@ longlong Item_func_isnull::val_int()
...
@@ -2351,7 +2352,7 @@ longlong Item_func_isnull::val_int()
Handle optimization if the argument can't be null
Handle optimization if the argument can't be null
This has to be here because of the test in update_used_tables().
This has to be here because of the test in update_used_tables().
*/
*/
if
(
!
used_tables_cache
)
if
(
!
used_tables_cache
&&
!
with_subselect
)
return
cached_value
;
return
cached_value
;
return
args
[
0
]
->
is_null
()
?
1
:
0
;
return
args
[
0
]
->
is_null
()
?
1
:
0
;
}
}
...
@@ -2360,7 +2361,7 @@ longlong Item_is_not_null_test::val_int()
...
@@ -2360,7 +2361,7 @@ longlong Item_is_not_null_test::val_int()
{
{
DBUG_ASSERT
(
fixed
==
1
);
DBUG_ASSERT
(
fixed
==
1
);
DBUG_ENTER
(
"Item_is_not_null_test::val_int"
);
DBUG_ENTER
(
"Item_is_not_null_test::val_int"
);
if
(
!
used_tables_cache
)
if
(
!
used_tables_cache
&&
!
with_subselect
)
{
{
owner
->
was_null
|=
(
!
cached_value
);
owner
->
was_null
|=
(
!
cached_value
);
DBUG_PRINT
(
"info"
,
(
"cached :%d"
,
cached_value
));
DBUG_PRINT
(
"info"
,
(
"cached :%d"
,
cached_value
));
...
@@ -2387,7 +2388,7 @@ void Item_is_not_null_test::update_used_tables()
...
@@ -2387,7 +2388,7 @@ void Item_is_not_null_test::update_used_tables()
else
else
{
{
args
[
0
]
->
update_used_tables
();
args
[
0
]
->
update_used_tables
();
if
(
!
(
used_tables_cache
=
args
[
0
]
->
used_tables
()))
if
(
!
(
used_tables_cache
=
args
[
0
]
->
used_tables
())
&&
!
with_subselect
)
{
{
/* Remember if the value is always NULL or never NULL */
/* Remember if the value is always NULL or never NULL */
cached_value
=
(
longlong
)
!
args
[
0
]
->
is_null
();
cached_value
=
(
longlong
)
!
args
[
0
]
->
is_null
();
...
...
sql/item_cmpfunc.h
View file @
e6c2cba5
...
@@ -843,7 +843,8 @@ class Item_func_isnull :public Item_bool_func
...
@@ -843,7 +843,8 @@ class Item_func_isnull :public Item_bool_func
else
else
{
{
args
[
0
]
->
update_used_tables
();
args
[
0
]
->
update_used_tables
();
if
((
const_item_cache
=
!
(
used_tables_cache
=
args
[
0
]
->
used_tables
())))
if
((
const_item_cache
=
!
(
used_tables_cache
=
args
[
0
]
->
used_tables
()))
&&
!
with_subselect
)
{
{
/* Remember if the value is always NULL or never NULL */
/* Remember if the value is always NULL or never NULL */
cached_value
=
(
longlong
)
args
[
0
]
->
is_null
();
cached_value
=
(
longlong
)
args
[
0
]
->
is_null
();
...
...
sql/item_func.cc
View file @
e6c2cba5
...
@@ -177,6 +177,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
...
@@ -177,6 +177,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
used_tables_cache
|=
item
->
used_tables
();
used_tables_cache
|=
item
->
used_tables
();
not_null_tables_cache
|=
item
->
not_null_tables
();
not_null_tables_cache
|=
item
->
not_null_tables
();
const_item_cache
&=
item
->
const_item
();
const_item_cache
&=
item
->
const_item
();
with_subselect
|=
item
->
with_subselect
;
}
}
}
}
fix_length_and_dec
();
fix_length_and_dec
();
...
...
sql/item_subselect.cc
View file @
e6c2cba5
...
@@ -39,6 +39,7 @@ Item_subselect::Item_subselect():
...
@@ -39,6 +39,7 @@ Item_subselect::Item_subselect():
engine
(
0
),
old_engine
(
0
),
used_tables_cache
(
0
),
have_to_be_excluded
(
0
),
engine
(
0
),
old_engine
(
0
),
used_tables_cache
(
0
),
have_to_be_excluded
(
0
),
const_item_cache
(
1
),
engine_changed
(
0
),
changed
(
0
)
const_item_cache
(
1
),
engine_changed
(
0
),
changed
(
0
)
{
{
with_subselect
=
1
;
reset
();
reset
();
/*
/*
item value is NULL if select_subselect not changed this value
item value is NULL if select_subselect not changed this value
...
@@ -201,6 +202,9 @@ bool Item_subselect::exec()
...
@@ -201,6 +202,9 @@ bool Item_subselect::exec()
mem root
mem root
*/
*/
thd
->
mem_root
=
&
thd
->
main_mem_root
;
thd
->
mem_root
=
&
thd
->
main_mem_root
;
if
(
thd
->
net
.
report_error
)
/* Do not execute subselect in case of a fatal error */
return
1
;
res
=
engine
->
exec
();
res
=
engine
->
exec
();
thd
->
mem_root
=
old_root
;
thd
->
mem_root
=
old_root
;
...
...
sql/opt_sum.cc
View file @
e6c2cba5
...
@@ -68,9 +68,9 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond);
...
@@ -68,9 +68,9 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond);
GROUP BY part.
GROUP BY part.
RETURN VALUES
RETURN VALUES
0
N
o errors
0
n
o errors
1 if all items were resolved
1
if all items were resolved
-1
on impossible conditions
HA_ERR_KEY_NOT_FOUND
on impossible conditions
OR an error number from my_base.h HA_ERR_... if a deadlock or a lock
OR an error number from my_base.h HA_ERR_... if a deadlock or a lock
wait timeout happens, for example
wait timeout happens, for example
*/
*/
...
@@ -216,7 +216,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
...
@@ -216,7 +216,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if
(
error
)
if
(
error
)
{
{
if
(
error
==
HA_ERR_KEY_NOT_FOUND
||
error
==
HA_ERR_END_OF_FILE
)
if
(
error
==
HA_ERR_KEY_NOT_FOUND
||
error
==
HA_ERR_END_OF_FILE
)
return
-
1
;
// No rows matching WHERE
return
HA_ERR_KEY_NOT_FOUND
;
// No rows matching WHERE
/* HA_ERR_LOCK_DEADLOCK or some other error */
/* HA_ERR_LOCK_DEADLOCK or some other error */
table
->
file
->
print_error
(
error
,
MYF
(
0
));
table
->
file
->
print_error
(
error
,
MYF
(
0
));
return
(
error
);
return
(
error
);
...
@@ -303,7 +303,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
...
@@ -303,7 +303,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if
(
error
)
if
(
error
)
{
{
if
(
error
==
HA_ERR_KEY_NOT_FOUND
||
error
==
HA_ERR_END_OF_FILE
)
if
(
error
==
HA_ERR_KEY_NOT_FOUND
||
error
==
HA_ERR_END_OF_FILE
)
return
-
1
;
// No rows matching WHERE
return
HA_ERR_KEY_NOT_FOUND
;
// No rows matching WHERE
/* HA_ERR_LOCK_DEADLOCK or some other error */
/* HA_ERR_LOCK_DEADLOCK or some other error */
table
->
file
->
print_error
(
error
,
MYF
(
0
));
table
->
file
->
print_error
(
error
,
MYF
(
0
));
return
(
error
);
return
(
error
);
...
...
sql/sql_select.cc
View file @
e6c2cba5
...
@@ -531,23 +531,25 @@ JOIN::optimize()
...
@@ -531,23 +531,25 @@ JOIN::optimize()
{
{
int
res
;
int
res
;
/*
/*
opt_sum_query() returns -1 if no rows match to the WHERE conditions,
opt_sum_query() returns HA_ERR_KEY_NOT_FOUND if no rows match
or 1 if all items were resolved, or 0, or an error number HA_ERR_...
to the WHERE conditions,
or 1 if all items were resolved,
or 0, or an error number HA_ERR_...
*/
*/
if
((
res
=
opt_sum_query
(
tables_list
,
all_fields
,
conds
)))
if
((
res
=
opt_sum_query
(
tables_list
,
all_fields
,
conds
)))
{
{
if
(
res
==
HA_ERR_KEY_NOT_FOUND
)
{
zero_result_cause
=
"No matching min/max row"
;
error
=
0
;
DBUG_RETURN
(
0
);
}
if
(
res
>
1
)
if
(
res
>
1
)
{
{
thd
->
fatal_error
();
thd
->
fatal_error
();
error
=
res
;
error
=
res
;
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
if
(
res
<
0
)
{
zero_result_cause
=
"No matching min/max row"
;
error
=
0
;
DBUG_RETURN
(
0
);
}
zero_result_cause
=
"Select tables optimized away"
;
zero_result_cause
=
"Select tables optimized away"
;
tables_list
=
0
;
// All tables resolved
tables_list
=
0
;
// All tables resolved
/*
/*
...
@@ -644,6 +646,13 @@ JOIN::optimize()
...
@@ -644,6 +646,13 @@ JOIN::optimize()
{
{
ORDER
*
org_order
=
order
;
ORDER
*
org_order
=
order
;
order
=
remove_const
(
this
,
order
,
conds
,
1
,
&
simple_order
);
order
=
remove_const
(
this
,
order
,
conds
,
1
,
&
simple_order
);
if
(
thd
->
net
.
report_error
)
{
error
=
1
;
DBUG_PRINT
(
"error"
,(
"Error from remove_const"
));
DBUG_RETURN
(
1
);
}
/*
/*
If we are using ORDER BY NULL or ORDER BY const_expression,
If we are using ORDER BY NULL or ORDER BY const_expression,
return result in any order (even if we are using a GROUP BY)
return result in any order (even if we are using a GROUP BY)
...
@@ -747,6 +756,12 @@ JOIN::optimize()
...
@@ -747,6 +756,12 @@ JOIN::optimize()
group_list
=
remove_const
(
this
,
(
old_group_list
=
group_list
),
conds
,
group_list
=
remove_const
(
this
,
(
old_group_list
=
group_list
),
conds
,
rollup
.
state
==
ROLLUP
::
STATE_NONE
,
rollup
.
state
==
ROLLUP
::
STATE_NONE
,
&
simple_group
);
&
simple_group
);
if
(
thd
->
net
.
report_error
)
{
error
=
1
;
DBUG_PRINT
(
"error"
,(
"Error from remove_const"
));
DBUG_RETURN
(
1
);
}
if
(
old_group_list
&&
!
group_list
)
if
(
old_group_list
&&
!
group_list
)
select_distinct
=
0
;
select_distinct
=
0
;
}
}
...
@@ -763,6 +778,12 @@ JOIN::optimize()
...
@@ -763,6 +778,12 @@ JOIN::optimize()
{
{
group_list
=
procedure
->
group
=
remove_const
(
this
,
procedure
->
group
,
conds
,
group_list
=
procedure
->
group
=
remove_const
(
this
,
procedure
->
group
,
conds
,
1
,
&
simple_group
);
1
,
&
simple_group
);
if
(
thd
->
net
.
report_error
)
{
error
=
1
;
DBUG_PRINT
(
"error"
,(
"Error from remove_const"
));
DBUG_RETURN
(
1
);
}
calc_group_buffer
(
this
,
group_list
);
calc_group_buffer
(
this
,
group_list
);
}
}
...
@@ -4428,6 +4449,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
...
@@ -4428,6 +4449,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
*
simple_order
=
0
;
// Must do a temp table to sort
*
simple_order
=
0
;
// Must do a temp table to sort
else
if
(
!
(
order_tables
&
not_const_tables
))
else
if
(
!
(
order_tables
&
not_const_tables
))
{
{
if
(
order
->
item
[
0
]
->
with_subselect
)
order
->
item
[
0
]
->
val_str
(
&
order
->
item
[
0
]
->
str_value
);
DBUG_PRINT
(
"info"
,(
"removing: %s"
,
order
->
item
[
0
]
->
full_name
()));
DBUG_PRINT
(
"info"
,(
"removing: %s"
,
order
->
item
[
0
]
->
full_name
()));
continue
;
// skip const item
continue
;
// skip const item
}
}
...
...
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