← Back to team overview

drizzle-discuss team mailing list archive

HA_KEYTYPE_VARTEXT1 and HA_KEYTYPE_VARTEXT2

 

G'day Drizzlers,

I was looking through index key handling code and discovered the
following enums:

 - HA_KEYTYPE_VARTEXT1
 - HA_KEYTYPE_VARTEXT2

The first question that popped in my mind was "What on earth is the
difference between these?". So, I did some grepping and found some
interesting things about them.

Firstly, these are only used in MyISAM and HEAP only. Here's the list
of files in the kernel that uses it (defined in base.h). It seems
hardly used too.

 - drizzled/base.h
 - drizzled/table.cc
 - drizzled/field/blob.h
 - drizzled/field/varstring.cc

Secondly, according to this comment in varchar.cc: "When VARCHAR is
stored in a key (for handler::index_read() etc) it's always stored
with a 2 byte prefix. (Just like blob keys).", this line of code:

res= length_bytes == 1 ? HA_KEYTYPE_VARTEXT1 : HA_KEYTYPE_VARTEXT2;

in drizzled/field/varstring.cc doesn't make sense to me (because it's
mentioned that the length of the variable length textual data for keys
is represented with 2 bytes).  So, my speculation is that
HA_KEYTYPE_VARTEXT1 represents a varchar that has a length
representation of 1 byte.

Since MyISAM and HEAP are about the only engines that uses this enum,
would it make sense to consider removing VARTEXT1 and make VARTEXT2,
"the one"?. I understand that this area of the code could be delicate
so I sent this email to see what you all think of this.

Cheers,
-- 
Toru Maesaka <dev@xxxxxxxxx>



Follow ups