Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Invalid key length when increasing character type field to near maximum length

370 views
Skip to first unread message

Dan Musicant

unread,
Jun 16, 2010, 11:09:23 PM6/16/10
to
Why does this happen? I have a character field with a simple index on it
and if I try to modify the structure to make the field anywhere near the
maximum of 254 characters for a character type field I get errors :
Invalid key length. I have to reduce the number of characters to not get
the error. I have no idea just how many characters I have to reduce it
from 254 to not get errors, it's a total mystery to me. I'm using VFP
9.0 here. Been having this problem for a while. Anyone know what may be
afoot? The field is named "desc" and the index is achieved thusly:

INDEX on desc TAG desc (i.e. as simple as can be)

Dan


Email: dmusicant at pacbell dot net

JayB

unread,
Jun 16, 2010, 11:13:58 PM6/16/10
to
it does not serve a purpose to have an index on a long field.
the first 50 or so chars should do it.
try
INDEX on left(desc,50) TAG desc
i also use
INDEX on upper(left(desc,50)) TAG desc

Dan Freeman

unread,
Jun 17, 2010, 2:18:20 AM6/17/10
to
Foxpro has never been particularly graceful when operating at the edges
of its limits.

Index expressions are evaluated before they're stuffed into the Btree,
and the evaluation isn't a 1:1 character length equivalent. Sometimes
an expression can evaluate to longer than the 100-byte limit on index
expressions.

We've all had complex index expressions that work just fine until a
data condition makes the expression evaluate to somethimg the index
engine can't handle. This is the same thing.

The limit isn't on the length of the data field, it's on the evaluation
of the index expression and that evaluation is a bit fluid.

Dan


Dan Musicant explained :

Gene Wirchenko

unread,
Jun 22, 2010, 5:14:03 PM6/22/10
to
On Wed, 16 Jun 2010 20:09:23 -0700, Dan Musicant <m...@privacy.net>
wrote:

^^^^ ^^^^
"desc" is a reserved word.

The limit is not 254. From the docs:

"Maximum # of bytes per index key in a non-compact index3.
100

Maximum # of bytes per index key in a compact index3.
240

...

3 If the collating sequence is set to MACHINE, each character uses one
byte. If the collating sequence is not set to MACHINE, each character
uses two bytes. If the indexed field supports null values, one
additional byte is used in the index key. Note that non-machine
indexes are always compact."

Sincerely,

Gene Wirchenko

0 new messages