List:Internals« Previous MessageNext Message »
From:Jan Lindström Date:December 7 2006 1:08pm
Subject:Time types and range search
View as plain text  
Hi,

I have problems with date (and other time types) when range search is
used. Consider following example:

mysql> create table td1(d date, key(d)) engine=soliddb;
Query OK, 0 rows affected (0.12 sec)

mysql> insert into td1 values
('2005-01-01'),('2005-02-02'),('2005-07-14'),('2006-01-01');
Query OK, 4 rows affected (0.05 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from td1 where d between '2005-01-01' and '2005-07-14'
order by d;

Now in ::index_read I find that:

#3  0x0830be3b in ha_soliddb::index_read (this=0x97da960, buf=0x97daa68
"ýîª\017", '¥' <repeats 12 times>, key=0x97ffd00 "",
key_len=4,
find_flag=HA_READ_KEY_OR_NEXT) at ha_soliddb.cc:7046

(gdb) p/d buf
$10 = 159230568

And after conversion to fields:

	case FIELD_TYPE_DATE:
                        {
                            j = ((Field_date*)field)->val_int();
                            break;
                        }

(gdb) p ((Field_date*)field)->val_int()
$9 = 20050714

Thus key value is from the larger date not from the smaller date as you
would expect when HA_READ_KEY_OR_NEXT is used. How dates and other time
types are stored and how should they be compared?

R: Jan Lindström
Solid Information Technology Ltd

Thread
Time types and range searchJan Lindström7 Dec
  • Re: Time types and range searchSergei Golubchik8 Jan