{*word*194} and strange SQLstring compare bug

**************************
      BUG REPORT
**************************

Looks like a rather inisidious bug in BDE/Paradox/SQL.  Some string comparisons
are not working.

Strange results were observed with SELECT statements.  For example
   WORKS   select ... where (tmdate > "_C3") or (tmdate = "CanNeverMatch")
   WORKS   select ... where (tmdate = "CanNeverMatch") or (tmdate > "_C3")
   FAILS   select ... where (tmdate > "_C3")
That is: Adding a dummy comparison fixes the bug!

Some test strings are well behaved others are pathological as above.

EXAMPLES

In the following four sets of results (from a custom tool) the first column
shows the actual 3-character data in the TMDATE field in brackets.  The second
column shows this interpreted as a date.

Report No 1:  Lists all the data.  Note how the first line is correctly
               sorted to the top of the list.
----------------------------------------------------------------------------------------------------------
SQL USED    :select "("+tmdate+")", tmdate,tmcharge,tmpzid from treatmt
              order by tmdate

----------------------------------------------------------------------------------------------------------
( + t|tmdate  |tmcharge  |tmpzid    |
- - -|------  |--------  |------    |
(_]B)|01 01 99|35.00    |5         |
(_b~)|29 06 00|40.00    |6         |
(_b~)|29 06 00|-1.00    |6         |
(_b?)|30 06 00|30.00    |6         |
(_b?)|30 06 00|30.00    |6         |
-----|--------|----------|----------|
(_b)|08 07 00|40.00    |4         |
(_b)|08 07 00|40.00    |6         |
(_b?)|09 07 00|40.00    |6         |
(_b?)|11 07 00|30.00    |4         |
(_b?)|11 07 00|40.00    |4         |
-----|--------|----------|----------|
(_c#)|02 08 00|40.00    |5         |
(_c#)|02 08 00|30.00    |5         |
(_c#)|02 08 00|40.00    |4         |
(_c#)|02 08 00|25.00    |5         |

Report No 2 : Note that the "=" has worked but we would expect that
               the ">" would bring in all the other records.
               ( "<" fails also! )
QUERY TEXT  :select "("+tmdate+")", tmdate,tmcharge,tmpzid from treatmt
              where tmdate >= {01 jan 1999}
              order by tmdate
----------------------------------------------------------------------------------------------------------
SQL USED    :select "("+tmdate+")", tmdate,tmcharge,tmpzid from treatmt
              where tmdate >=  "_]B"
              order by tmdate
----------------------------------------------------------------------------------------------------------
( + t|tmdate  |tmcharge  |tmpzid    |
- - -|------  |--------  |------    |
(_]B)|01 01 99|35.00    |5         |

Report No 3  (Compare with report 4)  Fails.

SQL USED    :select "("+TmDate+")",tmdate from treatmt
              where  (tmdate > "_C3")
              order by tmdate

----------------------------------------------------------------------------------------------------------
( + T|TmDate  |
- - -|------  |
(_]B)|01 01 99|

Report 4   : This is identical SQL to used in report 3
              except for the addition of a 'do nothing'
              third line.
----------------------------------------------------------------------------------------------------------
SQL USED    :select "("+TmDate+")",tmdate from treatmt
              where  (tmdate > "_C3")
              or (tmdate = "CanNeverMatch")
              order by tmdate

----------------------------------------------------------------------------------------------------------
( + T|TmDate  |
- - -|------  |
(_]B)|01 01 99|
(_b~)|29 06 00|
(_b~)|29 06 00|
(_b?)|30 06 00|
(_b?)|30 06 00|
-----|--------|
(_b)|08 07 00|
(_b)|08 07 00|
(_b?)|09 07 00|
(_b?)|11 07 00|
(_b?)|11 07 00|
-----|--------|
(_c#)|02 08 00|
(_c#)|02 08 00|
(_c#)|02 08 00|
(_c#)|02 08 00|

NOTES
Some test values appear to work but others don't
WORK : "_B?"  "_B?"  "_B?"  "_C""" (Last one dups quotes)
FAIL : "_C#"  "_C$"  "_C%"  "_C&"

Identical results in database desktop as well as in Delphi apps

TECH INFO
BDE version 5.1.1.1
Paradox driver Version 3 Level 4
Database Desktop Version 7
Windows 95 (Not Networked)
Paradox data files are at www.eminent.demon.co.uk/bugreport.zip

--
PETER FOX Not the same since the cardboard box company folded
2 Tees Close, Witham, Essex.            pe...@eminent.demon.co.uk
Gravity beer in Essex            <http://www.eminent.demon.co.uk>