22 #include "SqlUtil.h" // config length |
22 #include "SqlUtil.h" // config length |
23 #include "SqlSrvDriveSpace.h" //CSqlDriveSpace, RSqlDriveSpaceCol |
23 #include "SqlSrvDriveSpace.h" //CSqlDriveSpace, RSqlDriveSpaceCol |
24 #include "SqlSrvBlob.h" |
24 #include "SqlSrvBlob.h" |
25 #include "SqlResourceProfiler.h" |
25 #include "SqlResourceProfiler.h" |
26 #include "SqlCompact.h" |
26 #include "SqlCompact.h" |
27 #include "UTraceSql.h" |
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "SqlSrvSessionTraces.h" |
|
30 #endif |
|
31 #include "SqlTraceDef.h" |
|
32 |
28 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
33 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
29 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
34 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
30 |
35 |
31 #pragma BullseyeCoverage off |
36 #pragma BullseyeCoverage off |
32 |
37 |
157 @internalComponent |
162 @internalComponent |
158 */ |
163 */ |
159 template <class T> T& SqlSessObjFind(RDbObjContainer<T>& aContainer, TInt aHandle, const RMessage2& aMessage) |
164 template <class T> T& SqlSessObjFind(RDbObjContainer<T>& aContainer, TInt aHandle, const RMessage2& aMessage) |
160 { |
165 { |
161 T* obj = aContainer.Find(aHandle); |
166 T* obj = aContainer.Find(aHandle); |
162 __SQLPANIC_CLIENT(obj != NULL, aMessage, ESqlPanicBadArgument); |
167 __SQLPANIC_CLIENT2(obj != NULL, aMessage, ESqlPanicBadArgument); |
163 return *obj; |
168 return *obj; |
164 } |
169 } |
165 |
170 |
166 //This function return true, if there is free disk space on drive where the main database file is. |
171 //This function return true, if there is free disk space on drive where the main database file is. |
167 static TBool HasFreeDiskSpace(RFs& aFs, TDriveNumber aDrive) |
172 static TBool HasFreeDiskSpace(RFs& aFs, TDriveNumber aDrive) |
204 @see CSqlServer |
210 @see CSqlServer |
205 @see CSqlServer::NewSessionL() |
211 @see CSqlServer::NewSessionL() |
206 */ |
212 */ |
207 CSqlSrvSession* CSqlSrvSession::NewL() |
213 CSqlSrvSession* CSqlSrvSession::NewL() |
208 { |
214 { |
|
215 SQL_TRACE_SESSION(OstTrace0(TRACE_INTERNALS, CSQLSRVSESSION_NEWL_ENTRY, "Entry;0;CSqlSrvSession::NewL")); |
209 CSqlSrvSession* self = new (ELeave) CSqlSrvSession; |
216 CSqlSrvSession* self = new (ELeave) CSqlSrvSession; |
210 CleanupStack::PushL(self); |
217 CleanupStack::PushL(self); |
211 self->ConstructL(); |
218 self->ConstructL(); |
212 CleanupStack::Pop(self); |
219 CleanupStack::Pop(self); |
|
220 SQL_TRACE_SESSION(OstTrace1(TRACE_INTERNALS, CSQLSRVSESSION_NEWL_EXIT, "Exit;0x%X;CSqlSrvSession::NewL", (TUint)self)); |
213 return self; |
221 return self; |
214 } |
222 } |
215 |
223 |
216 /** |
224 /** |
217 Frees the allocated by CSqlSrvSession instance resources and memory. |
225 Frees the allocated by CSqlSrvSession instance resources and memory. |
218 */ |
226 */ |
219 CSqlSrvSession::~CSqlSrvSession() |
227 CSqlSrvSession::~CSqlSrvSession() |
220 { |
228 { |
|
229 SQL_TRACE_SESSION(OstTraceExt2(TRACE_INTERNALS, CSQLSRVSESSION_CSQLSRVSESSION2_ENTRY, "Entry;0x%X;CSqlSrvSession::~CSqlSrvSession;iDatabase=0x%X", (TUint)this, (TUint)iDatabase)); |
221 StopDbTestMode(); |
230 StopDbTestMode(); |
222 DbFreeReservedSpace(); |
231 DbFreeReservedSpace(); |
223 iIpcStreams.Close(); |
232 iIpcStreams.Close(); |
224 iStatements.Close(); |
233 iStatements.Close(); |
225 delete iDatabase; |
234 delete iDatabase; |
|
235 SQL_TRACE_SESSION(OstTrace1(TRACE_INTERNALS, CSQLSRVSESSION_CSQLSRVSESSION2_EXIT, "Exit;0x%X;CSqlSrvSession::~CSqlSrvSession", (TUint)this)); |
226 } |
236 } |
227 |
237 |
228 /** |
238 /** |
229 Receives and dispatches all client side requests. |
239 Receives and dispatches all client side requests. |
230 |
240 |
245 TInt retCode = KErrNone; |
255 TInt retCode = KErrNone; |
246 if(funcCode >= ESqlSrvDbBase) |
256 if(funcCode >= ESqlSrvDbBase) |
247 { |
257 { |
248 SQLPROFILER_REPORT_IPC(ESqlIpcRq, 0); |
258 SQLPROFILER_REPORT_IPC(ESqlIpcRq, 0); |
249 } |
259 } |
250 SYMBIAN_TRACE_SQL_EVENTS_ONLY(TPtrC8 funcName = GetIPCFuncStr(funcCode)); |
260 __SQLTRACE_SESSIONEXPR(++iIpcCallCounter); |
251 SYMBIAN_TRACE_SQL_EVENTS_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EBorder), KSrvMsgStr, &funcName)); |
261 SQL_TRACE_SESSION(OstTraceExt4(TRACE_INTERNALS, CSQLSRVSESSION_SERVICEL_ENTRY, "Entry;0x%X;CSqlSrvSession::ServiceL;aMessage.Handle()=0x%X;funcCode=0x%X;iIpcCallCounter=%u", (TUint)this, (TUint)aMessage.Handle(), (TUint)funcCode, iIpcCallCounter)); |
252 |
262 SQLPROFILER_IPC_START(iIpcCallCounter, iDatabase ? (TUint)iDatabase->RawDbHandle() : 0); |
253 SQLPROFILER_IPC_START(iIpcCounter, iDatabase ? (TUint)iDatabase->RawDbHandle() : 0); |
|
254 |
|
255 switch(funcCode) |
263 switch(funcCode) |
256 { |
264 { |
257 ////////////////////// resource check operations /////////////////////////// |
265 ////////////////////// resource check operations /////////////////////////// |
258 case ESqlSrvResourceMark: |
266 case ESqlSrvResourceMark: |
259 ResourceCountMarkStart(); |
267 ResourceCountMarkStart(); |
445 Server().MinimizeBuffers(); |
453 Server().MinimizeBuffers(); |
446 if(!aMessage.IsNull()) |
454 if(!aMessage.IsNull()) |
447 { |
455 { |
448 aMessage.Complete(retCode); |
456 aMessage.Complete(retCode); |
449 } |
457 } |
450 SQLPROFILER_IPC_END(iIpcCounter, funcCode, iDatabase ? (TUint)iDatabase->RawDbHandle() : 0, iIpcTraceData, retCode); |
458 SQL_TRACE_SESSION(OstTraceExt4(TRACE_INTERNALS, CSQLSRVSESSION_SERVICEL_EXIT, "Exit;0x%X;CSqlSrvSession::ServiceL;funcCode=0x%X;retCode=%d;iIpcCallCounter=%u", (TUint)this, (TUint)funcCode, retCode, iIpcCallCounter)); |
451 } |
459 } |
452 |
460 |
453 /** |
461 /** |
454 If aError is KErrBadDescriptor, then panic the client, else - default error handling. |
462 If aError is KErrBadDescriptor, then panic the client, else - default error handling. |
455 KErrBadDescriptor error may be thrown from "message write" operations, if the client supplied a bad |
463 KErrBadDescriptor error may be thrown from "message write" operations, if the client supplied a bad |
456 descriptor to the server. |
464 descriptor to the server. |
457 */ |
465 */ |
458 void CSqlSrvSession::ServiceError(const RMessage2& aMessage, TInt aError) |
466 void CSqlSrvSession::ServiceError(const RMessage2& aMessage, TInt aError) |
459 { |
467 { |
|
468 SQL_TRACE_SESSION(OstTraceExt4(TRACE_INTERNALS, CSQLSRVSESSION_SERVICEERROR_ENTRY, "Entry;0x%X;CSqlSrvSession::ServiceError;aMessage.Function()=0x%X;aError=%d;iIpcCallCounter=%u", (TUint)this, (TUint)aMessage.Function(), aError, iIpcCallCounter)); |
460 Server().MinimizeBuffers(); |
469 Server().MinimizeBuffers(); |
461 aError = ::ConvertSqlFull2DiskFullErr(aError, Server().FileData().Fs(), iDrive); |
470 aError = ::ConvertSqlFull2DiskFullErr(aError, Server().FileData().Fs(), iDrive); |
462 if(aError == KErrBadDescriptor) |
471 if(aError == KErrBadDescriptor) |
463 { |
472 { |
464 //The __SQLPANIC_CLIENT() macro cannot be used here because it calls a leaving function. A leaving call |
473 //The __SQLPANIC_CLIENT() macro cannot be used here because it calls a leaving function. A leaving call |
465 //from a leaving call will terminate the server. |
474 //from a leaving call will terminate the server. |
466 _LIT(KPanicCategory, "SqlDb"); |
475 _LIT(KPanicCategory, "SqlDb"); |
467 |
|
468 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), KSqlSrvPanicClient, aError)); |
|
469 aMessage.Panic(KPanicCategory, ESqlPanicBadDescriptor); |
476 aMessage.Panic(KPanicCategory, ESqlPanicBadDescriptor); |
470 } |
477 } |
471 |
478 SQLPROFILER_IPC_ERROR(iIpcCallCounter, static_cast <TSqlSrvFunction> (KSqlSrvFunctionMask & aMessage.Function()), |
472 SYMBIAN_TRACE_SQL_ERR_ONLY(UTF::Printf(UTF::TTraceContext(UTF::EError), KSqlSrvError, aError)); |
|
473 SQLPROFILER_IPC_ERROR(iIpcCounter, static_cast <TSqlSrvFunction> (KSqlSrvFunctionMask & aMessage.Function()), |
|
474 iDatabase ? (TUint)iDatabase->RawDbHandle() : 0, aError); |
479 iDatabase ? (TUint)iDatabase->RawDbHandle() : 0, aError); |
475 CSession2::ServiceError(aMessage, aError); |
480 CSession2::ServiceError(aMessage, aError); |
|
481 SQL_TRACE_SESSION(OstTraceExt3(TRACE_INTERNALS, CSQLSRVSESSION_SERVICEERROR_EXIT, "Exit;0x%X;CSqlSrvSession::ServiceError;aMessage.Function()=0x%X;iIpcCallCounter=%u", (TUint)this, (TUint)aMessage.Function(), iIpcCallCounter)); |
476 } |
482 } |
477 |
483 |
478 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
484 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
479 //////////////////////////// Profiler operations /////////////////////////////////// |
485 //////////////////////////// Profiler operations /////////////////////////////////// |
480 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
486 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
724 if(fileData.SecureUid() != aMessage.SecureId()) |
730 if(fileData.SecureUid() != aMessage.SecureId()) |
725 { |
731 { |
726 __SQLLEAVE(KErrPermissionDenied); |
732 __SQLLEAVE(KErrPermissionDenied); |
727 } |
733 } |
728 } |
734 } |
729 #ifdef _NOTIFY |
735 __SQLTRACE_SESSIONVAR(TPtrC fname(fileData.FileName())); |
730 TPtrC fname = fileData.FileName(); |
736 SQL_TRACE_SESSION(OstTraceExt2(TRACE_INTERNALS, CSQLSRVSESSION_DBDELETEFILEL, "0x%X;CSqlSrvSession::DbDeleteFileL;file='%S'", (TUint)this, __SQLPRNSTR(fname))); |
731 RDebug::Print(_L("--SrvSess, delete, fname=\"%S\"\r\n"), &fname); |
|
732 #endif |
|
733 __SQLLEAVE_IF_ERROR(fileData.Fs().Delete(fileData.FileName())); |
737 __SQLLEAVE_IF_ERROR(fileData.Fs().Delete(fileData.FileName())); |
734 } |
738 } |
735 |
739 |
736 /** |
740 /** |
737 Processes the request for retrieving the last error message. |
741 Processes the request for retrieving the last error message. |
1548 TInt CSqlSrvSession::NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf) |
1552 TInt CSqlSrvSession::NewOutputStreamL(const RMessage2& aMessage, MStreamBuf* aStreamBuf) |
1549 { |
1553 { |
1550 aStreamBuf->PushL(); |
1554 aStreamBuf->PushL(); |
1551 iIpcStreams.AllocL(); |
1555 iIpcStreams.AllocL(); |
1552 TInt size = aStreamBuf->SizeL(); |
1556 TInt size = aStreamBuf->SizeL(); |
1553 __SQLASSERT(size >= 0, ESqlPanicInternalError); |
1557 __ASSERT_DEBUG(size >= 0, __SQLPANIC(ESqlPanicInternalError)); |
1554 TPckgBuf<TIpcStreamBuf> ipcBuf; |
1558 TPckgBuf<TIpcStreamBuf> ipcBuf; |
1555 // read the first buffer-full |
1559 // read the first buffer-full |
1556 TInt len = Min(size, KIpcBufSize); |
1560 TInt len = Min(size, KIpcBufSize); |
1557 aStreamBuf->ReadL(ipcBuf().iData, len); |
1561 aStreamBuf->ReadL(ipcBuf().iData, len); |
1558 TInt handle = 0; |
1562 TInt handle = 0; |