diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-08-25 10:25:48 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-08-25 10:25:48 +0200 |
commit | 27412877dbcf601676f4515a99b2abee1f19623b (patch) | |
tree | 2cb1a2e1a58ba10f2a96fcdec43f5ed77c326fd0 /storage/connect/odbconn.cpp | |
parent | f2033df6ac0f64664d9aad2d56fdd74f4bf9d666 (diff) | |
parent | a544225d0a772bd4b67c96f5861ecc0ef7e69bba (diff) | |
download | mariadb-git-27412877dbcf601676f4515a99b2abee1f19623b.tar.gz |
Merge branch '10.2' into bb-10.2-ext
Diffstat (limited to 'storage/connect/odbconn.cpp')
-rw-r--r-- | storage/connect/odbconn.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index a1283998068..70a0a6a1450 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -55,6 +55,7 @@ extern "C" HINSTANCE s_hModule; // Saved module handle TYPCONV GetTypeConv(); int GetConvSize(); +void OdbcClose(PGLOBAL g, PFBLOCK fp); /***********************************************************************/ /* Some macro's (should be defined elsewhere to be more accessible) */ @@ -302,6 +303,13 @@ static void ResetNullValues(CATPARM *cap) #endif /***********************************************************************/ +/* Close an ODBC table after a thrown error (called by PlugCloseFile) */ +/***********************************************************************/ +void OdbcClose(PGLOBAL g, PFBLOCK fp) { + ((ODBConn*)fp->File)->Close(); +} // end of OdbcClose + +/***********************************************************************/ /* ODBCColumns: constructs the result blocks containing all columns */ /* of an ODBC table that will be retrieved by GetData commands. */ /***********************************************************************/ @@ -968,6 +976,7 @@ ODBConn::ODBConn(PGLOBAL g, TDBODBC *tdbp) m_Catver = (tdbp) ? tdbp->Catver : 0; m_Rows = 0; m_Fetch = 0; + m_Fp = NULL; m_Connect = NULL; m_User = NULL; m_Pwd = NULL; @@ -1137,7 +1146,25 @@ int ODBConn::Open(PCSZ ConnectString, POPARM sop, DWORD options) } else // Connect using SQLConnect Connect(); - /*ver = GetStringInfo(SQL_DRIVER_ODBC_VER);*/ + /*********************************************************************/ + /* Link a Fblock. This make possible to automatically close it */ + /* in case of error (throw). */ + /*********************************************************************/ + PDBUSER dbuserp = (PDBUSER)g->Activityp->Aptr; + + m_Fp = (PFBLOCK)PlugSubAlloc(g, NULL, sizeof(FBLOCK)); + m_Fp->Type = TYPE_FB_ODBC; + m_Fp->Fname = NULL; + m_Fp->Next = dbuserp->Openlist; + dbuserp->Openlist = m_Fp; + m_Fp->Count = 1; + m_Fp->Length = 0; + m_Fp->Memory = NULL; + m_Fp->Mode = MODE_ANY; + m_Fp->File = this; + m_Fp->Handle = 0; + + /*ver = GetStringInfo(SQL_DRIVER_ODBC_VER);*/ // Verify support for required functionality and cache info // VerifyConnect(); Deprecated GetConnectInfo(); @@ -2598,4 +2625,7 @@ void ODBConn::Close() m_henv = SQL_NULL_HENV; } // endif m_henv + if (m_Fp) + m_Fp->Count = 0; + } // end of Close |