Skip to content

Commit b3cbd00

Browse files
author
monty@mysql.com
committed
Cleanups during review of new code
Ensure mysql_close() is called if mysql_set_character_set() fails
1 parent 510d9a1 commit b3cbd00

File tree

15 files changed

+261
-316
lines changed

15 files changed

+261
-316
lines changed

libmysql/libmysql.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,13 +1599,8 @@ mysql_real_escape_string(MYSQL *mysql, char *to,const char *from,
15991599
ulong length)
16001600
{
16011601
if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES)
1602-
{
16031602
return escape_quotes_for_mysql(mysql->charset, to, 0, from, length);
1604-
}
1605-
else
1606-
{
1607-
return escape_string_for_mysql(mysql->charset, to, 0, from, length);
1608-
}
1603+
return escape_string_for_mysql(mysql->charset, to, 0, from, length);
16091604
}
16101605

16111606

mysql-test/r/select.result

Lines changed: 93 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,99 @@ select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid
24922492
id name gid uid ident level
24932493
1 fs NULL NULL 0 READ
24942494
drop table t1,t2,t3;
2495+
CREATE TABLE t1 (
2496+
acct_id int(11) NOT NULL default '0',
2497+
profile_id smallint(6) default NULL,
2498+
UNIQUE KEY t1$acct_id (acct_id),
2499+
KEY t1$profile_id (profile_id)
2500+
);
2501+
INSERT INTO t1 VALUES (132,17),(133,18);
2502+
CREATE TABLE t2 (
2503+
profile_id smallint(6) default NULL,
2504+
queue_id int(11) default NULL,
2505+
seq int(11) default NULL,
2506+
KEY t2$queue_id (queue_id)
2507+
);
2508+
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
2509+
CREATE TABLE t3 (
2510+
id int(11) NOT NULL default '0',
2511+
qtype int(11) default NULL,
2512+
seq int(11) default NULL,
2513+
warn_lvl int(11) default NULL,
2514+
crit_lvl int(11) default NULL,
2515+
rr1 tinyint(4) NOT NULL default '0',
2516+
rr2 int(11) default NULL,
2517+
default_queue tinyint(4) NOT NULL default '0',
2518+
KEY t3$qtype (qtype),
2519+
KEY t3$id (id)
2520+
);
2521+
INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
2522+
(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
2523+
SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q
2524+
WHERE
2525+
(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND
2526+
(pq.queue_id = q.id) AND (q.rr1 <> 1);
2527+
COUNT(*)
2528+
4
2529+
drop table t1,t2,t3;
2530+
create table t1 (f1 int);
2531+
insert into t1 values (1),(NULL);
2532+
create table t2 (f2 int, f3 int, f4 int);
2533+
create index idx1 on t2 (f4);
2534+
insert into t2 values (1,2,3),(2,4,6);
2535+
select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)
2536+
from t2 C where A.f4 = C.f4) or A.f3 IS NULL;
2537+
f2
2538+
1
2539+
NULL
2540+
drop table t1,t2;
2541+
create table t2 (a tinyint unsigned);
2542+
create index t2i on t2(a);
2543+
insert into t2 values (0), (254), (255);
2544+
explain select * from t2 where a > -1;
2545+
id select_type table type possible_keys key key_len ref rows Extra
2546+
1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index
2547+
select * from t2 where a > -1;
2548+
a
2549+
0
2550+
254
2551+
255
2552+
drop table t2;
2553+
CREATE TABLE t1 (a int, b int, c int);
2554+
INSERT INTO t1
2555+
SELECT 50, 3, 3 FROM DUAL
2556+
WHERE NOT EXISTS
2557+
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
2558+
SELECT * FROM t1;
2559+
a b c
2560+
50 3 3
2561+
INSERT INTO t1
2562+
SELECT 50, 3, 3 FROM DUAL
2563+
WHERE NOT EXISTS
2564+
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
2565+
select found_rows();
2566+
found_rows()
2567+
0
2568+
SELECT * FROM t1;
2569+
a b c
2570+
50 3 3
2571+
select count(*) from t1;
2572+
count(*)
2573+
1
2574+
select found_rows();
2575+
found_rows()
2576+
1
2577+
select count(*) from t1 limit 2,3;
2578+
count(*)
2579+
select found_rows();
2580+
found_rows()
2581+
0
2582+
select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3;
2583+
count(*)
2584+
select found_rows();
2585+
found_rows()
2586+
1
2587+
DROP TABLE t1;
24952588
CREATE TABLE t1 ( city char(30) );
24962589
INSERT INTO t1 VALUES ('London');
24972590
INSERT INTO t1 VALUES ('Paris');
@@ -2579,25 +2672,6 @@ K2C4 K4N4 F2I4
25792672
WART 0100 1
25802673
WART 0200 1
25812674
WART 0300 3
2582-
select found_rows();
2583-
found_rows()
2584-
3
2585-
select count(*) from t1;
2586-
count(*)
2587-
15
2588-
select found_rows();
2589-
found_rows()
2590-
1
2591-
select count(*) from t1 limit 2,3;
2592-
count(*)
2593-
select found_rows();
2594-
found_rows()
2595-
0
2596-
select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3;
2597-
count(*)
2598-
select found_rows();
2599-
found_rows()
2600-
1
26012675
DROP TABLE t1;
26022676
CREATE TABLE t1 ( a BLOB, INDEX (a(20)) );
26032677
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
26122686
1 SIMPLE t1 ALL NULL NULL NULL NULL 5
26132687
1 SIMPLE t2 ref a a 23 test.t1.a 2
26142688
DROP TABLE t1, t2;
2615-
CREATE TABLE t1 ( city char(30) );
2616-
INSERT INTO t1 VALUES ('London');
2617-
INSERT INTO t1 VALUES ('Paris');
2618-
SELECT * FROM t1 WHERE city='London';
2619-
city
2620-
London
2621-
SELECT * FROM t1 WHERE city='london';
2622-
city
2623-
London
2624-
EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london';
2625-
id select_type table type possible_keys key key_len ref rows Extra
2626-
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
2627-
SELECT * FROM t1 WHERE city='London' AND city='london';
2628-
city
2629-
London
2630-
EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
2631-
id select_type table type possible_keys key key_len ref rows Extra
2632-
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
2633-
SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London';
2634-
city
2635-
London
2636-
DROP TABLE t1;
2637-
create table t1 (a int(11) unsigned, b int(11) unsigned);
2638-
insert into t1 values (1,0), (1,1), (1,2);
2639-
select a-b from t1 order by 1;
2640-
a-b
2641-
0
2642-
1
2643-
18446744073709551615
2644-
select a-b , (a-b < 0) from t1 order by 1;
2645-
a-b (a-b < 0)
2646-
0 0
2647-
1 0
2648-
18446744073709551615 0
2649-
select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0;
2650-
d (a-b >= 0) b
2651-
1 1 0
2652-
0 1 1
2653-
18446744073709551615 1 2
2654-
select cast((a - b) as unsigned) from t1 order by 1;
2655-
cast((a - b) as unsigned)
2656-
0
2657-
1
2658-
18446744073709551615
2659-
drop table t1;
26602689
create table t1 (a int, b int);
26612690
create table t2 like t1;
26622691
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;
27302759
select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0;
27312760
x'10' + 0 X'10' + 0 b'10' + 0 B'10' + 0
27322761
16 16 2 2
2733-
CREATE TABLE t1 (
2734-
acct_id int(11) NOT NULL default '0',
2735-
profile_id smallint(6) default NULL,
2736-
UNIQUE KEY t1$acct_id (acct_id),
2737-
KEY t1$profile_id (profile_id)
2738-
);
2739-
INSERT INTO t1 VALUES (132,17),(133,18);
2740-
CREATE TABLE t2 (
2741-
profile_id smallint(6) default NULL,
2742-
queue_id int(11) default NULL,
2743-
seq int(11) default NULL,
2744-
KEY t2$queue_id (queue_id)
2745-
);
2746-
INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1);
2747-
CREATE TABLE t3 (
2748-
id int(11) NOT NULL default '0',
2749-
qtype int(11) default NULL,
2750-
seq int(11) default NULL,
2751-
warn_lvl int(11) default NULL,
2752-
crit_lvl int(11) default NULL,
2753-
rr1 tinyint(4) NOT NULL default '0',
2754-
rr2 int(11) default NULL,
2755-
default_queue tinyint(4) NOT NULL default '0',
2756-
KEY t3$qtype (qtype),
2757-
KEY t3$id (id)
2758-
);
2759-
INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0),
2760-
(36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0);
2761-
SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q
2762-
WHERE
2763-
(pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND
2764-
(pq.queue_id = q.id) AND (q.rr1 <> 1);
2765-
COUNT(*)
2766-
4
2767-
drop table t1,t2,t3;
2768-
create table t1 (f1 int);
2769-
insert into t1 values (1),(NULL);
2770-
create table t2 (f2 int, f3 int, f4 int);
2771-
create index idx1 on t2 (f4);
2772-
insert into t2 values (1,2,3),(2,4,6);
2773-
select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3)
2774-
from t2 C where A.f4 = C.f4) or A.f3 IS NULL;
2775-
f2
2776-
1
2777-
NULL
2778-
drop table t1,t2;
2779-
create table t2 (a tinyint unsigned);
2780-
create index t2i on t2(a);
2781-
insert into t2 values (0), (254), (255);
2782-
explain select * from t2 where a > -1;
2783-
id select_type table type possible_keys key key_len ref rows Extra
2784-
1 SIMPLE t2 index t2i t2i 2 NULL 3 Using where; Using index
2785-
select * from t2 where a > -1;
2786-
a
2787-
0
2788-
254
2789-
255
2790-
drop table t2;
2791-
CREATE TABLE t1 (a int, b int, c int);
2792-
INSERT INTO t1
2793-
SELECT 50, 3, 3 FROM DUAL
2794-
WHERE NOT EXISTS
2795-
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
2796-
SELECT * FROM t1;
2797-
a b c
2798-
50 3 3
2799-
INSERT INTO t1
2800-
SELECT 50, 3, 3 FROM DUAL
2801-
WHERE NOT EXISTS
2802-
(SELECT * FROM t1 WHERE a = 50 AND b = 3);
2803-
SELECT * FROM t1;
2804-
a b c
2805-
50 3 3
2806-
DROP TABLE t1;

mysql-test/r/type_newdecimal.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,13 @@ t1 CREATE TABLE `t1` (
946946
`sl` decimal(5,5) default NULL
947947
) ENGINE=MyISAM DEFAULT CHARSET=latin1
948948
drop table t1;
949+
create table t1 (sl decimal(65, 30));
950+
show create table t1;
951+
Table Create Table
952+
t1 CREATE TABLE `t1` (
953+
`sl` decimal(65,30) default NULL
954+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
955+
drop table t1;
949956
create table t1 (
950957
f1 decimal unsigned not null default 17.49,
951958
f2 decimal unsigned not null default 17.68,

0 commit comments

Comments
 (0)