Small company logo:
   History
 
Advertising banner:
 
 [DataCheck] Modification de type sur un cPostmark
Home • main site • faq_plug-ins • [DataCheck] Modification de type sur un c
 
From:Saturday, July 31, 2010 7:11 PM +0200
Subject:[DataCheck] Modification de type sur un c 
To:
Pour les possesseurs de DataCheck, voici un message de Paul Carnine, auteur de DataCheck :



I have been investigating issues related to boolean indexes.

I wanted to get back to you all to let you know that I have uncovered some
issues with both indexed and non-indexed use of QUERY after you have
modified the type of a field from integer to boolean.

To be very specific:

--------------------
NON-INDEXED FAILURE:
--------------------

* In any version of 4D after v6 (6.0 -> 6.8.2)
 (NB: v2.2.3 works, I have no key disk for v3.5).
* If you have a field of type Integer.
* If that field has values that are NOT 1 or 0.
* If you convert that field to type Boolean.
* If the field has no index
* If you Query on that field.

 Your non-indexed query will fail.

--------------------------------------
INDEXED FAILURE (poorly formed index):
--------------------------------------

* In any version of 4D/4D Tools that can use fast-mode (6.5.2 -> 6.8.2)
* If you have a field of type Integer.
* If that field has values that are NOT 1 or 0.
* If you convert that field to type Boolean.
* If you build the index using "Fast Index"

 Your index query will fail (poorly formed index).

-----------
DEFINITIONS
-----------

"Fast Index" mode is used:

   1) when you select it when manually building an index
   2) when you use SET INDEX with a "mode" parameter.
   3) when you use 4D Tools (compact, rebuild, etc).

"Failure" means:

   1) Specifically:

       QUERY($pTable->;$pField->;#;True;*)
       QUERY($pTable->;$pField->;#;False)

       returns records.
       this query should always return no records.

   2) In your data bases:

       Undefined results for any query
       against boolean fields.

   3) Any version of DataCheck shows index as damaged
      (reported as item [75])

----------------
HOW TO REPRODUCE
----------------

I have a very simple v6.8.2 mac database which exhibits the issue:


   1. Open the structure with 4D 6.8.2
   2. Follow directions you are "alerted" to do.

-------------
HOW TO DETECT
-------------

1) FAST:

   Use DataCheck v3.1.2 (available now).
       Problem is specifically detected; Reported.

  Use DataCheck v2 (for those who have not upgraded):
       check "Type Mismatch Warnings" on "Records" tab.
       if a field has "Mismatch" and it is a Boolean, the
       problem may exist.

  NOTE: Any version of DataCheck will complain
        when the index is poorly formed.

2) SLOW:

 For ($table;1;Count tables)
   $pTable:=Table($table)
   For ($field;1;Count fields($table))
     $pField:=Field($table;$field)
     GET FIELD PROPERTIES($pField;$type)
     If ($type=Is Boolean )
       QUERY($pTable->;$pField->;#;True;*)
       QUERY($pTable->;$pField->;#;False)
       If (Records in selection($pTable->)>0)
         $name:="["+Table name($pTable)+"]"
         $name:=$name+Field name($pField)
         ALERT("Bad bool query on "+$name)
       End if
      End if
    End for
  End for

-----------
WORK AROUND
-----------

 For each table that has a problem,
 run APPPLY TO SELECTION, rebuild index.
 field for APPLY TO SELECTION should not matter.

 Here's how you'd do all tables (brute force):

   For ($table;1;Count tables)
    $pTable:=Table($table)
    $pField:=Field($table;1)
    ALL RECORDS($pTable->)
    APPLY TO SELECTION($pTable->;$pField->:=$pField->)
   End for

  now rebuild your indexes on those boolean fields.

-------
SUMMARY
-------

Thanks to Bernd and Mark for putting me on the scent.

I am in contact with 4D and will do my best to help a fix for this get into
the next maintenance release of 4D.


--
Paul Carnine