os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvSession.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvSession.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,146 @@
     1.4 +// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +// NTT DOCOMO, INC - Fix for Bug 1915 "SQL server panics when using long column type strings"
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +#ifndef __SQLSRVSESSION_H__
    1.21 +#define __SQLSRVSESSION_H__
    1.22 +
    1.23 +#include <e32base.h>				//CSession2
    1.24 +#include "IPCStream.h"				//HIpcStream
    1.25 +#include "SqlUtil.h"				//TSqlSrvFunction
    1.26 +#include "SqlSrvObjContainer.h"		//RDbObjContainer
    1.27 +#include "SqlSrvDatabase.h"			//CSqlSrvDatabase
    1.28 +#include "SqlSrvResourceProfiler.h"
    1.29 +
    1.30 +//Forward declarations
    1.31 +class CSqlServer;
    1.32 +class CSqlSrvStatement;
    1.33 +class MStreamBuf;
    1.34 +class RMessage2;
    1.35 +class CSqlSecurityPolicy;
    1.36 +
    1.37 +/**
    1.38 +SQL server side session class.
    1.39 +
    1.40 +All client side requests come through a CSqlSrvSession instance which unpacks the client data,
    1.41 +performs the requested operation invoking the appropriate server side objects and functions and
    1.42 +packs and returns back to the client the results from the performed operation.
    1.43 +
    1.44 +CSqlSrvSession class owns the following set of data:
    1.45 +- A CSqlSrvDatabase instance - one per session;
    1.46 +- A RDbObjContainer instance - container for statement handles (CSqlSrvStatement class);
    1.47 +- A RDbObjContainer instance - container for IPC stream hadles (large data block transfer operations)
    1.48 +                               (HIpcStream class);
    1.49 +                  
    1.50 +CSqlSrvSession instances shall never be created via a direct call of CSqlSrvSession::NewL().
    1.51 +It is always the server, which creates a new session instance as a responce to the creation of a client side
    1.52 +session instance (CSqlServer::NewSessionL() function).
    1.53 +
    1.54 +@see CSqlSrvDatabase
    1.55 +@see CSqlSrvStatement
    1.56 +@see RDbObjContainer
    1.57 +@see HIpcStream
    1.58 +@see CSqlServer
    1.59 +@see CSqlServer::NewSessionL()
    1.60 +@see CSession2
    1.61 +
    1.62 +@internalComponent
    1.63 +*/
    1.64 +NONSHARABLE_CLASS(CSqlSrvSession) : public CSession2
    1.65 +	{
    1.66 +public:
    1.67 +	static CSqlSrvSession* NewL();
    1.68 +	virtual ~CSqlSrvSession();
    1.69 +	inline CSqlServer& Server();
    1.70 +	
    1.71 +private:	
    1.72 +	inline CSqlSrvSession();
    1.73 +	inline void ConstructL();
    1.74 +	//CSession2::ServiceL() implementation and overriden CSession2::ServiceError().
    1.75 +	virtual void ServiceL(const RMessage2& aMessage);
    1.76 +	virtual void ServiceError(const RMessage2& aMessage, TInt aError);
    1.77 +	//Profiler operations
    1.78 +	void ProfilerQueryL(const RMessage2& aMessage);
    1.79 +	//Database operations
    1.80 +	void DbCreateObjectL(const RMessage2& aMessage, TSqlSrvFunction aFunction);
    1.81 +	void DbCreateObjectFromHandleL(const RMessage2& aMessage);
    1.82 +	void DbAttachL(const RMessage2& aMessage);
    1.83 +	void DbAttachFromHandleL(const RMessage2& aMessage);
    1.84 +	void DbDetachL(const RMessage2& aMessage);
    1.85 +	inline void DbDestroyObject();
    1.86 +	void DbCopyFileL(const RMessage2& aMessage);
    1.87 +	void DbDeleteFileL(const RMessage2& aMessage);
    1.88 +	TInt DbLastErrorMessageL(const RMessage2& aMessage);
    1.89 +	void DbLastInsertedRowIdL(const RMessage2& aMessage);
    1.90 +	inline TInt DbExecSql8L(const RMessage2& aMessage);
    1.91 +	inline TInt DbExecSql16L(const RMessage2& aMessage);
    1.92 +	inline void DbSetIsolationLevelL(const RMessage2& aMessage);
    1.93 +	TInt DbGetSecurityPolicyL(const RMessage2& aMessage);
    1.94 +	TInt DbScalarFullSelectL(const RMessage2& aMessage, TBool aIsText16);
    1.95 +	TInt DbBlobSourceL(const RMessage2& aMessage);
    1.96 +	TBool DbInTransaction(const RMessage2& aMessage);
    1.97 +	TInt DbSizeL(const RMessage2& aMessage);
    1.98 +	void DbSize2L(const RMessage2& aMessage);
    1.99 +	TInt DbCompactL(const RMessage2& aMessage);
   1.100 +	void DbReserveDriveSpaceL();
   1.101 +	void DbFreeReservedSpace();
   1.102 +	void DbGetReserveAccessL();
   1.103 +	void DbReleaseReserveAccess();
   1.104 +	//Statement operations
   1.105 +	TInt StmtPrepareL(const RMessage2& aMessage, TBool aIsText16);
   1.106 +	TInt StmtExecL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
   1.107 +	TInt StmtNextL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
   1.108 +	TInt StmtNamesL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
   1.109 +	TInt StmtColumnSourceL(const RMessage2& aMessage, TInt aStmtHandle);
   1.110 +	TInt StmtParamSinkL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
   1.111 +	void StmtGetBufFlatL(const RMessage2& aMessage, TInt aStmtHandle);
   1.112 +	void StmtColumnValueL(const RMessage2& aMessage, TInt aStmtHandle);
   1.113 +	void DoStmtBindL(const RMessage2& aMessage, CSqlSrvStatement& aStmt);
   1.114 +	TInt StmtDeclColumnTypesL(const RMessage2& aMessage, TInt aStmtHandle);
   1.115 +	//Helper methods
   1.116 +	TInt NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf);
   1.117 +	TDes8& ReadString8ZL(const RMessage2& aMessage, TInt aArgNum, TInt aByteLen);
   1.118 +	TDes16& ReadString16ZL(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen);
   1.119 +	TDes16& ReadString16L(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen);
   1.120 +	CSqlSecurityPolicy* CreateSecurityPolicyL(const TDesC8& aSecurotyPolicyData);
   1.121 +	virtual TInt CountResources();
   1.122 +	void Extract(const RMessage2& aMessage, TSqlSrvFunction& aFunction, TInt& aHandle);
   1.123 +	TInt GetColumnValueL(const RMessage2& aMessage, CSqlSrvStatement& aStmt, TSqlColumnType aColType);
   1.124 +	void ExtractNameL(RDesReadStream& aStrm, TDes8& aNameOut, const TDesC& aEmptyNameSubstitute = KNullDesC);
   1.125 +	//Resource allocation testing related
   1.126 +	inline TBool ActivateDbTestMode(TInt aHeapFailureMode, TInt aFailedAllocNumber);
   1.127 +	inline void StopDbTestMode();
   1.128 +	inline void DbResourceMark();
   1.129 +	inline void DbResourceEnd(const RMessage2& aMessage);
   1.130 +	inline void DbSetAllocFail(TInt aHeapFailureMode, TInt aFailedAllocNumber);
   1.131 +	inline void DbSetDelayedAllocFail();
   1.132 +private:
   1.133 +	CSqlSrvDatabase*					iDatabase;				//The database object (one per session)
   1.134 +	RDbObjContainer<CSqlSrvStatement>	iStatements;			//Container for SQL statement handles
   1.135 +	RDbObjContainer<HIpcStream>			iIpcStreams;			//Container for IPC stream hansdles
   1.136 +	TInt								iDbResourceTestMode;	//Non-zero if this session is in test mode (memory leaks simulation/detection)
   1.137 +	TInt								iFailedAllocNumber;		//The failing allocation number - If iDbResourceTestMode is OR-ed with 0x1000
   1.138 +	TBool								iDriveSpaceReserved;	//True if this session reserved drive space
   1.139 +	TBool								iDriveSpaceInUse;		//True if the client has been given an access to the reserved drive space
   1.140 +	TDriveNumber 						iDrive;					//the drive number, where the database file is
   1.141 +	TUint                               iIpcCallCounter;
   1.142 +#ifdef _SQLPROFILER
   1.143 +    TSqlSrvIpcTraceData                 iIpcTraceData[KIpcTraceTypeCount];
   1.144 +#endif
   1.145 +	};
   1.146 +
   1.147 +#include "SqlSrvSession.inl"
   1.148 +
   1.149 +#endif//__SQLSRVSESSION_H__