[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fdo-commits
Subject:    [fdo-commits] r5813 - in trunk/Providers/GenericRdbms/Src:
From:       svn_fdo () osgeo ! org
Date:       2010-11-17 21:27:44
Message-ID: 20101117212744.1DFA8390388 () trac ! osgeo ! org
[Download RAW message or body]

Author: brentrobinson
Date: 2010-11-17 13:27:44 -0800 (Wed, 17 Nov 2010)
New Revision: 5813

Modified:
   trunk/Providers/GenericRdbms/Src/Fdo/Connection/FdoRdbmsConnection.cpp
   trunk/Providers/GenericRdbms/Src/SQLServerSpatial/SchemaMgr/Ph/Owner.cpp
Log:
Ticket#707: Flush Schema Manager caches when a CreateDatastore command fails.

Also fixed a problem in SQLServerSpatial provider where, after a CreateDatastore, the \
current database is still the datastore that was created. This is wrong since we're \
not actually connected to the datastore at that point. Now, the current database is \
set back to master when CreateDatastore completes. 

Modified: trunk/Providers/GenericRdbms/Src/Fdo/Connection/FdoRdbmsConnection.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/Fdo/Connection/FdoRdbmsConnection.cpp	2010-11-15 \
                15:28:41 UTC (rev 5812)
+++ trunk/Providers/GenericRdbms/Src/Fdo/Connection/FdoRdbmsConnection.cpp	2010-11-17 \
21:27:44 UTC (rev 5813) @@ -685,44 +685,59 @@
         );
 
 // Create a new Owner (physical schema) in the current database instance
-	FdoSmPhOwnerP newSchema = physicalMgr->GetDatabase()->CreateOwner( dbName, \
                isFdoEnabled );
-    newSchema->SetPassword( dbPassword );
-	newSchema->SetDescription( dbDescription );
+	
+    try
+    {
+        FdoSmPhOwnerP newSchema = physicalMgr->GetDatabase()->CreateOwner( dbName, \
isFdoEnabled ); +        newSchema->SetPassword( dbPassword );
+	    newSchema->SetDescription( dbDescription );
 
-	FdoLtLockModeType lt_mode = NoLtLock;
-	if ( wcscmp( ltMode, L"FDO" ) == 0 )
-		lt_mode = FdoMode;
-	else if ( wcscmp( ltMode, L"OWM" ) == 0 )
-		lt_mode = OWMMode;
+	    FdoLtLockModeType lt_mode = NoLtLock;
+	    if ( wcscmp( ltMode, L"FDO" ) == 0 )
+		    lt_mode = FdoMode;
+	    else if ( wcscmp( ltMode, L"OWM" ) == 0 )
+		    lt_mode = OWMMode;
 
-	newSchema->SetLtMode( lt_mode );
-	
-	FdoLtLockModeType lck_mode = NoLtLock;
-	if (  wcscmp( lckMode, L"FDO" ) == 0 )
-		lck_mode = FdoMode;
-	else if ( wcscmp( lckMode, L"OWM" ) == 0 )
-		lck_mode = OWMMode;
+	    newSchema->SetLtMode( lt_mode );
+    	
+	    FdoLtLockModeType lck_mode = NoLtLock;
+	    if (  wcscmp( lckMode, L"FDO" ) == 0 )
+		    lck_mode = FdoMode;
+	    else if ( wcscmp( lckMode, L"OWM" ) == 0 )
+		    lck_mode = OWMMode;
 
-    FdoPtr<FdoIConnectionCapabilities> connectionCapabilities = \
                this->GetConnectionCapabilities();
-	if (connectionCapabilities->SupportsLocking() ||
-		connectionCapabilities->SupportsLongTransactions())
-		newSchema->SetLckMode( lck_mode);
-	else
-		newSchema->SetLckMode( NoLtLock );
+        FdoPtr<FdoIConnectionCapabilities> connectionCapabilities = \
this->GetConnectionCapabilities(); +	    if \
(connectionCapabilities->SupportsLocking() || +		    \
connectionCapabilities->SupportsLongTransactions()) +		    newSchema->SetLckMode( \
lck_mode); +	    else
+		    newSchema->SetLckMode( NoLtLock );
 
-    // Post the new Owner to the RDBMS.
-    newSchema->Commit();
+        // Post the new Owner to the RDBMS.
+        newSchema->Commit();
 
-	// Check if FDOSYS is needed
-	if (newSchema->GetLtMode() == FdoMode ||
-		newSchema->GetLckMode() == FdoMode)	{
-		// Create FDOSYS
-		FdoSmPhOwnerP fdoOwner = \
                FdoSmPhDatabaseP(physicalMgr->GetDatabase())->FindOwner(FDOSYS_OWNER);
                
-		if (!fdoOwner)	{
-			CreateSysDb( FDOSYS_OWNER, L"", connectString);
-		}
-	}
+	    // Check if FDOSYS is needed
+	    if (newSchema->GetLtMode() == FdoMode ||
+		    newSchema->GetLckMode() == FdoMode)	{
+		    // Create FDOSYS
+		    FdoSmPhOwnerP fdoOwner = \
FdoSmPhDatabaseP(physicalMgr->GetDatabase())->FindOwner(FDOSYS_OWNER); +		    if \
(!fdoOwner)	{ +			    CreateSysDb( FDOSYS_OWNER, L"", connectString);
+		    }
+	    }
+    }
+    catch ( ... ) 
+    {
+        try
+        {
+            GetSchemaManager()->Clear(true);
+        }
+        catch (...) 
+        {
+        }
 
+        throw;
+    }
     // Creating an owner is a major operation so force refresh of schema 
     // info from the RDBMS by clearing the schema manager caches.
     GetSchemaManager()->Clear(true);

Modified: trunk/Providers/GenericRdbms/Src/SQLServerSpatial/SchemaMgr/Ph/Owner.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/SQLServerSpatial/SchemaMgr/Ph/Owner.cpp	2010-11-15 \
                15:28:41 UTC (rev 5812)
+++ trunk/Providers/GenericRdbms/Src/SQLServerSpatial/SchemaMgr/Ph/Owner.cpp	2010-11-17 \
21:27:44 UTC (rev 5813) @@ -362,6 +362,7 @@
 bool FdoSmPhSqsOwner::Add()
 {
     FdoSmPhSqsMgrP mgr = GetManager()->SmartCast<FdoSmPhSqsMgr>();
+    FdoSmPhDatabase* pDatabase = (FdoSmPhDatabase*)GetParent();
     GdbiConnection* gdbiConn = mgr->GetGdbiConnection();
     GdbiCommands* gdbiCommands = gdbiConn->GetCommands();
 	bool		  autoCmtChanged = false;
@@ -428,6 +429,8 @@
                 
                 if ( prevOwner )
                     prevOwner->SetCurrent();
+                else
+                    pDatabase->UnsetCurrentOwner();
             }
             catch (...) {
             }
@@ -445,6 +448,8 @@
                 
         if ( prevOwner && FdoStringP(prevOwner->GetName()).GetLength() != 0)
             prevOwner->SetCurrent();
+        else
+            pDatabase->UnsetCurrentOwner();
 
         //TODO: spatial handling?
     }

_______________________________________________
fdo-commits mailing list
fdo-commits@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic