Commit ca4bf4f7 authored by unknown's avatar unknown

Fixed bug in SAFEMALLOC for systems that requires longlong data to be aligned...

Fixed bug in SAFEMALLOC for systems that requires longlong data to be aligned on 8 byte boundaries (like sparc)
Removed thread marking of safemalloc blocks (becasue of alignment problems)
Temporary fix for bigint comparison.


configure.in:
  Added size checking of char*
BitKeeper/etc/ignore:
  Added sql-bench/innotest1 sql-bench/innotest1a sql-bench/innotest1b sql-bench/innotest2 sql-bench/innotest2a sql-bench/innotest2b to the ignore list
mysql-test/r/select.result:
  Cleaned up test
mysql-test/t/select.test:
  Cleaned up test
mysys/my_static.h:
  Fixed bug in SAFEMALLOC for systems that requires longlong data to be aligned on 8 byte boundaries (like sparc)
mysys/safemalloc.c:
  Fixed bug in SAFEMALLOC for systems that requires longlong data to be aligned on 8 byte boundaries (like sparc)
sql/field.h:
  Temporary fix for bigint comparison.
sql/gen_lex_hash.cc:
  Smaller hash table
sql/item_cmpfunc.cc:
  Cleanup
sql/mysqld.cc:
  Removed thread marking of safemalloc blocks (becasue of alignment problems)
sql/opt_range.cc:
  Comment
parent 08a1a52d
......@@ -485,3 +485,9 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
sql-bench/innotest1
sql-bench/innotest1a
sql-bench/innotest1b
sql-bench/innotest2
sql-bench/innotest2a
sql-bench/innotest2b
......@@ -1463,6 +1463,7 @@ install the static libraries and try again. If this isn't the problem,
examine config.log for possible errors. If you want to report this, use
'scripts/mysqlbug' and include at least the last 20 rows from config.log!])
fi
AC_CHECK_SIZEOF(char*, 4)
AC_CHECK_SIZEOF(int, 4)
if test "$ac_cv_sizeof_int" -eq 0
then
......
......@@ -3229,11 +3229,10 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
drop table t4, t3, t2, t1;
DO 1;
DO benchmark(100,1+1),1,1;
drop table t4, t3,t2, t1;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 ( gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp(14) NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) TYPE=MyISAM;
CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp(14) NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) TYPE=MyISAM;
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
......
......@@ -1712,6 +1712,8 @@ show full columns from t2 from test like 'f%';
show full columns from t2 from test like 's%';
show keys from t2;
drop table t4, t3, t2, t1;
#
# Test of DO
......@@ -1719,17 +1721,20 @@ DO 1;
DO benchmark(100,1+1),1,1;
#
# Drop the test tables
# Test of bug with SUM(CASE...)
#
drop table t4, t3,t2, t1;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 ( gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp(14) NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) TYPE=MyISAM;
CREATE TABLE t1 (gvid int(10) unsigned default NULL, hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, mmid int(10) unsigned default NULL, hdid int(10) unsigned default NULL, fsid int(10) unsigned default NULL, ctid int(10) unsigned default NULL, dtid int(10) unsigned default NULL, cost int(10) unsigned default NULL, performance int(10) unsigned default NULL, serialnumber bigint(20) unsigned default NULL, monitored tinyint(3) unsigned default '1', removed tinyint(3) unsigned default '0', target tinyint(3) unsigned default '0', dt_modified timestamp(14) NOT NULL, name varchar(255) binary default NULL, description varchar(255) default NULL, UNIQUE KEY hmid (hmid,volid)) TYPE=MyISAM;
INSERT INTO t1 VALUES (200001,2,1,1,100,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\E$',''),(200002,2,2,1,101,1,1,1,0,0,0,1,0,1,20020425060057,'\\\\ARKIVIO-TESTPDC\\C$',''),(200003,1,3,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,0,1,20020425060427,'c:',NULL);
CREATE TABLE t2 ( hmid int(10) unsigned default NULL, volid int(10) unsigned default NULL, sampletid smallint(5) unsigned default NULL, sampletime datetime default NULL, samplevalue bigint(20) unsigned default NULL, KEY idx1 (hmid,volid,sampletid,sampletime)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12:00:01',35);
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'NULL' AND b.sampletime < 'NULL' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
DROP TABLE t1,t2;
#
# Test of bigint comparision
#
create table t1 ( A_Id bigint(20) NOT NULL default '0', A_UpdateBy char(10) NOT NULL default '', A_UpdateDate bigint(20) NOT NULL default '0', A_UpdateSerial int(11) NOT NULL default '0', other_types bigint(20) NOT NULL default '0', wss_type bigint(20) NOT NULL default '0');
INSERT INTO t1 VALUES (102935998719055004,'brade',1029359987,2,102935229116544068,102935229216544093);
select wss_type from t1 where wss_type ='102935229216544106';
......
......@@ -32,16 +32,22 @@ struct st_remember {
sig_handler (*func)(int number);
};
struct irem {
struct remember *_pNext; /* Linked list of structures */
struct remember *_pPrev; /* Other link */
my_string _sFileName; /* File in which memory was new'ed */
uint _uLineNum; /* Line number in above file */
uint _uDataSize; /* Size requested */
#ifdef THREAD
pthread_t thread_id;
/*
The size of the following structure MUST be dividable by 8 to not cause
alignment problems on some cpu's
*/
struct irem
{
struct remember *_pNext; /* Linked list of structures */
struct remember *_pPrev; /* Other link */
char *_sFileName; /* File in which memory was new'ed */
uint32 _uLineNum; /* Line number in above file */
uint32 _uDataSize; /* Size requested */
#if SIZEOF_CHARP == 8
long _filler; /* For alignment */
#endif
long _lSpecialValue; /* Underrun marker value */
long _lSpecialValue; /* Underrun marker value */
};
struct remember {
......@@ -59,14 +65,6 @@ extern const char *soundex_map;
extern USED_MEM* my_once_root_block;
extern uint my_once_extra;
#ifdef THREAD
/*
These threads are exempt from safemalloc leak scrutiny unless
PEDANTIC_SAFEMALLOC is defined
*/
extern pthread_t signal_th, kill_th, main_th;
#endif
#ifndef HAVE_TEMPNAM
extern int _my_tempnam_used;
#endif
......
......@@ -71,16 +71,11 @@
ulonglong safemalloc_mem_limit = ~(ulonglong)0;
#ifdef THREAD
pthread_t shutdown_th,main_th,signal_th;
#endif
#define pNext tInt._pNext
#define pPrev tInt._pPrev
#define sFileName tInt._sFileName
#define uLineNum tInt._uLineNum
#define uDataSize tInt._uDataSize
#define thread_id tInt.thread_id
#define lSpecialValue tInt._lSpecialValue
#ifndef PEDANTIC_SAFEMALLOC
......@@ -148,7 +143,7 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
{
/* Allocate the physical memory */
pTmp = (struct remember *) malloc (
sizeof (struct irem) /* remember data */
ALIGN_SIZE(sizeof(struct irem)) /* remember data */
+ sf_malloc_prehunc
+ uSize /* size requested */
+ 4 /* overrun mark */
......@@ -187,9 +182,6 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
pTmp -> sFileName = (my_string) sFile;
pTmp -> uLineNum = uLine;
pTmp -> uDataSize = uSize;
#ifdef THREAD
pTmp->thread_id = pthread_self();
#endif
pTmp -> pPrev = NULL;
/* Add this remember structure to the linked list */
......@@ -244,7 +236,7 @@ gptr _myrealloc (register gptr pPtr, register uint uSize,
if (check_ptr("Reallocating",(byte*) pPtr,sFile,uLine))
DBUG_RETURN((gptr) NULL);
pRec = (struct remember *) ((char*) pPtr - sizeof (struct irem)-
pRec = (struct remember *) ((char*) pPtr - ALIGN_SIZE(sizeof(struct irem))-
sf_malloc_prehunc);
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY)
......@@ -290,7 +282,7 @@ void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags)
DBUG_VOID_RETURN;
/* Calculate the address of the remember structure */
pRec = (struct remember *) ((byte*) pPtr-sizeof(struct irem)-
pRec = (struct remember *) ((byte*) pPtr- ALIGN_SIZE(sizeof(struct irem))-
sf_malloc_prehunc);
/*
......@@ -352,7 +344,7 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
return 1;
}
#ifndef _MSC_VER
if ((long) ptr & (MY_ALIGN(1,sizeof(char *))-1))
if ((long) ptr & (ALIGN_SIZE(1)-1))
{
fprintf (stderr, "%s wrong aligned pointer at line %d, '%s'\n",
where,uLine, sFile);
......@@ -375,18 +367,6 @@ static int check_ptr(const char *where, byte *ptr, const char *sFile,
}
#if !defined(PEDANTIC_SAFEMALLOC) && defined(THREAD)
static int legal_leak(struct remember* pPtr)
{
/* TODO: This code needs to be made more general */
return (pthread_equal(pthread_self(), pPtr->thread_id) ||
pthread_equal(main_th, pPtr->thread_id) ||
pthread_equal(shutdown_th,pPtr->thread_id) ||
pthread_equal(signal_th,pPtr->thread_id));
}
#endif /* THREAD */
/*
TERMINATE(FILE *file)
Report on all the memory pieces that have not been
......@@ -405,48 +385,6 @@ void TERMINATE (FILE *file)
NEWs than FREEs. <0, etc.
*/
#if !defined(PEDANTIC_SAFEMALLOC) && defined(THREAD)
/*
Avoid false alarms for blocks that we cannot free before my_end()
This does miss some positives, but that is ok. This will only miss
failures to free things allocated in the main thread which
performs only one-time allocations. If you really need to
debug memory allocations in the main thread,
#define PEDANTIC_SAFEMALLOC
*/
if ((pPtr=pRememberRoot))
{
while (pPtr)
{
if (legal_leak(pPtr))
{
sf_malloc_tampered=1;
cNewCount--;
lCurMemory -= pPtr->uDataSize;
if (pPtr->pPrev)
{
struct remember* tmp;
tmp = pPtr->pPrev->pNext = pPtr->pNext;
if (tmp)
tmp->pPrev = pPtr->pPrev;
pPtr->pNext = pPtr->pPrev = 0;
pPtr = tmp;
}
else
{
pRememberRoot = pPtr->pNext;
pPtr->pNext = pPtr->pPrev = 0;
pPtr = pRememberRoot;
if (pPtr)
pPtr->pPrev=0;
}
}
else
pPtr = pPtr->pNext;
}
}
#endif
if (cNewCount)
{
if (file)
......@@ -479,9 +417,6 @@ void TERMINATE (FILE *file)
pPtr -> uDataSize,
(ulong) &(pPtr -> aData[sf_malloc_prehunc]),
pPtr -> uLineNum, pPtr -> sFileName);
#ifdef THREAD
fprintf(file, " in thread %ld", pPtr->thread_id);
#endif
fprintf(file, "\n");
(void) fflush(file);
}
......
......@@ -445,6 +445,7 @@ class Field_longlong :public Field_num {
void sort_string(char *buff,uint length);
uint32 pack_length() const { return 8; }
void sql_type(String &str) const;
bool store_for_compare() { return 1; }
};
#endif
......
......@@ -469,7 +469,7 @@ int main(int argc,char **argv)
int error;
MY_INIT(argv[0]);
start_value=7281255L; best_t1=4459515L; best_t2=321142L; best_type=2; /* mode=5953 add=7 type: 0 */
start_value=2925024L; best_t1=654916L; best_t2=1723390L; best_type=3; /* mode=4943 add=1 type: 0 */
if (get_options(argc,(char **) argv))
exit(1);
......
......@@ -42,13 +42,13 @@ static bool convert_constant_item(Field *field, Item **item)
{
if ((*item)->const_item())
{
(*item)->save_in_field(field);
if (!((*item)->null_value))
if (!(*item)->save_in_field(field) &&
!((*item)->null_value))
{
Item *tmp=new Item_int_with_ref(field->val_int(), *item);
if (tmp)
*item=tmp;
return 1;
return 1; // Item was replaced
}
}
return 0;
......@@ -57,7 +57,7 @@ static bool convert_constant_item(Field *field, Item **item)
void Item_bool_func2::fix_length_and_dec()
{
max_length=1;
max_length=1; // Function returns 0 or 1
/*
As some compare functions are generated after sql_yacc,
......@@ -69,7 +69,7 @@ void Item_bool_func2::fix_length_and_dec()
if (args[0]->type() == FIELD_ITEM)
{
Field *field=((Item_field*) args[0])->field;
if (field->store_for_compare() || field->result_type() == INT_RESULT)
if (field->store_for_compare())
{
if (convert_constant_item(field,&args[1]))
{
......@@ -81,7 +81,7 @@ void Item_bool_func2::fix_length_and_dec()
if (args[1]->type() == FIELD_ITEM)
{
Field *field=((Item_field*) args[1])->field;
if (field->store_for_compare() || field->result_type() == INT_RESULT)
if (field->store_for_compare())
{
if (convert_constant_item(field,&args[0]))
{
......
......@@ -37,15 +37,9 @@
#define ONE_THREAD
#endif
#ifdef SAFEMALLOC
#define SHUTDOWN_THD shutdown_th=pthread_self();
#define MAIN_THD main_th=pthread_self();
#define SIGNAL_THD signal_th=pthread_self();
#else
#define SHUTDOWN_THD
#define MAIN_THD
#define SIGNAL_THD
#endif
#ifdef PURIFY
#define IF_PURIFY(A,B) (A)
......@@ -763,7 +757,6 @@ static void __cdecl kill_server(int sig_ptr)
sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */
#if defined(USE_ONE_SIGNAL_HAND) && !defined(__WIN__) && !defined(OS2)
SHUTDOWN_THD;
my_thread_init(); // If this is a new thread
#endif
close_connections();
......
......@@ -1026,6 +1026,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
if (value->save_in_field(field))
{
// TODO; Check if we can we remove the following block.
if (type == Item_func::EQUAL_FUNC)
{
/* convert column_name <=> NULL -> column_name IS NULL */
......
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