Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/bk/work-bug_qc-4.1
This commit is contained in:
bell@sanja.is.com.ua 2005-07-04 01:36:55 +03:00
commit 67c9df1eb8
36 changed files with 381 additions and 104 deletions

View File

@ -23,7 +23,7 @@ EXTRA_DIST = INSTALL-SOURCE README COPYING EXCEPTIONS-CLIENT
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common \ @readline_topdir@ sql-common \
@thread_dirs@ pstack \ @thread_dirs@ pstack \
@sql_union_dirs@ scripts man tests \ @sql_union_dirs@ scripts @man_dirs@ tests \
netware @libmysqld_dirs@ \ netware @libmysqld_dirs@ \
@bench_dirs@ support-files @fs_dirs@ @tools_dirs@ @bench_dirs@ support-files @fs_dirs@ @tools_dirs@

View File

@ -272,7 +272,7 @@ LINK32=xilink6.exe
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /D "NDEBUG" /FD /c # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "DBUG_OFF" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /D "NDEBUG" /FD /c
# SUBTRACT BASE CPP /YX # SUBTRACT BASE CPP /YX
# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D LICENSE=Commercial /D "NDEBUG" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-pro-nt" /FD # ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../regex" /I "../zlib" /D "__NT__" /D "DBUG_OFF" /D "HAVE_INNOBASE_DB" /D LICENSE=Commercial /D "NDEBUG" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "HAVE_DLOPEN" /D MYSQL_SERVER_SUFFIX=-pro-nt /FD
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe

View File

@ -60,7 +60,12 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <violite.h> #include <violite.h>
#include <regex.h> /* Our own version of lib */ #include <regex.h> /* Our own version of lib */
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
#endif
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
#endif
#define MAX_QUERY 131072 #define MAX_QUERY 131072
#define MAX_VAR_NAME 256 #define MAX_VAR_NAME 256
#define MAX_COLUMNS 256 #define MAX_COLUMNS 256

View File

@ -419,9 +419,14 @@ then
if echo $CXX | grep gcc > /dev/null 2>&1 if echo $CXX | grep gcc > /dev/null 2>&1
then then
if $CXX -v 2>&1 | grep 'version 3' > /dev/null 2>&1 AC_MSG_CHECKING([if CXX is gcc 3 or 4])
if $CXX -v 2>&1 | grep 'version [[34]]' > /dev/null 2>&1
then then
AC_MSG_RESULT([yes])
AC_MSG_NOTICE([using MySQL tricks to avoid linking C++ code with C++ libraries])
CXXFLAGS="$CXXFLAGS -DUSE_MYSYS_NEW -DDEFINE_CXA_PURE_VIRTUAL" CXXFLAGS="$CXXFLAGS -DUSE_MYSYS_NEW -DDEFINE_CXA_PURE_VIRTUAL"
else
AC_MSG_RESULT([no])
fi fi
fi fi
fi fi

View File

