Changes between Version 1 and Version 2 of rfc54_dataset_transactions


Ignore:
Timestamp:
Feb 24, 2015, 1:33:15 AM (9 years ago)
Author:
Even Rouault
Comment:

drv_pg_advanced.html: explain the effect of SetAttributeFilter() or SetSpatialFilter()

Legend:

Unmodified
Added
Removed
Modified
  • rfc54_dataset_transactions

    v1 v2  
    378378reading from the beginning.
    379379
     380As calling SetAttributeFilter() or SetSpatialFilter() implies an implicit
     381ResetReading(), they have the same effect as ResetReading(). That is to say,
     382while an implict transaction is in progress, the transaction will be committed
     383(if no other layer is being read), and a new one will be started again at the next
     384GetNextFeature() call. On the contrary, if they are called within an explicit
     385transaction, the transaction is maintained.
     386
    380387With the above rules, the below examples show the SQL instructions that are
    381388run when using the OGR API in different scenarios.
     
    386393                                   FETCH 1 IN cur1
    387394
     395lyr1->SetAttributeFilter('xxx')
     396     --> lyr1->ResetReading()      CLOSE cur1
     397                                   COMMIT (implicit)
     398
     399lyr1->GetNextFeature()             BEGIN (implict)
     400                                   DECLARE cur1 CURSOR  FOR SELECT * FROM lyr1 WHERE xxx
     401                                   FETCH 1 IN cur1
     402
    388403lyr2->GetNextFeature()             DECLARE cur2 CURSOR  FOR SELECT * FROM lyr2
    389404                                   FETCH 1 IN cur2
     
    395410lyr1->CreateFeature(f)             INSERT INTO cur1 ...
    396411
     412lyr1->SetAttributeFilter('xxx')
     413     --> lyr1->ResetReading()      CLOSE cur1
     414                                   COMMIT (implicit)
     415
     416lyr1->GetNextFeature()             DECLARE cur1 CURSOR  FOR SELECT * FROM lyr1 WHERE xxx
     417                                   FETCH 1 IN cur1
     418
    397419lyr1->ResetReading()               CLOSE cur1
    398420
     
    400422                                   COMMIT (implicit)
    401423
    402 
     424~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    403425
    404426ds->StartTransaction()             BEGIN
     
    412434lyr1->CreateFeature(f)             INSERT INTO cur1 ...
    413435
     436lyr1->SetAttributeFilter('xxx')
     437     --> lyr1->ResetReading()      CLOSE cur1
     438                                   COMMIT (implicit)
     439
     440lyr1->GetNextFeature()             DECLARE cur1 CURSOR  FOR SELECT * FROM lyr1 WHERE xxx
     441                                   FETCH 1 IN cur1
     442
    414443lyr1->ResetReading()               CLOSE cur1
    415444
     
    418447ds->CommitTransaction()            COMMIT
    419448
    420 
     449~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    421450
    422451ds->StartTransaction()             BEGIN
     
    432461lyr1->GetNextFeature()             FETCH 1 IN cur1      ==> Error since the cursor was closed with the commit. Explicit ResetReading() required before
    433462
    434 
     463~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    435464
    436465lyr1->GetNextFeature()             BEGIN (implicit)