Opened 15 years ago
Closed 9 years ago
#2556 closed enhancement (fixed)
Set encoding, start/stop/rollback transaction (PG driver)
Reported by: | bishop | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | svn-trunk |
Severity: | normal | Keywords: | OGR PG |
Cc: |
Description
- Add function SetEncoding
- Make functions (SoftStartTransaction, SoftCommit, SoftRollback) exported from dll
Attachments (4)
Change History (18)
by , 15 years ago
comment:1 by , 15 years ago
Please attach patches to existing files instead of full files.
And please make those patches against GDAL SVN trunk for new features, which resides at http://svn.osgeo.org/gdal/trunk/gdal (http://trac.osgeo.org/gdal/browser)
follow-up: 3 comment:2 by , 15 years ago
Summary: | Set encoding, start/stop/rollback transaction → Set encoding, start/stop/rollback transaction (PG driver) |
---|
comment:3 by , 15 years ago
Replying to bishop: Sorry, but I'm a newbie, so can you provide some instructions, to do it, or point me of some kind of faq.
comment:4 by , 15 years ago
Assuming that you're somehow familiar with subversion, otherwise please read a user manual of it or some tutorial
- Checkout the trunk repository with :
svn checkout http://svn.osgeo.org/gdal/trunk/gdal (or with any graphical interface that exists)
- Apply your changes; Build; Test
- svn diff > name_of_the_patch.patch
As Frank says try to isolate each functionnal change to make a separate patch.
comment:6 by , 15 years ago
Version: | 1.5.2 → svn-trunk |
---|
comment:7 by , 15 years ago
Why is it necessary to export the transaction functions at the OGRPGDataSource level ? They are already exposed at the OGRLayer level.
comment:8 by , 15 years ago
There is necessary to make some changes in several tables (layers) and if some change return error to roll back all operations. This is very important in related tables too
by , 14 years ago
Attachment: | export_transaction_functions_from_dll_#2556.patch added |
---|
SetEncoding & exoprts some functions
comment:9 by , 14 years ago
I updated patch to current svn tranc. I also want to note that using PGCLIENTENCODING environment variable is not a good way. Because SetEncoding method returns OGRErr and log some info. So developer can manage this situation in program logic.
comment:10 by , 14 years ago
Adding new exported method is not a good solution as it implies people to use C++ and depend on the non-installed private headers of the driver.
1) OGRPGDataSource::SetEncoding(const char* Encoding) is probably unnecessary. You can call poDS->ExecuteSQL("SET client_encoding TO blahblah") and install before an error handler with CPLPushErrorHandler() to track any error issued by the server.
2) Exporting SoftStartTransaction(), SoftCommit(), SoftRollback() and FlushSoftTransaction() is probably not a good solution either. It would be more interesting if could provide a small Python script or C/C++ code that demonstrates the problems that lead you to call them explicitely. This way perhaps we could perhaps make the driver more clever to call itself those functions when it's needed, without requiring the user to mess with that.
comment:11 by , 14 years ago
1) I tested poDS->ExecuteSQL("SET client_encoding TO blahblah") - it's works 2) As I wrote I need make changes in several tables and if it will be some errors to Rollback all changes For example:
void CreateDoubleFeatures() { OGRLayer* pLayer1 = m_pOGRPGDataSource->GetLayerByName("layer1"); if(pLayer1 == NULL) return; OGRLayer* pLayer2 = m_pOGRPGDataSource->GetLayerByName("pLayer2"); if(pLayer2 == NULL) return; //start transactions m_pOGRPGDataSource->SoftStartTransaction(); OGRFeature *pFeature1 = OGRFeature::CreateFeature( pLayer1->GetLayerDefn() ); pFeature1->SetField("someid", 0); pFeature1->SetField("sometext", "some text"); if( pFeature1->CreateFeature( pFeature1 ) != OGRERR_NONE ) { m_pOGRPGDataSource->SoftRollback(); return; } OGRFeature::DestroyFeature( pFeature1 ); OGRFeature *pFeature2 = OGRFeature::CreateFeature( pLayer2->GetLayerDefn() ); pFeature2->SetField("somedata", 1.1); pFeature1->SetField("sometext", "over some text"); if( pFeature2->CreateFeature( pFeature2 ) != OGRERR_NONE ) { m_pOGRPGDataSource->SoftRollback(); return; } OGRFeature::DestroyFeature( pFeature2 ); //stop transactions m_pOGRPGDataSource->SoftCommit(); }
comment:12 by , 14 years ago
It's make sense to change PG driver documentation to explain the way to set encoding
CPLPushErrorHandler(); poDS->ExecuteSQL("SET client_encoding TO blahblah"); CPLPopErrorHandler();
pg header