@ -3400,9 +3400,9 @@ fil_extend_space_to_desired_size(
fil_space_t* space; fil_space_t* space;
byte* buf2; byte* buf2;
byte* buf; byte* buf;
ulint buf_size;
ulint start_page_no; ulint start_page_no;
ulint file_start_page_no; ulint file_start_page_no;
ulint n_pages;
ulint offset_high; ulint offset_high;
ulint offset_low; ulint offset_low;
ibool success = TRUE; ibool success = TRUE;
@ -3427,22 +3427,20 @@ fil_extend_space_to_desired_size(
fil_node_prepare_for_io(node, system, space); fil_node_prepare_for_io(node, system, space);
/* Extend 1 MB at a time */
buf2 = mem_alloc(1024 * 1024 + UNIV_PAGE_SIZE);
buf = ut_align(buf2, UNIV_PAGE_SIZE);
memset(buf, '\0', 1024 * 1024);
start_page_no = space->size; start_page_no = space->size;
file_start_page_no = space->size - node->size; file_start_page_no = space->size - node->size;
while (start_page_no < size_after_extend) { /* Extend at most 64 pages at a time */
n_pages = size_after_extend - start_page_no; buf_size = ut_min(64, size_after_extend - start_page_no)
* UNIV_PAGE_SIZE;
buf2 = mem_alloc(buf_size + UNIV_PAGE_SIZE);
buf = ut_align(buf2, UNIV_PAGE_SIZE);
if (n_pages > (1024 * 1024) / UNIV_PAGE_SIZE) { memset(buf, 0, buf_size);
n_pages = (1024 * 1024) / UNIV_PAGE_SIZE;
} while (start_page_no < size_after_extend) {
ulint n_pages = ut_min(buf_size / UNIV_PAGE_SIZE,
size_after_extend - start_page_no);
offset_high = (start_page_no - file_start_page_no) offset_high = (start_page_no - file_start_page_no)
/ (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE)); / (4096 * ((1024 * 1024) / UNIV_PAGE_SIZE));

View File

@ -368,7 +368,7 @@ os_file_get_size_as_iblonglong(
/* out: size in bytes, -1 if error */ /* out: size in bytes, -1 if error */
os_file_t file); /* in: handle to a file */ os_file_t file); /* in: handle to a file */
/*************************************************************************** /***************************************************************************
Sets a file size. This function can be used to extend or truncate a file. */ Write the specified number of zeros to a newly created file. */
ibool ibool
os_file_set_size( os_file_set_size(

View File

@ -1642,7 +1642,7 @@ os_file_get_size_as_iblonglong(
} }
/*************************************************************************** /***************************************************************************
Sets a file size. This function can be used to extend or truncate a file. */ Write the specified number of zeros to a newly created file. */
ibool ibool
os_file_set_size( os_file_set_size(
@ -1655,47 +1655,46 @@ os_file_set_size(
size */ size */
ulint size_high)/* in: most significant 32 bits of size */ ulint size_high)/* in: most significant 32 bits of size */
{ {
ib_longlong offset; ib_longlong current_size;
ib_longlong low; ib_longlong desired_size;
ulint n_bytes;
ibool ret; ibool ret;
byte* buf; byte* buf;
byte* buf2; byte* buf2;
ulint i; ulint buf_size;
ut_a(size == (size & 0xFFFFFFFF)); ut_a(size == (size & 0xFFFFFFFF));
/* We use a very big 8 MB buffer in writing because Linux may be current_size = 0;
extremely slow in fsync on 1 MB writes */ desired_size = (ib_longlong)size + (((ib_longlong)size_high) << 32);
buf2 = ut_malloc(UNIV_PAGE_SIZE * 513); /* Write up to 1 megabyte at a time. */
buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE))
* UNIV_PAGE_SIZE;
buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE);
/* Align the buffer for possible raw i/o */ /* Align the buffer for possible raw i/o */
buf = ut_align(buf2, UNIV_PAGE_SIZE); buf = ut_align(buf2, UNIV_PAGE_SIZE);
/* Write buffer full of zeros */ /* Write buffer full of zeros */
for (i = 0; i < UNIV_PAGE_SIZE * 512; i++) { memset(buf, 0, buf_size);
buf[i] = '\0';
}
offset = 0; if (desired_size >= (ib_longlong)(100 * 1024 * 1024)) {
low = (ib_longlong)size + (((ib_longlong)size_high) << 32);
if (low >= (ib_longlong)(100 * 1024 * 1024)) {
fprintf(stderr, "InnoDB: Progress in MB:"); fprintf(stderr, "InnoDB: Progress in MB:");
} }
while (offset < low) { while (current_size < desired_size) {
if (low - offset < UNIV_PAGE_SIZE * 512) { ulint n_bytes;
n_bytes = (ulint)(low - offset);
} else { if (desired_size - current_size < (ib_longlong) buf_size) {
n_bytes = UNIV_PAGE_SIZE * 512; n_bytes = (ulint) (desired_size - current_size);
} } else {
n_bytes = buf_size;
}
ret = os_file_write(name, file, buf, ret = os_file_write(name, file, buf,
(ulint)(offset & 0xFFFFFFFF), (ulint)(current_size & 0xFFFFFFFF),
(ulint)(offset >> 32), (ulint)(current_size >> 32),
n_bytes); n_bytes);
if (!ret) { if (!ret) {
ut_free(buf2); ut_free(buf2);
@ -1703,18 +1702,18 @@ os_file_set_size(
} }
/* Print about progress for each 100 MB written */ /* Print about progress for each 100 MB written */
if ((offset + n_bytes) / (ib_longlong)(100 * 1024 * 1024) if ((current_size + n_bytes) / (ib_longlong)(100 * 1024 * 1024)
!= offset / (ib_longlong)(100 * 1024 * 1024)) { != current_size / (ib_longlong)(100 * 1024 * 1024)) {
fprintf(stderr, " %lu00", fprintf(stderr, " %lu00",
(ulong) ((offset + n_bytes) (ulong) ((current_size + n_bytes)
/ (ib_longlong)(100 * 1024 * 1024))); / (ib_longlong)(100 * 1024 * 1024)));
} }
offset += n_bytes; current_size += n_bytes;
} }
if (low >= (ib_longlong)(100 * 1024 * 1024)) { if (desired_size >= (ib_longlong)(100 * 1024 * 1024)) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }

View File

@ -194,11 +194,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
test(test_all_bits(options, HA_OPTION_CHECKSUM | HA_PACK_RECORD)); test(test_all_bits(options, HA_OPTION_CHECKSUM | HA_PACK_RECORD));
min_pack_length+=packed; min_pack_length+=packed;
if (!ci->data_file_length) if (!ci->data_file_length && ci->max_rows)
{ {
if (ci->max_rows == 0 || pack_reclength == INT_MAX32) if (pack_reclength == INT_MAX32 ||
ci->data_file_length= INT_MAX32-1; /* Should be enough */ (~(ulonglong) 0)/ci->max_rows < (ulonglong) pack_reclength)
else if ((~(ulonglong) 0)/ci->max_rows < (ulonglong) pack_reclength)
ci->data_file_length= ~(ulonglong) 0; ci->data_file_length= ~(ulonglong) 0;
else else
ci->data_file_length=(ulonglong) ci->max_rows*pack_reclength; ci->data_file_length=(ulonglong) ci->max_rows*pack_reclength;
@ -724,10 +723,13 @@ err:
uint mi_get_pointer_length(ulonglong file_length, uint def) uint mi_get_pointer_length(ulonglong file_length, uint def)
{ {
DBUG_ASSERT(def >= 2 && def <= 7);
if (file_length) /* If not default */ if (file_length) /* If not default */
{ {
#ifdef NOT_YET_READY_FOR_8_BYTE_POINTERS
if (file_length >= (longlong) 1 << 56) if (file_length >= (longlong) 1 << 56)
def=8; def=8;
#endif
if (file_length >= (longlong) 1 << 48) if (file_length >= (longlong) 1 << 48)
def=7; def=7;
if (file_length >= (longlong) 1 << 40) if (file_length >= (longlong) 1 << 40)

View File

@ -630,3 +630,14 @@ Warnings:
Warning 1265 Data truncated for column 'Field1' at row 1 Warning 1265 Data truncated for column 'Field1' at row 1
DROP TABLE t1; DROP TABLE t1;
SET NAMES latin1; SET NAMES latin1;
CREATE TABLE t1 (
a varchar(255) NOT NULL default '',
KEY a (a)
) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE ucs2_general_ci;
insert into t1 values (0x803d);
insert into t1 values (0x005b);
select hex(a) from t1;
hex(a)
005B
803D
drop table t1;

View File

@ -939,3 +939,14 @@ content msisdn
ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми 1234567890 ERR Имри.Афимим.Аеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ад.Д имдимримрад.Адимримримрмдиримримримр м.Дадимфшьмримд им.Адимимрн имадми 1234567890
11 g 1234567890 11 g 1234567890
DROP TABLE t1,t2; DROP TABLE t1,t2;
CREATE TABLE t1 (
a varchar(255) NOT NULL default '',
KEY a (a)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
insert into t1 values (_utf8 0xe880bd);
insert into t1 values (_utf8 0x5b);
select hex(a) from t1;
hex(a)
5B
E880BD
drop table t1;

View File

@ -789,3 +789,64 @@ field(0,NULL,1,0) field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
select field(NULL,1,2,NULL), field(NULL,1,2,0); select field(NULL,1,2,NULL), field(NULL,1,2,0);
field(NULL,1,2,NULL) field(NULL,1,2,0) field(NULL,1,2,NULL) field(NULL,1,2,0)
0 0 0 0
CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
CREATE TABLE t2 (num int primary key);
INSERT INTO t1 VALUES ('notnumber');
INSERT INTO t2 VALUES (0), (1);
SELECT * FROM t1, t2 WHERE num=str;
str num
notnumber 0
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
str num
notnumber 0
DROP TABLE t1,t2;
CREATE TABLE t1(
id int(11) NOT NULL auto_increment,
pc int(11) NOT NULL default '0',
title varchar(20) default NULL,
PRIMARY KEY (id)
);
INSERT INTO t1 VALUES
(1, 0, 'Main'),
(2, 1, 'Toys'),
(3, 1, 'Games');
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
id col1
1 Main
2 Main->Toys
3 Main->Games
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
LEFT JOIN t1 AS t3 ON t2.pc=t3.id
WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
id col1
2 Main->Toys
DROP TABLE t1;
CREATE TABLE t1(
trackid int(10) unsigned NOT NULL auto_increment,
trackname varchar(100) NOT NULL default '',
PRIMARY KEY (trackid)
);
CREATE TABLE t2(
artistid int(10) unsigned NOT NULL auto_increment,
artistname varchar(100) NOT NULL default '',
PRIMARY KEY (artistid)
);
CREATE TABLE t3(
trackid int(10) unsigned NOT NULL,
artistid int(10) unsigned NOT NULL,
PRIMARY KEY (trackid,artistid)
);
INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
INSERT INTO t2 VALUES (1, 'Vernon Duke');
INSERT INTO t3 VALUES (1,1);
SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
LEFT JOIN t2 ON t2.artistid=t3.artistid
WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
trackname artistname
April In Paris Vernon Duke Vernon Duke
Autumn In New York NULL
DROP TABLE t1,t2,t3;

View File

@ -751,3 +751,9 @@ COUNT(DISTINCT(t1.id)) err_comment
1 NULL 1 NULL
1 a problem 1 a problem
DROP TABLE t1, t2; DROP TABLE t1, t2;
CREATE TABLE t1 (n int);
INSERT INTO t1 VALUES (1);
SELECT n+1 AS n FROM t1 GROUP BY n;
n
2
DROP TABLE t1;

View File

@ -2515,3 +2515,12 @@ SELECT b FROM t1 WHERE b=0x8000000000000000;
b b
9223372036854775808 9223372036854775808
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
INSERT INTO `t2` VALUES (0,'READ');
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
INSERT INTO `t3` VALUES (1,'fs');
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
id name gid uid ident level
1 fs NULL NULL 0 READ
drop table t1,t2,t3;

View File

@ -482,10 +482,10 @@ t1 CREATE TABLE `t1` (
`c3` longtext `c3` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1; drop table t1;
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8; SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
Variable_name Value Variable_name Value
myisam_data_pointer_size 8 myisam_data_pointer_size 7
SET GLOBAL table_cache=-1; SET GLOBAL table_cache=-1;
SHOW VARIABLES LIKE 'table_cache'; SHOW VARIABLES LIKE 'table_cache';
Variable_name Value Variable_name Value

View File

@ -404,3 +404,15 @@ CREATE TABLE t1 (Field1 int(10) unsigned default '0');
INSERT INTO t1 VALUES ('-1'); INSERT INTO t1 VALUES ('-1');
DROP TABLE t1; DROP TABLE t1;
SET NAMES latin1; SET NAMES latin1;
#
# Bug#9557 MyISAM utf8 table crash
#
CREATE TABLE t1 (
a varchar(255) NOT NULL default '',
KEY a (a)
) ENGINE=MyISAM DEFAULT CHARSET=ucs2 COLLATE ucs2_general_ci;
insert into t1 values (0x803d);
insert into t1 values (0x005b);
select hex(a) from t1;
drop table t1;

View File

@ -788,3 +788,15 @@ INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25');
SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890'; SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890';
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug#9557 MyISAM utf8 table crash
#
CREATE TABLE t1 (
a varchar(255) NOT NULL default '',
KEY a (a)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;
insert into t1 values (_utf8 0xe880bd);
insert into t1 values (_utf8 0x5b);
select hex(a) from t1;
drop table t1;

View File

@ -527,3 +527,73 @@ DROP TABLE t1, t2;
# #
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0); select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
select field(NULL,1,2,NULL), field(NULL,1,2,0); select field(NULL,1,2,NULL), field(NULL,1,2,0);
#
# Bug #10124: access by integer index with a string key that is not a number
#
CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
CREATE TABLE t2 (num int primary key);
INSERT INTO t1 VALUES ('notnumber');
INSERT INTO t2 VALUES (0), (1);
SELECT * FROM t1, t2 WHERE num=str;
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
DROP TABLE t1,t2;
#
# Bug #11469: NOT NULL optimization wrongly used for arguments of CONCAT_WS
#
CREATE TABLE t1(
id int(11) NOT NULL auto_increment,
pc int(11) NOT NULL default '0',
title varchar(20) default NULL,
PRIMARY KEY (id)
);
INSERT INTO t1 VALUES
(1, 0, 'Main'),
(2, 1, 'Toys'),
(3, 1, 'Games');
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
LEFT JOIN t1 AS t3 ON t2.pc=t3.id
WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
DROP TABLE t1;
CREATE TABLE t1(
trackid int(10) unsigned NOT NULL auto_increment,
trackname varchar(100) NOT NULL default '',
PRIMARY KEY (trackid)
);
CREATE TABLE t2(
artistid int(10) unsigned NOT NULL auto_increment,
artistname varchar(100) NOT NULL default '',
PRIMARY KEY (artistid)
);
CREATE TABLE t3(
trackid int(10) unsigned NOT NULL,
artistid int(10) unsigned NOT NULL,
PRIMARY KEY (trackid,artistid)
);
INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
INSERT INTO t2 VALUES (1, 'Vernon Duke');
INSERT INTO t3 VALUES (1,1);
SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
LEFT JOIN t2 ON t2.artistid=t3.artistid
WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
DROP TABLE t1,t2,t3;

View File

@ -580,3 +580,15 @@ SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS err_comment
FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY err_comment; FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY err_comment;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# Test for bug #11414: crash on Windows for a simple GROUP BY query
#
CREATE TABLE t1 (n int);
INSERT INTO t1 VALUES (1);
SELECT n+1 AS n FROM t1 GROUP BY n;
DROP TABLE t1;

View File

@ -7,6 +7,13 @@ DROP TABLE IF EXISTS t1;
drop database if exists mysqltest; drop database if exists mysqltest;
--enable_warnings --enable_warnings
connect (con1,localhost,root,,test);
connect (con2,localhost,root,,test);
connection con2;
-- sleep 2
connection con1;
# #
# Basic test to show that the ALTER TABLE # Basic test to show that the ALTER TABLE
# is working # is working
@ -88,10 +95,6 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (9410,9412); INSERT INTO t1 VALUES (9410,9412);
connect (con1,localhost,,,test);
connect (con2,localhost,,,test);
connection con1;
ALTER TABLE t1 ADD COLUMN c int not null; ALTER TABLE t1 ADD COLUMN c int not null;
select * from t1 order by a; select * from t1 order by a;

View File

@ -2060,3 +2060,18 @@ CREATE TABLE t1 (b BIGINT(20) UNSIGNED NOT NULL, PRIMARY KEY (b));
INSERT INTO t1 VALUES (0x8000000000000000); INSERT INTO t1 VALUES (0x8000000000000000);
SELECT b FROM t1 WHERE b=0x8000000000000000; SELECT b FROM t1 WHERE b=0x8000000000000000;
DROP TABLE t1; DROP TABLE t1;
#
# IN with outer join condition (BUG#9393)
#
CREATE TABLE `t1` ( `gid` int(11) default NULL, `uid` int(11) default NULL);
CREATE TABLE `t2` ( `ident` int(11) default NULL, `level` char(16) default NULL);
INSERT INTO `t2` VALUES (0,'READ');
CREATE TABLE `t3` ( `id` int(11) default NULL, `name` char(16) default NULL);
INSERT INTO `t3` VALUES (1,'fs');
select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid, t3.id, 0);
drop table t1,t2,t3;

View File

@ -363,9 +363,13 @@ drop table t1;
# #
# Bug #6993: myisam_data_pointer_size # Bug #6993: myisam_data_pointer_size
# Wrong bug report, data pointer size must be restricted to 7,
# setting to 8 will not work on all computers, myisamchk and
# the server may see a wrong value, such as 0 or negative number
# if 8 bytes is set.
# #
SET GLOBAL MYISAM_DATA_POINTER_SIZE= 8; SET GLOBAL MYISAM_DATA_POINTER_SIZE= 7;
SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE'; SHOW VARIABLES LIKE 'MYISAM_DATA_POINTER_SIZE';
# #

View File

@ -86,6 +86,7 @@ void init_thr_alarm(uint max_alarms)
{ {
struct sigaction sact; struct sigaction sact;
sact.sa_flags = 0; sact.sa_flags = 0;
bzero((char*) &sact, sizeof(sact));
sact.sa_handler = thread_alarm; sact.sa_handler = thread_alarm;
sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0); sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
} }

View File

@ -357,6 +357,9 @@ if [ -d $BASE/SSL/SCCS ]
then then
find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f
fi fi
find $BASE/ -type d -name .deps -printf " \"%p\"" | xargs rm -r -f
find $BASE/ -type d -name .libs -printf " \"%p\"" | xargs rm -r -f
rm -r -f "$BASE/mysql-test/var"
# #
# Initialize the initial data directory # Initialize the initial data directory

View File

@ -2480,7 +2480,10 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
if (error || if (error ||
(from+len != end && table->in_use->count_cuted_fields && (from+len != end && table->in_use->count_cuted_fields &&
!test_if_int(from,len,end,cs))) !test_if_int(from,len,end,cs)))
error= 1; {
if (error != 1)
error= 2;
}
#if SIZEOF_LONG > 4 #if SIZEOF_LONG > 4
if (unsigned_flag) if (unsigned_flag)
{ {
@ -2508,10 +2511,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs)
} }
#endif #endif
if (error) if (error)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
error= 1;
}
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first) if (table->db_low_byte_first)
{ {
@ -2777,8 +2777,11 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs)
(from+len != end && table->in_use->count_cuted_fields && (from+len != end && table->in_use->count_cuted_fields &&
!test_if_int(from,len,end,cs))) !test_if_int(from,len,end,cs)))
{ {
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); if (error != 1)
error= 1; {
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
error= 2;
}
} }
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first) if (table->db_low_byte_first)
@ -2998,7 +3001,7 @@ int Field_float::store(const char *from,uint len,CHARSET_INFO *cs)
double nr= my_strntod(cs,(char*) from,len,&end,&error); double nr= my_strntod(cs,(char*) from,len,&end,&error);
if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields)) if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields))
{ {
error= 1; error= 2;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
} }
Field_float::store(nr); Field_float::store(nr);
@ -3284,7 +3287,7 @@ int Field_double::store(const char *from,uint len,CHARSET_INFO *cs)
double nr= my_strntod(cs,(char*) from, len, &end, &error); double nr= my_strntod(cs,(char*) from, len, &end, &error);
if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields)) if (error || ((uint) (end-from) != len && table->in_use->count_cuted_fields))
{ {
error= 1; error= 2;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
} }
Field_double::store(nr); Field_double::store(nr);
@ -3666,6 +3669,8 @@ int Field_timestamp::store(const char *from,uint len,CHARSET_INFO *cs)
error= 1; error= 1;
} }
} }
if (error > 1)
error= 2;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first) if (table->db_low_byte_first)
@ -3954,7 +3959,7 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
if (str_to_time(from, len, &ltime, &error)) if (str_to_time(from, len, &ltime, &error))
{ {
tmp=0L; tmp=0L;
error= 1; error= 2;
set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED,
from, len, MYSQL_TIMESTAMP_TIME, 1); from, len, MYSQL_TIMESTAMP_TIME, 1);
} }
@ -3976,6 +3981,8 @@ int Field_time::store(const char *from,uint len,CHARSET_INFO *cs)
from, len, MYSQL_TIMESTAMP_TIME, !error); from, len, MYSQL_TIMESTAMP_TIME, !error);
error= 1; error= 1;
} }
if (error > 1)
error= 2;
} }
if (ltime.neg) if (ltime.neg)
@ -4305,7 +4312,7 @@ int Field_date::store(const char *from, uint len,CHARSET_INFO *cs)
if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR) if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR)
{ {
tmp=0; tmp=0;
error= 1; error= 2;
} }
else else
tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day); tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
@ -4496,7 +4503,7 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR) if (str_to_datetime(from, len, &l_time, 1, &error) <= MYSQL_TIMESTAMP_ERROR)
{ {
tmp=0L; tmp=0L;
error= 1; error= 2;
} }
else else
tmp= l_time.day + l_time.month*32 + l_time.year*16*32; tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
@ -4938,7 +4945,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
from= tmpstr.ptr(); from= tmpstr.ptr();
length= tmpstr.length(); length= tmpstr.length();
if (conv_errors) if (conv_errors)
error= 1; error= 2;
} }
/* /*
@ -4962,7 +4969,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
from+= field_charset->cset->scan(field_charset, from, end, from+= field_charset->cset->scan(field_charset, from, end,
MY_SEQ_SPACES); MY_SEQ_SPACES);
if (from != end) if (from != end)
error= 1; error= 2;
} }
if (error) if (error)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
@ -5217,12 +5224,12 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
from= tmpstr.ptr(); from= tmpstr.ptr();
length= tmpstr.length(); length= tmpstr.length();
if (conv_errors) if (conv_errors)
error= 1; error= 2;
} }
if (length > field_length) if (length > field_length)
{ {
length=field_length; length=field_length;
error= 1; error= 2;
} }
if (error) if (error)
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1); set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_TRUNCATED, 1);
@ -5575,7 +5582,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
from= tmpstr.ptr(); from= tmpstr.ptr();
length= tmpstr.length(); length= tmpstr.length();
if (conv_errors) if (conv_errors)
error= 1; error= 2;
} }
copy_length= max_data_length(); copy_length= max_data_length();
@ -5590,7 +5597,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
copy_length, copy_length,
&well_formed_error); &well_formed_error);
if (copy_length < length) if (copy_length < length)
error= 1; error= 2;
Field_blob::store_length(copy_length); Field_blob::store_length(copy_length);
if (was_conversion || table->copy_blobs || copy_length <= MAX_FIELD_WIDTH) if (was_conversion || table->copy_blobs || copy_length <= MAX_FIELD_WIDTH)
{ // Must make a copy { // Must make a copy

View File

@ -769,6 +769,12 @@ class Item_func_in :public Item_int_func
bool nulls_in_row(); bool nulls_in_row();
bool is_bool_func() { return 1; } bool is_bool_func() { return 1; }
CHARSET_INFO *compare_collation() { return cmp_collation.collation; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
/*
IN() protect from NULL only first argument, if construction like
"expression IN ()" will be allowed, we will need to check number of
argument here, because "NOT(NULL IN ())" is TRUE.
*/
table_map not_null_tables() const { return args[0]->not_null_tables(); }
}; };
/* Functions used by where clause */ /* Functions used by where clause */

