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