summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc7
-rw-r--r--include/my_base.h1
-rw-r--r--myisam/mi_create.c4
-rw-r--r--myisam/sp_key.c71
-rw-r--r--mysql-test/r/ctype_collate.result8
-rw-r--r--mysql-test/r/gis-rtree.result13
-rw-r--r--mysql-test/r/join_nested.result111
-rw-r--r--mysql-test/r/symlink.result22
-rw-r--r--mysql-test/r/type_enum.result20
-rw-r--r--mysql-test/r/type_ranges.result4
-rw-r--r--mysql-test/r/type_time.result24
-rw-r--r--mysql-test/t/create_not_windows.test1
-rw-r--r--mysql-test/t/ctype_collate.test11
-rw-r--r--mysql-test/t/gis-rtree.test19
-rw-r--r--mysql-test/t/join_nested.test114
-rw-r--r--mysql-test/t/symlink.test38
-rw-r--r--mysql-test/t/type_enum.test18
-rw-r--r--mysql-test/t/type_time.test18
-rw-r--r--mysys/my_conio.c7
-rw-r--r--sql/field_conv.cc17
-rw-r--r--sql/ha_myisam.cc2
-rw-r--r--sql/item_cmpfunc.cc36
-rw-r--r--sql/set_var.cc6
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/unireg.cc2
-rw-r--r--strings/ctype-simple.c2
28 files changed, 522 insertions, 67 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 368fce30d67..277b56328a6 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1086,7 +1086,12 @@ static int read_and_execute(bool interactive)
something else is still in console input buffer
*/
} while (tmpbuf.alloced_length() <= clen);
- line= buffer.c_ptr();
+ /*
+ An empty line is returned from my_cgets when there's error reading :
+ Ctrl-c for example
+ */
+ if (line)
+ line= buffer.c_ptr();
#else /* OS2 */
buffer.length(0);
/* _cgets() expects the buffer size - 3 as the first byte */
diff --git a/include/my_base.h b/include/my_base.h
index 4ce7a87105d..ef5ac364fed 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -284,6 +284,7 @@ enum ha_base_keytype {
#define HA_PACK_RECORD 2 /* Request packed record format */
#define HA_CREATE_TMP_TABLE 4
#define HA_CREATE_CHECKSUM 8
+#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
#define HA_CREATE_DELAY_KEY_WRITE 64
/*
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index ea1d8c7b83e..75863ed976f 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -586,7 +586,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
32 : 0));
linkname_ptr=0;
/* Replace the current file */
- create_flag=MY_DELETE_OLD;
+ create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
/*
@@ -647,7 +647,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
{
fn_format(filename,name,"",MI_NAME_DEXT,4);
linkname_ptr=0;
- create_flag=MY_DELETE_OLD;
+ create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
if ((dfile=
my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
diff --git a/myisam/sp_key.c b/myisam/sp_key.c
index 34c96a219c7..e9728df4a14 100644
--- a/myisam/sp_key.c
+++ b/myisam/sp_key.c
@@ -31,11 +31,6 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims,
double *mbr, int top);
static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr);
-static void get_double(double *d, const byte *pos)
-{
- float8get(*d, pos);
-}
-
uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
const byte *record, my_off_t filepos)
{
@@ -62,48 +57,40 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++)
{
- uint length = keyseg->length;
+ uint length = keyseg->length, start= keyseg->start;
+ double val;
+
+ DBUG_ASSERT(length == sizeof(double));
+ DBUG_ASSERT(!(start % sizeof(double)));
+ DBUG_ASSERT(start < sizeof(mbr));
+ DBUG_ASSERT(keyseg->type == HA_KEYTYPE_DOUBLE);
- pos = ((byte*)mbr) + keyseg->start;
- if (keyseg->flag & HA_SWAP_KEY)
- {
+ val= mbr[start / sizeof (double)];
#ifdef HAVE_ISNAN
- if (keyseg->type == HA_KEYTYPE_FLOAT)
- {
- float nr;
- float4get(nr, pos);
- if (isnan(nr))
- {
- /* Replace NAN with zero */
- bzero(key, length);
- key+= length;
- continue;
- }
- }
- else if (keyseg->type == HA_KEYTYPE_DOUBLE)
- {
- double nr;
- get_double(&nr, pos);
- if (isnan(nr))
- {
- bzero(key, length);
- key+= length;
- continue;
- }
- }
+ if (isnan(val))
+ {
+ bzero(key, length);
+ key+= length;
+ len+= length;
+ continue;
+ }
#endif
- pos += length;
- while (length--)
- {
+
+ if (keyseg->flag & HA_SWAP_KEY)
+ {
+ char buf[sizeof(double)];
+
+ float8store(buf, val);
+ pos= &buf[length];
+ while (pos > buf)
*key++ = *--pos;
- }
}
else
{
- memcpy((byte*)key, pos, length);
- key += keyseg->length;
+ float8store((byte *)key, val);
+ key += length;
}
- len += keyseg->length;
+ len+= length;
}
_mi_dpointer(info, key, filepos);
return len;
@@ -141,13 +128,13 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims,
{
if ((*wkb) > end - 8)
return -1;
- get_double(&ord, (const byte*) *wkb);
+ float8get(ord, (const byte*) *wkb);
(*wkb)+= 8;
if (ord < *mbr)
- float8store((char*) mbr, ord);
+ *mbr= ord;
mbr++;
if (ord > *mbr)
- float8store((char*) mbr, ord);
+ *mbr= ord;
mbr++;
}
return 0;
diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result
index 52ee76d1948..5c9bb93103e 100644
--- a/mysql-test/r/ctype_collate.result
+++ b/mysql-test/r/ctype_collate.result
@@ -603,3 +603,11 @@ check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
+insert into t1 set a=0x4c20;
+insert into t1 set a=0x6c;
+insert into t1 set a=0x4c98;
+check table t1 extended;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
index e4b52fc0392..8476ea9e838 100644
--- a/mysql-test/r/gis-rtree.result
+++ b/mysql-test/r/gis-rtree.result
@@ -1444,3 +1444,16 @@ OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1;
+CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
+INSERT INTO t1 VALUES (1, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+INSERT INTO t1 VALUES (2, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+SELECT COUNT(*) FROM t1 WHERE
+MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
+MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+COUNT(*)
+2
+DROP TABLE t1;
+End of 5.0 tests.
diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result
index 006488f9d43..daf63579e9c 100644
--- a/mysql-test/r/join_nested.result
+++ b/mysql-test/r/join_nested.result
@@ -1632,4 +1632,115 @@ INSERT INTO t3 VALUES (1,1);
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
ERROR 23000: Column 'a' in from clause is ambiguous
DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (
+carrier char(2) default NULL,
+id int NOT NULL auto_increment PRIMARY KEY
+);
+INSERT INTO t1 VALUES
+('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
+('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
+('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
+('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
+('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
+('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
+('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
+('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
+('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
+CREATE TABLE t2 (
+scan_date date default NULL,
+package_id int default NULL,
+INDEX scan_date(scan_date),
+INDEX package_id(package_id)
+);
+INSERT INTO t2 VALUES
+('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
+('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
+('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
+('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
+('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
+('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
+('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
+('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
+('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
+('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
+('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
+('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
+('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
+('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
+('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
+CREATE TABLE t3 (
+package_id int default NULL,
+INDEX package_id(package_id)
+);
+INSERT INTO t3 VALUES
+(231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
+(231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
+(231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
+(231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
+(231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
+(231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
+(231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
+(231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
+(231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
+(231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
+(231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
+(231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
+(231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
+(231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
+(231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
+(231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
+(231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
+(231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
+(231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
+(231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
+(231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
+(231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
+(231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
+CREATE TABLE t4 (
+carrier char(2) NOT NULL default '' PRIMARY KEY,
+id int(11) default NULL,
+INDEX id(id)
+);
+INSERT INTO t4 VALUES
+('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
+CREATE TABLE t5 (
+carrier_id int default NULL,
+INDEX carrier_id(carrier_id)
+);
+INSERT INTO t5 VALUES
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
+(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
+(456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
+SELECT COUNT(*)
+FROM((t2 JOIN t1 ON t2.package_id = t1.id)
+JOIN t3 ON t3.package_id = t1.id);
+COUNT(*)
+6
+EXPLAIN
+SELECT COUNT(*)
+FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+JOIN t3 ON t3.package_id = t1.id)
+LEFT JOIN
+(t5 JOIN t4 ON t5.carrier_id = t4.id)
+ON t4.carrier = t1.carrier;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index package_id package_id 5 NULL 45 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1
+1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1
+1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index
+1 SIMPLE t3 ref package_id package_id 5 test.t1.id 1 Using where; Using index
+SELECT COUNT(*)
+FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+JOIN t3 ON t3.package_id = t1.id)
+LEFT JOIN
+(t5 JOIN t4 ON t5.carrier_id = t4.id)
+ON t4.carrier = t1.carrier;
+COUNT(*)
+6
+DROP TABLE t1,t2,t3,t4,t5;
End of 5.0 tests
diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result
index 4725bcc0ac9..18299bf4298 100644
--- a/mysql-test/r/symlink.result
+++ b/mysql-test/r/symlink.result
@@ -133,4 +133,26 @@ a
42
drop table t1;
End of 4.1 tests
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+USE db2;
+INSERT INTO db2.t1 VALUES (1);
+SELECT * FROM db2.t1;
+b
+1
+RESET QUERY CACHE;
+USE db1;
+SET SESSION keep_files_on_create = TRUE;
+CREATE TABLE t1 (a INT) ENGINE MYISAM;
+ERROR HY000: Can't create/write to file './db1/t1.MYD' (Errcode: 17)
+CREATE TABLE t3 (a INT) Engine=MyISAM;
+INSERT INTO t3 VALUES (1),(2),(3);
+TRUNCATE TABLE t3;
+SELECT * from t3;
+a
+SET SESSION keep_files_on_create = DEFAULT;
+DROP TABLE db2.t1, db1.t3;
+DROP DATABASE db1;
+DROP DATABASE db2;
+USE test;
End of 5.0 tests
diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result
index f537b7140ba..ca516f027ba 100644
--- a/mysql-test/r/type_enum.result
+++ b/mysql-test/r/type_enum.result
@@ -1809,3 +1809,23 @@ f1
drop table t1;
+CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
+INSERT INTO t1 (c1) VALUES ('b');
+INSERT INTO t1 (c1) VALUES ('');
+INSERT INTO t1 (c1) VALUES (0);
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 1
+INSERT INTO t1 (c1) VALUES ('');
+SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
+c1 + 0 COUNT(c1)
+0 1
+2 2
+3 1
+CREATE TABLE t2 SELECT * FROM t1;
+SELECT c1 + 0 FROM t2;
+c1 + 0
+3
+2
+0
+2
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
index e949d734944..5c2d3b84d89 100644
--- a/mysql-test/r/type_ranges.result
+++ b/mysql-test/r/type_ranges.result
@@ -208,10 +208,6 @@ options flags
one one
drop table t2;
create table t2 select * from t1;
-Warnings:
-Warning 1265 Data truncated for column 'options' at row 4
-Warning 1265 Data truncated for column 'options' at row 5
-Warning 1265 Data truncated for column 'options' at row 6
update t2 set string="changed" where auto=16;
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index 442435b0459..71bd8b68a0b 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -85,3 +85,27 @@ sec_to_time(time_to_sec(t))
13:00:00
09:00:00
drop table t1;
+select cast('100:55:50' as time) < cast('24:00:00' as time);
+cast('100:55:50' as time) < cast('24:00:00' as time)
+0
+select cast('100:55:50' as time) < cast('024:00:00' as time);
+cast('100:55:50' as time) < cast('024:00:00' as time)
+0
+select cast('300:55:50' as time) < cast('240:00:00' as time);
+cast('300:55:50' as time) < cast('240:00:00' as time)
+0
+select cast('100:55:50' as time) > cast('24:00:00' as time);
+cast('100:55:50' as time) > cast('24:00:00' as time)
+1
+select cast('100:55:50' as time) > cast('024:00:00' as time);
+cast('100:55:50' as time) > cast('024:00:00' as time)
+1
+select cast('300:55:50' as time) > cast('240:00:00' as time);
+cast('300:55:50' as time) > cast('240:00:00' as time)
+1
+create table t1(f1 time, f2 time);
+insert into t1 values('20:00:00','150:00:00');
+select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
+1
+1
+drop table t1;
diff --git a/mysql-test/t/create_not_windows.test b/mysql-test/t/create_not_windows.test
index 71ad9ccd7fe..7e51ff51024 100644
--- a/mysql-test/t/create_not_windows.test
+++ b/mysql-test/t/create_not_windows.test
@@ -17,4 +17,5 @@ primary key (_id)
show create table `about:text`;
drop table `about:text`;
+
# End of 5.0 tests
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
index 4bbae42559a..cfef8dfe81a 100644
--- a/mysql-test/t/ctype_collate.test
+++ b/mysql-test/t/ctype_collate.test
@@ -218,3 +218,14 @@ insert into t1 set f1=0x3F3F1E563F;
insert into t1 set f1=0x3F3F;
check table t1 extended;
drop table t1;
+
+#
+# Bug#29461: Sort order of the collation wasn't used when comparing characters
+# with the space character.
+#
+create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
+insert into t1 set a=0x4c20;
+insert into t1 set a=0x6c;
+insert into t1 set a=0x4c98;
+check table t1 extended;
+drop table t1;
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
index 3368aea9741..74b12caca41 100644
--- a/mysql-test/t/gis-rtree.test
+++ b/mysql-test/t/gis-rtree.test
@@ -827,3 +827,22 @@ INSERT INTO t1 (b) SELECT b FROM t1;
OPTIMIZE TABLE t1;
DROP TABLE t1;
+
+
+#
+# Bug #29070: Error in spatial index
+#
+
+CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
+INSERT INTO t1 VALUES (1, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+INSERT INTO t1 VALUES (2, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+
+# must return the same number as the next select
+SELECT COUNT(*) FROM t1 WHERE
+ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
+ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test
index f29366797f6..5b07d8966f1 100644
--- a/mysql-test/t/join_nested.test
+++ b/mysql-test/t/join_nested.test
@@ -1083,4 +1083,118 @@ SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
DROP TABLE t1,t2,t3;
+#
+# BUG#29604: inner nest of left join interleaves with outer tables
+#
+
+CREATE TABLE t1 (
+ carrier char(2) default NULL,
+ id int NOT NULL auto_increment PRIMARY KEY
+);
+INSERT INTO t1 VALUES
+ ('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
+ ('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
+ ('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
+ ('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
+ ('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
+ ('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
+ ('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
+ ('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
+ ('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
+
+CREATE TABLE t2 (
+ scan_date date default NULL,
+ package_id int default NULL,
+ INDEX scan_date(scan_date),
+ INDEX package_id(package_id)
+);
+INSERT INTO t2 VALUES
+ ('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
+ ('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
+ ('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
+ ('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
+ ('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
+ ('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
+ ('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
+ ('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
+ ('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
+ ('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
+ ('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
+ ('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
+ ('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
+ ('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
+ ('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
+
+CREATE TABLE t3 (
+ package_id int default NULL,
+ INDEX package_id(package_id)
+);
+INSERT INTO t3 VALUES
+ (231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
+ (231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
+ (231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
+ (231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
+ (231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
+ (231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
+ (231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
+ (231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
+ (231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
+ (231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
+ (231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
+ (231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
+ (231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
+ (231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
+ (231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
+ (231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
+ (231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
+ (231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
+ (231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
+ (231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
+ (231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
+ (231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
+ (231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
+
+CREATE TABLE t4 (
+ carrier char(2) NOT NULL default '' PRIMARY KEY,
+ id int(11) default NULL,
+ INDEX id(id)
+);
+INSERT INTO t4 VALUES
+ ('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
+
+CREATE TABLE t5 (
+ carrier_id int default NULL,
+ INDEX carrier_id(carrier_id)
+);
+INSERT INTO t5 VALUES
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
+ (456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
+ (456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
+
+SELECT COUNT(*)
+ FROM((t2 JOIN t1 ON t2.package_id = t1.id)
+ JOIN t3 ON t3.package_id = t1.id);
+
+EXPLAIN
+SELECT COUNT(*)
+ FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+ JOIN t3 ON t3.package_id = t1.id)
+ LEFT JOIN
+ (t5 JOIN t4 ON t5.carrier_id = t4.id)
+ ON t4.carrier = t1.carrier;
+SELECT COUNT(*)
+ FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+ JOIN t3 ON t3.package_id = t1.id)
+ LEFT JOIN
+ (t5 JOIN t4 ON t5.carrier_id = t4.id)
+ ON t4.carrier = t1.carrier;
+
+DROP TABLE t1,t2,t3,t4,t5;
+
--echo End of 5.0 tests
+
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index d79b6905224..8c67a4c1048 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -178,4 +178,42 @@ drop table t1;
--echo End of 4.1 tests
+#
+# Bug #29325: create table overwrites .MYD file of other table (datadir)
+#
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+USE db2;
+--disable_query_log
+eval CREATE TABLE t1 (b INT) ENGINE MYISAM
+DATA DIRECTORY = '$MYSQLTEST_VARDIR/master-data/db1/';
+--enable_query_log
+
+INSERT INTO db2.t1 VALUES (1);
+SELECT * FROM db2.t1;
+RESET QUERY CACHE;
+
+USE db1;
+
+#no warning from create table
+SET SESSION keep_files_on_create = TRUE;
+--disable_abort_on_error
+CREATE TABLE t1 (a INT) ENGINE MYISAM;
+--enable_abort_on_error
+
+CREATE TABLE t3 (a INT) Engine=MyISAM;
+INSERT INTO t3 VALUES (1),(2),(3);
+TRUNCATE TABLE t3;
+SELECT * from t3;
+
+SET SESSION keep_files_on_create = DEFAULT;
+
+DROP TABLE db2.t1, db1.t3;
+DROP DATABASE db1;
+DROP DATABASE db2;
+USE test;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test
index ecc945a3157..fbba38f926d 100644
--- a/mysql-test/t/type_enum.test
+++ b/mysql-test/t/type_enum.test
@@ -182,3 +182,21 @@ create table t1(f1 set('a','b'), index(f1));
insert into t1 values(''),(''),('a'),('b');
select * from t1 where f1='';
drop table t1;
+
+#
+# Bug#29360: Confluence of the special 0 enum value with the normal empty string
+# value during field to field copy.
+#
+
+CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
+INSERT INTO t1 (c1) VALUES ('b');
+INSERT INTO t1 (c1) VALUES ('');
+INSERT INTO t1 (c1) VALUES (0);
+INSERT INTO t1 (c1) VALUES ('');
+
+SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
+
+CREATE TABLE t2 SELECT * FROM t1;
+SELECT c1 + 0 FROM t2;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index cb7e4f85ad1..82d701e29b5 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -40,3 +40,21 @@ drop table t1;
# ##########################################################
# End of 4.1 tests
+
+#
+# Bug#29555: Comparing time values as strings may lead to a wrong result.
+#
+select cast('100:55:50' as time) < cast('24:00:00' as time);
+select cast('100:55:50' as time) < cast('024:00:00' as time);
+select cast('300:55:50' as time) < cast('240:00:00' as time);
+select cast('100:55:50' as time) > cast('24:00:00' as time);
+select cast('100:55:50' as time) > cast('024:00:00' as time);
+select cast('300:55:50' as time) > cast('240:00:00' as time);
+
+#
+# Bug#29739: Incorrect time comparison in BETWEEN.
+#
+create table t1(f1 time, f2 time);
+insert into t1 values('20:00:00','150:00:00');
+select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
+drop table t1;
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index 23b0c55e7a9..def15674f26 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -184,16 +184,19 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen)
}
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
+ /* We go here on error reading the string (Ctrl-C for example) */
+ if (!*plen)
+ result= NULL; /* purecov: inspected */
if (result != NULL)
{
- if (buffer[*plen - 2] == '\r')
+ if (*plen > 1 && buffer[*plen - 2] == '\r')
{
*plen= *plen - 2;
}
else
{
- if (buffer[*plen - 1] == '\r')
+ if (*plen > 0 && buffer[*plen - 1] == '\r')
{
char tmp[3];
int tmplen= sizeof(tmp);
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index a286255ec23..2705d4f617b 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -790,11 +790,18 @@ int field_conv(Field *to,Field *from)
blob->value.copy();
return blob->store(blob->value.ptr(),blob->value.length(),from->charset());
}
- if ((from->result_type() == STRING_RESULT &&
- (to->result_type() == STRING_RESULT ||
- (from->real_type() != FIELD_TYPE_ENUM &&
- from->real_type() != FIELD_TYPE_SET))) ||
- to->type() == FIELD_TYPE_DECIMAL)
+ if (from->real_type() == FIELD_TYPE_ENUM &&
+ to->real_type() == FIELD_TYPE_ENUM &&
+ from->val_int() == 0)
+ {
+ ((Field_enum *)(to))->store_type(0);
+ return 0;
+ }
+ else if ((from->result_type() == STRING_RESULT &&
+ (to->result_type() == STRING_RESULT ||
+ (from->real_type() != FIELD_TYPE_ENUM &&
+ from->real_type() != FIELD_TYPE_SET))) ||
+ to->type() == FIELD_TYPE_DECIMAL)
{
char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),from->charset());
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 5e953092436..4efa19bad78 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -1809,6 +1809,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
create_flags|= HA_CREATE_TMP_TABLE;
+ if (ha_create_info->options & HA_CREATE_KEEP_FILES)
+ create_flags|= HA_CREATE_KEEP_FILES;
if (options & HA_OPTION_PACK_RECORD)
create_flags|= HA_PACK_RECORD;
if (options & HA_OPTION_CHECKSUM)
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index ed0c09f0b32..555384b2bfc 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -706,6 +706,18 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
func= &Arg_comparator::compare_datetime;
return 0;
}
+ else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME &&
+ (*b)->field_type() == MYSQL_TYPE_TIME)
+ {
+ /* Compare TIME values as integers. */
+ thd= current_thd;
+ owner= owner_arg;
+ func= ((test(owner && owner->functype() == Item_func::EQUAL_FUNC)) ?
+ &Arg_comparator::compare_e_int :
+ &Arg_comparator::compare_int_unsigned);
+ return 0;
+ }
+
return set_compare_func(owner_arg, type);
}
@@ -1716,6 +1728,7 @@ void Item_func_between::fix_length_and_dec()
THD *thd= current_thd;
int i;
bool datetime_found= FALSE;
+ int time_items_found= 0;
compare_as_dates= TRUE;
/*
@@ -1735,17 +1748,19 @@ void Item_func_between::fix_length_and_dec()
At least one of items should be a DATE/DATETIME item and other items
should return the STRING result.
*/
- for (i= 0; i < 3; i++)
+ if (cmp_type == STRING_RESULT)
{
- if (args[i]->is_datetime())
+ for (i= 0; i < 3; i++)
{
- datetime_found= TRUE;
- continue;
+ if (args[i]->is_datetime())
+ {
+ datetime_found= TRUE;
+ continue;
+ }
+ if (args[i]->field_type() == MYSQL_TYPE_TIME &&
+ args[i]->result_as_longlong())
+ time_items_found++;
}
- if (args[i]->result_type() == STRING_RESULT)
- continue;
- compare_as_dates= FALSE;
- break;
}
if (!datetime_found)
compare_as_dates= FALSE;
@@ -1755,6 +1770,11 @@ void Item_func_between::fix_length_and_dec()
ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2);
}
+ else if (time_items_found == 3)
+ {
+ /* Compare TIME items as integers. */
+ cmp_type= INT_RESULT;
+ }
else if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 09cdc34f803..b30aa008366 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -592,6 +592,10 @@ sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE));
/* Global read-only variable containing hostname */
sys_var_const_str sys_hostname("hostname", glob_hostname);
+sys_var_thd_bool sys_keep_files_on_create("keep_files_on_create",
+ &SV::keep_files_on_create);
+
+
/*
@@ -637,6 +641,7 @@ sys_var *sys_variables[]=
&sys_delayed_insert_limit,
&sys_delayed_insert_timeout,
&sys_delayed_queue_size,
+ &sys_keep_files_on_create,
&sys_error_count,
&sys_expire_logs_days,
&sys_flush,
@@ -849,6 +854,7 @@ struct show_var_st init_vars[]= {
{sys_delayed_insert_timeout.name, (char*) &sys_delayed_insert_timeout, SHOW_SYS},
{sys_delayed_queue_size.name,(char*) &sys_delayed_queue_size, SHOW_SYS},
{sys_div_precincrement.name,(char*) &sys_div_precincrement,SHOW_SYS},
+ {sys_keep_files_on_create.name,(char*) &sys_keep_files_on_create, SHOW_SYS},
{sys_engine_condition_pushdown.name,
(char*) &sys_engine_condition_pushdown, SHOW_SYS},
{sys_expire_logs_days.name, (char*) &sys_expire_logs_days, SHOW_SYS},
diff --git a/sql/sql_class.h b/sql/sql_class.h
index a5cbc21684f..112538cbe95 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -566,6 +566,7 @@ struct system_variables
my_bool new_mode;
my_bool query_cache_wlock_invalidate;
my_bool engine_condition_pushdown;
+ my_bool keep_files_on_create;
#ifdef HAVE_INNOBASE_DB
my_bool innodb_table_locks;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9d27ab4bb4e..c62a19b2752 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8486,9 +8486,15 @@ static void restore_prev_nj_state(JOIN_TAB *last)
{
TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding;
JOIN *join= last->join;
- while (last_emb && !(--last_emb->nested_join->counter))
+ while (last_emb)
{
- join->cur_embedding_map &= last_emb->nested_join->nj_map;
+ if (!(--last_emb->nested_join->counter))
+ join->cur_embedding_map&= ~last_emb->nested_join->nj_map;
+ else if (last_emb->nested_join->join_list.elements-1 ==
+ last_emb->nested_join->counter)
+ join->cur_embedding_map|= last_emb->nested_join->nj_map;
+ else
+ break;
last_emb= last_emb->embedding;
}
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 87f23097a66..e02595836ca 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -2841,6 +2841,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
and temporary tables).
*/
*fn_ext(dst_path)= 0;
+ if (thd->variables.keep_files_on_create)
+ create_info->options|= HA_CREATE_KEEP_FILES;
err= ha_create_table(dst_path, create_info, 1);
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
diff --git a/sql/unireg.cc b/sql/unireg.cc
index c01e6a0f00c..d8e63bb78e1 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -285,6 +285,8 @@ int rea_create_table(THD *thd, my_string file_name,
if (mysql_create_frm(thd, file_name, db, table, create_info,
create_fields, keys, key_info, NULL))
DBUG_RETURN(1);
+ if (thd->variables.keep_files_on_create)
+ create_info->options|= HA_CREATE_KEEP_FILES;
if (!create_info->frm_only && ha_create_table(file_name,create_info,0))
{
my_delete(file_name,MYF(0));
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index fca5607e152..8b1b0d6790d 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -179,7 +179,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length,
}
for (end= a + a_length-length; a < end ; a++)
{
- if (*a != ' ')
+ if (map[*a] != ' ')
return (map[*a] < ' ') ? -swap : swap;
}
}