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
2e63f22a
Commit
2e63f22a
authored
Nov 22, 2004
by
tomas@poseidon.ndb.mysql.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1-mysqladmin
parents
816fe259
77a58fb7
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
251 additions
and
82 deletions
+251
-82
innobase/row/row0sel.c
innobase/row/row0sel.c
+72
-62
mysql-test/r/myisam.result
mysql-test/r/myisam.result
+1
-0
mysql-test/r/ndb_index_unique.result
mysql-test/r/ndb_index_unique.result
+52
-0
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+15
-0
mysql-test/t/myisam.test
mysql-test/t/myisam.test
+2
-1
mysql-test/t/ndb_autodiscover.test
mysql-test/t/ndb_autodiscover.test
+7
-7
mysql-test/t/ndb_index_unique.test
mysql-test/t/ndb_index_unique.test
+34
-0
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+19
-0
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.cc
+22
-1
sql/ha_ndbcluster.h
sql/ha_ndbcluster.h
+2
-1
sql/set_var.cc
sql/set_var.cc
+11
-6
sql/sql_do.cc
sql/sql_do.cc
+1
-0
strings/uca-dump.c
strings/uca-dump.c
+13
-4
No files found.
innobase/row/row0sel.c
View file @
2e63f22a
...
@@ -642,16 +642,17 @@ row_sel_get_clust_rec(
...
@@ -642,16 +642,17 @@ row_sel_get_clust_rec(
we lock only the record, i.e. next-key locking is
we lock only the record, i.e. next-key locking is
not used.
not used.
*/
*/
if
(
srv_locks_unsafe_for_binlog
)
{
err
=
lock_clust_rec_read_check_and_lock
(
0
,
clust_rec
,
index
,
node
->
row_lock_mode
,
LOCK_REC_NOT_GAP
,
thr
);
}
else
{
err
=
lock_clust_rec_read_check_and_lock
(
0
,
clust_rec
,
index
,
node
->
row_lock_mode
,
LOCK_ORDINARY
,
thr
);
if
(
srv_locks_unsafe_for_binlog
)
{
err
=
lock_clust_rec_read_check_and_lock
(
0
,
clust_rec
,
index
,
node
->
row_lock_mode
,
LOCK_REC_NOT_GAP
,
thr
);
}
else
{
err
=
lock_clust_rec_read_check_and_lock
(
0
,
clust_rec
,
index
,
node
->
row_lock_mode
,
LOCK_ORDINARY
,
thr
);
}
}
if
(
err
!=
DB_SUCCESS
)
{
if
(
err
!=
DB_SUCCESS
)
{
...
@@ -1210,16 +1211,18 @@ rec_loop:
...
@@ -1210,16 +1211,18 @@ rec_loop:
not used.
not used.
*/
*/
if
(
srv_locks_unsafe_for_binlog
)
if
(
srv_locks_unsafe_for_binlog
)
{
{
err
=
sel_set_rec_lock
(
page_rec_get_next
(
rec
),
err
=
sel_set_rec_lock
(
page_rec_get_next
(
rec
),
index
,
index
,
node
->
row_lock_mode
,
LOCK_REC_NOT_GAP
,
thr
);
node
->
row_lock_mode
,
}
LOCK_REC_NOT_GAP
,
thr
);
else
}
else
{
{
err
=
sel_set_rec_lock
(
page_rec_get_next
(
rec
),
err
=
sel_set_rec_lock
(
page_rec_get_next
(
rec
),
index
,
index
,
node
->
row_lock_mode
,
LOCK_ORDINARY
,
thr
);
node
->
row_lock_mode
,
LOCK_ORDINARY
,
thr
);
}
}
if
(
err
!=
DB_SUCCESS
)
{
if
(
err
!=
DB_SUCCESS
)
{
/* Note that in this case we will store in pcur
/* Note that in this case we will store in pcur
the PREDECESSOR of the record we are waiting
the PREDECESSOR of the record we are waiting
...
@@ -1250,13 +1253,10 @@ rec_loop:
...
@@ -1250,13 +1253,10 @@ rec_loop:
not used.
not used.
*/
*/
if
(
srv_locks_unsafe_for_binlog
)
if
(
srv_locks_unsafe_for_binlog
)
{
{
err
=
sel_set_rec_lock
(
rec
,
index
,
node
->
row_lock_mode
,
err
=
sel_set_rec_lock
(
rec
,
index
,
node
->
row_lock_mode
,
LOCK_REC_NOT_GAP
,
thr
);
LOCK_REC_NOT_GAP
,
thr
);
}
}
else
{
else
{
err
=
sel_set_rec_lock
(
rec
,
index
,
node
->
row_lock_mode
,
err
=
sel_set_rec_lock
(
rec
,
index
,
node
->
row_lock_mode
,
LOCK_ORDINARY
,
thr
);
LOCK_ORDINARY
,
thr
);
}
}
...
@@ -3209,8 +3209,7 @@ rec_loop:
...
@@ -3209,8 +3209,7 @@ rec_loop:
we do not lock gaps. Supremum record is really
we do not lock gaps. Supremum record is really
a gap and therefore we do not set locks there. */
a gap and therefore we do not set locks there. */
if
(
srv_locks_unsafe_for_binlog
==
FALSE
)
if
(
srv_locks_unsafe_for_binlog
==
FALSE
)
{
{
err
=
sel_set_rec_lock
(
rec
,
index
,
err
=
sel_set_rec_lock
(
rec
,
index
,
prebuilt
->
select_lock_type
,
prebuilt
->
select_lock_type
,
LOCK_ORDINARY
,
thr
);
LOCK_ORDINARY
,
thr
);
...
@@ -3312,11 +3311,18 @@ rec_loop:
...
@@ -3312,11 +3311,18 @@ rec_loop:
if
(
prebuilt
->
select_lock_type
!=
LOCK_NONE
if
(
prebuilt
->
select_lock_type
!=
LOCK_NONE
&&
set_also_gap_locks
)
{
&&
set_also_gap_locks
)
{
/* Try to place a lock on the index record */
/* Try to place a gap lock on the index
record only if innodb_locks_unsafe_for_binlog
option is not set */
if
(
srv_locks_unsafe_for_binlog
==
FALSE
)
{
err
=
sel_set_rec_lock
(
rec
,
index
,
err
=
sel_set_rec_lock
(
rec
,
index
,
prebuilt
->
select_lock_type
,
prebuilt
->
select_lock_type
,
LOCK_GAP
,
thr
);
LOCK_GAP
,
thr
);
}
if
(
err
!=
DB_SUCCESS
)
{
if
(
err
!=
DB_SUCCESS
)
{
goto
lock_wait_or_error
;
goto
lock_wait_or_error
;
...
@@ -3338,11 +3344,18 @@ rec_loop:
...
@@ -3338,11 +3344,18 @@ rec_loop:
if
(
prebuilt
->
select_lock_type
!=
LOCK_NONE
if
(
prebuilt
->
select_lock_type
!=
LOCK_NONE
&&
set_also_gap_locks
)
{
&&
set_also_gap_locks
)
{
/* Try to place a lock on the index record */
/* Try to place a gap lock on the index
record only if innodb_locks_unsafe_for_binlog
option is not set */
if
(
srv_locks_unsafe_for_binlog
==
FALSE
)
{
err
=
sel_set_rec_lock
(
rec
,
index
,
err
=
sel_set_rec_lock
(
rec
,
index
,
prebuilt
->
select_lock_type
,
prebuilt
->
select_lock_type
,
LOCK_GAP
,
thr
);
LOCK_GAP
,
thr
);
}
if
(
err
!=
DB_SUCCESS
)
{
if
(
err
!=
DB_SUCCESS
)
{
goto
lock_wait_or_error
;
goto
lock_wait_or_error
;
...
@@ -3378,16 +3391,13 @@ rec_loop:
...
@@ -3378,16 +3391,13 @@ rec_loop:
}
else
{
}
else
{
/* If innodb_locks_unsafe_for_binlog option is used,
/* If innodb_locks_unsafe_for_binlog option is used,
we lock only the record, i.e. next-key locking is
we lock only the record, i.e. next-key locking is
not used.
not used. */
*/
if
(
srv_locks_unsafe_for_binlog
)
if
(
srv_locks_unsafe_for_binlog
)
{
{
err
=
sel_set_rec_lock
(
rec
,
index
,
err
=
sel_set_rec_lock
(
rec
,
index
,
prebuilt
->
select_lock_type
,
prebuilt
->
select_lock_type
,
LOCK_REC_NOT_GAP
,
thr
);
LOCK_REC_NOT_GAP
,
thr
);
}
}
else
{
else
{
err
=
sel_set_rec_lock
(
rec
,
index
,
err
=
sel_set_rec_lock
(
rec
,
index
,
prebuilt
->
select_lock_type
,
prebuilt
->
select_lock_type
,
LOCK_ORDINARY
,
thr
);
LOCK_ORDINARY
,
thr
);
...
...
mysql-test/r/myisam.result
View file @
2e63f22a
...
@@ -529,6 +529,7 @@ show keys from t1;
...
@@ -529,6 +529,7 @@ show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
create table t2 (a int);
create table t2 (a int);
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
insert t1 select * from t2;
insert t1 select * from t2;
show keys from t1;
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
...
...
mysql-test/r/ndb_index_unique.result
View file @
2e63f22a
...
@@ -44,6 +44,51 @@ a b c
...
@@ -44,6 +44,51 @@ a b c
7 8 3
7 8 3
8 2 3
8 2 3
drop table t1;
drop table t1;
CREATE TABLE t1 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned,
c int unsigned,
UNIQUE bc(b,c)
) engine = ndb;
insert into t1 values(1,1,1),(2,NULL,2),(3,NULL,NULL),(4,4,NULL);
select * from t1 use index (bc) where b IS NULL order by a;
a b c
2 NULL 2
3 NULL NULL
select * from t1 use index (bc)order by a;
a b c
1 1 1
2 NULL 2
3 NULL NULL
4 4 NULL
select * from t1 use index (bc) order by a;
a b c
1 1 1
2 NULL 2
3 NULL NULL
4 4 NULL
select * from t1 use index (PRIMARY) where b IS NULL order by a;
a b c
2 NULL 2
3 NULL NULL
select * from t1 use index (bc) where b IS NULL order by a;
a b c
2 NULL 2
3 NULL NULL
select * from t1 use index (bc) where b IS NULL and c IS NULL order by a;
a b c
select * from t1 use index (bc) where b IS NULL and c = 2 order by a;
a b c
select * from t1 use index (bc) where b < 4 order by a;
a b c
1 1 1
select * from t1 use index (bc) where b IS NOT NULL order by a;
a b c
1 1 1
4 4 NULL
insert into t1 values(5,1,1);
ERROR 23000: Duplicate entry '5' for key 1
drop table t1;
CREATE TABLE t2 (
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
b int unsigned not null,
...
@@ -87,6 +132,13 @@ a b c
...
@@ -87,6 +132,13 @@ a b c
7 8 3
7 8 3
8 2 3
8 2 3
drop table t2;
drop table t2;
CREATE TABLE t2 (
a int unsigned NOT NULL PRIMARY KEY,
b int unsigned not null,
c int unsigned,
UNIQUE USING HASH (b, c)
) engine=ndbcluster;
ERROR 42000: Column 'c' is used with UNIQUE or INDEX but is not defined as NOT NULL
CREATE TABLE t3 (
CREATE TABLE t3 (
a int unsigned NOT NULL,
a int unsigned NOT NULL,
b int unsigned not null,
b int unsigned not null,
...
...
mysql-test/r/subselect.result
View file @
2e63f22a
...
@@ -1990,3 +1990,18 @@ ac
...
@@ -1990,3 +1990,18 @@ ac
700
700
NULL
NULL
drop tables t1,t2;
drop tables t1,t2;
create table t1 (a int not null, b int not null, c int, primary key (a,b));
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
set @b:= 0;
explain select sum(a) from t1 where b > @b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using where; Using index
set @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
do @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
drop table t1;
mysql-test/t/myisam.test
View file @
2e63f22a
...
@@ -498,11 +498,12 @@ alter table t1 disable keys;
...
@@ -498,11 +498,12 @@ alter table t1 disable keys;
show
keys
from
t1
;
show
keys
from
t1
;
create
table
t2
(
a
int
);
create
table
t2
(
a
int
);
let
$i
=
1000
;
let
$i
=
1000
;
set
@@
rand_seed1
=
31415926
,
@@
rand_seed2
=
2718281828
;
--
disable_query_log
--
disable_query_log
while
(
$i
)
while
(
$i
)
{
{
dec
$i
;
dec
$i
;
eval
insert
t2
values
(
rand
()
*
100000
);
insert
t2
values
(
rand
()
*
100000
);
}
}
--
enable_query_log
--
enable_query_log
insert
t1
select
*
from
t2
;
insert
t1
select
*
from
t2
;
...
...
mysql-test/t/ndb_autodiscover.test
View file @
2e63f22a
...
@@ -199,7 +199,7 @@ insert into t4 values (1, "Automatic");
...
@@ -199,7 +199,7 @@ insert into t4 values (1, "Automatic");
select
*
from
t4
;
select
*
from
t4
;
# Remove the table from NDB
# Remove the table from NDB
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
t4
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
t4
>
/
dev
/
null
;
#
#
# Test that correct error is returned
# Test that correct error is returned
...
@@ -230,7 +230,7 @@ select * from t4;
...
@@ -230,7 +230,7 @@ select * from t4;
flush
tables
;
flush
tables
;
# Remove the table from NDB
# Remove the table from NDB
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
t4
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
t4
>
/
dev
/
null
;
SHOW
TABLES
;
SHOW
TABLES
;
...
@@ -264,8 +264,8 @@ insert into t8 values (8, "myisam table 8");
...
@@ -264,8 +264,8 @@ insert into t8 values (8, "myisam table 8");
insert
into
t9
values
(
9
);
insert
into
t9
values
(
9
);
# Remove t3, t5 from NDB
# Remove t3, t5 from NDB
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
t3
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
t3
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
t5
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
t5
>
/
dev
/
null
;
# Remove t6, t7 from disk
# Remove t6, t7 from disk
system
rm
var
/
master
-
data
/
test
/
t6
.
frm
>
/
dev
/
null
;
system
rm
var
/
master
-
data
/
test
/
t6
.
frm
>
/
dev
/
null
;
system
rm
var
/
master
-
data
/
test
/
t7
.
frm
>
/
dev
/
null
;
system
rm
var
/
master
-
data
/
test
/
t7
.
frm
>
/
dev
/
null
;
...
@@ -306,8 +306,8 @@ insert into t8 values (8, "myisam table 8");
...
@@ -306,8 +306,8 @@ insert into t8 values (8, "myisam table 8");
insert
into
t9
values
(
9
);
insert
into
t9
values
(
9
);
# Remove t3, t5 from NDB
# Remove t3, t5 from NDB
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
t3
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
t3
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
t5
>
/
dev
/
null
;
system
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
t5
>
/
dev
/
null
;
# Remove t6, t7 from disk
# Remove t6, t7 from disk
system
rm
var
/
master
-
data
/
test
/
t6
.
frm
>
/
dev
/
null
;
system
rm
var
/
master
-
data
/
test
/
t6
.
frm
>
/
dev
/
null
;
system
rm
var
/
master
-
data
/
test
/
t7
.
frm
>
/
dev
/
null
;
system
rm
var
/
master
-
data
/
test
/
t7
.
frm
>
/
dev
/
null
;
...
@@ -479,4 +479,4 @@ create table t10 (
...
@@ -479,4 +479,4 @@ create table t10 (
insert
into
t10
values
(
1
,
'kalle'
);
insert
into
t10
values
(
1
,
'kalle'
);
--
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
d
test
`$NDB_TOOLS_DIR/ndb_show_table
s | grep BLOB`
>
/
dev
/
null
2
>&
1
||
true
--
exec
$NDB_TOOLS_DIR
/
ndb_drop_table
-
-
no
-
defaults
-
d
test
`$NDB_TOOLS_DIR/ndb_show_tables --no-default
s | grep BLOB`
>
/
dev
/
null
2
>&
1
||
true
mysql-test/t/ndb_index_unique.test
View file @
2e63f22a
...
@@ -30,6 +30,32 @@ select * from t1 order by a;
...
@@ -30,6 +30,32 @@ select * from t1 order by a;
drop
table
t1
;
drop
table
t1
;
#
# Indexing NULL values
#
CREATE
TABLE
t1
(
a
int
unsigned
NOT
NULL
PRIMARY
KEY
,
b
int
unsigned
,
c
int
unsigned
,
UNIQUE
bc
(
b
,
c
)
)
engine
=
ndb
;
insert
into
t1
values
(
1
,
1
,
1
),(
2
,
NULL
,
2
),(
3
,
NULL
,
NULL
),(
4
,
4
,
NULL
);
select
*
from
t1
use
index
(bc) where b IS NULL order by a
;
select
*
from
t1
use
index
(bc)order by a
;
select
*
from
t1
use
index
(bc) order by a
;
select
*
from
t1
use
index
(PRIMARY) where b IS NULL order by a
;
select
*
from
t1
use
index
(bc) where b IS NULL order by a
;
select
*
from
t1
use
index
(bc) where b IS NULL and c IS NULL order by a
;
select
*
from
t1
use
index
(bc) where b IS NULL and c = 2 order by a
;
select
*
from
t1
use
index
(bc) where b < 4 order by a
;
select
*
from
t1
use
index
(bc) where b IS NOT NULL order by a
;
--
error
1062
insert
into
t1
values
(
5
,
1
,
1
);
drop
table
t1
;
#
#
# Show use of UNIQUE USING HASH indexes
# Show use of UNIQUE USING HASH indexes
...
@@ -58,6 +84,14 @@ select * from t2 order by a;
...
@@ -58,6 +84,14 @@ select * from t2 order by a;
drop
table
t2
;
drop
table
t2
;
--
error
1121
CREATE
TABLE
t2
(
a
int
unsigned
NOT
NULL
PRIMARY
KEY
,
b
int
unsigned
not
null
,
c
int
unsigned
,
UNIQUE
USING
HASH
(
b
,
c
)
)
engine
=
ndbcluster
;
#
#
# Show use of PRIMARY KEY USING HASH indexes
# Show use of PRIMARY KEY USING HASH indexes
#
#
...
...
mysql-test/t/subselect.test
View file @
2e63f22a
...
@@ -1282,3 +1282,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
...
@@ -1282,3 +1282,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
SELECT
b
.
sc
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
SELECT
b
.
sc
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
SELECT
b
.
ac
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
SELECT
b
.
ac
FROM
(
SELECT
(
SELECT
a
.
access
FROM
t1
a
WHERE
a
.
map
=
op
.
map
AND
a
.
slave
=
op
.
pid
AND
a
.
master
=
1
)
ac
FROM
t2
op
WHERE
op
.
id
=
12
AND
op
.
map
=
0
)
b
;
drop
tables
t1
,
t2
;
drop
tables
t1
,
t2
;
#
# Test for bug #6462. "Same request on same data returns different
# results." a.k.a. "Proper cleanup of subqueries is missing for
# SET and DO statements".
#
create
table
t1
(
a
int
not
null
,
b
int
not
null
,
c
int
,
primary
key
(
a
,
b
));
insert
into
t1
values
(
1
,
1
,
1
),
(
2
,
2
,
2
),
(
3
,
3
,
3
);
set
@
b
:=
0
;
# Let us check that subquery will use covering index
explain
select
sum
(
a
)
from
t1
where
b
>
@
b
;
# This should not crash -debug server due to failing assertion
set
@
a
:=
(
select
sum
(
a
)
from
t1
where
b
>
@
b
);
# And this should not falsely report index usage
explain
select
a
from
t1
where
c
=
2
;
# Same for DO statement
do
@
a
:=
(
select
sum
(
a
)
from
t1
where
b
>
@
b
);
explain
select
a
from
t1
where
c
=
2
;
drop
table
t1
;
sql/ha_ndbcluster.cc
View file @
2e63f22a
...
@@ -796,6 +796,7 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
...
@@ -796,6 +796,7 @@ int ha_ndbcluster::build_index_list(TABLE *tab, enum ILBP phase)
error
=
create_unique_index
(
unique_index_name
,
key_info
);
error
=
create_unique_index
(
unique_index_name
,
key_info
);
break
;
break
;
case
UNIQUE_INDEX
:
case
UNIQUE_INDEX
:
if
(
!
(
error
=
check_index_fields_not_null
(
i
)))
error
=
create_unique_index
(
unique_index_name
,
key_info
);
error
=
create_unique_index
(
unique_index_name
,
key_info
);
break
;
break
;
case
ORDERED_INDEX
:
case
ORDERED_INDEX
:
...
@@ -848,6 +849,26 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const
...
@@ -848,6 +849,26 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_type_from_table(uint inx) const
ORDERED_INDEX
);
ORDERED_INDEX
);
}
}
int
ha_ndbcluster
::
check_index_fields_not_null
(
uint
inx
)
{
KEY
*
key_info
=
table
->
key_info
+
inx
;
KEY_PART_INFO
*
key_part
=
key_info
->
key_part
;
KEY_PART_INFO
*
end
=
key_part
+
key_info
->
key_parts
;
DBUG_ENTER
(
"check_index_fields_not_null"
);
for
(;
key_part
!=
end
;
key_part
++
)
{
Field
*
field
=
key_part
->
field
;
if
(
field
->
maybe_null
())
{
my_printf_error
(
ER_NULL_COLUMN_IN_INDEX
,
ER
(
ER_NULL_COLUMN_IN_INDEX
),
MYF
(
0
),
field
->
field_name
);
DBUG_RETURN
(
ER_NULL_COLUMN_IN_INDEX
);
}
}
DBUG_RETURN
(
0
);
}
void
ha_ndbcluster
::
release_metadata
()
void
ha_ndbcluster
::
release_metadata
()
{
{
...
...
sql/ha_ndbcluster.h
View file @
2e63f22a
...
@@ -160,6 +160,7 @@ class ha_ndbcluster: public handler
...
@@ -160,6 +160,7 @@ class ha_ndbcluster: public handler
void
release_metadata
();
void
release_metadata
();
NDB_INDEX_TYPE
get_index_type
(
uint
idx_no
)
const
;
NDB_INDEX_TYPE
get_index_type
(
uint
idx_no
)
const
;
NDB_INDEX_TYPE
get_index_type_from_table
(
uint
index_no
)
const
;
NDB_INDEX_TYPE
get_index_type_from_table
(
uint
index_no
)
const
;
int
check_index_fields_not_null
(
uint
index_no
);
int
pk_read
(
const
byte
*
key
,
uint
key_len
,
byte
*
buf
);
int
pk_read
(
const
byte
*
key
,
uint
key_len
,
byte
*
buf
);
int
complemented_pk_read
(
const
byte
*
old_data
,
byte
*
new_data
);
int
complemented_pk_read
(
const
byte
*
old_data
,
byte
*
new_data
);
...
...
sql/set_var.cc
View file @
2e63f22a
...
@@ -2733,13 +2733,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
...
@@ -2733,13 +2733,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
while
((
var
=
it
++
))
while
((
var
=
it
++
))
{
{
if
((
error
=
var
->
check
(
thd
)))
if
((
error
=
var
->
check
(
thd
)))
DBUG_RETURN
(
error
)
;
goto
err
;
}
}
if
(
thd
->
net
.
report_error
)
if
(
!
thd
->
net
.
report_error
)
DBUG_RETURN
(
1
);
{
it
.
rewind
();
it
.
rewind
();
while
((
var
=
it
++
))
while
((
var
=
it
++
))
error
|=
var
->
update
(
thd
);
// Returns 0, -1 or 1
error
|=
var
->
update
(
thd
);
// Returns 0, -1 or 1
}
else
error
=
1
;
err:
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
DBUG_RETURN
(
error
);
DBUG_RETURN
(
error
);
}
}
...
...
sql/sql_do.cc
View file @
2e63f22a
...
@@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values)
...
@@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values)
DBUG_RETURN
(
-
1
);
DBUG_RETURN
(
-
1
);
while
((
value
=
li
++
))
while
((
value
=
li
++
))
value
->
val_int
();
value
->
val_int
();
free_underlaid_joins
(
thd
,
&
thd
->
lex
->
select_lex
);
thd
->
clear_error
();
// DO always is OK
thd
->
clear_error
();
// DO always is OK
send_ok
(
thd
);
send_ok
(
thd
);
DBUG_RETURN
(
0
);
DBUG_RETURN
(
0
);
...
...
strings/uca-dump.c
View file @
2e63f22a
...
@@ -218,7 +218,6 @@ int main(int ac, char **av)
...
@@ -218,7 +218,6 @@ int main(int ac, char **av)
*/
*/
if
(
ndefs
==
MY_UCA_NCHARS
)
if
(
ndefs
==
MY_UCA_NCHARS
)
{
{
printf
(
"/* Don't dump w=%d pg=%3X: ndefs=%d */
\n
"
,
w
,
page
,
ndefs
);
continue
;
continue
;
}
}
switch
(
maxnum
)
switch
(
maxnum
)
...
@@ -263,7 +262,17 @@ int main(int ac, char **av)
...
@@ -263,7 +262,17 @@ int main(int ac, char **av)
for
(
i
=
0
;
i
<
maxnum
;
i
++
)
for
(
i
=
0
;
i
<
maxnum
;
i
++
)
{
{
printf
(
"0x%04X"
,(
int
)
weight
[
i
]);
/*
Invert weights for secondary level to
sort upper case letters before their
lower case counter part.
*/
int
tmp
=
weight
[
i
];
if
(
w
==
2
&&
tmp
)
tmp
=
(
int
)(
0x100
-
weight
[
i
]);
printf
(
"0x%04X"
,
tmp
);
if
((
offs
+
1
!=
MY_UCA_NCHARS
)
||
(
i
+
1
!=
maxnum
))
if
((
offs
+
1
!=
MY_UCA_NCHARS
)
||
(
i
+
1
!=
maxnum
))
printf
(
","
);
printf
(
","
);
nchars
++
;
nchars
++
;
...
@@ -281,7 +290,7 @@ int main(int ac, char **av)
...
@@ -281,7 +290,7 @@ int main(int ac, char **av)
printf
(
"};
\n\n
"
);
printf
(
"};
\n\n
"
);
}
}
printf
(
"uchar uca
l
%s[%d]={
\n
"
,
pname
[
w
],
MY_UCA_NPAGES
);
printf
(
"uchar uca
_length
%s[%d]={
\n
"
,
pname
[
w
],
MY_UCA_NPAGES
);
for
(
page
=
0
;
page
<
MY_UCA_NPAGES
;
page
++
)
for
(
page
=
0
;
page
<
MY_UCA_NPAGES
;
page
++
)
{
{
printf
(
"%d%s%s"
,
pagemaxlen
[
page
],
page
<
MY_UCA_NPAGES
-
1
?
","
:
""
,(
page
+
1
)
%
16
?
""
:
"
\n
"
);
printf
(
"%d%s%s"
,
pagemaxlen
[
page
],
page
<
MY_UCA_NPAGES
-
1
?
","
:
""
,(
page
+
1
)
%
16
?
""
:
"
\n
"
);
...
@@ -289,7 +298,7 @@ int main(int ac, char **av)
...
@@ -289,7 +298,7 @@ int main(int ac, char **av)
printf
(
"};
\n
"
);
printf
(
"};
\n
"
);
printf
(
"uint16 *uca
w
%s[%d]={
\n
"
,
pname
[
w
],
MY_UCA_NPAGES
);
printf
(
"uint16 *uca
_weight
%s[%d]={
\n
"
,
pname
[
w
],
MY_UCA_NPAGES
);
for
(
page
=
0
;
page
<
MY_UCA_NPAGES
;
page
++
)
for
(
page
=
0
;
page
<
MY_UCA_NPAGES
;
page
++
)
{
{
const
char
*
comma
=
page
<
MY_UCA_NPAGES
-
1
?
","
:
""
;
const
char
*
comma
=
page
<
MY_UCA_NPAGES
-
1
?
","
:
""
;
...
...
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