summaryrefslogtreecommitdiff
path: root/storage/myisam
diff options
context:
space:
mode:
authorunknown <ndbdev@dl145c.mysql.com>2005-09-06 09:20:15 +0200
committerunknown <ndbdev@dl145c.mysql.com>2005-09-06 09:20:15 +0200
commitf6c1d4191cf001ba9e895e174bec2f443b28dbc0 (patch)
treeeba8383b8ab4df02b107bb55ef6ec8c5abb477ce /storage/myisam
parent644a444b6b3df10bc2de4f26a486594df42b932c (diff)
parentb48e721d2f2e4f2ae591de5c581e002db8d7cc88 (diff)
downloadmariadb-git-f6c1d4191cf001ba9e895e174bec2f443b28dbc0.tar.gz
Merge
Makefile.am: Auto merged BitKeeper/etc/config: Auto merged scripts/Makefile.am: Auto merged sql/ha_federated.h: Auto merged sql/ha_innodb.cc: Auto merged sql/item.cc: Auto merged sql/item_subselect.cc: Auto merged sql/mysql_priv.h: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/innobase/include/page0page.ic: Auto merged storage/innobase/include/univ.i: Auto merged storage/innobase/row/row0mysql.c: Auto merged storage/innobase/row/row0sel.c: Auto merged storage/myisam/mi_check.c: Auto merged storage/myisam/mi_packrec.c: Auto merged storage/myisam/mi_static.c: Auto merged storage/myisam/myisamdef.h: Auto merged storage/myisam/myisampack.c: Auto merged storage/ndb/include/kernel/signaldata/SignalData.hpp: Auto merged storage/ndb/include/kernel/signaldata/StartFragReq.hpp: Auto merged storage/ndb/src/common/debugger/EventLogger.cpp: Auto merged storage/ndb/src/common/debugger/signaldata/SignalDataPrint.cpp: Auto merged storage/ndb/src/common/debugger/signaldata/StartRec.cpp: Auto merged storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Auto merged storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.cpp: Auto merged storage/ndb/src/kernel/blocks/dblqh/redoLogReader/records.hpp: Auto merged storage/ndb/src/kernel/blocks/dblqh/redoLogReader/redoLogFileReader.cpp: Auto merged storage/ndb/src/kernel/main.cpp: Auto merged storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged storage/ndb/src/kernel/vm/Emulator.cpp: Auto merged sql/log_event.cc: SCCS merged sql/sql_prepare.cc: SCCS merged sql/share/errmsg.txt: merge
Diffstat (limited to 'storage/myisam')
-rw-r--r--storage/myisam/mi_check.c6
-rw-r--r--storage/myisam/mi_packrec.c113
-rw-r--r--storage/myisam/mi_static.c2
-rw-r--r--storage/myisam/myisamdef.h5
-rw-r--r--storage/myisam/myisampack.c26
5 files changed, 69 insertions, 83 deletions
diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c
index ffb7cdd503f..ee64f9b9979 100644
--- a/storage/myisam/mi_check.c
+++ b/storage/myisam/mi_check.c
@@ -3194,9 +3194,11 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
break;
case COMPRESSED_RECORD:
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)
- 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) ||
my_b_write(&info->rec_cache,(byte*) sort_param->rec_buff,reclength))
{
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index c251e4dda4a..e242e9d506d 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -151,11 +151,12 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys)
my_errno=HA_ERR_END_OF_FILE;
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;
goto err0;
}
+ share->pack.version= header[3];
share->pack.header_length= uint4korr(header+4);
share->min_pack_length=(uint) uint4korr(header+8);
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,
return BLOCK_FATAL_ERROR;
DBUG_DUMP("header",(byte*) header,ref_length);
}
- if (header[0] < 254)
- {
- 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;
- }
+ head_length= read_pack_length((uint) myisam->s->pack.version, header,
+ &info->rec_len);
if (myisam->s->base.blobs)
{
- if (header[head_length] < 254)
- {
- 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;
- }
+ head_length+= read_pack_length((uint) myisam->s->pack.version,
+ header + head_length, &info->blob_len);
if (!(mi_alloc_rec_buff(myisam,info->rec_len + info->blob_len,
&myisam->rec_buff)))
return BLOCK_FATAL_ERROR; /* not enough memory */
@@ -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,
uchar *header)
{
- if (header[0] < 254)
- info->rec_len= *header++;
- else if (header[0] == 254)
- {
- info->rec_len=uint2korr(header+1);
- header+=3;
- }
- else
- {
- info->rec_len=uint3korr(header+1);
- header+=4;
- }
+ header+= read_pack_length((uint) myisam->s->pack.version, header,
+ &info->rec_len);
if (myisam->s->base.blobs)
{
- if (header[0] < 254)
- {
- 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;
- }
+ header+= read_pack_length((uint) myisam->s->pack.version, header,
+ &info->blob_len);
/* mi_alloc_rec_buff sets my_errno on error */
if (!(mi_alloc_rec_buff(myisam, info->blob_len,
&myisam->rec_buff)))
@@ -1350,7 +1303,7 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf,
/* 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)
{
@@ -1364,6 +1317,46 @@ uint save_pack_length(byte *block_buff,ulong length)
return 3;
}
*(uchar*) block_buff=255;
- int3store(block_buff+1,(ulong) length);
- return 4;
+ if (version == 1) /* old format */
+ {
+ 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;
}
diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c
index 4c9d814f7d6..fc585eb5543 100644
--- a/storage/myisam/mi_static.c
+++ b/storage/myisam/mi_static.c
@@ -27,7 +27,7 @@ LIST *myisam_open_list=0;
uchar NEAR myisam_file_magic[]=
{ (uchar) 254, (uchar) 254,'\007', '\001', };
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";
File myisam_log_file= -1;
uint myisam_quick_table_bits=9;
diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h
index 74463ec065a..82f7fd7360e 100644
--- a/storage/myisam/myisamdef.h
+++ b/storage/myisam/myisamdef.h
@@ -149,6 +149,7 @@ typedef struct st_mi_blob /* Info of record */
typedef struct st_mi_isam_pack {
ulong header_length;
uint ref_length;
+ uchar version;
} MI_PACK;
@@ -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 my_bool _mi_memmap_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);
char *mi_state_info_read(uchar *ptr, MI_STATE_INFO *state);
diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c
index b8f21392f8a..3b091cd6ea2 100644
--- a/storage/myisam/myisampack.c
+++ b/storage/myisam/myisampack.c
@@ -2417,6 +2417,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
HUFF_COUNTS *count,*end_count;
HUFF_TREE *tree;
MI_INFO *isam_file=mrg->file[0];
+ uint pack_version= (uint) isam_file->s->pack.version;
DBUG_ENTER("compress_isam_file");
/* 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)
huff_counts[i].tree->height+huff_counts[i].length_bits;
}
max_calc_length= (max_calc_length + 7) / 8;
- if (max_calc_length < 254)
- pack_ref_length=1;
- else if (max_calc_length <= 65535)
- pack_ref_length=3;
- else
- pack_ref_length=4;
-
+ pack_ref_length= calc_pack_length(pack_version, max_calc_length);
record_count=0;
/* 'max_blob_length' is the max length of all blobs of a record. */
- pack_blob_length=0;
- if (isam_file->s->base.blobs)
- {
- 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;
- }
+ pack_blob_length= isam_file->s->base.blobs ?
+ calc_pack_length(pack_version, mrg->max_blob_length) : 0;
max_pack_length=pack_ref_length+pack_blob_length;
DBUG_PRINT("fields", ("==="));
@@ -2746,9 +2733,10 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
}
flush_bits();
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)
- 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 "
"length-bytes: %lu", (ulong) record_count, length,
tot_blob_length, pack_length));