diff options
author | unknown <monty@mysql.com> | 2004-12-18 05:19:21 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2004-12-18 05:19:21 +0200 |
commit | 8eaef91fff849885a7369a21a752e87cb1e592c8 (patch) | |
tree | eb62c04f31efc6c7cb435cef36a43e2e361eed1c /heap | |
parent | 5ae35e327a39ec036a9d938f8555278bf96f2a27 (diff) | |
download | mariadb-git-8eaef91fff849885a7369a21a752e87cb1e592c8.tar.gz |
Add 0x before pointers (to help with debugging)
Add support for VARCHAR with 1 or 2 length bytes
Enable VARCHAR packing in MyISAM files (previous patch didn't pack data properly)
Give error if we got problems in temporary tables during a SELECT
Don't use new table generated by ALTER TABLE if index generation fails
Fixed wrong call by range_end() (Could cause an ASSERT in debug mode)
BUILD/SETUP.sh:
Add flags for Intel 64
dbug/dbug.c:
Add 0x before pointers (to help with debugging)
heap/_check.c:
Add 0x before pointers (to help with debugging)
heap/hp_create.c:
Add support for VARCHAR with 1 or 2 length bytes
heap/hp_delete.c:
Add 0x before pointers
heap/hp_hash.c:
Add support for VARCHAR with 1 or 2 length bytes
Added more debugging
heap/hp_open.c:
Add 0x before pointers
heap/hp_rkey.c:
Add 0x before pointers
heap/hp_rrnd.c:
Add 0x before pointers
heap/hp_write.c:
Add 0x before pointers
include/my_base.h:
Add support for VARCHAR with 1 or 2 length bytes
myisam/ft_static.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/ft_test1.c:
Add support for VARCHAR with 1 or 2 length bytes
Fixed indentation
(This file should probably be deleted as it doesn't compile)
myisam/ft_update.c:
Add support for VARCHAR with 1 or 2 length bytes
Fixed indentation
Removed some not needed 'else'
myisam/mi_check.c:
Don't give an error for tables packed with myisampack
myisam/mi_checksum.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_create.c:
Add support for VARCHAR with 1 or 2 length bytes
Store in number of pack-length-bytes in keyseg->bit_start
myisam/mi_dbug.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_dynrec.c:
Add support for VARCHAR with 1 or 2 length bytes
(old code in _mi_rec_unpack() didn't really work with VARCHAR's)
myisam/mi_key.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_open.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_packrec.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_search.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_test1.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_test3.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/mi_test_all.res:
Update results
myisam/mi_unique.c:
Add support for VARCHAR with 1 or 2 length bytes
myisam/myisampack.c:
Add support for VARCHAR with 1 or 2 length bytes
mysql-test/include/varchar.inc:
Added more tests
mysql-test/r/bdb.result:
Update results after new tests
mysql-test/r/information_schema.result:
Update results
mysql-test/r/innodb.result:
Update results
mysql-test/r/myisam.result:
Update results after new tests
mysql-test/r/ps_1general.result:
Update results
mysql-test/t/bdb.test:
Shorter comments
mysys/list.c:
Add 0x before pointers
mysys/my_handler.c:
Add support for VARCHAR with 1 or 2 length bytes
mysys/raid.cc:
Add 0x before pointers
sql/field.cc:
Add support for VARCHAR with 1 or 2 length bytes
sql/field.h:
Add support for VARCHAR with 1 or 2 length bytes
sql/field_conv.cc:
Add support for VARCHAR with 1 or 2 length bytes
sql/ha_berkeley.cc:
Add support for VARCHAR with 1 or 2 length bytes
sql/ha_heap.cc:
Add support for VARCHAR with 1 or 2 length bytes
sql/ha_myisam.cc:
Ensure that enable_indexes() will report an error if it fails
Enable VARCHAR packing for MyISAM files
sql/item_sum.cc:
Change key_cmp -> cmp() as we are comparing fields, not key segements
sql/opt_range.cc:
Add support for VARCHAR with 1 or 2 length bytes
Change range_end to call ha_index_or_rnd_end() as in some error cases we may be in rnd mode when we abort
sql/sql_base.cc:
Remove compiler warning
sql/sql_parse.cc:
Move length checking code to sql_table.cc (as we don't have character set for fields at this stage)
sql/sql_select.cc:
Add support for VARCHAR with 1 or 2 length bytes
Ensure that we report an error if we get an error while writing to internal temporary tables
sql/sql_select.h:
Add support for VARCHAR with 1 or 2 length bytes
sql/sql_show.cc:
Fix typo in comment
sql/sql_table.cc:
Don't use new table generated by ALTER TABLE if index generation fails
vio/vio.c:
Fixed DBUG info
vio/viosocket.c:
Fixed DBUG info
vio/viossl.c:
Fixed DBUG info
vio/viosslfactories.c:
Fixed DBUG info
Diffstat (limited to 'heap')
-rw-r--r-- | heap/_check.c | 4 | ||||
-rw-r--r-- | heap/hp_create.c | 23 | ||||
-rw-r--r-- | heap/hp_delete.c | 4 | ||||
-rw-r--r-- | heap/hp_hash.c | 101 | ||||
-rw-r--r-- | heap/hp_open.c | 4 | ||||
-rw-r--r-- | heap/hp_rkey.c | 2 | ||||
-rw-r--r-- | heap/hp_rrnd.c | 8 | ||||
-rw-r--r-- | heap/hp_write.c | 2 |
8 files changed, 99 insertions, 49 deletions
diff --git a/heap/_check.c b/heap/_check.c index a745aee48bf..4316a9926f7 100644 --- a/heap/_check.c +++ b/heap/_check.c @@ -123,7 +123,7 @@ static int check_one_key(HP_KEYDEF *keydef, uint keynr, ulong records, blength, records)) != i) { - DBUG_PRINT("error",("Record in wrong link: Link %d Record: %lx Record-link %d", i,hash_info->ptr_to_rec,rec_link)); + DBUG_PRINT("error",("Record in wrong link: Link %d Record: 0x%lx Record-link %d", i,hash_info->ptr_to_rec,rec_link)); error=1; } else @@ -180,7 +180,7 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, key_length, SEARCH_FIND | SEARCH_SAME, ¬_used)) { error= 1; - DBUG_PRINT("error",("Record in wrong link: key: %d Record: %lx\n", + DBUG_PRINT("error",("Record in wrong link: key: %d Record: 0x%lx\n", keynr, recpos)); } else diff --git a/heap/hp_create.c b/heap/hp_create.c index d296c9db28b..0580c178498 100644 --- a/heap/hp_create.c +++ b/heap/hp_create.c @@ -77,14 +77,31 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, case HA_KEYTYPE_INT8: keyinfo->seg[j].flag|= HA_SWAP_KEY; break; - case HA_KEYTYPE_VARBINARY: + case HA_KEYTYPE_VARBINARY1: /* Case-insensitiveness is handled in coll->hash_sort */ - keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT; + keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1; /* fall_through */ - case HA_KEYTYPE_VARTEXT: + case HA_KEYTYPE_VARTEXT1: if (!my_binary_compare(keyinfo->seg[j].charset)) keyinfo->flag|= HA_END_SPACE_KEY; keyinfo->flag|= HA_VAR_LENGTH_KEY; + /* Save number of bytes used to store length */ + keyinfo->seg[j].bit_start= 1; + break; + case HA_KEYTYPE_VARBINARY2: + /* Case-insensitiveness is handled in coll->hash_sort */ + /* fall_through */ + case HA_KEYTYPE_VARTEXT2: + if (!my_binary_compare(keyinfo->seg[j].charset)) + keyinfo->flag|= HA_END_SPACE_KEY; + keyinfo->flag|= HA_VAR_LENGTH_KEY; + /* Save number of bytes used to store length */ + keyinfo->seg[j].bit_start= 2; + /* + Make future comparison simpler by only having to check for + one type + */ + keyinfo->seg[j].type= HA_KEYTYPE_VARTEXT1; break; default: break; diff --git a/heap/hp_delete.c b/heap/hp_delete.c index 4adefde1fe9..5287533ae0a 100644 --- a/heap/hp_delete.c +++ b/heap/hp_delete.c @@ -24,7 +24,7 @@ int heap_delete(HP_INFO *info, const byte *record) HP_SHARE *share=info->s; HP_KEYDEF *keydef, *end, *p_lastinx; DBUG_ENTER("heap_delete"); - DBUG_PRINT("enter",("info: %lx record: %lx",info,record)); + DBUG_PRINT("enter",("info: %lx record: 0x%lx",info,record)); test_active(info); @@ -139,7 +139,7 @@ int hp_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, /* Save for heap_rnext/heap_rprev */ info->current_hash_ptr=last_ptr; info->current_ptr = last_ptr ? last_ptr->ptr_to_rec : 0; - DBUG_PRINT("info",("Corrected current_ptr to point at: %lx", + DBUG_PRINT("info",("Corrected current_ptr to point at: 0x%lx", info->current_ptr)); } empty=pos; diff --git a/heap/hp_hash.c b/heap/hp_hash.c index 7e5f92bc7b8..3121ef71fb0 100644 --- a/heap/hp_hash.c +++ b/heap/hp_hash.c @@ -271,18 +271,21 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) } cs->coll->hash_sort(cs, pos, length, &nr, &nr2); } - else if (seg->type == HA_KEYTYPE_VARTEXT) + else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { CHARSET_INFO *cs= seg->charset; + uint pack_length= 2; /* Key packing is constant */ uint length= uint2korr(pos); if (cs->mbmaxlen > 1) { uint char_length; - char_length= my_charpos(cs, pos +2, pos +2 + length, + char_length= my_charpos(cs, pos +pack_length, + pos +pack_length + length, seg->length/cs->mbmaxlen); set_if_smaller(length, char_length); } - cs->coll->hash_sort(cs, pos+2, length, &nr, &nr2); + cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2); + key+= pack_length; } else { @@ -293,6 +296,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) } } } + DBUG_PRINT("exit", ("hash: 0x%lx", nr)); return((ulong) nr); } @@ -300,7 +304,6 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) { - /*register*/ ulong nr=1, nr2=4; HA_KEYSEG *seg,*endseg; @@ -327,18 +330,20 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) } cs->coll->hash_sort(cs, pos, char_length, &nr, &nr2); } - else if (seg->type == HA_KEYTYPE_VARTEXT) + else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { CHARSET_INFO *cs= seg->charset; - uint length= uint2korr(pos); + uint pack_length= seg->bit_start; + uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos)); if (cs->mbmaxlen > 1) { uint char_length; - char_length= my_charpos(cs, pos + 2 , pos + 2 + length, + char_length= my_charpos(cs, pos + pack_length, + pos + pack_length + length, seg->length/cs->mbmaxlen); set_if_smaller(length, char_length); } - cs->coll->hash_sort(cs, pos+2, length, &nr, &nr2); + cs->coll->hash_sort(cs, pos+pack_length, length, &nr, &nr2); } else { @@ -349,7 +354,8 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) } } } - return((ulong) nr); + DBUG_PRINT("exit", ("hash: 0x%lx", nr)); + return(nr); } #else @@ -392,10 +398,13 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) { seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,NULL); } - else if (seg->type == HA_KEYTYPE_VARTEXT) + else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { + uint pack_length= 2; /* Key packing is constant */ uint length= uint2korr(pos); - seg->charset->hash_sort(seg->charset, pos+2, length, &nr, NULL); + seg->charset->hash_sort(seg->charset, pos+pack_length, length, &nr, + NULL); + key+= pack_length; } else { @@ -406,7 +415,8 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) } } } - return((ulong) nr); + DBUG_PRINT("exit", ("hash: 0x%lx", nr)); + return(nr); } /* Calc hashvalue for a key in a record */ @@ -418,7 +428,7 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) { - uchar *pos=(uchar*) rec+seg->start,*end=pos+seg->length; + uchar *pos=(uchar*) rec+seg->start; if (seg->null_bit) { if (rec[seg->null_pos] & seg->null_bit) @@ -431,13 +441,16 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) { seg->charset->hash_sort(seg->charset,pos,((uchar*)key)-pos,&nr,NULL); } - else if (seg->type == HA_KEYTYPE_VARTEXT) + else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { - uint length= uint2korr(pos); - seg->charset->hash_sort(seg->charset, pos+2, length, &nr, NULL); + uint pack_length= seg->bit_start; + uint length= (pack_length == 1 ? (uint) *(uchar*) pos : uint2korr(pos)); + seg->charset->hash_sort(seg->charset, pos+pack_length, + length, &nr, NULL); } else { + uchar *end= pos+seg->length; for ( ; pos < end ; pos++) { nr *=16777619; @@ -445,7 +458,8 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) } } } - return((ulong) nr); + DBUG_PRINT("exit", ("hash: 0x%lx", nr)); + return(nr); } #endif @@ -510,13 +524,25 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2, pos2,char_length2, 0)) return 1; } - else if (seg->type == HA_KEYTYPE_VARTEXT) + else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { - uchar *pos1= (uchar*)rec1 + seg->start; - uchar *pos2= (uchar*)rec2 + seg->start; - uint char_length1= uint2korr(pos1); - uint char_length2= uint2korr(pos2); + uchar *pos1= (uchar*) rec1 + seg->start; + uchar *pos2= (uchar*) rec2 + seg->start; + uint char_length1, char_length2; + uint pack_length= seg->bit_start; CHARSET_INFO *cs= seg->charset; + if (pack_length == 1) + { + char_length1= (uint) *(uchar*) pos1++; + char_length2= (uint) *(uchar*) pos2++; + } + else + { + char_length1= uint2korr(pos1); + char_length2= uint2korr(pos2); + pos1+= 2; + pos2+= 2; + } if (cs->mbmaxlen > 1) { uint char_length= seg->length / cs->mbmaxlen; @@ -527,8 +553,8 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2, } if (cs->coll->strnncollsp(seg->charset, - pos1+2, char_length1, - pos2+2, char_length2, + pos1, char_length1, + pos2, char_length2, seg->flag & HA_END_SPACE_ARE_EQUAL ? 0 : diff_if_only_endspace_difference)) return 1; @@ -585,28 +611,31 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key) (uchar*) key, char_length_key, 0)) return 1; } - else if (seg->type == HA_KEYTYPE_VARTEXT) + else if (seg->type == HA_KEYTYPE_VARTEXT1) /* Any VARCHAR segments */ { uchar *pos= (uchar*) rec + seg->start; CHARSET_INFO *cs= seg->charset; - uint char_length_rec= uint2korr(pos); + uint pack_length= seg->bit_start; + uint char_length_rec= (pack_length == 1 ? (uint) *(uchar*) pos : + uint2korr(pos)); + /* Key segments are always packed with 2 bytes */ uint char_length_key= uint2korr(key); - + pos+= pack_length; + key+= 2; /* skip key pack length */ if (cs->mbmaxlen > 1) { uint char_length= seg->length / cs->mbmaxlen; - char_length_key= my_charpos(cs, key+2, key +2 + char_length_key, + char_length_key= my_charpos(cs, key, key + char_length_key, char_length); set_if_smaller(char_length_key, seg->length); - char_length_rec= my_charpos(cs, pos +2 , pos + 2 + char_length_rec, + char_length_rec= my_charpos(cs, pos, pos + char_length_rec, char_length); set_if_smaller(char_length_rec, seg->length); } - if (cs->coll->strnncollsp(seg->charset, - (uchar*) pos+2, char_length_rec, - (uchar*) key+2, char_length_key, 0)) + (uchar*) pos, char_length_rec, + (uchar*) key, char_length_key, 0)) return 1; } else @@ -638,6 +667,8 @@ void hp_make_key(HP_KEYDEF *keydef, byte *key, const byte *rec) char_length / cs->mbmaxlen); set_if_smaller(char_length, seg->length); /* QQ: ok to remove? */ } + if (seg->type == HA_KEYTYPE_VARTEXT1) + char_length+= seg->bit_start; /* Copy also length */ memcpy(key,rec+seg->start,(size_t) char_length); key+= char_length; } @@ -707,11 +738,13 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, { uchar *pos= (uchar*) rec + seg->start; uint length= seg->length; - uint tmp_length= uint2korr(pos); + uint pack_length= seg->bit_start; + uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos : + uint2korr(pos)); CHARSET_INFO *cs= seg->charset; char_length= length/cs->mbmaxlen; - pos+=2; /* Skip VARCHAR length */ + pos+= pack_length; /* Skip VARCHAR length */ set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); diff --git a/heap/hp_open.c b/heap/hp_open.c index 1fa832208fb..fd937229b0d 100644 --- a/heap/hp_open.c +++ b/heap/hp_open.c @@ -63,7 +63,7 @@ HP_INFO *heap_open(const char *name, int mode) #ifndef DBUG_OFF info->opt_flag= READ_CHECK_USED; /* Check when changing */ #endif - DBUG_PRINT("exit",("heap: %lx reclength: %d records_in_block: %d", + DBUG_PRINT("exit",("heap: 0x%lx reclength: %d records_in_block: %d", info,share->reclength,share->block.records_in_block)); DBUG_RETURN(info); } @@ -82,7 +82,7 @@ HP_SHARE *hp_find_named_heap(const char *name) info= (HP_SHARE*) pos->data; if (!strcmp(name, info->name)) { - DBUG_PRINT("exit", ("Old heap_database: %lx",info)); + DBUG_PRINT("exit", ("Old heap_database: 0x%lx",info)); DBUG_RETURN(info); } } diff --git a/heap/hp_rkey.c b/heap/hp_rkey.c index a88139bbdee..f5f22a877a1 100644 --- a/heap/hp_rkey.c +++ b/heap/hp_rkey.c @@ -23,7 +23,7 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, HP_SHARE *share= info->s; HP_KEYDEF *keyinfo= share->keydef + inx; DBUG_ENTER("heap_rkey"); - DBUG_PRINT("enter",("base: %lx inx: %d",info,inx)); + DBUG_PRINT("enter",("base: 0x%lx inx: %d",info,inx)); if ((uint) inx >= share->keys) { diff --git a/heap/hp_rrnd.c b/heap/hp_rrnd.c index cce3ce24e51..4daa3a06377 100644 --- a/heap/hp_rrnd.c +++ b/heap/hp_rrnd.c @@ -29,7 +29,7 @@ int heap_rrnd(register HP_INFO *info, byte *record, byte *pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); - DBUG_PRINT("enter",("info: %lx pos: %lx",info,pos)); + DBUG_PRINT("enter",("info: 0x%lx pos: %lx",info,pos)); info->lastinx= -1; if (!(info->current_ptr= pos)) @@ -44,7 +44,7 @@ int heap_rrnd(register HP_INFO *info, byte *record, byte *pos) } info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; memcpy(record,info->current_ptr,(size_t) share->reclength); - DBUG_PRINT("exit",("found record at %lx",info->current_ptr)); + DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr)); info->current_hash_ptr=0; /* Can't use rnext */ DBUG_RETURN(0); } /* heap_rrnd */ @@ -64,7 +64,7 @@ int heap_rrnd_old(register HP_INFO *info, byte *record, ulong pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); - DBUG_PRINT("enter",("info: %lx pos: %ld",info,pos)); + DBUG_PRINT("enter",("info: 0x%lx pos: %ld",info,pos)); info->lastinx= -1; if (pos == (ulong) -1) @@ -98,7 +98,7 @@ end: } info->update=HA_STATE_PREV_FOUND | HA_STATE_NEXT_FOUND | HA_STATE_AKTIV; memcpy(record,info->current_ptr,(size_t) share->reclength); - DBUG_PRINT("exit",("found record at %lx",info->current_ptr)); + DBUG_PRINT("exit",("found record at 0x%lx",info->current_ptr)); info->current_hash_ptr=0; /* Can't use rnext */ DBUG_RETURN(0); } /* heap_rrnd */ diff --git a/heap/hp_write.c b/heap/hp_write.c index 577c52a007d..171998e9125 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -138,7 +138,7 @@ static byte *next_free_record_pos(HP_SHARE *info) pos=info->del_link; info->del_link= *((byte**) pos); info->deleted--; - DBUG_PRINT("exit",("Used old position: %lx",pos)); + DBUG_PRINT("exit",("Used old position: 0x%lx",pos)); DBUG_RETURN(pos); } if (!(block_pos=(info->records % info->block.records_in_block))) |