I am implementing an extension for manipulating IEEE754 decimal
numbers. Numbers are stored as blobs using a standard encoding.
Numbers that are mathematically equal may have different
representations, (e.g., 1.0 may have mantissa 10 and exponent -1
while 1.00 may have mantissa 100 and exponent -2).

Since I am going to perform point and range queries on decimal
columns, I'd like to have them indexed. So far, I have been able to
create an expression index based on a decstr() function that
converts a decimal into a string, which I can use in queries like
the following:

    select decstr(d) from T where decstr(d) = '1.2345';

(Btw, if I use `like`, as in `decstr(d) like '1.2%'`, the index is
not used. Does it depend on my data, or can't the optimizer use an
index with a pattern matching condition?)

Anyway, string-based comparisons are limited. But, (correct me if
I am wrong), if I index the blob column directly, comparisons are
based on memcpy(), which in my case is not what I want. Is it
possible to create an index that somehow uses a custom comparison
function instead? E.g., I have a deccmp(x,y) function that returns
-1 if x<y, 0 if x=y, and 1 if x>y. Can I define an index based on
that?

Thanks,
Life.


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to