persistentstorage/sql/SRC/Server/SqlSrvSession.cpp
changeset 22 a7ba600cb39d
parent 17 55f2396f6d25
child 31 ba1c4f4a893f
equal deleted inserted replaced
19:d6ef85bc5971 22:a7ba600cb39d
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 // NTT DOCOMO, INC - Fix for defect 1915 "SQL server panics when using long column type strings"
    12 // NTT DOCOMO, INC - Fix for Bug 1915 "SQL server panics when using long column type strings"
    13 //
    13 //
    14 // Description:
    14 // Description:
    15 //
    15 //
    16 
    16 
    17 #include "SqlSrvMain.h"			//CSqlServer
    17 #include "SqlSrvMain.h"			//CSqlServer
   477 
   477 
   478 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   478 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   479 ////////////////////////////          Profiler  operations           ///////////////////////////////////
   479 ////////////////////////////          Profiler  operations           ///////////////////////////////////
   480 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   480 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   481 
   481 
       
   482 #pragma BullseyeCoverage off
       
   483 
   482 /**
   484 /**
   483 Retrieves the counter values for the specified profiling counter.
   485 Retrieves the counter values for the specified profiling counter.
   484 
   486 
   485 @leave  KErrNone, the operation completed successfully,
   487 @leave  KErrNone, the operation completed successfully,
   486         KErrOverflow, the receiving buffer size is too small;
   488         KErrOverflow, the receiving buffer size is too small;
   512 	else
   514 	else
   513 		{
   515 		{
   514 		TSqlSrvResourceProfiler::QueryL(aMessage);
   516 		TSqlSrvResourceProfiler::QueryL(aMessage);
   515 		}				
   517 		}				
   516 	}
   518 	}
       
   519 
       
   520 #pragma BullseyeCoverage on
   517 
   521 
   518 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   522 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   519 ////////////////////////////          Database operations           ///////////////////////////////////
   523 ////////////////////////////          Database operations           ///////////////////////////////////
   520 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   524 ///////////////////////////////////////////////////////////////////////////////////////////////////////
   521 
   525 
  1080 Arg 1: [in]  db names buffer
  1084 Arg 1: [in]  db names buffer
  1081 Arg 2: [in]  file session handle
  1085 Arg 2: [in]  file session handle
  1082 Arg 3: [in]  database file handle
  1086 Arg 3: [in]  database file handle
  1083 
  1087 
  1084 @panic SqlDb 2 Client panic. iDatabase is NULL (the database object is not created yet).
  1088 @panic SqlDb 2 Client panic. iDatabase is NULL (the database object is not created yet).
       
  1089 @panic SqlDb 4 Client panic. Invalid IPC data, an indication of a problme in client side sql library.
  1085 */
  1090 */
  1086 void CSqlSrvSession::DbAttachFromHandleL(const RMessage2& aMessage)
  1091 void CSqlSrvSession::DbAttachFromHandleL(const RMessage2& aMessage)
  1087 	{
  1092 	{
  1088 	__SQLPANIC_CLIENT(iDatabase != NULL, aMessage, ESqlPanicInvalidObj);
  1093 	__SQLPANIC_CLIENT(iDatabase != NULL, aMessage, ESqlPanicInvalidObj);
  1089 	//Read-only flag, buffer length, buffer allocation
  1094 	//Read-only flag, buffer length, buffer allocation
  1090 	TBool readOnly = (aMessage.Int0() & 0x80000000) != 0;
  1095 	TBool readOnly = (aMessage.Int0() & 0x80000000) != 0;
  1091 	const TInt KBufLen = aMessage.Int0() & 0x7FFFFFFF;
  1096 	const TInt KBufLen = aMessage.Int0() & 0x7FFFFFFF;
  1092 	if(KBufLen <= 0)
  1097     __SQLPANIC_CLIENT(KBufLen > 0, aMessage, ESqlPanicBadArgument);
  1093 		{
       
  1094 		__SQLLEAVE(KErrArgument);
       
  1095 		}
       
  1096 	HBufC8* buf = HBufC8::NewLC(KBufLen);
  1098 	HBufC8* buf = HBufC8::NewLC(KBufLen);
  1097 	TPtr8 bufPtr = buf->Des();
  1099 	TPtr8 bufPtr = buf->Des();
  1098 	aMessage.ReadL(1, bufPtr);
  1100 	aMessage.ReadL(1, bufPtr);
  1099 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, KBufLen);
  1101 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, KBufLen);
  1100 	if(KBufLen != bufPtr.Length())
  1102 	if(KBufLen != bufPtr.Length())
  1196 @param aMessage The client request wrapped in an IPC message
  1198 @param aMessage The client request wrapped in an IPC message
  1197 
  1199 
  1198 @return The blob stream handle
  1200 @return The blob stream handle
  1199 
  1201 
  1200 @leave KErrNoMemory, 		 An out of memory condition has occurred;
  1202 @leave KErrNoMemory, 		 An out of memory condition has occurred;
  1201 	   KErrArgument, 		 The IPC data buffer length is invalid, or the ROWID is invalid,
  1203 	   KErrArgument, 		 The ROWID is invalid or UTF-16 to UTF-8 string conversion failed;	
  1202 	   				 		 or UTF-16 to UTF-8 string conversion failed;	
       
  1203 	   KErrBadDescriptor 	 The transferred data is bigger than the specified length;
  1204 	   KErrBadDescriptor 	 The transferred data is bigger than the specified length;
  1204 	   KErrBadName,	 		 The table name, column name or database name has an invalid length;
  1205 	   KErrBadName,	 		 The table name, column name or database name has an invalid length;
  1205        KErrPermissionDenied, The client does not have the required security capabilites for this operation; 						 
  1206        KErrPermissionDenied, The client does not have the required security capabilites for this operation; 						 
  1206        						 Note that the function may also leave with some other system wide errors or 
  1207        						 Note that the function may also leave with some other system wide errors or 
  1207                      		 database specific errors categorised as ESqlDbError.
  1208                      		 database specific errors categorised as ESqlDbError.
  1208 
  1209 
  1209 @panic SqlDb 2 Client panic. The database object is not yet created (iDatabase is NULL)
  1210 @panic SqlDb 2 Client panic. The database object is not yet created (iDatabase is NULL).
  1210 @panic SqlDb 3 Client panic. Failed to create a blob stream handle
  1211 @panic SqlDb 3 Client panic. Failed to create a blob stream handle.
       
  1212 @panic SqlDb 4 Client panic. IPC buffer length is 0.
  1211 
  1213 
  1212 Usage of the IPC call arguments:
  1214 Usage of the IPC call arguments:
  1213 Arg 0: [in]	    The length of the IPC data buffer
  1215 Arg 0: [in]	    The length of the IPC data buffer
  1214 Arg 1: [in]	    IPC data buffer containing blob parameters: table name, column name, rowid, mode, database name.
  1216 Arg 1: [in]	    IPC data buffer containing blob parameters: table name, column name, rowid, mode, database name.
  1215 Arg 2: [out]	IPC buffer containing the blob stream handle
  1217 Arg 2: [out]	IPC buffer containing the blob stream handle
  1216 */
  1218 */
  1217 TInt CSqlSrvSession::DbBlobSourceL(const RMessage2& aMessage)
  1219 TInt CSqlSrvSession::DbBlobSourceL(const RMessage2& aMessage)
  1218 	{	
  1220 	{	
  1219 	__SQLPANIC_CLIENT(iDatabase != NULL, aMessage, ESqlPanicInvalidObj);
  1221 	__SQLPANIC_CLIENT(iDatabase != NULL, aMessage, ESqlPanicInvalidObj);
  1220 	
  1222 	
       
  1223 	TInt ipcPrmLen = aMessage.Int0();
       
  1224 	__SQLPANIC_CLIENT(ipcPrmLen > 0, aMessage, ESqlPanicBadArgument);
       
  1225 	
  1221 	iIpcStreams.AllocL();
  1226 	iIpcStreams.AllocL();
  1222 	
  1227 	
  1223 	TInt ipcPrmLen = aMessage.Int0();
       
  1224 	if(ipcPrmLen < 1)
       
  1225 		{
       
  1226 		__SQLLEAVE(KErrArgument);
       
  1227 		}
       
  1228 	TDes8& ipcPrmDes = ReadString8ZL(aMessage, 1, ipcPrmLen);
  1228 	TDes8& ipcPrmDes = ReadString8ZL(aMessage, 1, ipcPrmLen);
  1229 	RDesReadStream strm(ipcPrmDes);
  1229 	RDesReadStream strm(ipcPrmDes);
  1230 	
  1230 	
  1231 	TBuf8<KMaxFileName + 1> tblName;
  1231 	TBuf8<KMaxFileName + 1> tblName;
  1232 	ExtractNameL(strm, tblName);
  1232 	ExtractNameL(strm, tblName);
  1576 /**
  1576 /**
  1577 Reads a 8-bit string with "aByteLen" bytes length, which is in "aArgNum" argument of aMessage.
  1577 Reads a 8-bit string with "aByteLen" bytes length, which is in "aArgNum" argument of aMessage.
  1578 The string will be zero terminated after the "read" operation.
  1578 The string will be zero terminated after the "read" operation.
  1579 Returns TDes8 reference pointing to the zero-terminated string.
  1579 Returns TDes8 reference pointing to the zero-terminated string.
  1580 
  1580 
  1581 @leave KErrBadDescriptor The transferred data length is bigger than the aByteLen value 
  1581 @panic SqlDb 3 Client panic. The string length is not equal to aByteLen. If happens then it is an indication of a 
  1582 
  1582                              problem inside client side sql library.
  1583 @panic SqlDb 4 Client panic. Negative aByteLen value.
  1583 @panic SqlDb 4 Client panic. Negative aByteLen value.
  1584 */
  1584 */
  1585 TDes8& CSqlSrvSession::ReadString8ZL(const RMessage2& aMessage, TInt aArgNum, TInt aByteLen)
  1585 TDes8& CSqlSrvSession::ReadString8ZL(const RMessage2& aMessage, TInt aArgNum, TInt aByteLen)
  1586 	{
  1586 	{
  1587 	__SQLPANIC_CLIENT(aByteLen >= 0, aMessage, ESqlPanicBadArgument);
  1587 	__SQLPANIC_CLIENT(aByteLen >= 0, aMessage, ESqlPanicBadArgument);
  1588 	TDes8& buf = Server().GetBuf8L(aByteLen + 1);
  1588 	TDes8& buf = Server().GetBuf8L(aByteLen + 1);
  1589 	aMessage.ReadL(aArgNum, buf);
  1589 	aMessage.ReadL(aArgNum, buf);
  1590 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, aByteLen);
  1590 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, aByteLen);
  1591 	if(buf.Length() > aByteLen)
  1591     __SQLPANIC_CLIENT(buf.Length() == aByteLen, aMessage, ESqlPanicBadHandle);
  1592 		{
       
  1593 		__SQLLEAVE(KErrBadDescriptor);
       
  1594 		}
       
  1595 	buf.Append(TChar(0));
  1592 	buf.Append(TChar(0));
  1596 	return buf;
  1593 	return buf;
  1597 	}
  1594 	}
  1598 
  1595 
  1599 /**
  1596 /**
  1600 Reads a 16-bit string with "aCharLen" character length, which is in "aArgNum" argument of aMessage.
  1597 Reads a 16-bit string with "aCharLen" character length, which is in "aArgNum" argument of aMessage.
  1601 The string will be zero terminated after the "read" operation.
  1598 The string will be zero terminated after the "read" operation.
  1602 Returns TDes16 reference pointing to the zero-terminated string.
  1599 Returns TDes16 reference pointing to the zero-terminated string.
  1603 
  1600 
  1604 @leave KErrBadDescriptor The transferred data length is bigger than the aCharLen value
  1601 @panic SqlDb 3 Client panic. The string length is not equal to aCharLen. If happens then it is an indication of a 
  1605 
  1602                              problem inside client side sql library.
  1606 @panic SqlDb 4 Client panic. Negative aCharLen value.
  1603 @panic SqlDb 4 Client panic. Negative aCharLen value.
  1607 */
  1604 */
  1608 TDes16& CSqlSrvSession::ReadString16ZL(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen)
  1605 TDes16& CSqlSrvSession::ReadString16ZL(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen)
  1609 	{
  1606 	{
  1610 	__SQLPANIC_CLIENT(aCharLen >= 0, aMessage, ESqlPanicBadArgument);
  1607 	__SQLPANIC_CLIENT(aCharLen >= 0, aMessage, ESqlPanicBadArgument);
  1611 	TDes16& buf = Server().GetBuf16L(aCharLen + 1);
  1608 	TDes16& buf = Server().GetBuf16L(aCharLen + 1);
  1612 	aMessage.ReadL(aArgNum, buf);
  1609 	aMessage.ReadL(aArgNum, buf);
  1613 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, (aCharLen * sizeof(TText)));
  1610 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, (aCharLen * sizeof(TText)));
  1614 	if(buf.Length() > aCharLen)
  1611     __SQLPANIC_CLIENT(buf.Length() == aCharLen, aMessage, ESqlPanicBadHandle);
  1615 		{
       
  1616 		__SQLLEAVE(KErrBadDescriptor);
       
  1617 		}
       
  1618 	buf.Append(TChar(0));
  1612 	buf.Append(TChar(0));
  1619 	return buf;
  1613 	return buf;
  1620 	}
  1614 	}
  1621 
  1615 
  1622 /**
  1616 /**
  1623 Reads a 16-bit string with "aCharLen" character length, which is in "aArgNum" argument of aMessage.
  1617 Reads a 16-bit string with "aCharLen" character length, which is in "aArgNum" argument of aMessage.
  1624 Returns TDes16 reference pointing to the string.
  1618 Returns TDes16 reference pointing to the string.
  1625 
  1619 
  1626 @leave KErrBadDescriptor The transferred data length is bigger than the aCharLen value
  1620 @panic SqlDb 3 Client panic. The string length is not equal to aCharLen. If happens then it is an indication of a 
  1627 
  1621                              problem inside client side sql library.
  1628 @panic SqlDb 4 Client panic. Negative aCharLen value.
  1622 @panic SqlDb 4 Client panic. Negative aCharLen value.
  1629 */
  1623 */
  1630 TDes16& CSqlSrvSession::ReadString16L(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen)
  1624 TDes16& CSqlSrvSession::ReadString16L(const RMessage2& aMessage, TInt aArgNum, TInt aCharLen)
  1631 	{
  1625 	{
  1632 	__SQLPANIC_CLIENT(aCharLen >= 0, aMessage, ESqlPanicBadArgument);
  1626 	__SQLPANIC_CLIENT(aCharLen >= 0, aMessage, ESqlPanicBadArgument);
  1633 	TDes16& buf = Server().GetBuf16L(aCharLen);
  1627 	TDes16& buf = Server().GetBuf16L(aCharLen);
  1634 	aMessage.ReadL(aArgNum, buf);
  1628 	aMessage.ReadL(aArgNum, buf);
  1635 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, (aCharLen * sizeof(TText)));
  1629 	SQLPROFILER_REPORT_IPC(ESqlIpcRead, (aCharLen * sizeof(TText)));
  1636 	if(buf.Length() > aCharLen)
  1630     __SQLPANIC_CLIENT(buf.Length() == aCharLen, aMessage, ESqlPanicBadHandle);
  1637 		{
       
  1638 		__SQLLEAVE(KErrBadDescriptor);
       
  1639 		}
       
  1640 	return buf;
  1631 	return buf;
  1641 	}
  1632 	}
  1642 
  1633 
  1643 /**
  1634 /**
  1644 The method constructs a CSqlSecurityPolicy object from the passed as an argument descriptor.
  1635 The method constructs a CSqlSecurityPolicy object from the passed as an argument descriptor.