os/persistentdata/persistentstorage/sql/SRC/Server/SqlSrvSession.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
// NTT DOCOMO, INC - Fix for Bug 1915 "SQL server panics when using long column type strings"
sl@0
    13
//
sl@0
    14
// Description:
sl@0
    15
//
sl@0
    16
sl@0
    17
#ifndef __SQLSRVSESSION_H__
sl@0
    18
#define __SQLSRVSESSION_H__
sl@0
    19
sl@0
    20
#include <e32base.h>				//CSession2
sl@0
    21
#include "IPCStream.h"				//HIpcStream
sl@0
    22
#include "SqlUtil.h"				//TSqlSrvFunction
sl@0
    23
#include "SqlSrvObjContainer.h"		//RDbObjContainer
sl@0
    24
#include "SqlSrvDatabase.h"			//CSqlSrvDatabase
sl@0
    25
#include "SqlSrvResourceProfiler.h"
sl@0
    26
sl@0
    27
//Forward declarations
sl@0
    28
class CSqlServer;
sl@0
    29
class CSqlSrvStatement;
sl@0
    30
class MStreamBuf;
sl@0
    31
class RMessage2;
sl@0
    32
class CSqlSecurityPolicy;
sl@0
    33
sl@0
    34
/**
sl@0
    35
SQL server side session class.
sl@0
    36
sl@0
    37
All client side requests come through a CSqlSrvSession instance which unpacks the client data,
sl@0
    38
performs the requested operation invoking the appropriate server side objects and functions and
sl@0
    39
packs and returns back to the client the results from the performed operation.
sl@0
    40
sl@0
    41
CSqlSrvSession class owns the following set of data:
sl@0
    42
- A CSqlSrvDatabase instance - one per session;
sl@0
    43
- A RDbObjContainer instance - container for statement handles (CSqlSrvStatement class);
sl@0
    44
- A RDbObjContainer instance - container for IPC stream hadles (large data block transfer operations)
sl@0
    45
                               (HIpcStream class);
sl@0
    46
                  
sl@0
    47
CSqlSrvSession instances shall never be created via a direct call of CSqlSrvSession::NewL().
sl@0
    48
It is always the server, which creates a new session instance as a responce to the creation of a client side
sl@0
    49
session instance (CSqlServer::NewSessionL() function).
sl@0
    50
sl@0
    51
@see CSqlSrvDatabase
sl@0
    52
@see CSqlSrvStatement
sl@0
    53
@see RDbObjContainer
sl@0
    54
@see HIpcStream
sl@0
    55
@see CSqlServer
sl@0
    56
@see CSqlServer::NewSessionL()
sl@0
    57
@see CSession2
sl@0
    58
sl@0
    59
@internalComponent
sl@0
    60
*/
sl@0
    61
NONSHARABLE_CLASS(CSqlSrvSession) : public CSession2
sl@0
    62
	{
sl@0
    63
public:
sl@0
    64
	static CSqlSrvSession* NewL();
sl@0
    65
	virtual ~CSqlSrvSession();
sl@0
    66
	inline CSqlServer& Server();
sl@0
    67
	
sl@0
    68
private:	
sl@0
    69
	inline CSqlSrvSession();
sl@0
    70
	inline void ConstructL();
sl@0
    71
	//CSession2::ServiceL() implementation and overriden CSession2::ServiceError().
sl@0
    72
	virtual void ServiceL(const RMessage2& aMessage);
sl@0
    73
	virtual void ServiceError(const RMessage2& aMessage, TInt aError);
sl@0
    74
	//Profiler operations
sl@0
    75
	void ProfilerQueryL(const RMessage2& aMessage);
sl@0
    76
	//Database operations
sl@0
    77
	void DbCreateObjectL(const RMessage2& aMessage, TSqlSrvFunction aFunction);
sl@0
    78
	void DbCreateObjectFromHandleL(const RMessage2& aMessage);
sl@0
    79
	void DbAttachL(const RMessage2& aMessage);
sl@0
    80
	void DbAttachFromHandleL(const RMessage2& aMessage);
sl@0
    81
	void DbDetachL(const RMessage2& aMessage);
sl@0
    82
	inline void DbDestroyObject();
sl@0
    83
	void DbCopyFileL(const RMessage2& aMessage);
sl@0
    84
	void DbDeleteFileL(const RMessage2& aMessage);
sl@0
    85
	TInt DbLastErrorMessageL(const RMessage2& aMessage);
sl@0
    86
	void DbLastInsertedRowIdL(const RMessage2& aMessage);
sl@0
    87
	inline TInt DbExecSql8L(const RMessage2& aMessage);
sl@0
    88
	inline TInt DbExecSql16L(const RMessage2& aMessage);
sl@0
    89
	inline void DbSetIsolationLevelL(const RMessage2& aMessage);
sl@0
    90
	TInt DbGetSecurityPolicyL(const RMessage2& aMessage);
sl@0
    91
	TInt DbScalarFullSelectL(const RMessage2& aMessage, TBool aIsText16);
sl@0
    92
	TInt DbBlobSourceL(const RMessage2& aMessage);
sl@0
    93
	TBool DbInTransaction(const RMessage2& aMessage);
sl@0
    94
	TInt DbSizeL(const RMessage2& aMessage);
sl@0
    95
	void DbSize2L(const RMessage2& aMessage);
sl@0
    96
	TInt DbCompactL(const RMessage2& aMessage);
sl@0
    97
	void DbReserveDriveSpaceL();
sl@0
    98
	void DbFreeReservedSpace();
sl@0
    99
	void DbGetReserveAccessL();
sl@0
   100
	void DbReleaseReserveAccess();
sl@0
   101
	//Statement operations
sl@0
   102
	TInt StmtPrepareL(const RMessage2& aMessage, TBool aIsText16);
sl@0
   103
	TInt StmtExecL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
sl@0
   104
	TInt StmtNextL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
sl@0
   105
	TInt StmtNamesL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
sl@0
   106
	TInt StmtColumnSourceL(const RMessage2& aMessage, TInt aStmtHandle);
sl@0
   107
	TInt StmtParamSinkL(const RMessage2& aMessage, TInt aStmtHandle, TSqlSrvFunction aFunction);
sl@0
   108
	void StmtGetBufFlatL(const RMessage2& aMessage, TInt aStmtHandle);
sl@0
   109
	void StmtColumnValueL(const RMessage2& aMessage, TInt aStmtHandle);
sl@0
   110
	void DoStmtBindL(const RMessage2& aMessage, CSqlSrvStatement& aStmt);
sl@0
   111
	TInt StmtDeclColumnTypesL(const RMessage2& aMessage, TInt aStmtHandle);
sl@0
   112
	//Helper methods
sl@0
   113
	TInt NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf);
