Commit 92b65b8a authored by gshchepa/uchum@gleb.loc's avatar gshchepa/uchum@gleb.loc

Merge gleb.loc:/home/uchum/work/bk/5.0

into  gleb.loc:/home/uchum/work/bk/5.0-opt
parents 06c80870 d6ad4e6e
...@@ -1086,6 +1086,11 @@ static int read_and_execute(bool interactive) ...@@ -1086,6 +1086,11 @@ static int read_and_execute(bool interactive)
something else is still in console input buffer something else is still in console input buffer
*/ */
} while (tmpbuf.alloced_length() <= clen); } while (tmpbuf.alloced_length() <= clen);
/*
An empty line is returned from my_cgets when there's error reading :
Ctrl-c for example
*/
if (line)
line= buffer.c_ptr(); line= buffer.c_ptr();
#else /* OS2 */ #else /* OS2 */
buffer.length(0); buffer.length(0);
......
...@@ -284,6 +284,7 @@ enum ha_base_keytype { ...@@ -284,6 +284,7 @@ enum ha_base_keytype {
#define HA_PACK_RECORD 2 /* Request packed record format */ #define HA_PACK_RECORD 2 /* Request packed record format */
#define HA_CREATE_TMP_TABLE 4 #define HA_CREATE_TMP_TABLE 4
#define HA_CREATE_CHECKSUM 8 #define HA_CREATE_CHECKSUM 8
#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
#define HA_CREATE_DELAY_KEY_WRITE 64 #define HA_CREATE_DELAY_KEY_WRITE 64
/* /*
......
...@@ -586,7 +586,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -586,7 +586,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
32 : 0)); 32 : 0));
linkname_ptr=0; linkname_ptr=0;
/* Replace the current file */ /* 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, ...@@ -647,7 +647,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
{ {
fn_format(filename,name,"",MI_NAME_DEXT,4); fn_format(filename,name,"",MI_NAME_DEXT,4);
linkname_ptr=0; linkname_ptr=0;
create_flag=MY_DELETE_OLD; create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
} }
if ((dfile= if ((dfile=
my_create_with_symlink(linkname_ptr, filename, 0, create_mode, my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
......
...@@ -31,11 +31,6 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims, ...@@ -31,11 +31,6 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims,
double *mbr, int top); double *mbr, int top);
static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr); 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, uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
const byte *record, my_off_t filepos) const byte *record, my_off_t filepos)
{ {
...@@ -62,48 +57,40 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, ...@@ -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++) for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++)
{ {
uint length = keyseg->length; uint length = keyseg->length, start= keyseg->start;
double val;
pos = ((byte*)mbr) + keyseg->start; DBUG_ASSERT(length == sizeof(double));
if (keyseg->flag & HA_SWAP_KEY) DBUG_ASSERT(!(start % sizeof(double)));
{ DBUG_ASSERT(start < sizeof(mbr));
DBUG_ASSERT(keyseg->type == HA_KEYTYPE_DOUBLE);
val= mbr[start / sizeof (double)];
#ifdef HAVE_ISNAN #ifdef HAVE_ISNAN
if (keyseg->type == HA_KEYTYPE_FLOAT) if (isnan(val))
{
float nr;
float4get(nr, pos);
if (isnan(nr))
{ {
/* Replace NAN with zero */
bzero(key, length); bzero(key, length);
key+= length; key+= length;
len+= length;
continue; continue;
} }
}
else if (keyseg->type == HA_KEYTYPE_DOUBLE)
{
double nr;
get_double(&nr, pos);
if (isnan(nr))
{
bzero(key, length);
key+= length;
continue;
}
}
#endif #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; *key++ = *--pos;
} }
}
else else
{ {
memcpy((byte*)key, pos, length); float8store((byte *)key, val);
key += keyseg->length; key += length;
} }
len += keyseg->length; len+= length;
} }
_mi_dpointer(info, key, filepos); _mi_dpointer(info, key, filepos);
return len; return len;
...@@ -141,13 +128,13 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims, ...@@ -141,13 +128,13 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims,
{ {
if ((*wkb) > end - 8) if ((*wkb) > end - 8)
return -1; return -1;
get_double(&ord, (const byte*) *wkb); float8get(ord, (const byte*) *wkb);
(*wkb)+= 8; (*wkb)+= 8;
if (ord < *mbr) if (ord < *mbr)
float8store((char*) mbr, ord); *mbr= ord;
mbr++; mbr++;
if (ord > *mbr) if (ord > *mbr)
float8store((char*) mbr, ord); *mbr= ord;
mbr++; mbr++;
} }
return 0; return 0;
......
...@@ -603,3 +603,11 @@ check table t1 extended; ...@@ -603,3 +603,11 @@ check table t1 extended;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 check status OK test.t1 check status OK
drop table t1; 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;
...@@ -1444,3 +1444,16 @@ OPTIMIZE TABLE t1; ...@@ -1444,3 +1444,16 @@ OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 optimize status OK test.t1 optimize status OK
DROP TABLE t1; 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.
...@@ -1632,4 +1632,115 @@ INSERT INTO t3 VALUES (1,1); ...@@ -1632,4 +1632,115 @@ INSERT INTO t3 VALUES (1,1);
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
ERROR 23000: Column 'a' in from clause is ambiguous ERROR 23000: Column 'a' in from clause is ambiguous
DROP TABLE t1,t2,t3; 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 End of 5.0 tests
...@@ -133,4 +133,26 @@ a ...@@ -133,4 +133,26 @@ a
42 42
drop table t1; drop table t1;
End of 4.1 tests 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 End of 5.0 tests
...@@ -1809,3 +1809,23 @@ f1 ...@@ -1809,3 +1809,23 @@ f1
drop table t1; 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;
......
...@@ -208,10 +208,6 @@ options flags ...@@ -208,10 +208,6 @@ options flags
one one one one
drop table t2; drop table t2;
create table t2 select * from t1; 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; update t2 set string="changed" where auto=16;
show full columns from t1; show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
......
...@@ -85,3 +85,27 @@ sec_to_time(time_to_sec(t)) ...@@ -85,3 +85,27 @@ sec_to_time(time_to_sec(t))
13:00:00 13:00:00
09:00:00 09:00:00
drop table t1; 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;
...@@ -17,4 +17,5 @@ primary key (_id) ...@@ -17,4 +17,5 @@ primary key (_id)
show create table `about:text`; show create table `about:text`;
drop table `about:text`; drop table `about:text`;
# End of 5.0 tests # End of 5.0 tests
...@@ -218,3 +218,14 @@ insert into t1 set f1=0x3F3F1E563F; ...@@ -218,3 +218,14 @@ insert into t1 set f1=0x3F3F1E563F;
insert into t1 set f1=0x3F3F; insert into t1 set f1=0x3F3F;
check table t1 extended; check table t1 extended;
drop table t1; 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;
...@@ -827,3 +827,22 @@ INSERT INTO t1 (b) SELECT b FROM t1; ...@@ -827,3 +827,22 @@ INSERT INTO t1 (b) SELECT b FROM t1;
OPTIMIZE TABLE t1; OPTIMIZE TABLE t1;
DROP 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.
...@@ -1083,4 +1083,118 @@ SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a); ...@@ -1083,4 +1083,118 @@ SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
DROP TABLE t1,t2,t3; 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 --echo End of 5.0 tests
...@@ -178,4 +178,42 @@ drop table t1; ...@@ -178,4 +178,42 @@ drop table t1;
--echo End of 4.1 tests --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 --echo End of 5.0 tests
...@@ -182,3 +182,21 @@ create table t1(f1 set('a','b'), index(f1)); ...@@ -182,3 +182,21 @@ create table t1(f1 set('a','b'), index(f1));
insert into t1 values(''),(''),('a'),('b'); insert into t1 values(''),(''),('a'),('b');
select * from t1 where f1=''; select * from t1 where f1='';
drop table t1; 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;
......
...@@ -40,3 +40,21 @@ drop table t1; ...@@ -40,3 +40,21 @@ drop table t1;
# ########################################################## # ##########################################################
# End of 4.1 tests # 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;
...@@ -184,16 +184,19 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen) ...@@ -184,16 +184,19 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen)
} }
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY); 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 (result != NULL)
{ {
if (buffer[*plen - 2] == '\r') if (*plen > 1 && buffer[*plen - 2] == '\r')
{ {
*plen= *plen - 2; *plen= *plen - 2;
} }
else else
{ {
if (buffer[*plen - 1] == '\r') if (*plen > 0 && buffer[*plen - 1] == '\r')
{ {
char tmp[3]; char tmp[3];
int tmplen= sizeof(tmp); int tmplen= sizeof(tmp);
......
...@@ -790,7 +790,14 @@ int field_conv(Field *to,Field *from) ...@@ -790,7 +790,14 @@ int field_conv(Field *to,Field *from)
blob->value.copy(); blob->value.copy();
return blob->store(blob->value.ptr(),blob->value.length(),from->charset()); return blob->store(blob->value.ptr(),blob->value.length(),from->charset());
} }
if ((from->result_type() == STRING_RESULT && 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 || (to->result_type() == STRING_RESULT ||
(from->real_type() != FIELD_TYPE_ENUM && (from->real_type() != FIELD_TYPE_ENUM &&
from->real_type() != FIELD_TYPE_SET))) || from->real_type() != FIELD_TYPE_SET))) ||
......
...@@ -1809,6 +1809,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, ...@@ -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) if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
create_flags|= HA_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) if (options & HA_OPTION_PACK_RECORD)
create_flags|= HA_PACK_RECORD; create_flags|= HA_PACK_RECORD;
if (options & HA_OPTION_CHECKSUM) if (options & HA_OPTION_CHECKSUM)
......
...@@ -706,6 +706,18 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg, ...@@ -706,6 +706,18 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
func= &Arg_comparator::compare_datetime; func= &Arg_comparator::compare_datetime;
return 0; 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); return set_compare_func(owner_arg, type);
} }
...@@ -1716,6 +1728,7 @@ void Item_func_between::fix_length_and_dec() ...@@ -1716,6 +1728,7 @@ void Item_func_between::fix_length_and_dec()
THD *thd= current_thd; THD *thd= current_thd;
int i; int i;
bool datetime_found= FALSE; bool datetime_found= FALSE;
int time_items_found= 0;
compare_as_dates= TRUE; compare_as_dates= TRUE;
/* /*
...@@ -1735,6 +1748,8 @@ void Item_func_between::fix_length_and_dec() ...@@ -1735,6 +1748,8 @@ void Item_func_between::fix_length_and_dec()
At least one of items should be a DATE/DATETIME item and other items At least one of items should be a DATE/DATETIME item and other items
should return the STRING result. should return the STRING result.
*/ */
if (cmp_type == STRING_RESULT)
{
for (i= 0; i < 3; i++) for (i= 0; i < 3; i++)
{ {
if (args[i]->is_datetime()) if (args[i]->is_datetime())
...@@ -1742,10 +1757,10 @@ void Item_func_between::fix_length_and_dec() ...@@ -1742,10 +1757,10 @@ void Item_func_between::fix_length_and_dec()
datetime_found= TRUE; datetime_found= TRUE;
continue; continue;
} }
if (args[i]->result_type() == STRING_RESULT) if (args[i]->field_type() == MYSQL_TYPE_TIME &&
continue; args[i]->result_as_longlong())
compare_as_dates= FALSE; time_items_found++;
break; }
} }
if (!datetime_found) if (!datetime_found)
compare_as_dates= FALSE; compare_as_dates= FALSE;
...@@ -1755,6 +1770,11 @@ void Item_func_between::fix_length_and_dec() ...@@ -1755,6 +1770,11 @@ void Item_func_between::fix_length_and_dec()
ge_cmp.set_datetime_cmp_func(args, args + 1); ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2); 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 && else if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW && thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE) thd->lex->sql_command != SQLCOM_SHOW_CREATE)
......
...@@ -592,6 +592,10 @@ sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE)); ...@@ -592,6 +592,10 @@ sys_var_const_str sys_license("license", STRINGIFY_ARG(LICENSE));
/* Global read-only variable containing hostname */ /* Global read-only variable containing hostname */
sys_var_const_str sys_hostname("hostname", glob_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[]= ...@@ -637,6 +641,7 @@ sys_var *sys_variables[]=
&sys_delayed_insert_limit, &sys_delayed_insert_limit,
&sys_delayed_insert_timeout, &sys_delayed_insert_timeout,
&sys_delayed_queue_size, &sys_delayed_queue_size,
&sys_keep_files_on_create,
&sys_error_count, &sys_error_count,
&sys_expire_logs_days, &sys_expire_logs_days,
&sys_flush, &sys_flush,
...@@ -849,6 +854,7 @@ struct show_var_st init_vars[]= { ...@@ -849,6 +854,7 @@ struct show_var_st init_vars[]= {
{sys_delayed_insert_timeout.name, (char*) &sys_delayed_insert_timeout, SHOW_SYS}, {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_delayed_queue_size.name,(char*) &sys_delayed_queue_size, SHOW_SYS},
{sys_div_precincrement.name,(char*) &sys_div_precincrement,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, {sys_engine_condition_pushdown.name,
(char*) &sys_engine_condition_pushdown, SHOW_SYS}, (char*) &sys_engine_condition_pushdown, SHOW_SYS},
{sys_expire_logs_days.name, (char*) &sys_expire_logs_days, SHOW_SYS}, {sys_expire_logs_days.name, (char*) &sys_expire_logs_days, SHOW_SYS},
......
...@@ -566,6 +566,7 @@ struct system_variables ...@@ -566,6 +566,7 @@ struct system_variables
my_bool new_mode; my_bool new_mode;
my_bool query_cache_wlock_invalidate; my_bool query_cache_wlock_invalidate;
my_bool engine_condition_pushdown; my_bool engine_condition_pushdown;
my_bool keep_files_on_create;
#ifdef HAVE_INNOBASE_DB #ifdef HAVE_INNOBASE_DB
my_bool innodb_table_locks; my_bool innodb_table_locks;
......
...@@ -8486,9 +8486,15 @@ static void restore_prev_nj_state(JOIN_TAB *last) ...@@ -8486,9 +8486,15 @@ static void restore_prev_nj_state(JOIN_TAB *last)
{ {
TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding; TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding;
JOIN *join= last->join; 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; last_emb= last_emb->embedding;
} }
} }
......
...@@ -2841,6 +2841,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table, ...@@ -2841,6 +2841,8 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST *src_table,
and temporary tables). and temporary tables).
*/ */
*fn_ext(dst_path)= 0; *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); err= ha_create_table(dst_path, create_info, 1);
if (create_info->options & HA_LEX_CREATE_TMP_TABLE) if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
......
...@@ -285,6 +285,8 @@ int rea_create_table(THD *thd, my_string file_name, ...@@ -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, if (mysql_create_frm(thd, file_name, db, table, create_info,
create_fields, keys, key_info, NULL)) create_fields, keys, key_info, NULL))
DBUG_RETURN(1); 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)) if (!create_info->frm_only && ha_create_table(file_name,create_info,0))
{ {
my_delete(file_name,MYF(0)); my_delete(file_name,MYF(0));
......
...@@ -179,7 +179,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, ...@@ -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++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (map[*a] != ' ')
return (map[*a] < ' ') ? -swap : swap; return (map[*a] < ' ') ? -swap : swap;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment