home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TP4DBFIX.ZIP / TACCESS.FIX < prev   
Encoding:
Text File  |  1988-10-14  |  3.3 KB  |  69 lines

  1.   The Borland Database Toolbox version 4.00 contains a subtle bug which
  2. affects index file operations in some cases.  Specifically, index files which
  3. allow for duplicate keys and use record numbers greater than 32767 will
  4. suddenly get unexpected results when searching for keys.  Typically, this
  5. would be a result of OK = false when you know the key should exist.
  6.   This is caused by a subtle bug in the key comparison routine and has to do
  7. with saving a longint result into an integer.  There is another minor problem
  8. with indexes containing record numbers > MaxLongInt.  Instead of returning
  9. duplicate keys in record number order, the existing code will return them in
  10. sequence interpreted as signed numbers.  Normally this is no problem since
  11. there is no hard disk for DOS that could possibly hold that many records.
  12. However if you're using the record number field for something else (say counts
  13. instead of record numbers) this could possibly affect you.  The routine below
  14. will fix both problems at once.
  15.   To fix the problems, replace the existing TaCompKeys routine in the file
  16. TACCESS.PAS from your Database Toolbox master disk with the routine below.
  17. It's located about line 1050 in the file.  You then need to rebuild all of
  18. the TACCESS.TPU files for your programs (i.e. running TABUILD again) and then
  19. recompile your programs themselves.  FURTHER, you should rebuild all of your
  20. index files which allow for duplicate keys.  Since the bug can affect the
  21. AddKey routine, the index files themselves may contain bad information and
  22. should be recreated from the data files.  I'll grant you that this is a pain,
  23. but do it anyway -- it'll save you headaches later on.
  24.   Another comment for those people working with medium to large indexes. When
  25. you are rerunning the TABUILD program as I described above, use the /W+ option
  26. on the command line to enable the worksheet (i.e. use 'TABUILD /W+ PROG' to
  27. compile the TPU for PROG).  One of the choices in the worksheet is the
  28. estimated number of records in the database.  This is really the maximum
  29. number of keys in an index file and defaults to only 1000.  DO NOT
  30. UNDERESTIMATE THIS NUMBER!  It costs you very little to overstate this value
  31. and if you make it too small it can cause bizarre errors to occur at runtime.
  32. This number is used to calculate the constant MaxHeight and the default is far
  33. too small in my opinion.  So while you're fixing the other problem, be sure to
  34. adjust this constant as well.
  35.   If you have any trouble with this fix, please leave me a message on the
  36. Borland Compuserve forum for Turbo Pascal (GO BPROGA).
  37.  
  38.              Scott Bussinger
  39.              Professional Practice Systems
  40.              110 South 131st Street
  41.              Tacoma, WA  98444
  42.              (206)531-8944
  43.              Compuserve 72247,2671
  44.  
  45. function TaCompKeys(var K1,
  46.                         K2;
  47.                         DR1,
  48.                         DR2 : LongInt;
  49.                         Dup : Boolean ) : Integer;
  50. begin
  51.   if TaKeyStr(K1) = TaKeyStr(K2)
  52.    then
  53.     if not Dup or (DR1=DR2)
  54.      then
  55.       TaCompKeys := 0
  56.     else
  57.      if (DR1+$80000000) > (DR2+$80000000)
  58.       then
  59.        TaCompKeys := 1
  60.       else
  61.        TaCompKeys := -1
  62.    else
  63.     if TaKeyStr(K1) > TaKeyStr(K2)
  64.      then
  65.       TaCompKeys := 1
  66.      else
  67.       TaCompKeys := -1
  68. end;
  69.