Changeset 13808

Show
Ignore:
Timestamp:
02/17/08 11:29:35 (3 months ago)
Author:
warmerdam
Message:

Add "shared" attribute on SrcDataSource? to control sharing. Default to OFF
for SrcLayer? layers, and ON for SrcSQL layers. This endevours to avoid
conflicts of layer state. (#2229)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/ogr/ogrsf_frmts/vrt/drv_vrt.html

    r13708 r13808  
    3535a <b>relativeToVRT</b> attribute which defaults to "0", but if "1" indicates 
    3636that the source datasource should be interpreted as relative to the virtual 
    37 file.  This can be any OGR supported dataset, including ODBC, CSV, etc.<p> 
     37file.  This can be any OGR supported dataset, including ODBC, CSV, etc. 
     38The element may also have a <b>shared</b> attribute to control whether the datasource should be opened in shared mode. Defaults to OFF for SrcLayer use and ON for SrcSQL use.<p> 
    3839 
    3940<li> <b>SrcLayer</b> (optional): The value is the name of the layer on the 
  • trunk/gdal/ogr/ogrsf_frmts/vrt/ogr_vrt.h

    r10645 r13808  
    5757    int                 bNeedReset; 
    5858    int                 bSrcLayerFromSQL; 
     59    int                 bSrcDSShared; 
    5960 
    6061    // Layer spatial reference system, and srid. 
  • trunk/gdal/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp

    r13755 r13808  
    105105            poSrcDS->ReleaseResultSet( poSrcLayer ); 
    106106 
    107         OGRSFDriverRegistrar::GetRegistrar()->ReleaseDataSource( poSrcDS ); 
     107        if( bSrcDSShared ) 
     108            OGRSFDriverRegistrar::GetRegistrar()->ReleaseDataSource( poSrcDS ); 
     109        else 
     110            delete poSrcDS; 
    108111    } 
    109112 
     
    171174 
    172175/* -------------------------------------------------------------------- */ 
     176/*      Are we accessing this datasource in shared mode?  We default    */ 
     177/*      to shared for SrcSQL requests, but we also allow the XML to     */ 
     178/*      control our shared setting with an attribute on the             */ 
     179/*      datasource element.                                             */ 
     180/* -------------------------------------------------------------------- */ 
     181    const char *pszSharedSetting = CPLGetXMLValue( psLTree,  
     182                                                   "SrcDataSource.shared", 
     183                                                   NULL ); 
     184    if( pszSharedSetting == NULL ) 
     185    { 
     186        if( CPLGetXMLValue( psLTree, "SrcSQL", NULL ) == NULL ) 
     187            pszSharedSetting = "OFF"; 
     188        else 
     189            pszSharedSetting = "ON"; 
     190    } 
     191 
     192    bSrcDSShared = CSLTestBoolean( pszSharedSetting ); 
     193 
     194/* -------------------------------------------------------------------- */ 
    173195/*      Try to access the datasource.                                   */ 
    174196/* -------------------------------------------------------------------- */ 
    175197    CPLErrorReset(); 
    176     poSrcDS = poReg->OpenShared( pszSrcDSName, FALSE, NULL ); 
     198    if( bSrcDSShared ) 
     199        poSrcDS = poReg->OpenShared( pszSrcDSName, FALSE, NULL ); 
     200    else 
     201        poSrcDS = poReg->Open( pszSrcDSName, FALSE, NULL ); 
    177202 
    178203    if( poSrcDS == NULL )