Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG: SELECT NOT IN (SELECT ) result can be wrong
Message
From
24/06/2004 05:32:53
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Title:
BUG: SELECT NOT IN (SELECT ) result can be wrong
Miscellaneous
Thread ID:
00916741
Message ID:
00916741
Views:
55
Subject:
on the Thread #915981 i post a program code where various SELECTs return incorrect data.
Now i post a more evident program code where the SELECT data are bads, and explain why this occur.

Run this code:
CLEAR
CREATE CURSOR T1 (F1 L NULL)
FOR K=1 TO 100
	INSERT INTO T1 VALUES (.T.)
NEXT

SYS(3054,11)

* in the next query a temp index is used and the result is correct
SELECT * FROM T1 WHERE F1 NOT IN (SELECT F1 FROM T1) INTO CURSOR R_IN
? _TALLY, ' expected 100'

* in the next query a temp index is used and the result is correct
SELECT * FROM T1 WHERE F1 NOT IN (SELECT .T. FROM T1 GROUP BY 1) INTO CURSOR R_NOT_IN
? _TALLY, ' expected 0'

* in the next query a cartesian product is used and result is not correct
SELECT * FROM T1 WHERE F1 = ALL (SELECT .T. FROM T1) INTO CURSOR R_NOT_IN
? _TALLY, ' expected 100'

* in the next query a cartesian product is used and result is not correct
SELECT * FROM T1 WHERE F1 <> ANY (SELECT .F. FROM T1) INTO CURSOR R_NOT_IN
? _TALLY, ' expected 100'

* in the next query a cartesian product is used and result is not correct
SELECT * FROM T1 WHERE F1 <> ALL (SELECT .T. FROM T1) INTO CURSOR R_NOT_IN
? _TALLY, ' expected 0'

* in the next query a cartesian product is used and result is not correct
SELECT * FROM T1 WHERE F1 IN (SELECT .T. FROM T1) INTO CURSOR R_NOT_IN
? _TALLY, ' expected 0'

* in the next query a cartesian product is used and result is not correct
SELECT * FROM T1 WHERE F1 NOT IN (SELECT .T. FROM T1) INTO CURSOR R_NOT_IN
? _TALLY, ' expected 0'
If you observe the Rushmore ( SYS(3054) ) output,
you can see that when the VFP Query Engine executes the query with a Cartesian product plan,
the results of the query are wrong.
Probably this is the internal cause of this bug,
i.e the VFP Query Engine chooses the wrong execution plan,
and returns the Cartesian product ( like an JOIN ).

When you run the code specified above,
the VFP environment can sometimes become corrupted,
and randomly, C5 crash exceptions can occur.

This bug occurs also in VFP8SP1.

Fabio
Next
Reply
Map
View

Click here to load this message in the networking platform