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 /myisam/mi_create.c | |
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 'myisam/mi_create.c')
-rw-r--r-- | myisam/mi_create.c | 82 |
1 files changed, 61 insertions, 21 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c index e139997e0c7..0164555272d 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -43,7 +43,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, myf create_flag; uint fields,length,max_key_length,packed,pointer,real_length_diff, key_length,info_length,key_segs,options,min_key_length_skip, - base_pos,varchar_count,long_varchar_count,varchar_length, + base_pos,long_varchar_count,varchar_length, max_key_block_length,unique_key_parts,fulltext_keys,offset; ulong reclength, real_reclength,min_pack_length; char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr; @@ -99,7 +99,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, /* Start by checking fields and field-types used */ - reclength=varchar_count=varchar_length=long_varchar_count=packed= + reclength=varchar_length=long_varchar_count=packed= min_pack_length=pack_reclength=0; for (rec=recinfo, fields=0 ; fields != columns ; @@ -130,14 +130,15 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } else if (type == FIELD_VARCHAR) { - varchar_count++; - varchar_length+=rec->length-2; + varchar_length+= rec->length-1; /* Used for min_pack_length */ packed--; - pack_reclength+=1; - if (test(rec->length > 257)) - { /* May be packed on 3 bytes */ + pack_reclength++; + min_pack_length++; + /* We must test for 257 as length includes pack-length */ + if (test(rec->length >= 257)) + { long_varchar_count++; - pack_reclength+=2; + pack_reclength+= 2; /* May be packed on 3 bytes */ } } else if (type != FIELD_SKIP_ZERO) @@ -169,12 +170,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, /* We can't use checksum with static length rows */ if (!(options & HA_OPTION_PACK_RECORD)) options&= ~HA_OPTION_CHECKSUM; - if (options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) - min_pack_length+=varchar_count; /* Min length to pack */ - else - { - min_pack_length+=varchar_length+2*varchar_count; - } + if (!(options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD))) + min_pack_length+= varchar_length; if (flags & HA_CREATE_TMP_TABLE) options|= HA_OPTION_TMP_TABLE; if (flags & HA_CREATE_CHECKSUM || (options & HA_OPTION_CHECKSUM)) @@ -220,7 +217,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, reclength=pointer+1; /* reserve place for delete link */ } else - reclength+=long_varchar_count; /* We need space for this! */ + reclength+= long_varchar_count; /* We need space for varchar! */ max_key_length=0; tot_length=0 ; key_segs=0; fulltext_keys=0; @@ -261,7 +258,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, j++, keyseg++) { if (keyseg->type != HA_KEYTYPE_BINARY && - keyseg->type != HA_KEYTYPE_VARBINARY) + keyseg->type != HA_KEYTYPE_VARBINARY1 && + keyseg->type != HA_KEYTYPE_VARBINARY2) { my_errno=HA_WRONG_CREATE_OPTION; goto err; @@ -285,11 +283,22 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, j++, keyseg++) { if (keyseg->type != HA_KEYTYPE_TEXT && - keyseg->type != HA_KEYTYPE_VARTEXT) + keyseg->type != HA_KEYTYPE_VARTEXT1 && + keyseg->type != HA_KEYTYPE_VARTEXT2) { my_errno=HA_WRONG_CREATE_OPTION; goto err; } + if (!(keyseg->flag & HA_BLOB_PART) && + (keyseg->type == HA_KEYTYPE_VARTEXT1 || + keyseg->type == HA_KEYTYPE_VARTEXT2)) + { + /* Make a flag that this is a VARCHAR */ + keyseg->flag|= HA_VAR_LENGTH_PART; + /* Store in bit_start number of bytes used to pack the length */ + keyseg->bit_start= ((keyseg->type == HA_KEYTYPE_VARTEXT1)? + 1 : 2); + } } fulltext_keys++; @@ -345,10 +354,19 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, case HA_KEYTYPE_INT8: keyseg->flag|= HA_SWAP_KEY; break; - case HA_KEYTYPE_VARTEXT: - case HA_KEYTYPE_VARBINARY: + case HA_KEYTYPE_VARTEXT1: + case HA_KEYTYPE_VARTEXT2: + case HA_KEYTYPE_VARBINARY1: + case HA_KEYTYPE_VARBINARY2: if (!(keyseg->flag & HA_BLOB_PART)) + { + /* Make a flag that this is a VARCHAR */ keyseg->flag|= HA_VAR_LENGTH_PART; + /* Store in bit_start number of bytes used to pack the length */ + keyseg->bit_start= ((keyseg->type == HA_KEYTYPE_VARTEXT1 || + keyseg->type == HA_KEYTYPE_VARBINARY1) ? + 1 : 2); + } break; default: break; @@ -368,6 +386,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, } if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART)) { + DBUG_ASSERT(!test_all_bits(keyseg->flag, + (HA_VAR_LENGTH_PART | HA_BLOB_PART))); keydef->flag|=HA_VAR_LENGTH_KEY; length++; /* At least one length byte */ options|=HA_OPTION_PACK_KEYS; /* Using packed keys */ @@ -646,11 +666,31 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, /* Save unique definition */ for (i=0 ; i < share.state.header.uniques ; i++) { + HA_KEYSEG *keyseg_end; + keyseg= uniquedefs[i].seg; if (mi_uniquedef_write(file, &uniquedefs[i])) goto err; - for (j=0 ; j < uniquedefs[i].keysegs ; j++) + for (keyseg= uniquedefs[i].seg, keyseg_end= keyseg+ uniquedefs[i].keysegs; + keyseg < keyseg_end; + keyseg++) { - if (mi_keyseg_write(file, &uniquedefs[i].seg[j])) + switch (keyseg->type) { + case HA_KEYTYPE_VARTEXT1: + case HA_KEYTYPE_VARTEXT2: + case HA_KEYTYPE_VARBINARY1: + case HA_KEYTYPE_VARBINARY2: + if (!(keyseg->flag & HA_BLOB_PART)) + { + keyseg->flag|= HA_VAR_LENGTH_PART; + keyseg->bit_start= ((keyseg->type == HA_KEYTYPE_VARTEXT1 || + keyseg->type == HA_KEYTYPE_VARBINARY1) ? + 1 : 2); + } + break; + default: + break; + } + if (mi_keyseg_write(file, keyseg)) goto err; } } |