sl@0
   114
	TDes8& ReadString8ZL(const RMessage2& aMessage, TInt aArgNum, TInt aByteLen);
sl@0
   115
	TDes16& ReadString16ZL(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen);
sl@0
   116
	TDes16& ReadString16L(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen);
sl@0
   117
	CSqlSecurityPolicy* CreateSecurityPolicyL(const TDesC8& aSecurotyPolicyData);
sl@0
   118
	virtual TInt CountResources();
sl@0
   119
	void Extract(const RMessage2& aMessage, TSqlSrvFunction& aFunction, TInt& aHandle);
sl@0
   120
	TInt GetColumnValueL(const RMessage2& aMessage, CSqlSrvStatement& aStmt, TSqlColumnType aColType);
sl@0
   121
	void ExtractNameL(RDesReadStream& aStrm, TDes8& aNameOut, const TDesC& aEmptyNameSubstitute = KNullDesC);
sl@0
   122
	//Resource allocation testing related
sl@0
   123
	inline TBool ActivateDbTestMode(TInt aHeapFailureMode, TInt aFailedAllocNumber);
sl@0
   124
	inline void StopDbTestMode();
sl@0
   125
	inline void DbResourceMark();
sl@0
   126
	inline void DbResourceEnd(const RMessage2& aMessage);
sl@0
   127
	inline void DbSetAllocFail(TInt aHeapFailureMode, TInt aFailedAllocNumber);
sl@0
   128
	inline void DbSetDelayedAllocFail();
sl@0
   129
private:
sl@0
   130
	CSqlSrvDatabase*					iDatabase;				//The database object (one per session)
sl@0
   131
	RDbObjContainer<CSqlSrvStatement>	iStatements;			//Container for SQL statement handles
sl@0
   132
	RDbObjContainer<HIpcStream>			iIpcStreams;			//Container for IPC stream hansdles
sl@0
   133
	TInt								iDbResourceTestMode;	//Non-zero if this session is in test mode (memory leaks simulation/detection)
sl@0
   134
	TInt								iFailedAllocNumber;		//The failing allocation number - If iDbResourceTestMode is OR-ed with 0x1000
sl@0
   135
	TBool								iDriveSpaceReserved;	//True if this session reserved drive space
sl@0
   136
	TBool								iDriveSpaceInUse;		//True if the client has been given an access to the reserved drive space
sl@0
   137
	TDriveNumber 						iDrive;					//the drive number, where the database file is
sl@0
   138
	TUint                               iIpcCallCounter;
sl@0
   139
#ifdef _SQLPROFILER
sl@0
   140
    TSqlSrvIpcTraceData                 iIpcTraceData[KIpcTraceTypeCount];
sl@0
   141
#endif
sl@0
   142
	};
sl@0
   143
sl@0
   144
#include "SqlSrvSession.inl"
sl@0
   145
sl@0
   146
#endif//__SQLSRVSESSION_H__