flightaware / speedtables

Speed tables is a high-performance memory-resident database. The speed table compiler reads a table definition and generates a set of C access routines to create, manipulate and search tables containing millions of rows. Currently oriented towards Tcl.
https://flightaware.github.io/speedtables/
BSD 3-Clause "New" or "Revised" License
65 stars 15 forks source link

search with match against integer fields will crash #54

Closed bovine closed 8 years ago

bovine commented 8 years ago

The following command will crash speedtables because match is being used against an integer (long) field:

inflight search -compare "{match arrivalTime 123456}"

The following command works, without crashing:

inflight search -compare "{= arrivalTime 123456}"

Either "match" should be made to work against integer fields, or it should return an error if you attempt to use that in a query.

resuna commented 8 years ago

New work branch "issue54".

lehenbauer commented 8 years ago

I don't see a useful behavior for match on integers, so my preference is to make match on integer be an error. Maybe if you converted them on the fly to strings and then did a string match, but, yuk.

Match on floats probably also will crash for the same reason as integers.

resuna commented 8 years ago

I can see reasons to want string match on other types (eg if you use integers to store serial numbers with internal structure), but there are likely numerical (and faster, if indexed) alternatives and putting a string conversion in the search loop would be pretty slow. I'm already working on making anything but fixed or var strings an error.

resuna commented 8 years ago

Jeff - can you check issue54 and maybe merge it if you're happy with the results?

Also added checks in tests for this case.

bovine commented 8 years ago

Seems to work. I'll merge it into master.

connect {fa_birdseye - connect from ::1 51008 - help for help}
inflight search -compare "{match arrivalTime 123456}"
error {term "arrivalTime" must be a string type for "match" operation while processing search compare}
inflight search -compare "{= arrivalTime 123456}"
ok 0
bovine commented 8 years ago

merged