sl@0: // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // NTT DOCOMO, INC - Fix for Bug 1915 "SQL server panics when using long column type strings" sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __SQLSRVSESSION_H__ sl@0: #define __SQLSRVSESSION_H__ sl@0: sl@0: #include //CSession2 sl@0: #include "IPCStream.h" //HIpcStream sl@0: #include "SqlUtil.h" //TSqlSrvFunction sl@0: #include "SqlSrvObjContainer.h" //RDbObjContainer sl@0: #include "SqlSrvDatabase.h" //CSqlSrvDatabase sl@0: #include "SqlSrvResourceProfiler.h" sl@0: sl@0: //Forward declarations sl@0: class CSqlServer; sl@0: class CSqlSrvStatement; sl@0: class MStreamBuf; sl@0: class RMessage2; sl@0: class CSqlSecurityPolicy; sl@0: sl@0: /** sl@0: SQL server side session class. sl@0: sl@0: All client side requests come through a CSqlSrvSession instance which unpacks the client data, sl@0: performs the requested operation invoking the appropriate server side objects and functions and sl@0: packs and returns back to the client the results from the performed operation. sl@0: sl@0: CSqlSrvSession class owns the following set of data: sl@0: - A CSqlSrvDatabase instance - one per session; sl@0: - A RDbObjContainer instance - container for statement handles (CSqlSrvStatement class); sl@0: - A RDbObjContainer instance - container for IPC stream hadles (large data block transfer operations) sl@0: (HIpcStream class); sl@0: sl@0: CSqlSrvSession instances shall never be created via a direct call of CSqlSrvSession::NewL(). sl@0: It is always the server, which creates a new session instance as a responce to the creation of a client side sl@0: session instance (CSqlServer::NewSessionL() function). sl@0: sl@0: @see CSqlSrvDatabase sl@0: @see CSqlSrvStatement sl@0: @see RDbObjContainer sl@0: @see HIpcStream sl@0: @see CSqlServer sl@0: @see CSqlServer::NewSessionL() sl@0: @see CSession2 sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(CSqlSrvSession) : public CSession2 sl@0: { sl@0: public: sl@0: static CSqlSrvSession* NewL(); sl@0: virtual ~CSqlSrvSession(); sl@0: inline CSqlServer& Server(); sl@0: sl@0: private: sl@0: inline CSqlSrvSession(); sl@0: inline void ConstructL(); sl@0: //CSession2::ServiceL() implementation and overriden CSession2::ServiceError(). sl@0: virtual void ServiceL(const RMessage2& aMessage); sl@0: virtual void ServiceError(const RMessage2& aMessage, TInt aError); sl@0: //Profiler operations sl@0: void ProfilerQueryL(const RMessage2& aMessage); sl@0: //Database operations sl@0: void DbCreateObjectL(const RMessage2& aMessage, TSqlSrvFunction aFunction); sl@0: void DbCreateObjectFromHandleL(const RMessage2& aMessage); sl@0: void DbAttachL(const RMessage2& aMessage); sl@0: void DbAttachFromHandleL(const RMessage2& aMessage); sl@0: void DbDetachL(const RMessage2& aMessage); sl@0: inline void DbDestroyObject(); sl@0: void DbCopyFileL(const RMessage2& aMessage); sl@0: void DbDeleteFileL(const RMessage2& aMessage); sl@0: TInt DbLastErrorMessageL(const RMessage2& aMessage); sl@0: void DbLastInsertedRowIdL(const RMessage2& aMessage); sl@0: inline TInt DbExecSql8L(const RMessage2& aMessage); sl@0: inline TInt DbExecSql16L(const RMessage2& aMessage); sl@0: inline void DbSetIsolationLevelL(const RMessage2& aMessage); sl@0: TInt DbGetSecurityPolicyL(const RMessage2& aMessage); sl@0: TInt DbScalarFullSelectL(const RMessage2& aMessage, TBool aIsText16); sl@0: TInt DbBlobSourceL(const RMessage2& aMessage); sl@0: TBool DbInTransaction(const RMessage2& aMessage); sl@0: TInt DbSizeL(const RMessage2& aMessage); sl@0: void DbSize2L(const RMessage2& aMessage); sl@0: TInt DbCompactL(const RMessage2& aMessage); sl@0: void DbReserveDriveSpaceL(); sl@0: void DbFreeReservedSpace(); sl@0: void DbGetReserveAccessL(); sl@0: void DbReleaseReserveAccess(); sl@0: //Statement operations sl@0: TInt StmtPrepareL(const RMessage2& aMessage, TBool aIsText16); sl@0: TInt StmtExecL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction); sl@0: TInt StmtNextL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction); sl@0: TInt StmtNamesL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction); sl@0: TInt StmtColumnSourceL(const RMessage2& aMessage, TInt aStmtHandle); sl@0: TInt StmtParamSinkL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction); sl@0: void StmtGetBufFlatL(const RMessage2& aMessage, TInt aStmtHandle); sl@0: void StmtColumnValueL(const RMessage2& aMessage, TInt aStmtHandle); sl@0: void DoStmtBindL(const RMessage2& aMessage, CSqlSrvStatement& aStmt); sl@0: TInt StmtDeclColumnTypesL(const RMessage2& aMessage, TInt aStmtHandle); sl@0: //Helper methods sl@0: TInt NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf); sl@0: TDes8& ReadString8ZL(const RMessage2& aMessage, TInt aArgNum, TInt aByteLen); sl@0: TDes16& ReadString16ZL(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen); sl@0: TDes16& ReadString16L(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen); sl@0: CSqlSecurityPolicy* CreateSecurityPolicyL(const TDesC8& aSecurotyPolicyData); sl@0: virtual TInt CountResources(); sl@0: void Extract(const RMessage2& aMessage, TSqlSrvFunction& aFunction, TInt& aHandle); sl@0: TInt GetColumnValueL(const RMessage2& aMessage, CSqlSrvStatement& aStmt, TSqlColumnType aColType); sl@0: void ExtractNameL(RDesReadStream& aStrm, TDes8& aNameOut, const TDesC& aEmptyNameSubstitute = KNullDesC); sl@0: //Resource allocation testing related sl@0: inline TBool ActivateDbTestMode(TInt aHeapFailureMode, TInt aFailedAllocNumber); sl@0: inline void StopDbTestMode(); sl@0: inline void DbResourceMark(); sl@0: inline void DbResourceEnd(const RMessage2& aMessage); sl@0: inline void DbSetAllocFail(TInt aHeapFailureMode, TInt aFailedAllocNumber); sl@0: inline void DbSetDelayedAllocFail(); sl@0: private: sl@0: CSqlSrvDatabase* iDatabase; //The database object (one per session) sl@0: RDbObjContainer iStatements; //Container for SQL statement handles sl@0: RDbObjContainer iIpcStreams; //Container for IPC stream hansdles sl@0: TInt iDbResourceTestMode; //Non-zero if this session is in test mode (memory leaks simulation/detection) sl@0: TInt iFailedAllocNumber; //The failing allocation number - If iDbResourceTestMode is OR-ed with 0x1000 sl@0: TBool iDriveSpaceReserved; //True if this session reserved drive space sl@0: TBool iDriveSpaceInUse; //True if the client has been given an access to the reserved drive space sl@0: TDriveNumber iDrive; //the drive number, where the database file is sl@0: TUint iIpcCallCounter; sl@0: #ifdef _SQLPROFILER sl@0: TSqlSrvIpcTraceData iIpcTraceData[KIpcTraceTypeCount]; sl@0: #endif sl@0: }; sl@0: sl@0: #include "SqlSrvSession.inl" sl@0: sl@0: #endif//__SQLSRVSESSION_H__