[fdo-commits] r724 - in branches/3.2.x/Providers/GenericRdbms/Src:
Fdo/Connection ODBC/Fdo
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Wed Jan 31 21:24:12 EST 2007
Author: jacklee
Date: 2007-01-31 21:24:12 -0500 (Wed, 31 Jan 2007)
New Revision: 724
Modified:
branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.cpp
branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.h
branches/3.2.x/Providers/GenericRdbms/Src/ODBC/Fdo/FdoRdbmsOdbcConnection.cpp
Log:
Revert Fixed ODBC(Oracle) provider describe schema is slow fix
Modified: branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.cpp 2007-01-31 23:52:59 UTC (rev 723)
+++ branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.cpp 2007-02-01 02:24:12 UTC (rev 724)
@@ -81,7 +81,8 @@
mFilterProcessor( NULL ),
mSchemaUtil( NULL ),
mIndex(0),
- mContext(NULL)
+ mContext(NULL),
+ mParsedConnection(NULL)
{
// Set the flag that indicates whether or not the RDBMS user has a Workspace
// Manager environment.
@@ -91,8 +92,8 @@
// Workspace Manager or Alternate API.
mIsWorkspaceManagerEnvironment = FALSE;
- mParsedConnection = new ParseInfo();
+
}
DbiConnection::~DbiConnection(void)
@@ -180,6 +181,8 @@
mGdbiConnection->SetIsGeometryFromOrdinatesWanted((char*)(const char*)(mParsedConnection->mIsGeometryFromOrdinatesWanted));
}
+ mDbSchemaName = mParsedConnection->mSchema;
+
return mOpen;
}
@@ -201,7 +204,7 @@
rdbi_disconnect( mContext );
mOpen = FdoConnectionState_Closed;
mGdbiConnection->Close();
- mParsedConnection->mSchema = L"";
+ mDbSchemaName = L"";
mDbiContextId = -1;
}
}
@@ -261,29 +264,25 @@
FdoStringP DbiConnection::GetUser()
{
- return mParsedConnection->mUser;
+ return (NULL == mParsedConnection) ? L"" : mParsedConnection->mUser;
}
FdoStringP DbiConnection::GetPassword()
{
- return mParsedConnection->mPassword;
+ return (NULL == mParsedConnection) ? L"" : mParsedConnection->mPassword;
}
FdoStringP DbiConnection::GetSchema()
{
- return mParsedConnection->mSchema;
+ return (NULL == mParsedConnection) ? L"" : mParsedConnection->mSchema;
}
+
FdoStringP DbiConnection::GetDataSource()
{
- return mParsedConnection->mDataSource;
+ return (NULL == mParsedConnection) ? L"" : mParsedConnection->mDataSource;
}
-FdoStringP DbiConnection::GetConnectionString()
-{
- return mParsedConnection->mConnectionStringProperty;
-}
-
void DbiConnection::SetConnectData (FdoString *datasource, FdoString *user, FdoString *password, FdoString *schema, FdoString *connectionString, FdoString *defaultGeometryWanted)
{
if ( !mParsedConnection )
@@ -761,12 +760,12 @@
FdoStringP DbiConnection::GetDbSchemaName()
{
- return mParsedConnection->mSchema;
+ return mDbSchemaName;
}
void DbiConnection::SetDbSchemaName(const wchar_t * schemaName)
{
- mParsedConnection->mSchema = schemaName;
+ mDbSchemaName = schemaName;
}
Modified: branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.h
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.h 2007-01-31 23:52:59 UTC (rev 723)
+++ branches/3.2.x/Providers/GenericRdbms/Src/Fdo/Connection/DbiConnection.h 2007-02-01 02:24:12 UTC (rev 724)
@@ -62,8 +62,7 @@
FdoStringP mConnectionStringProperty; // A connection property actually named "ConnectionString"
FdoStringP mIsGeometryFromOrdinatesWanted; // Unspecified if empty. Can be "true" or "false".
- ParseInfo (FdoString *datasource = L"", FdoString *user = L"", FdoString *password = L"", FdoString *schema = L"",
- FdoString *connectionString = L"", FdoString *defaultGeometryWanted = L"");
+ ParseInfo (FdoString *datasource, FdoString *user, FdoString *password, FdoString *schema, FdoString *connectionString, FdoString *defaultGeometryWanted);
virtual ~ParseInfo ();
};
@@ -71,6 +70,8 @@
ParseInfo* mParsedConnection;
+ FdoStringP mDbSchemaName;
+
FdoConnectionState mOpen; // if the database is open
bool mIsWorkspaceManagerEnvironment;
@@ -105,7 +106,6 @@
FdoStringP GetPassword();
FdoStringP GetSchema ();
FdoStringP GetDataSource ();
- FdoStringP GetConnectionString ();
FDORDBMS_TEST void Close ();
//dbi_context_def *GetCtxt() { return mContext; }
Modified: branches/3.2.x/Providers/GenericRdbms/Src/ODBC/Fdo/FdoRdbmsOdbcConnection.cpp
===================================================================
--- branches/3.2.x/Providers/GenericRdbms/Src/ODBC/Fdo/FdoRdbmsOdbcConnection.cpp 2007-01-31 23:52:59 UTC (rev 723)
+++ branches/3.2.x/Providers/GenericRdbms/Src/ODBC/Fdo/FdoRdbmsOdbcConnection.cpp 2007-02-01 02:24:12 UTC (rev 724)
@@ -22,15 +22,8 @@
#ifdef _WIN32
#include <tchar.h>
-#include<odbcinst.h>
-#else
-// remove #if 0 when FdoRdbmsOdbcConnection::GetSchemaNameFromDsn is active on Linux
-#if 0
-#include<odbcinst.h>
#endif
-#endif
-
#include <Inc/ut.h>
#include "FdoRdbmsOdbcConnectionInfo.h"
#include "FdoRdbmsOdbcConnection.h"
@@ -52,7 +45,6 @@
#include "FdoRdbmsOdbcSpatialManager.h"
#include "DbiConnection.h"
-#include <FdoCommonConnStringParser.h>
#include <Inc/Rdbi/proto.h>
#include "../../ODBCDriver/context.h"
@@ -183,37 +175,16 @@
FdoSchemaManagerP FdoRdbmsOdbcConnection::CreateSchemaManager()
{
FdoStringP userName = GetDbiConnection()->GetUser();
- FdoStringP schemaName = GetDbiConnection()->GetDbSchemaName();
- if (schemaName.GetLength() == 0)
+ FdoStringP schemaName = GetSchemaNameFromDsn();
+
+ if (schemaName.GetLength() > 0)
{
- FdoStringP connectionStringProperty = GetDbiConnection()->GetConnectionString();
- if (connectionStringProperty.GetLength() != 0)
- {
- FdoCommonConnStringParser parser (NULL, connectionStringProperty);
- if (parser.IsConnStringValid())
- {
- FdoStringP drvName = parser.GetPropertyValueW(L"DRIVER");
- if (drvName.Contains(L"Oracle") && drvName.Contains(L"10g"))
- {
- schemaName = parser.GetPropertyValueW(L"XSM");
- if (schemaName == L"Default")
- schemaName = L"";
- }
- }
- }
-
- if (schemaName.GetLength() == 0)
- schemaName = GetSchemaNameFromDsn();
-
- if (schemaName.GetLength() > 0)
- {
- // If the DSN contained a schema name, take that as the only one that
- // we want to see, and which will be specified in all future requests
- // from this provider.
- // If this is not set, all schemas will be visible (occasionally more
- // useful, but also can be slow).
- GetDbiConnection()->SetDbSchemaName(schemaName);
- }
+ // If the DSN contained a schema name, take that as the only one that
+ // we want to see, and which will be specified in all future requests
+ // from this provider.
+ // If this is not set, all schemas will be visible (occasionally more
+ // useful, but also can be slow).
+ GetDbiConnection()->SetDbSchemaName(schemaName);
}
#if 0
@@ -448,48 +419,86 @@
}
#ifdef _WIN32
-#define ODBC_FODBC_INI L"ODBC.INI"
+static HKEY GetRegistryKey(HKEY topkey, const char * subkeyName)
+{
+ HKEY hkey = NULL;
+ TCHAR value[ODBCDR_CONNECTION_SIZE];
+ DWORD size = sizeof(value) / sizeof(value[0]);;
+ LONG errStatus = ERROR_SUCCESS;
+ int status = FALSE;
+
+ if (ERROR_SUCCESS != RegOpenKeyEx (
+ topkey,
+ _T(subkeyName), /* subkey name */
+ 0L, /* reserved */
+ KEY_QUERY_VALUE, /* security access mask */
+ &hkey)) /* handle to open key */
+ {
+ hkey = NULL;
+ }
+ return hkey;
+}
+
+static FdoStringP GetRegistryValue(HKEY hkey, const char * name)
+{
+ TCHAR value[ODBCDR_CONNECTION_SIZE];
+ DWORD size = sizeof(value) / sizeof(value[0]);;
+ LONG errStatus = ERROR_SUCCESS;
+ DWORD type;
+ FdoStringP valueP;
+
+ errStatus = RegQueryValueEx (
+ hkey, /* handle to key */
+ _T(name), /* value name */
+ NULL, /* reserved */
+ &type, /* type buffer */
+ (LPBYTE)value,/* data buffer */
+ &size); /* size of data buffer */
+
+ if (ERROR_SUCCESS == errStatus)
+ {
+ valueP = FdoStringP::Format(L"%hs", (char *) value);
+ }
+ return valueP;
+}
+
+#endif
+
+#define SUBKEYNAME_PREFIX "Software\\ODBC\\ODBC.INI\\"
+#define KEYNAME_DRIVER "Driver"
+#define KEYNAME_USERID_ORACLENATIVE "UserID"
+#define DRIVER_NAME_ORACLENATIVE L"SQORA32"
+
FdoStringP FdoRdbmsOdbcConnection::GetSchemaNameFromDsn()
{
FdoStringP schemaName;
+#ifdef _WIN32
// For Oracle on Windows, get the UserId field.
// This field is normally just a default for the username, so this use does overload
// it. However, Oracle's driver does not offer a separate "schema" field as other
// drivers do.
+
FdoStringP dsn = GetDbiConnection()->GetDataSource();
- wchar_t buffValue[ODBCDR_CONNECTION_SIZE];
- if(0 != ::SQLGetPrivateProfileStringW( L"ODBC Data Sources", dsn, L"", buffValue, ODBCDR_CONNECTION_SIZE, ODBC_FODBC_INI ))
+ HKEY hkey = NULL;
+ char subkeyName[ODBCDR_CONNECTION_SIZE];
+ size_t subkeyNameSize = sizeof(subkeyName) / sizeof(subkeyName[0]);
+ (void) _snprintf(subkeyName, subkeyNameSize-1, "%s%ls", SUBKEYNAME_PREFIX, (const wchar_t *)dsn);
+
+ hkey = GetRegistryKey(HKEY_CURRENT_USER, subkeyName);
+ if (NULL == hkey)
+ hkey = GetRegistryKey(HKEY_LOCAL_MACHINE, subkeyName);
+ if (NULL != hkey)
{
- FdoStringP drvName = buffValue;
- if (drvName.Contains(L"Oracle") && drvName.Contains(L"10g"))
+ FdoStringP driver = GetRegistryValue(hkey, KEYNAME_DRIVER);
+ if (driver.Contains(DRIVER_NAME_ORACLENATIVE))
{
- if(0 != ::SQLGetPrivateProfileStringW( dsn, L"UserID", L"", buffValue, ODBCDR_CONNECTION_SIZE, ODBC_FODBC_INI ))
- schemaName = buffValue;
+ FdoStringP userId = GetRegistryValue(hkey, KEYNAME_USERID_ORACLENATIVE);
+ if (userId.GetLength() > 0)
+ schemaName = userId;
}
}
- return schemaName;
-}
-#else
-#define ODBC_FODBC_INI "ODBC.INI"
-FdoStringP FdoRdbmsOdbcConnection::GetSchemaNameFromDsn()
-{
- FdoStringP schemaName;
-#if 0
- // this code is intended for Linux but is untested.
- // not sure if SQLGetPrivateProfileString is implemented on Linux
- FdoStringP dsn = GetDbiConnection()->GetDataSource();
- char buffValue[ODBCDR_CONNECTION_SIZE];
- if(0 != ::SQLGetPrivateProfileString( "ODBC Data Sources", dsn, "", buffValue, ODBCDR_CONNECTION_SIZE, ODBC_FODBC_INI ))
- {
- FdoStringP drvName = buffValue;
- if (drvName.Contains("Oracle") && drvName.Contains("10g"))
- {
- if(0 != ::SQLGetPrivateProfileString( dsn, "UserID", "", buffValue, ODBCDR_CONNECTION_SIZE, ODBC_FODBC_INI ))
- schemaName = buffValue;
- }
- }
#endif
+
return schemaName;
}
-#endif
More information about the fdo-commits
mailing list