Commit ae04bc7e authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  neptunus.(none):/home/msvensson/mysql/mysql-5.0
parents 2c4dcaef 7655c128
...@@ -3194,9 +3194,11 @@ int sort_write_record(MI_SORT_PARAM *sort_param) ...@@ -3194,9 +3194,11 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
break; break;
case COMPRESSED_RECORD: case COMPRESSED_RECORD:
reclength=info->packed_length; reclength=info->packed_length;
length=save_pack_length(block_buff,reclength); length= save_pack_length((uint) share->pack.version, block_buff,
reclength);
if (info->s->base.blobs) if (info->s->base.blobs)
length+=save_pack_length(block_buff+length,info->blob_length); length+= save_pack_length((uint) share->pack.version,
block_buff + length, info->blob_length);
if (my_b_write(&info->rec_cache,block_buff,length) || if (my_b_write(&info->rec_cache,block_buff,length) ||
my_b_write(&info->rec_cache,(byte*) sort_param->rec_buff,reclength)) my_b_write(&info->rec_cache,(byte*) sort_param->rec_buff,reclength))
{ {
......
...@@ -151,11 +151,12 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) ...@@ -151,11 +151,12 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
my_errno=HA_ERR_END_OF_FILE; my_errno=HA_ERR_END_OF_FILE;
goto err0; goto err0;
} }
if (memcmp((byte*) header,(byte*) myisam_pack_file_magic,4)) if (memcmp((byte*) header, (byte*) myisam_pack_file_magic, 3))
{ {
my_errno=HA_ERR_WRONG_IN_RECORD; my_errno=HA_ERR_WRONG_IN_RECORD;
goto err0; goto err0;
} }
share->pack.version= header[3];
share->pack.header_length= uint4korr(header+4); share->pack.header_length= uint4korr(header+4);
share->min_pack_length=(uint) uint4korr(header+8); share->min_pack_length=(uint) uint4korr(header+8);
share->max_pack_length=(uint) uint4korr(header+12); share->max_pack_length=(uint) uint4korr(header+12);
...@@ -1070,38 +1071,12 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BLOCK_INFO *info, File file, ...@@ -1070,38 +1071,12 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BLOCK_INFO *info, File file,
return BLOCK_FATAL_ERROR; return BLOCK_FATAL_ERROR;
DBUG_DUMP("header",(byte*) header,ref_length); DBUG_DUMP("header",(byte*) header,ref_length);
} }
if (header[0] < 254) head_length= read_pack_length((uint) myisam->s->pack.version, header,
{ &info->rec_len);
info->rec_len=header[0];
head_length=1;
}
else if (header[0] == 254)
{
info->rec_len=uint2korr(header+1);
head_length=3;
}
else
{
info->rec_len=uint3korr(header+1);
head_length=4;
}
if (myisam->s->base.blobs) if (myisam->s->base.blobs)
{ {
if (header[head_length] < 254) head_length+= read_pack_length((uint) myisam->s->pack.version,
{ header + head_length, &info->blob_len);
info->blob_len=header[head_length];
head_length++;
}
else if (header[head_length] == 254)
{
info->blob_len=uint2korr(header+head_length+1);
head_length+=3;
}
else
{
info->blob_len=uint3korr(header+head_length+1);
head_length+=4;
}
if (!(mi_alloc_rec_buff(myisam,info->rec_len + info->blob_len, if (!(mi_alloc_rec_buff(myisam,info->rec_len + info->blob_len,
&myisam->rec_buff))) &myisam->rec_buff)))
return BLOCK_FATAL_ERROR; /* not enough memory */ return BLOCK_FATAL_ERROR; /* not enough memory */
...@@ -1251,34 +1226,12 @@ void _mi_unmap_file(MI_INFO *info) ...@@ -1251,34 +1226,12 @@ void _mi_unmap_file(MI_INFO *info)
static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info, static uchar *_mi_mempack_get_block_info(MI_INFO *myisam,MI_BLOCK_INFO *info,
uchar *header) uchar *header)
{ {
if (header[0] < 254) header+= read_pack_length((uint) myisam->s->pack.version, header,
info->rec_len= *header++; &info->rec_len);
else if (header[0] == 254)
{
info->rec_len=uint2korr(header+1);
header+=3;
}
else
{
info->rec_len=uint3korr(header+1);
header+=4;
}
if (myisam->s->base.blobs) if (myisam->s->base.blobs)
{ {
if (header[0] < 254) header+= read_pack_length((uint) myisam->s->pack.version, header,
{ &info->blob_len);
info->blob_len= *header++;
}
else if (header[0] == 254)
{
info->blob_len=uint2korr(header+1);
header+=3;
}
else
{
info->blob_len=uint3korr(header+1);
header+=4;
}
/* mi_alloc_rec_buff sets my_errno on error */ /* mi_alloc_rec_buff sets my_errno on error */
if (!(mi_alloc_rec_buff(myisam, info->blob_len, if (!(mi_alloc_rec_buff(myisam, info->blob_len,
&myisam->rec_buff))) &myisam->rec_buff)))
...@@ -1350,7 +1303,7 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf, ...@@ -1350,7 +1303,7 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf,
/* Save length of row */ /* Save length of row */
uint save_pack_length(byte *block_buff,ulong length) uint save_pack_length(uint version, byte *block_buff, ulong length)
{ {
if (length < 254) if (length < 254)
{ {
...@@ -1364,6 +1317,46 @@ uint save_pack_length(byte *block_buff,ulong length) ...@@ -1364,6 +1317,46 @@ uint save_pack_length(byte *block_buff,ulong length)
return 3; return 3;
} }
*(uchar*) block_buff=255; *(uchar*) block_buff=255;
int3store(block_buff+1,(ulong) length); if (version == 1) /* old format */
return 4; {
DBUG_ASSERT(length <= 0xFFFFFF);
int3store(block_buff + 1, (ulong) length);
return 4;
}
else
{
int4store(block_buff + 1, (ulong) length);
return 5;
}
}
uint read_pack_length(uint version, const uchar *buf, ulong *length)
{
if (buf[0] < 254)
{
*length= buf[0];
return 1;
}
else if (buf[0] == 254)
{
*length= uint2korr(buf + 1);
return 3;
}
if (version == 1) /* old format */
{
*length= uint3korr(buf + 1);
return 4;
}
else
{
*length= uint4korr(buf + 1);
return 5;
}
}
uint calc_pack_length(uint version, ulong length)
{
return (length < 254) ? 1 : (length < 65536) ? 3 : (version == 1) ? 4 : 5;
} }
...@@ -27,7 +27,7 @@ LIST *myisam_open_list=0; ...@@ -27,7 +27,7 @@ LIST *myisam_open_list=0;
uchar NEAR myisam_file_magic[]= uchar NEAR myisam_file_magic[]=
{ (uchar) 254, (uchar) 254,'\007', '\001', }; { (uchar) 254, (uchar) 254,'\007', '\001', };
uchar NEAR myisam_pack_file_magic[]= uchar NEAR myisam_pack_file_magic[]=
{ (uchar) 254, (uchar) 254,'\010', '\001', }; { (uchar) 254, (uchar) 254,'\010', '\002', };
my_string myisam_log_filename=(char*) "myisam.log"; my_string myisam_log_filename=(char*) "myisam.log";
File myisam_log_file= -1; File myisam_log_file= -1;
uint myisam_quick_table_bits=9; uint myisam_quick_table_bits=9;
......
...@@ -149,6 +149,7 @@ typedef struct st_mi_blob /* Info of record */ ...@@ -149,6 +149,7 @@ typedef struct st_mi_blob /* Info of record */
typedef struct st_mi_isam_pack { typedef struct st_mi_isam_pack {
ulong header_length; ulong header_length;
uint ref_length; uint ref_length;
uchar version;
} MI_PACK; } MI_PACK;
...@@ -673,7 +674,9 @@ extern void _myisam_log_record(enum myisam_log_commands command,MI_INFO *info, ...@@ -673,7 +674,9 @@ extern void _myisam_log_record(enum myisam_log_commands command,MI_INFO *info,
extern void mi_report_error(int errcode, const char *file_name); extern void mi_report_error(int errcode, const char *file_name);
extern my_bool _mi_memmap_file(MI_INFO *info); extern my_bool _mi_memmap_file(MI_INFO *info);
extern void _mi_unmap_file(MI_INFO *info); extern void _mi_unmap_file(MI_INFO *info);
extern uint save_pack_length(byte *block_buff,ulong length); extern uint save_pack_length(uint version, byte *block_buff, ulong length);
extern uint read_pack_length(uint version, const uchar *buf, ulong *length);
extern uint calc_pack_length(uint version, ulong length);
uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite); uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite);
char *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state); char *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state);
......
...@@ -2417,6 +2417,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) ...@@ -2417,6 +2417,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
HUFF_COUNTS *count,*end_count; HUFF_COUNTS *count,*end_count;
HUFF_TREE *tree; HUFF_TREE *tree;
MI_INFO *isam_file=mrg->file[0]; MI_INFO *isam_file=mrg->file[0];
uint pack_version= (uint) isam_file->s->pack.version;
DBUG_ENTER("compress_isam_file"); DBUG_ENTER("compress_isam_file");
/* Allocate a buffer for the records (excluding blobs). */ /* Allocate a buffer for the records (excluding blobs). */
...@@ -2455,25 +2456,11 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) ...@@ -2455,25 +2456,11 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
huff_counts[i].tree->height+huff_counts[i].length_bits; huff_counts[i].tree->height+huff_counts[i].length_bits;
} }
max_calc_length= (max_calc_length + 7) / 8; max_calc_length= (max_calc_length + 7) / 8;
if (max_calc_length < 254) pack_ref_length= calc_pack_length(pack_version, max_calc_length);
pack_ref_length=1;
else if (max_calc_length <= 65535)
pack_ref_length=3;
else
pack_ref_length=4;
record_count=0; record_count=0;
/* 'max_blob_length' is the max length of all blobs of a record. */ /* 'max_blob_length' is the max length of all blobs of a record. */
pack_blob_length=0; pack_blob_length= isam_file->s->base.blobs ?
if (isam_file->s->base.blobs) calc_pack_length(pack_version, mrg->max_blob_length) : 0;
{
if (mrg->max_blob_length < 254)
pack_blob_length=1;
else if (mrg->max_blob_length <= 65535)
pack_blob_length=3;
else
pack_blob_length=4;
}
max_pack_length=pack_ref_length+pack_blob_length; max_pack_length=pack_ref_length+pack_blob_length;
DBUG_PRINT("fields", ("===")); DBUG_PRINT("fields", ("==="));
...@@ -2746,9 +2733,10 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) ...@@ -2746,9 +2733,10 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
} }
flush_bits(); flush_bits();
length=(ulong) ((byte*) file_buffer.pos - record_pos) - max_pack_length; length=(ulong) ((byte*) file_buffer.pos - record_pos) - max_pack_length;
pack_length=save_pack_length(record_pos,length); pack_length= save_pack_length(pack_version, record_pos, length);
if (pack_blob_length) if (pack_blob_length)
pack_length+=save_pack_length(record_pos+pack_length,tot_blob_length); pack_length+= save_pack_length(pack_version, record_pos + pack_length,
tot_blob_length);
DBUG_PRINT("fields", ("record: %lu length: %lu blob-length: %lu " DBUG_PRINT("fields", ("record: %lu length: %lu blob-length: %lu "
"length-bytes: %lu", (ulong) record_count, length, "length-bytes: %lu", (ulong) record_count, length,
tot_blob_length, pack_length)); tot_blob_length, pack_length));
......
...@@ -134,7 +134,9 @@ bool PrepareOperationRecord::check() { ...@@ -134,7 +134,9 @@ bool PrepareOperationRecord::check() {
return true; return true;
} }
Uint32 PrepareOperationRecord::getLogRecordSize() { Uint32 PrepareOperationRecord::getLogRecordSize(Uint32 wordsRead) {
if (wordsRead < 2)
return 2; // make sure we read more
return m_logRecordSize; return m_logRecordSize;
} }
......
...@@ -83,7 +83,7 @@ class PrepareOperationRecord { ...@@ -83,7 +83,7 @@ class PrepareOperationRecord {
friend NdbOut& operator<<(NdbOut&, const PrepareOperationRecord&); friend NdbOut& operator<<(NdbOut&, const PrepareOperationRecord&);
public: public:
bool check(); bool check();
Uint32 getLogRecordSize(); Uint32 getLogRecordSize(Uint32 wordsRead);
protected: protected:
Uint32 m_recordType; Uint32 m_recordType;
......
...@@ -41,6 +41,7 @@ void doExit(); ...@@ -41,6 +41,7 @@ void doExit();
FILE * f= 0; FILE * f= 0;
char fileName[256]; char fileName[256];
bool theDumpFlag = false;
bool thePrintFlag = true; bool thePrintFlag = true;
bool theCheckFlag = true; bool theCheckFlag = true;
bool onlyPageHeaders = false; bool onlyPageHeaders = false;
...@@ -208,7 +209,7 @@ NDB_COMMAND(redoLogFileReader, "redoLogFileReader", "redoLogFileReader", "Read ...@@ -208,7 +209,7 @@ NDB_COMMAND(redoLogFileReader, "redoLogFileReader", "redoLogFileReader", "Read
case ZPREP_OP_TYPE: case ZPREP_OP_TYPE:
poRecord = (PrepareOperationRecord *) redoLogPagePos; poRecord = (PrepareOperationRecord *) redoLogPagePos;
wordIndex += poRecord->getLogRecordSize(); wordIndex += poRecord->getLogRecordSize(PAGESIZE-wordIndex);
if (wordIndex <= PAGESIZE) { if (wordIndex <= PAGESIZE) {
if (thePrintFlag) ndbout << (*poRecord); if (thePrintFlag) ndbout << (*poRecord);
if (theCheckFlag) { if (theCheckFlag) {
...@@ -277,10 +278,9 @@ NDB_COMMAND(redoLogFileReader, "redoLogFileReader", "redoLogFileReader", "Read ...@@ -277,10 +278,9 @@ NDB_COMMAND(redoLogFileReader, "redoLogFileReader", "redoLogFileReader", "Read
ndbout << " ------ERROR: UNKNOWN RECORD TYPE------" << endl; ndbout << " ------ERROR: UNKNOWN RECORD TYPE------" << endl;
// Print out remaining data in this page // Print out remaining data in this page
for (int j = wordIndex; j < PAGESIZE; j++){ for (int k = wordIndex; k < PAGESIZE; k++){
Uint32 unknown = redoLogPage[i*PAGESIZE + j]; Uint32 unknown = redoLogPage[i*PAGESIZE + k];
ndbout_c("%-30d%-12u%-12x", k, unknown, unknown);
ndbout_c("%-30d%-12u%-12x", j, unknown, unknown);
} }
doExit(); doExit();
...@@ -289,8 +289,19 @@ NDB_COMMAND(redoLogFileReader, "redoLogFileReader", "redoLogFileReader", "Read ...@@ -289,8 +289,19 @@ NDB_COMMAND(redoLogFileReader, "redoLogFileReader", "redoLogFileReader", "Read
if (lastPage) if (lastPage)
{
if (theDumpFlag)
{
ndbout << " ------PAGE END: DUMPING REST OF PAGE------" << endl;
for (int k = wordIndex > PAGESIZE ? oldWordIndex : wordIndex;
k < PAGESIZE; k++)
{
Uint32 word = redoLogPage[i*PAGESIZE + k];
ndbout_c("%-30d%-12u%-12x", k, word, word);
}
}
break; break;
}
if (wordIndex > PAGESIZE) { if (wordIndex > PAGESIZE) {
words_from_previous_page = PAGESIZE - oldWordIndex; words_from_previous_page = PAGESIZE - oldWordIndex;
ndbout << " ----------- Record continues on next page -----------" << endl; ndbout << " ----------- Record continues on next page -----------" << endl;
...@@ -353,6 +364,8 @@ void readArguments(int argc, const char** argv) ...@@ -353,6 +364,8 @@ void readArguments(int argc, const char** argv)
{ {
if (strcmp(argv[i], "-noprint") == 0) { if (strcmp(argv[i], "-noprint") == 0) {
thePrintFlag = false; thePrintFlag = false;
} else if (strcmp(argv[i], "-dump") == 0) {
theDumpFlag = true;
} else if (strcmp(argv[i], "-nocheck") == 0) { } else if (strcmp(argv[i], "-nocheck") == 0) {
theCheckFlag = false; theCheckFlag = false;
} else if (strcmp(argv[i], "-mbyteheaders") == 0) { } else if (strcmp(argv[i], "-mbyteheaders") == 0) {
......
...@@ -60,7 +60,7 @@ int main(int argc, char** argv) ...@@ -60,7 +60,7 @@ int main(int argc, char** argv)
NDB_INIT(argv[0]); NDB_INIT(argv[0]);
// Print to stdout/console // Print to stdout/console
g_eventLogger.createConsoleHandler(); g_eventLogger.createConsoleHandler();
g_eventLogger.setCategory("NDB"); g_eventLogger.setCategory("ndbd");
g_eventLogger.enable(Logger::LL_ON, Logger::LL_CRITICAL); g_eventLogger.enable(Logger::LL_ON, Logger::LL_CRITICAL);
g_eventLogger.enable(Logger::LL_ON, Logger::LL_ERROR); g_eventLogger.enable(Logger::LL_ON, Logger::LL_ERROR);
g_eventLogger.enable(Logger::LL_ON, Logger::LL_WARNING); g_eventLogger.enable(Logger::LL_ON, Logger::LL_WARNING);
......
...@@ -30,13 +30,15 @@ ...@@ -30,13 +30,15 @@
#include <NodeState.hpp> #include <NodeState.hpp>
#include <NdbMem.h> #include <NdbMem.h>
#include <NdbOut.hpp>
#include <NdbMutex.h> #include <NdbMutex.h>
#include <NdbSleep.h> #include <NdbSleep.h>
#include <EventLogger.hpp>
extern "C" { extern "C" {
extern void (* ndb_new_handler)(); extern void (* ndb_new_handler)();
} }
extern EventLogger g_eventLogger;
/** /**
* Declare the global variables * Declare the global variables
...@@ -141,23 +143,23 @@ NdbShutdown(NdbShutdownType type, ...@@ -141,23 +143,23 @@ NdbShutdown(NdbShutdownType type,
switch(type){ switch(type){
case NST_Normal: case NST_Normal:
ndbout << "Shutdown initiated" << endl; g_eventLogger.info("Shutdown initiated");
break; break;
case NST_Watchdog: case NST_Watchdog:
ndbout << "Watchdog " << shutting << " system" << endl; g_eventLogger.info("Watchdog %s system", shutting);
break; break;
case NST_ErrorHandler: case NST_ErrorHandler:
ndbout << "Error handler " << shutting << " system" << endl; g_eventLogger.info("Error handler %s system", shutting);
break; break;
case NST_ErrorHandlerSignal: case NST_ErrorHandlerSignal:
ndbout << "Error handler signal " << shutting << " system" << endl; g_eventLogger.info("Error handler signal %s system", shutting);
break; break;
case NST_Restart: case NST_Restart:
ndbout << "Restarting system" << endl; g_eventLogger.info("Restarting system");
break; break;
default: default:
ndbout << "Error handler " << shutting << " system" g_eventLogger.info("Error handler %s system (unknown type: %u)",
<< " (unknown type: " << (unsigned)type << ")" << endl; shutting, (unsigned)type);
type = NST_ErrorHandler; type = NST_ErrorHandler;
break; break;
} }
...@@ -173,7 +175,7 @@ NdbShutdown(NdbShutdownType type, ...@@ -173,7 +175,7 @@ NdbShutdown(NdbShutdownType type,
/** /**
* Very serious, don't attempt to free, just die!! * Very serious, don't attempt to free, just die!!
*/ */
ndbout << "Watchdog shutdown completed - " << exitAbort << endl; g_eventLogger.info("Watchdog shutdown completed - %s", exitAbort);
#if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) ) #if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) )
signal(6, SIG_DFL); signal(6, SIG_DFL);
abort(); abort();
...@@ -227,7 +229,7 @@ NdbShutdown(NdbShutdownType type, ...@@ -227,7 +229,7 @@ NdbShutdown(NdbShutdownType type,
} }
if(type != NST_Normal && type != NST_Restart){ if(type != NST_Normal && type != NST_Restart){
ndbout << "Error handler shutdown completed - " << exitAbort << endl; g_eventLogger.info("Error handler shutdown completed - %s", exitAbort);
#if ( defined VM_TRACE || defined ERROR_INSERT ) && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) ) #if ( defined VM_TRACE || defined ERROR_INSERT ) && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) )
signal(6, SIG_DFL); signal(6, SIG_DFL);
abort(); abort();
...@@ -243,7 +245,7 @@ NdbShutdown(NdbShutdownType type, ...@@ -243,7 +245,7 @@ NdbShutdown(NdbShutdownType type,
exit(restartType); exit(restartType);
} }
ndbout << "Shutdown completed - exiting" << endl; g_eventLogger.info("Shutdown completed - exiting");
} else { } else {
/** /**
* Shutdown is already in progress * Shutdown is already in progress
...@@ -253,7 +255,7 @@ NdbShutdown(NdbShutdownType type, ...@@ -253,7 +255,7 @@ NdbShutdown(NdbShutdownType type,
* If this is the watchdog, kill system the hard way * If this is the watchdog, kill system the hard way
*/ */
if (type== NST_Watchdog){ if (type== NST_Watchdog){
ndbout << "Watchdog is killing system the hard way" << endl; g_eventLogger.info("Watchdog is killing system the hard way");
#if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) ) #if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) )
signal(6, SIG_DFL); signal(6, SIG_DFL);
abort(); abort();
......
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