Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GETFLDSTATE() problem in SELECT
Message
De
13/06/2004 13:46:17
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Beta
Titre:
GETFLDSTATE() problem in SELECT
Divers
Thread ID:
00913252
Message ID:
00913252
Vues:
140
**** Start Notes *****
try to solve the Thread #913176 i found a old issue.

This is complex to explain.

This is a old issue, VFP SELECT command use ( )this 3 phases schema:
- first : VFP build the result cursor,
- second : VFP try to optimize the SELECT
- third : VFP start the SELECT execution plan (a variouse loop cycles )

This problem is correlate with the second phase:
like first optimization step, VFP have to choice the reference table for the plan ( PIVOT TABLE )
for do this VFP try to check and optimize the WHERE condition ( WHERE PARSING )
for do the WHERE PARSING VFP evaluate the WHERE condition expression ( factor by factor )
if VFP Parser think that one condition factor it is invariant and WHERE PARSING value for it is .F. or .NULL.
it consider this value constant and then if the condition is a fixed .F. or .NULL. it skip the third phase.

Because VFP have not choice the PIVOT TABLE,
if the current workarea is allocated
then it keep like active workarea the current workarea,
else it set the result cursor like active workarea.

Now, GETFLDSTATE(-1) before VFP9 have not direct correlation with the SELECT, and then this problem is new.

*** REPRO CODE ***

RUN this AND read print
CLEAR
CREATE CURSOR noBuffer (du I)
ON ERROR ?? "ERROR: "+MESSAGE()

SET MULTILOCKS ON
Create Cursor abcd (abc C(10))
insert into abcd values('xyz')
insert into abcd values('xyz1')
cursorsetprop("buffering",5)
insert into abcd values('xyz2')
insert into abcd values('xyz3')
replace RECORD 2 abc WITH 'xyz4'

? "Now set like active workarea a not buffered cursor, this not allow GETFLDSTATE(-1) and errors are fired"
SELECT noBuffer
? "THIS IS the value that VFP use WHERE PARSING phase: ",GETFLDSTATE(-1)
? "executing 1 "
select * from abcd with (buffering = .t.) WHERE "2" $ GETFLDSTATE(-1) INTO ARRAY pippo
?? " Expected 1"
?
? "Now set no active workarea, on SELECT it catch the issue, and then set like active workarea the result cursor,"
? " but this is empty, and GETFLDSTATE(-1) return a .NULL."
SELECT 0
? "THIS IS the value that VFP use WHERE PARSING phase: NULL"
? "executing 2 "
select * from abcd with (buffering = .t.) WHERE "2" $ GETFLDSTATE(-1) INTO ARRAY pippo
?? _TALLY," Expected 1"

?
? "Now set a buffered cursor with a unbuffered record"
SELECT abcd
GO 1
? "THIS IS the value that VFP use WHERE PARSING phase: ",GETFLDSTATE(-1)
? "executing 3 "
select * from abcd with (buffering = .t.) WHERE "2" $ GETFLDSTATE(-1) INTO ARRAY pippo
?? _TALLY," Expected 1"

?
? "Now set a buffered cursor with a buffered record"
SELECT abcd
GO 2
? "THIS IS the value that VFP use WHERE PARSING phase: ",GETFLDSTATE(-1)
? "executing 4 "
select * from abcd with (buffering = .t.) WHERE "2" $ GETFLDSTATE(-1) INTO ARRAY pippo
?? _TALLY," Expected 1"

* WORKAROUND: force VFP to think the where condition not invariant

select * from abcd with (buffering = .t.) WHERE "2" $ GETFLDSTATE(-1)+LEFT(abc,0)

ON ERROR
*** FINAL NOTES ***
I think VFP have a list of variant functions DATETIME(),RAND() and then VFPT have to add GETFLDSTATE(-1) to this list.
But this not fixed the "executing 1 " case.

Fabio
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform