Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GETFLDSTATE() problem in SELECT
Message
De
14/06/2004 00:13:56
Suhas Hegde
Dental Surgeon
Sirsi, Inde
 
 
À
13/06/2004 13:46:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Beta
Divers
Thread ID:
00913252
Message ID:
00913310
Vues:
25
>**** 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

Hi Fabio,

I still dont think it solves the problem.

consider this..
clear
close all
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'

?"updating Abcd : " + Icase(tableupdate(2,.t.,"abcd"),"Updated","not updated")

insert into abcd values('xyz5')
replace abc with "xyz5 + R" for abc = 'xyz5'
?"Replacing after insert"

select * from abcd with (buffering = .t.) WHERE "2" $ GETFLDSTATE(-1)+LEFT(abc,0)
?_tally,"records returned . expected 1"
select * from abcd with (buffering = .t.)
?_tally,"records returned -- total number in buffered alias"
select * from abcd
?_tally,"records returned -- total number from disk"
Any ideas

Suhas
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform