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
b3cbd004
Commit
b3cbd004
authored
Jul 28, 2005
by
monty@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups during review of new code
Ensure mysql_close() is called if mysql_set_character_set() fails
parent
510d9a19
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
261 additions
and
316 deletions
+261
-316
libmysql/libmysql.c
libmysql/libmysql.c
+1
-6
mysql-test/r/select.result
mysql-test/r/select.result
+93
-138
mysql-test/r/type_newdecimal.result
mysql-test/r/type_newdecimal.result
+7
-0
mysql-test/t/select.test
mysql-test/t/select.test
+88
-118
mysql-test/t/type_newdecimal.test
mysql-test/t/type_newdecimal.test
+4
-0
mysys/charset.c
mysys/charset.c
+2
-1
mysys/default.c
mysys/default.c
+26
-26
sql-common/client.c
sql-common/client.c
+10
-2
sql/log.cc
sql/log.cc
+1
-1
sql/sp.cc
sql/sp.cc
+4
-1
sql/sql_acl.cc
sql/sql_acl.cc
+2
-2
sql/sql_base.cc
sql/sql_base.cc
+8
-8
sql/sql_show.cc
sql/sql_show.cc
+9
-9
sql/sql_trigger.cc
sql/sql_trigger.cc
+1
-2
strings/decimal.c
strings/decimal.c
+5
-2
No files found.
libmysql/libmysql.c
View file @
b3cbd004
...
...
@@ -1599,13 +1599,8 @@ mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
ulong
length
)
{
if
(
mysql
->
server_status
&
SERVER_STATUS_NO_BACKSLASH_ESCAPES
)
{
return
escape_quotes_for_mysql
(
mysql
->
charset
,
to
,
0
,
from
,
length
);
}
else
{
return
escape_string_for_mysql
(
mysql
->
charset
,
to
,
0
,
from
,
length
);
}
return
escape_string_for_mysql
(
mysql
->
charset
,
to
,
0
,
from
,
length
);
}
...
...
mysql-test/r/select.result
View file @
b3cbd004
...
...
@@ -2492,6 +2492,99 @@ select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid
id name gid uid ident level
1 fs NULL NULL 0 READ
drop table t1,t2,t3;
CREATE TABLE t1 (
acct_id int(11) NOT NULL default '0',
profile_id smallint(6) default NULL,
UNIQUE KEY t1$acct_id (acct_id),
KEY t1$profile_id (profile_id)
);
INSERT INTO t1 VALUES (132,17),(133,18);
CREATE TABLE t2 (
profile_id smallint(6) default NULL,
queue_id int(11) default NULL,
seq int(11) default NULL,
KEY t2$queue_id (queue_id)
);
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
CREATE TABLE t3 (
id int(11) NOT NULL default '0',
qtype int(11) default NULL,
seq int(11) default NULL,
warn_lvl int(11) default NULL,
crit_lvl int(11) default NULL,
rr1 tinyint(4) NOT NULL default '0',
rr2 int(11) default NULL,
default_queue tinyint(4) NOT NULL default '0',
KEY t3$qtype (qtype),
KEY t3$id (id)
);
INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q
WHERE
(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND
(pq.queue_id = q.id) AND (q.rr1 <> 1);
COUNT(*)
4
drop table t1,t2,t3;
create table t1 (f1 int);
insert into t1 values (1),(NULL);
create table t2 (f2 int, f3 int, f4 int);
create index idx1 on t2 (f4);
insert into t2 values (1,2,3),(2,4,6);
select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)
from t2 C where A.f4 = C.f4) or A.f3 IS NULL;
f2
1
NULL
drop table t1,t2;
create table t2 (a tinyint unsigned);
create index t2i on t2(a);
insert into t2 values (0), (254), (255);
explain select * from t2 where a > -1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index
select * from t2 where a > -1;
a
0
254
255
drop table t2;
CREATE TABLE t1 (a int, b int, c int);
INSERT INTO t1
SELECT 50, 3, 3 FROM DUAL
WHERE NOT EXISTS
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
SELECT * FROM t1;
a b c
50 3 3
INSERT INTO t1
SELECT 50, 3, 3 FROM DUAL
WHERE NOT EXISTS
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
select found_rows();
found_rows()
0
SELECT * FROM t1;
a b c
50 3 3
select count(*) from t1;
count(*)
1
select found_rows();
found_rows()
1
select count(*) from t1 limit 2,3;
count(*)
select found_rows();
found_rows()
0
select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3;
count(*)
select found_rows();
found_rows()
1
DROP TABLE t1;
CREATE TABLE t1 ( city char(30) );
INSERT INTO t1 VALUES ('London');
INSERT INTO t1 VALUES ('Paris');
...
...
@@ -2579,25 +2672,6 @@ K2C4 K4N4 F2I4
WART 0100 1
WART 0200 1
WART 0300 3
select found_rows();
found_rows()
3
select count(*) from t1;
count(*)
15
select found_rows();
found_rows()
1
select count(*) from t1 limit 2,3;
count(*)
select found_rows();
found_rows()
0
select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3;
count(*)
select found_rows();
found_rows()
1
DROP TABLE t1;
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
CREATE TABLE t2 ( a BLOB, INDEX (a(20)) );
...
...
@@ -2612,51 +2686,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
1 SIMPLE t2 ref a a 23 test.t1.a 2
DROP TABLE t1, t2;
CREATE TABLE t1 ( city char(30) );
INSERT INTO t1 VALUES ('London');
INSERT INTO t1 VALUES ('Paris');
SELECT * FROM t1 WHERE city='London';
city
London
SELECT * FROM t1 WHERE city='london';
city
London
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE city='London' AND city='london';
city
London
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
city
London
DROP TABLE t1;
create table t1 (a int(11) unsigned, b int(11) unsigned);
insert into t1 values (1,0), (1,1), (1,2);
select a-b from t1 order by 1;
a-b
0
1
18446744073709551615
select a-b , (a-b < 0) from t1 order by 1;
a-b (a-b < 0)
0 0
1 0
18446744073709551615 0
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
d (a-b >= 0) b
1 1 0
0 1 1
18446744073709551615 1 2
select cast((a - b) as unsigned) from t1 order by 1;
cast((a - b) as unsigned)
0
1
18446744073709551615
drop table t1;
create table t1 (a int, b int);
create table t2 like t1;
select t1.a from (t1 inner join t2 on t1.a=t2.a) where t2.a=1;
...
...
@@ -2730,77 +2759,3 @@ DROP TABLE t1,t2;
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0
16 16 2 2
CREATE TABLE t1 (
acct_id int(11) NOT NULL default '0',
profile_id smallint(6) default NULL,
UNIQUE KEY t1$acct_id (acct_id),
KEY t1$profile_id (profile_id)
);
INSERT INTO t1 VALUES (132,17),(133,18);
CREATE TABLE t2 (
profile_id smallint(6) default NULL,
queue_id int(11) default NULL,
seq int(11) default NULL,
KEY t2$queue_id (queue_id)
);
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
CREATE TABLE t3 (
id int(11) NOT NULL default '0',
qtype int(11) default NULL,
seq int(11) default NULL,
warn_lvl int(11) default NULL,
crit_lvl int(11) default NULL,
rr1 tinyint(4) NOT NULL default '0',
rr2 int(11) default NULL,
default_queue tinyint(4) NOT NULL default '0',
KEY t3$qtype (qtype),
KEY t3$id (id)
);
INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q
WHERE
(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND
(pq.queue_id = q.id) AND (q.rr1 <> 1);
COUNT(*)
4
drop table t1,t2,t3;
create table t1 (f1 int);
insert into t1 values (1),(NULL);
create table t2 (f2 int, f3 int, f4 int);
create index idx1 on t2 (f4);
insert into t2 values (1,2,3),(2,4,6);
select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)
from t2 C where A.f4 = C.f4) or A.f3 IS NULL;
f2
1
NULL
drop table t1,t2;
create table t2 (a tinyint unsigned);
create index t2i on t2(a);
insert into t2 values (0), (254), (255);
explain select * from t2 where a > -1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index
select * from t2 where a > -1;
a
0
254
255
drop table t2;
CREATE TABLE t1 (a int, b int, c int);
INSERT INTO t1
SELECT 50, 3, 3 FROM DUAL
WHERE NOT EXISTS
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
SELECT * FROM t1;
a b c
50 3 3
INSERT INTO t1
SELECT 50, 3, 3 FROM DUAL
WHERE NOT EXISTS
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
SELECT * FROM t1;
a b c
50 3 3
DROP TABLE t1;
mysql-test/r/type_newdecimal.result
View file @
b3cbd004
...
...
@@ -946,6 +946,13 @@ t1 CREATE TABLE `t1` (
`sl` decimal(5,5) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (sl decimal(65, 30));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`sl` decimal(65,30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (
f1 decimal unsigned not null default 17.49,
f2 decimal unsigned not null default 17.68,
...
...
mysql-test/t/select.test
View file @
b3cbd004
...
...
@@ -2080,6 +2080,94 @@ select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid
drop
table
t1
,
t2
,
t3
;
# Test for BUG#11700
CREATE
TABLE
t1
(
acct_id
int
(
11
)
NOT
NULL
default
'0'
,
profile_id
smallint
(
6
)
default
NULL
,
UNIQUE
KEY
t1
$acct_id
(
acct_id
),
KEY
t1
$profile_id
(
profile_id
)
);
INSERT
INTO
t1
VALUES
(
132
,
17
),(
133
,
18
);
CREATE
TABLE
t2
(
profile_id
smallint
(
6
)
default
NULL
,
queue_id
int
(
11
)
default
NULL
,
seq
int
(
11
)
default
NULL
,
KEY
t2
$queue_id
(
queue_id
)
);
INSERT
INTO
t2
VALUES
(
17
,
31
,
4
),(
17
,
30
,
3
),(
17
,
36
,
2
),(
17
,
37
,
1
);
CREATE
TABLE
t3
(
id
int
(
11
)
NOT
NULL
default
'0'
,
qtype
int
(
11
)
default
NULL
,
seq
int
(
11
)
default
NULL
,
warn_lvl
int
(
11
)
default
NULL
,
crit_lvl
int
(
11
)
default
NULL
,
rr1
tinyint
(
4
)
NOT
NULL
default
'0'
,
rr2
int
(
11
)
default
NULL
,
default_queue
tinyint
(
4
)
NOT
NULL
default
'0'
,
KEY
t3
$qtype
(
qtype
),
KEY
t3
$id
(
id
)
);
INSERT
INTO
t3
VALUES
(
30
,
1
,
29
,
NULL
,
NULL
,
0
,
NULL
,
0
),(
31
,
1
,
28
,
NULL
,
NULL
,
0
,
NULL
,
0
),
(
36
,
1
,
34
,
NULL
,
NULL
,
0
,
NULL
,
0
),(
37
,
1
,
35
,
NULL
,
NULL
,
0
,
121
,
0
);
SELECT
COUNT
(
*
)
FROM
t1
a
STRAIGHT_JOIN
t2
pq
STRAIGHT_JOIN
t3
q
WHERE
(
pq
.
profile_id
=
a
.
profile_id
)
AND
(
a
.
acct_id
=
132
)
AND
(
pq
.
queue_id
=
q
.
id
)
AND
(
q
.
rr1
<>
1
);
drop
table
t1
,
t2
,
t3
;
#
# Bug #11482 Wrongly applied optimization was erroneously rejecting valid
# rows
create
table
t1
(
f1
int
);
insert
into
t1
values
(
1
),(
NULL
);
create
table
t2
(
f2
int
,
f3
int
,
f4
int
);
create
index
idx1
on
t2
(
f4
);
insert
into
t2
values
(
1
,
2
,
3
),(
2
,
4
,
6
);
select
A
.
f2
from
t1
left
join
t2
A
on
A
.
f2
=
f1
where
A
.
f3
=
(
select
min
(
f3
)
from
t2
C
where
A
.
f4
=
C
.
f4
)
or
A
.
f3
IS
NULL
;
drop
table
t1
,
t2
;
#
# Bug #11521 Negative integer keys incorrectly substituted for 0 during
# range analysis.
create
table
t2
(
a
tinyint
unsigned
);
create
index
t2i
on
t2
(
a
);
insert
into
t2
values
(
0
),
(
254
),
(
255
);
explain
select
*
from
t2
where
a
>
-
1
;
select
*
from
t2
where
a
>
-
1
;
drop
table
t2
;
#
# Bug #11745: SELECT ... FROM DUAL with WHERE condition
#
CREATE
TABLE
t1
(
a
int
,
b
int
,
c
int
);
INSERT
INTO
t1
SELECT
50
,
3
,
3
FROM
DUAL
WHERE
NOT
EXISTS
(
SELECT
*
FROM
t1
WHERE
a
=
50
AND
b
=
3
);
SELECT
*
FROM
t1
;
INSERT
INTO
t1
SELECT
50
,
3
,
3
FROM
DUAL
WHERE
NOT
EXISTS
(
SELECT
*
FROM
t1
WHERE
a
=
50
AND
b
=
3
);
select
found_rows
();
SELECT
*
FROM
t1
;
select
count
(
*
)
from
t1
;
select
found_rows
();
select
count
(
*
)
from
t1
limit
2
,
3
;
select
found_rows
();
select
SQL_CALC_FOUND_ROWS
count
(
*
)
from
t1
limit
2
,
3
;
select
found_rows
();
DROP
TABLE
t1
;
#
# Test case for bug 7098: substitution of a constant for a string field
#
...
...
@@ -2154,15 +2242,6 @@ SELECT K2C4, K4N4, F2I4 FROM t1
(
F2I4
=
2
AND
K2C4
=
'WART'
OR
(
F2I4
=
2
OR
K4N4
=
'0200'
));
SELECT
K2C4
,
K4N4
,
F2I4
FROM
t1
WHERE
K2C4
=
'WART'
AND
(
K2C4
=
'WART'
OR
K4N4
=
'0200'
);
select
found_rows
();
select
count
(
*
)
from
t1
;
select
found_rows
();
select
count
(
*
)
from
t1
limit
2
,
3
;
select
found_rows
();
select
SQL_CALC_FOUND_ROWS
count
(
*
)
from
t1
limit
2
,
3
;
select
found_rows
();
DROP
TABLE
t1
;
#
...
...
@@ -2180,36 +2259,6 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a;
DROP
TABLE
t1
,
t2
;
#
# Test case for bug 7098: substitution of a constant for a string field
#
CREATE
TABLE
t1
(
city
char
(
30
)
);
INSERT
INTO
t1
VALUES
(
'London'
);
INSERT
INTO
t1
VALUES
(
'Paris'
);
SELECT
*
FROM
t1
WHERE
city
=
'London'
;
SELECT
*
FROM
t1
WHERE
city
=
'london'
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
city
=
'London'
AND
city
=
'london'
;
SELECT
*
FROM
t1
WHERE
city
=
'London'
AND
city
=
'london'
;
EXPLAIN
SELECT
*
FROM
t1
WHERE
city
LIKE
'%london%'
AND
city
=
'London'
;
SELECT
*
FROM
t1
WHERE
city
LIKE
'%london%'
AND
city
=
'London'
;
DROP
TABLE
t1
;
#
# Bug#7425 inconsistent sort order on unsigned columns result of substraction
#
create
table
t1
(
a
int
(
11
)
unsigned
,
b
int
(
11
)
unsigned
);
insert
into
t1
values
(
1
,
0
),
(
1
,
1
),
(
1
,
2
);
select
a
-
b
from
t1
order
by
1
;
select
a
-
b
,
(
a
-
b
<
0
)
from
t1
order
by
1
;
select
a
-
b
as
d
,
(
a
-
b
>=
0
),
b
from
t1
group
by
b
having
d
>=
0
;
select
cast
((
a
-
b
)
as
unsigned
)
from
t1
order
by
1
;
drop
table
t1
;
#
# Bug#8670
#
...
...
@@ -2297,82 +2346,3 @@ DROP TABLE t1,t2;
#
select
x
'10'
+
0
,
X
'10'
+
0
,
b
'10'
+
0
,
B
'10'
+
0
;
# Test for BUG#11700
CREATE
TABLE
t1
(
acct_id
int
(
11
)
NOT
NULL
default
'0'
,
profile_id
smallint
(
6
)
default
NULL
,
UNIQUE
KEY
t1
$acct_id
(
acct_id
),
KEY
t1
$profile_id
(
profile_id
)
);
INSERT
INTO
t1
VALUES
(
132
,
17
),(
133
,
18
);
CREATE
TABLE
t2
(
profile_id
smallint
(
6
)
default
NULL
,
queue_id
int
(
11
)
default
NULL
,
seq
int
(
11
)
default
NULL
,
KEY
t2
$queue_id
(
queue_id
)
);
INSERT
INTO
t2
VALUES
(
17
,
31
,
4
),(
17
,
30
,
3
),(
17
,
36
,
2
),(
17
,
37
,
1
);
CREATE
TABLE
t3
(
id
int
(
11
)
NOT
NULL
default
'0'
,
qtype
int
(
11
)
default
NULL
,
seq
int
(
11
)
default
NULL
,
warn_lvl
int
(
11
)
default
NULL
,
crit_lvl
int
(
11
)
default
NULL
,
rr1
tinyint
(
4
)
NOT
NULL
default
'0'
,
rr2
int
(
11
)
default
NULL
,
default_queue
tinyint
(
4
)
NOT
NULL
default
'0'
,
KEY
t3
$qtype
(
qtype
),
KEY
t3
$id
(
id
)
);
INSERT
INTO
t3
VALUES
(
30
,
1
,
29
,
NULL
,
NULL
,
0
,
NULL
,
0
),(
31
,
1
,
28
,
NULL
,
NULL
,
0
,
NULL
,
0
),
(
36
,
1
,
34
,
NULL
,
NULL
,
0
,
NULL
,
0
),(
37
,
1
,
35
,
NULL
,
NULL
,
0
,
121
,
0
);
SELECT
COUNT
(
*
)
FROM
t1
a
STRAIGHT_JOIN
t2
pq
STRAIGHT_JOIN
t3
q
WHERE
(
pq
.
profile_id
=
a
.
profile_id
)
AND
(
a
.
acct_id
=
132
)
AND
(
pq
.
queue_id
=
q
.
id
)
AND
(
q
.
rr1
<>
1
);
drop
table
t1
,
t2
,
t3
;
#
# Bug #11482 Wrongly applied optimization was erroneously rejecting valid
# rows
create
table
t1
(
f1
int
);
insert
into
t1
values
(
1
),(
NULL
);
create
table
t2
(
f2
int
,
f3
int
,
f4
int
);
create
index
idx1
on
t2
(
f4
);
insert
into
t2
values
(
1
,
2
,
3
),(
2
,
4
,
6
);
select
A
.
f2
from
t1
left
join
t2
A
on
A
.
f2
=
f1
where
A
.
f3
=
(
select
min
(
f3
)
from
t2
C
where
A
.
f4
=
C
.
f4
)
or
A
.
f3
IS
NULL
;
drop
table
t1
,
t2
;
#
# Bug #11521 Negative integer keys incorrectly substituted for 0 during
# range analysis.
create
table
t2
(
a
tinyint
unsigned
);
create
index
t2i
on
t2
(
a
);
insert
into
t2
values
(
0
),
(
254
),
(
255
);
explain
select
*
from
t2
where
a
>
-
1
;
select
*
from
t2
where
a
>
-
1
;
drop
table
t2
;
#
# Bug #11745: SELECT ... FROM DUAL with WHERE condition
#
CREATE
TABLE
t1
(
a
int
,
b
int
,
c
int
);
INSERT
INTO
t1
SELECT
50
,
3
,
3
FROM
DUAL
WHERE
NOT
EXISTS
(
SELECT
*
FROM
t1
WHERE
a
=
50
AND
b
=
3
);
SELECT
*
FROM
t1
;
INSERT
INTO
t1
SELECT
50
,
3
,
3
FROM
DUAL
WHERE
NOT
EXISTS
(
SELECT
*
FROM
t1
WHERE
a
=
50
AND
b
=
3
);
SELECT
*
FROM
t1
;
DROP
TABLE
t1
;
mysql-test/t/type_newdecimal.test
View file @
b3cbd004
...
...
@@ -986,6 +986,10 @@ create table t1 (sl decimal(0,30));
create
table
t1
(
sl
decimal
(
5
,
5
));
show
create
table
t1
;
drop
table
t1
;
# Test limits
create
table
t1
(
sl
decimal
(
65
,
30
));
show
create
table
t1
;
drop
table
t1
;
#
# Bug 11557 (DEFAULT values rounded improperly
...
...
mysys/charset.c
View file @
b3cbd004
...
...
@@ -588,6 +588,7 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name,
~0 The escaped string did not fit in the to buffer
>=0 The length of the escaped string
*/
ulong
escape_string_for_mysql
(
CHARSET_INFO
*
charset_info
,
char
*
to
,
ulong
to_length
,
const
char
*
from
,
ulong
length
)
...
...
@@ -702,6 +703,7 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
~0 The escaped string did not fit in the to buffer
>=0 The length of the escaped string
*/
ulong
escape_quotes_for_mysql
(
CHARSET_INFO
*
charset_info
,
char
*
to
,
ulong
to_length
,
const
char
*
from
,
ulong
length
)
...
...
@@ -714,7 +716,6 @@ ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info,
#endif
for
(
end
=
from
+
length
;
from
<
end
;
from
++
)
{
char
escape
=
0
;
#ifdef USE_MB
int
tmp_length
;
if
(
use_mb_flag
&&
(
tmp_length
=
my_ismbchar
(
charset_info
,
from
,
end
)))
...
...
mysys/default.c
View file @
b3cbd004
...
...
@@ -917,6 +917,7 @@ typedef UINT (WINAPI *GET_SYSTEM_WINDOWS_DIRECTORY)(LPSTR, UINT);
static
uint
my_get_system_windows_directory
(
char
*
buffer
,
uint
size
)
{
uint
count
;
GET_SYSTEM_WINDOWS_DIRECTORY
func_ptr
=
(
GET_SYSTEM_WINDOWS_DIRECTORY
)
GetProcAddress
(
GetModuleHandle
(
"kernel32.dll"
),
...
...
@@ -924,22 +925,19 @@ static uint my_get_system_windows_directory(char *buffer, uint size)
if
(
func_ptr
)
return
func_ptr
(
buffer
,
size
);
else
{
/*
Windows NT 4.0 Terminal Server Edition:
To retrieve the shared Windows directory, call GetSystemDirectory and
trim the "System32" element from the end of the returned path.
*/
UINT
count
=
GetSystemDirectory
(
buffer
,
size
);
if
(
count
>
8
&&
stricmp
(
buffer
+
(
count
-
8
),
"
\\
System32"
)
==
0
)
{
count
-=
8
;
buffer
[
count
]
=
'\0'
;
}
return
count
;
/*
Windows NT 4.0 Terminal Server Edition:
To retrieve the shared Windows directory, call GetSystemDirectory and
trim the "System32" element from the end of the returned path.
*/
count
=
GetSystemDirectory
(
buffer
,
size
);
if
(
count
>
8
&&
stricmp
(
buffer
+
(
count
-
8
),
"
\\
System32"
)
==
0
)
{
count
-=
8
;
buffer
[
count
]
=
'\0'
;
}
return
count
;
}
#endif
...
...
@@ -952,7 +950,7 @@ static uint my_get_system_windows_directory(char *buffer, uint size)
2. GetWindowsDirectory()
3. GetSystemWindowsDirectory()
4. getenv(DEFAULT_HOME_ENV)
5. Direc
ot
ry above where the executable is located
5. Direc
to
ry above where the executable is located
6. ""
On Novell NetWare, this is:
...
...
@@ -1011,26 +1009,28 @@ static void init_default_directories()
Look for the second-to-last \ in the filename, but hang on
to a pointer after the last \ in case we're in the root of
a drive.
*/
*/
for
(
;
end
>
config_dir
;
end
--
)
{
if
(
*
end
==
FN_LIBCHAR
)
{
if
(
last
)
{
if
(
end
!=
config_dir
)
{
/* Keep the last '\' as this works both with D:\ and a directory */
end
[
1
]
=
0
;
}
else
{
/
'
No
parent
directory
(
strange
).
Use
current
dir
+
'\
' '
*/
last
[
1
]
=
0
;
}
break
;
}
last
=
end
;
}
}
if
(
last
)
{
if
(
end
!=
config_dir
&&
end
[
-
1
]
==
FN_DEVCHAR
)
/* Ended up with D:\ */
end
[
1
]
=
0
;
/* Keep one \ */
else
if
(
end
!=
config_dir
)
end
[
0
]
=
0
;
else
last
[
1
]
=
0
;
}
*
ptr
++=
(
char
*
)
&
config_dir
;
}
#endif
...
...
sql-common/client.c
View file @
b3cbd004
...
...
@@ -2206,14 +2206,22 @@ my_bool mysql_reconnect(MYSQL *mysql)
tmp_mysql
.
rpl_pivot
=
mysql
->
rpl_pivot
;
if
(
!
mysql_real_connect
(
&
tmp_mysql
,
mysql
->
host
,
mysql
->
user
,
mysql
->
passwd
,
mysql
->
db
,
mysql
->
port
,
mysql
->
unix_socket
,
mysql
->
client_flag
|
CLIENT_REMEMBER_OPTIONS
)
||
mysql_set_character_set
(
&
tmp_mysql
,
mysql
->
charset
->
csname
))
mysql
->
client_flag
|
CLIENT_REMEMBER_OPTIONS
))
{
mysql
->
net
.
last_errno
=
tmp_mysql
.
net
.
last_errno
;
strmov
(
mysql
->
net
.
last_error
,
tmp_mysql
.
net
.
last_error
);
strmov
(
mysql
->
net
.
sqlstate
,
tmp_mysql
.
net
.
sqlstate
);
DBUG_RETURN
(
1
);
}
if
(
mysql_set_character_set
(
&
tmp_mysql
,
mysql
->
charset
->
csname
))
{
mysql_close
(
&
tmp_mysql
);
mysql
->
net
.
last_errno
=
tmp_mysql
.
net
.
last_errno
;
strmov
(
mysql
->
net
.
last_error
,
tmp_mysql
.
net
.
last_error
);
strmov
(
mysql
->
net
.
sqlstate
,
tmp_mysql
.
net
.
sqlstate
);
DBUG_RETURN
(
1
);
}
tmp_mysql
.
reconnect
=
1
;
tmp_mysql
.
free_me
=
mysql
->
free_me
;
...
...
sql/log.cc
View file @
b3cbd004
...
...
@@ -2209,7 +2209,7 @@ bool flush_error_log()
On Windows is necessary a temporary file for to rename
the current error file.
*/
str
mov
(
strmov
(
err_temp
,
err_renamed
),
"-tmp"
);
str
xmov
(
err_temp
,
err_renamed
,
"-tmp"
,
NullS
);
(
void
)
my_delete
(
err_temp
,
MYF
(
0
));
if
(
freopen
(
err_temp
,
"a+"
,
stdout
))
{
...
...
sql/sp.cc
View file @
b3cbd004
...
...
@@ -1443,7 +1443,9 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
Sroutine_hash_entry
**
last_cached_routine_ptr
=
(
Sroutine_hash_entry
**
)
lex
->
sroutines_list
.
next
;
for
(
int
i
=
0
;
i
<
(
int
)
TRG_EVENT_MAX
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
TRG_ACTION_MAX
;
j
++
)
{
if
(
triggers
->
bodies
[
i
][
j
])
{
(
void
)
triggers
->
bodies
[
i
][
j
]
->
add_used_tables_to_table_list
(
thd
,
...
...
@@ -1451,7 +1453,8 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex,
sp_update_stmt_used_routines
(
thd
,
lex
,
&
triggers
->
bodies
[
i
][
j
]
->
m_sroutines
);
}
}
}
(
void
)
sp_cache_routines_and_add_tables_aux
(
thd
,
lex
,
*
last_cached_routine_ptr
);
}
...
...
sql/sql_acl.cc
View file @
b3cbd004
...
...
@@ -3547,9 +3547,9 @@ bool check_grant_db(THD *thd,const char *db)
{
char
helping
[
NAME_LEN
+
USERNAME_LENGTH
+
2
];
uint
len
;
bool
error
=
1
;
bool
error
=
1
;
len
=
(
uint
)
(
strmov
(
strmov
(
helping
,
thd
->
priv_user
)
+
1
,
db
)
-
helping
)
+
1
;
len
=
(
uint
)
(
strmov
(
strmov
(
helping
,
thd
->
priv_user
)
+
1
,
db
)
-
helping
)
+
1
;
rw_rdlock
(
&
LOCK_grant
);
for
(
uint
idx
=
0
;
idx
<
column_priv_hash
.
records
;
idx
++
)
...
...
sql/sql_base.cc
View file @
b3cbd004
...
...
@@ -1043,26 +1043,26 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
if
(
thd
->
locked_tables
||
thd
->
prelocked_mode
)
{
// Using table locks
TABLE
*
best_table
=
0
;
int
best_distance
=
INT_MIN
,
distance
;
int
best_distance
=
INT_MIN
;
for
(
table
=
thd
->
open_tables
;
table
;
table
=
table
->
next
)
{
if
(
table
->
s
->
key_length
==
key_length
&&
!
memcmp
(
table
->
s
->
table_cache_key
,
key
,
key_length
)
&&
!
my_strcasecmp
(
system_charset_info
,
table
->
alias
,
alias
)
&&
table
->
query_id
!=
thd
->
query_id
&&
/* skip tables already used
by this query
*/
table
->
query_id
!=
thd
->
query_id
&&
/* skip tables already used */
!
(
thd
->
prelocked_mode
&&
table
->
query_id
))
{
distance
=
((
int
)
table
->
reginfo
.
lock_type
-
(
int
)
table_list
->
lock_type
);
int
distance
=
((
int
)
table
->
reginfo
.
lock_type
-
(
int
)
table_list
->
lock_type
);
/*
Find a table that either has the exact lock type requested,
or has the best suitable lock. In case there is no locked
table that has an equal or higher lock than requested,
we
still maitain the best_table to produce an error message
about wrong lock mode on the table. The best_table is changed
we
us the closest matching lock to be able to produce an error
message
about wrong lock mode on the table. The best_table is changed
if bd < 0 <= d or bd < d < 0 or 0 <= d < bd.
distance < 0 -
we have not enough high lock mode
distance < 0 -
No suitable lock found
distance > 0 - we have lock mode higher then we require
distance == 0 - we have lock mode exactly which we need
*/
...
...
@@ -1071,7 +1071,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
{
best_distance
=
distance
;
best_table
=
table
;
if
(
best_distance
==
0
)
if
(
best_distance
==
0
)
// Found perfect lock
break
;
}
}
...
...
sql/sql_show.cc
View file @
b3cbd004
...
...
@@ -3543,9 +3543,8 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
if
(
table_list
->
schema_table_reformed
)
// show command
{
SELECT_LEX
*
sel
=
lex
->
current_select
;
uint
i
=
0
;
Item
*
item
;
Field_translator
*
transl
;
Field_translator
*
transl
,
*
org_transl
;
if
(
table_list
->
field_translation
)
{
...
...
@@ -3566,16 +3565,17 @@ int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list)
{
DBUG_RETURN
(
1
);
}
while
((
item
=
it
++
)
)
for
(
org_transl
=
transl
;
(
item
=
it
++
);
transl
++
)
{
char
*
name
=
item
->
name
;
transl
[
i
].
item
=
item
;
if
(
!
item
->
fixed
&&
item
->
fix_fields
(
thd
,
&
transl
[
i
].
item
))
transl
->
item
=
item
;
transl
->
name
=
item
->
name
;
if
(
!
item
->
fixed
&&
item
->
fix_fields
(
thd
,
&
transl
->
item
))
{
DBUG_RETURN
(
1
);
transl
[
i
++
].
name
=
name
;
}
}
table_list
->
field_translation
=
transl
;
table_list
->
field_translation_end
=
transl
+
sel
->
item_list
.
elements
;
table_list
->
field_translation
=
org_
transl
;
table_list
->
field_translation_end
=
transl
;
}
DBUG_RETURN
(
0
);
...
...
sql/sql_trigger.cc
View file @
b3cbd004
...
...
@@ -564,8 +564,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
alloc_root
(
&
table
->
mem_root
,
triggers
->
sroutines_key
.
length
)))
DBUG_RETURN
(
1
);
triggers
->
sroutines_key
.
str
[
0
]
=
TYPE_ENUM_TRIGGER
;
strmov
(
strmov
(
strmov
(
triggers
->
sroutines_key
.
str
+
1
,
db
),
"."
),
table_name
);
strxmov
(
triggers
->
sroutines_key
.
str
+
1
,
db
,
"."
,
table_name
,
NullS
);
/*
TODO: This could be avoided if there is no triggers
...
...
strings/decimal.c
View file @
b3cbd004
...
...
@@ -745,14 +745,17 @@ int decimal_shift(decimal_t *dec, int shift)
new_point
=
ROUND_UP
(
new_point
)
-
1
;
if
(
new_point
>
end
)
{
do
{
dec
->
buf
[
new_point
]
=
0
;
}
while
(
--
new_point
>
end
);
}
while
(
--
new_point
>
end
);
}
else
{
for
(;
new_point
<
beg
;
new_point
++
)
dec
->
buf
[
new_point
]
=
0
;
}
dec
->
intg
=
digits_int
;
dec
->
frac
=
digits_frac
;
return
err
;
...
...
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