OleDB: fixed for private Connection in Sql

git-svn-id: svn://ultimatepp.org/upp/trunk@4353 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-12-28 19:33:38 +00:00
parent 0b7b0f5af4
commit 5f0b18e7ae
5 changed files with 204 additions and 192 deletions

View file

@ -1141,7 +1141,8 @@ Array<OleDBSession::Provider> OleDBSession::EnumProviders()
OleDBSession dummy; OleDBSession dummy;
One<OleDBConnection> conn = new OleDBConnection(&dummy); One<OleDBConnection> conn = new OleDBConnection(&dummy);
conn->Execute(rowset); conn->Execute(rowset);
Sql cursor(-conn); Sql0 cursor;
Attach(cursor, -conn);
int cname = -1, cdesc = -1, cguid = -1; int cname = -1, cdesc = -1, cguid = -1;
for(int i = 0; i < cursor.GetColumns(); i++) { for(int i = 0; i < cursor.GetColumns(); i++) {
String ci = cursor.GetColumnInfo(i).name; String ci = cursor.GetColumnInfo(i).name;
@ -1351,7 +1352,8 @@ Vector<String> OleDBSession::EnumDatabases()
OleVerify(srowset->GetRowset(NULL, DBSCHEMA_CATALOGS, 0, NULL, trowset.GetIID(), 0, NULL, trowset.SetUnk())); OleVerify(srowset->GetRowset(NULL, DBSCHEMA_CATALOGS, 0, NULL, trowset.GetIID(), 0, NULL, trowset.SetUnk()));
One<OleDBConnection> conn = new OleDBConnection(this); One<OleDBConnection> conn = new OleDBConnection(this);
conn->Execute(trowset); conn->Execute(trowset);
Sql cursor(-conn); Sql0 cursor;
Attach(cursor, -conn);
int ccat = -1; int ccat = -1;
for(int i = 0; i < cursor.GetColumns(); i++) { for(int i = 0; i < cursor.GetColumns(); i++) {
String n = cursor.GetColumnInfo(i).name; String n = cursor.GetColumnInfo(i).name;
@ -1376,7 +1378,8 @@ Vector<String> OleDBSession::EnumTables(String database)
OleVerify(srowset->GetRowset(NULL, DBSCHEMA_TABLES, 1, restrictions, trowset.GetIID(), 0, NULL, trowset.SetUnk())); OleVerify(srowset->GetRowset(NULL, DBSCHEMA_TABLES, 1, restrictions, trowset.GetIID(), 0, NULL, trowset.SetUnk()));
One<OleDBConnection> conn = new OleDBConnection(this); One<OleDBConnection> conn = new OleDBConnection(this);
conn->Execute(trowset); conn->Execute(trowset);
Sql cursor(-conn); Sql0 cursor;
Attach(cursor, -conn);
int cname = -1; int cname = -1;
int cschema = -1; int cschema = -1;
int ctype = -1; int ctype = -1;
@ -1418,7 +1421,8 @@ Vector<String> OleDBSession::EnumViews(String database)
OleVerify(srowset->GetRowset(NULL, DBSCHEMA_TABLES, 1, restrictions, trowset.GetIID(), 0, NULL, trowset.SetUnk())); OleVerify(srowset->GetRowset(NULL, DBSCHEMA_TABLES, 1, restrictions, trowset.GetIID(), 0, NULL, trowset.SetUnk()));
One<OleDBConnection> conn = new OleDBConnection(this); One<OleDBConnection> conn = new OleDBConnection(this);
conn->Execute(trowset); conn->Execute(trowset);
Sql cursor(-conn); Sql0 cursor;
Attach(cursor, -conn);
int cname = -1; int cname = -1;
int cschema = -1; int cschema = -1;
int ctype = -1; int ctype = -1;
@ -1476,7 +1480,8 @@ Vector<String> OleDBSession::EnumPrimaryKey(String database, String table)
trowset.GetIID(), 0, NULL, trowset.SetUnk())); trowset.GetIID(), 0, NULL, trowset.SetUnk()));
One<OleDBConnection> conn = new OleDBConnection(this); One<OleDBConnection> conn = new OleDBConnection(this);
conn->Execute(trowset); conn->Execute(trowset);
Sql cursor(-conn); Sql0 cursor;
Attach(cursor, -conn);
int cname = -1; int cname = -1;
int cord = -1; int cord = -1;
Vector<int> ordinal; Vector<int> ordinal;

View file

@ -2,6 +2,11 @@
NAMESPACE_UPP NAMESPACE_UPP
void SqlSession::Attach(Sql& sql, SqlConnection *con)
{
sql.Attach(con); // Duck tape to fix OleDB
}
SqlSession::SqlSession() SqlSession::SqlSession()
{ {
trace = NULL; trace = NULL;

View file

@ -610,7 +610,7 @@ bool Sql::IsOpen() { return cn && GetSession().Is
void SqlConnection::Attach(Sql& sql, SqlConnection *con) void SqlConnection::Attach(Sql& sql, SqlConnection *con)
{ {
sql.Attach(con); sql.Attach(con); // Duck tape to fix Oci8
} }
#ifndef NOAPPSQL #ifndef NOAPPSQL

View file

@ -322,6 +322,8 @@ protected:
void SessionClose(); void SessionClose();
static void Attach(Sql& sql, SqlConnection *con);
public: public:
virtual void Begin(); virtual void Begin();
virtual void Commit(); virtual void Commit();

View file

@ -3,7 +3,7 @@
#include "SqlCtrl/init" #include "SqlCtrl/init"
#include "Oracle/init" #include "Oracle/init"
#include "OleDB/init" #include "OleDB/init"
#include "MySql/init"
#include "plugin\sqlite3/init" #include "plugin\sqlite3/init"
#include "PostgreSQL/init" #include "PostgreSQL/init"
#include "MySql/init"
#endif #endif