View File

@ -95,6 +95,7 @@ public:
String *val_str(String *); String *val_str(String *);
void fix_length_and_dec(); void fix_length_and_dec();
const char *func_name() const { return "concat_ws"; } const char *func_name() const { return "concat_ws"; }
table_map not_null_tables() const { return 0; }
}; };
class Item_func_reverse :public Item_str_func class Item_func_reverse :public Item_str_func

View File

@ -1361,7 +1361,7 @@ int subselect_uniquesubquery_engine::exec()
TABLE *table= tab->table; TABLE *table= tab->table;
for (store_key **copy=tab->ref.key_copy ; *copy ; copy++) for (store_key **copy=tab->ref.key_copy ; *copy ; copy++)
{ {
if (tab->ref.key_err= (*copy)->copy()) if ((tab->ref.key_err= (*copy)->copy()) & 1)
{ {
table->status= STATUS_NOT_FOUND; table->status= STATUS_NOT_FOUND;
DBUG_RETURN(1); DBUG_RETURN(1);
@ -1414,7 +1414,7 @@ int subselect_indexsubquery_engine::exec()
for (store_key **copy=tab->ref.key_copy ; *copy ; copy++) for (store_key **copy=tab->ref.key_copy ; *copy ; copy++)
{ {
if (tab->ref.key_err= (*copy)->copy()) if ((tab->ref.key_err= (*copy)->copy()) & 1)
{ {
table->status= STATUS_NOT_FOUND; table->status= STATUS_NOT_FOUND;
DBUG_RETURN(1); DBUG_RETURN(1);

View File

@ -5153,7 +5153,7 @@ The minimum value for this variable is 4096.",
"Default pointer size to be used for MyISAM tables.", "Default pointer size to be used for MyISAM tables.",
(gptr*) &myisam_data_pointer_size, (gptr*) &myisam_data_pointer_size,
(gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, (gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG,
4, 2, 8, 0, 1, 0}, 4, 2, 7, 0, 1, 0},
{"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE,
"Used to help MySQL to decide when to use the slow but safe key cache index create method.", "Used to help MySQL to decide when to use the slow but safe key cache index create method.",
(gptr*) &global_system_variables.myisam_max_extra_sort_file_size, (gptr*) &global_system_variables.myisam_max_extra_sort_file_size,

View File

@ -981,8 +981,7 @@ get_mm_parts(PARAM *param, COND *cond_func, Field *field,
SEL_TREE *tree2= get_mm_parts(param, cond_func, SEL_TREE *tree2= get_mm_parts(param, cond_func,
field, Item_func::GT_FUNC, field, Item_func::GT_FUNC,
value, cmp_type); value, cmp_type);
if (!tree2) /* tree_or() will return 0 if tree2 is 0 */
DBUG_RETURN(0)
tree= tree_or(param,tree,tree2); tree= tree_or(param,tree,tree2);
} }
DBUG_RETURN(tree); DBUG_RETURN(tree);

View File

@ -979,6 +979,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
if (table->timestamp_field) if (table->timestamp_field)
table->timestamp_field_type= table->timestamp_field->get_auto_set_type(); table->timestamp_field_type= table->timestamp_field->get_auto_set_type();
DBUG_ASSERT(table->key_read == 0); DBUG_ASSERT(table->key_read == 0);
DBUG_ASSERT(table->insert_values == 0);
DBUG_RETURN(table); DBUG_RETURN(table);
} }

View File

@ -516,6 +516,10 @@ abort:
ON DUPLICATE KEY ... ON DUPLICATE KEY ...
we should be able to refer to sum1 in the ON DUPLICATE KEY part we should be able to refer to sum1 in the ON DUPLICATE KEY part
WARNING
You MUST set table->insert_values to 0 after calling this function
before releasing the table object.
RETURN VALUE RETURN VALUE
0 OK 0 OK
-1 error (message is not sent to user) -1 error (message is not sent to user)

View File

@ -2891,12 +2891,12 @@ unsent_create_error:
/* revert changes for SP */ /* revert changes for SP */
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE; lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
delete result; delete result;
insert_table->insert_values= 0;
if (thd->net.report_error) if (thd->net.report_error)
res= -1; res= -1;
} }
else else
res= -1; res= -1;
insert_table->insert_values= 0; // Set by mysql_prepare_insert()
first_local_table->next= tables; first_local_table->next= tables;
lex->select_lex.table_list.first= (byte*) first_local_table; lex->select_lex.table_list.first= (byte*) first_local_table;
break; break;

View File

@ -134,8 +134,8 @@ static void read_cached_record(JOIN_TAB *tab);
static bool cmp_buffer_with_ref(JOIN_TAB *tab); static bool cmp_buffer_with_ref(JOIN_TAB *tab);
static bool setup_new_fields(THD *thd,TABLE_LIST *tables,List<Item> &fields, static bool setup_new_fields(THD *thd,TABLE_LIST *tables,List<Item> &fields,
List<Item> &all_fields,ORDER *new_order); List<Item> &all_fields,ORDER *new_order);
static ORDER *create_distinct_group(THD *thd, ORDER *order, static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array,
List<Item> &fields, ORDER *order, List<Item> &fields,
bool *all_order_by_fields_used); bool *all_order_by_fields_used);
static bool test_if_subpart(ORDER *a,ORDER *b); static bool test_if_subpart(ORDER *a,ORDER *b);
static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables); static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables);
@ -642,7 +642,8 @@ JOIN::optimize()
bool all_order_fields_used; bool all_order_fields_used;
if (order) if (order)
skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1); skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1);
if ((group_list=create_distinct_group(thd, order, fields_list, if ((group_list=create_distinct_group(thd, select_lex->ref_pointer_array,
order, fields_list,
&all_order_fields_used))) &all_order_fields_used)))
{ {
bool skip_group= (skip_sort_order && bool skip_group= (skip_sort_order &&
@ -8221,11 +8222,13 @@ cp_buffer_from_ref(THD *thd, TABLE_REF *ref)
enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; enum enum_check_fields save_count_cuted_fields= thd->count_cuted_fields;
thd->count_cuted_fields= CHECK_FIELD_IGNORE; thd->count_cuted_fields= CHECK_FIELD_IGNORE;
for (store_key **copy=ref->key_copy ; *copy ; copy++) for (store_key **copy=ref->key_copy ; *copy ; copy++)
if ((*copy)->copy()) {
if ((*copy)->copy() & 1)
{ {
thd->count_cuted_fields= save_count_cuted_fields; thd->count_cuted_fields= save_count_cuted_fields;
return 1; // Something went wrong return 1; // Something went wrong
} }
}
thd->count_cuted_fields= save_count_cuted_fields; thd->count_cuted_fields= save_count_cuted_fields;
return 0; return 0;
} }
@ -8436,12 +8439,14 @@ setup_new_fields(THD *thd,TABLE_LIST *tables,List<Item> &fields,
*/ */
static ORDER * static ORDER *
create_distinct_group(THD *thd, ORDER *order_list, List<Item> &fields, create_distinct_group(THD *thd, Item **ref_pointer_array,
ORDER *order_list, List<Item> &fields,
bool *all_order_by_fields_used) bool *all_order_by_fields_used)
{ {
List_iterator<Item> li(fields); List_iterator<Item> li(fields);
Item *item; Item *item;
ORDER *order,*group,**prev; ORDER *order,*group,**prev;
uint index= 0;
*all_order_by_fields_used= 1; *all_order_by_fields_used= 1;
while ((item=li++)) while ((item=li++))
@ -8473,11 +8478,17 @@ create_distinct_group(THD *thd, ORDER *order_list, List<Item> &fields,
ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER)); ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
if (!ord) if (!ord)
return 0; return 0;
ord->item=li.ref(); /*
We have here only field_list (not all_field_list), so we can use
simple indexing of ref_pointer_array (order in the array and in the
list are same)
*/
ord->item= ref_pointer_array + index;
ord->asc=1; ord->asc=1;
*prev=ord; *prev=ord;
prev= &ord->next; prev= &ord->next;
} }
index++;
} }
*prev=0; *prev=0;
return group; return group;
@ -8721,7 +8732,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
{ {
Item *pos; Item *pos;
List_iterator_fast<Item> li(all_fields); List_iterator_fast<Item> li(all_fields);
Copy_field *copy; Copy_field *copy= NULL;
res_selected_fields.empty(); res_selected_fields.empty();
res_all_fields.empty(); res_all_fields.empty();
List_iterator_fast<Item> itr(res_all_fields); List_iterator_fast<Item> itr(res_all_fields);
@ -8729,7 +8740,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
uint i, border= all_fields.elements - elements; uint i, border= all_fields.elements - elements;
DBUG_ENTER("setup_copy_fields"); DBUG_ENTER("setup_copy_fields");
if (!(copy=param->copy_field= new Copy_field[param->field_count])) if (param->field_count &&
!(copy=param->copy_field= new Copy_field[param->field_count]))
goto err2; goto err2;
param->copy_funcs.empty(); param->copy_funcs.empty();
@ -8813,7 +8825,8 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
DBUG_RETURN(0); DBUG_RETURN(0);
err: err:
delete [] param->copy_field; // This is never 0 if (copy)
delete [] param->copy_field;
param->copy_field=0; param->copy_field=0;
err2: err2:
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);

View File

@ -356,6 +356,7 @@ class store_key :public Sql_alloc
char *null_ptr; char *null_ptr;
char err; char err;
public: public:
enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length) store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length)
:null_ptr(null),err(0) :null_ptr(null),err(0)
{ {
@ -371,7 +372,7 @@ class store_key :public Sql_alloc
} }
} }
virtual ~store_key() {} /* Not actually needed */ virtual ~store_key() {} /* Not actually needed */
virtual bool copy()=0; virtual enum store_key_result copy()=0;
virtual const char *name() const=0; virtual const char *name() const=0;
}; };
@ -392,10 +393,10 @@ class store_key_field: public store_key
copy_field.set(to_field,from_field,0); copy_field.set(to_field,from_field,0);
} }
} }
bool copy() enum store_key_result copy()
{ {
copy_field.do_copy(&copy_field); copy_field.do_copy(&copy_field);
return err != 0; return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK;
} }
const char *name() const { return field_name; } const char *name() const { return field_name; }
}; };
@ -412,9 +413,11 @@ public:
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ? null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
&err : NullS, length), item(item_arg) &err : NullS, length), item(item_arg)
{} {}
bool copy() enum store_key_result copy()
{ {
return item->save_in_field(to_field, 1) || err != 0; int res= item->save_in_field(to_field, 1);
return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res);
} }
const char *name() const { return "func"; } const char *name() const { return "func"; }
}; };
@ -432,15 +435,19 @@ public:
&err : NullS, length, item_arg), inited(0) &err : NullS, length, item_arg), inited(0)
{ {
} }
bool copy() enum store_key_result copy()
{ {
int res;
if (!inited) if (!inited)
{ {
inited=1; inited=1;
if (item->save_in_field(to_field, 1)) if ((res= item->save_in_field(to_field, 1)))
err= 1; {
if (!err)
err= res;
}
} }
return err != 0; return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
} }
const char *name() const { return "const"; } const char *name() const { return "const"; }
}; };

View File

@ -209,7 +209,7 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs,
t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; s+=s_res;
@ -267,7 +267,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)),
int t_wc = uni_plane[t[0]] ? (int) uni_plane[t[0]][t[1]].sort : int t_wc = uni_plane[t[0]] ? (int) uni_plane[t[0]][t[1]].sort :
(((int) t[0]) << 8) + (int) t[1]; (((int) t[0]) << 8) + (int) t[1];
if ( s_wc != t_wc ) if ( s_wc != t_wc )
return s_wc - t_wc; return s_wc > t_wc ? 1 : -1;
s+= 2; s+= 2;
t+= 2; t+= 2;
@ -1343,7 +1343,7 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs,
} }
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; s+=s_res;

View File

@ -2000,7 +2000,7 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs,
t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; s+=s_res;
@ -2065,7 +2065,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs,
t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc; t_wc = uni_plane[plane] ? uni_plane[plane][t_wc & 0xFF].sort : t_wc;
if ( s_wc != t_wc ) if ( s_wc != t_wc )
{ {
return ((int) s_wc) - ((int) t_wc); return s_wc > t_wc ? 1 : -1;
} }
s+=s_res; s+=s_res;