Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // IRowsetIdentity interface implementation
  7. //
  8. ///////////////////////////////////////////////////////////////////////////////////////////
  9. #include "headers.h"
  10. ///////////////////////////////////////////////////////////////////////////////////////////
  11. //
  12. // Compares two row handles to see if they refer to the same row instance.
  13. //
  14. // HRESULT
  15. // S_FALSE Method Succeeded but did not refer to the same row
  16. // S_OK Method Succeeded
  17. // DB_E_BADROWHANDLE Invalid row handle given
  18. // OTHER Other HRESULTs returned by called functions
  19. //
  20. ///////////////////////////////////////////////////////////////////////////////////////////
  21. STDMETHODIMP CImpIRowsetIdentity::IsSameRow ( HROW hThisRow, //IN The handle of an active row
  22. HROW hThatRow //IN The handle of an active row
  23. )
  24. {
  25. HRESULT hr = S_OK;
  26. BSTR strKeyThisRow = NULL,strKeyThatRow = NULL;
  27. DWORD dwStatusThisRow = 0 , dwStatusThatRow = 0;
  28. CSetStructuredExceptionHandler seh;
  29. TRY_BLOCK;
  30. // Seriliaze the object
  31. CAutoBlock cab(ROWSET->GetCriticalSection());
  32. // Clear Error information
  33. g_pCError->ClearErrorInfo();
  34. if(m_pObj->IsZoombie())
  35. {
  36. hr = E_UNEXPECTED;
  37. }
  38. else
  39. if (!m_pObj->BitArrayInitialized()){
  40. //=================================================================================
  41. // This is the case when the method was called even before the rowset got fully
  42. // intialized, hence no rows could have been fetched yet, therefore there do not
  43. // exist valid row handles, and all row handles provided must be invalid.
  44. //=================================================================================
  45. hr = DB_E_BADROWHANDLE;
  46. }
  47. else
  48. {
  49. //=================================================================================
  50. // Check validity of input handles
  51. //=================================================================================
  52. // NTBuild : 138810
  53. // 07/18/00
  54. if(TRUE == m_pObj->IsRowExists(hThisRow) && TRUE == m_pObj->IsRowExists(hThatRow))
  55. {
  56. //NTRaid:138810
  57. // 07/18/00
  58. /// Get the status of the row and check
  59. // if it is deleted
  60. dwStatusThisRow = m_pObj->GetRowStatus(hThisRow);
  61. dwStatusThatRow = m_pObj->GetRowStatus(hThatRow);
  62. if( DBROWSTATUS_S_OK != dwStatusThisRow || DBROWSTATUS_S_OK != dwStatusThatRow)
  63. {
  64. hr = DB_E_ERRORSOCCURRED;
  65. if( DBROWSTATUS_E_DELETED == dwStatusThisRow || DBROWSTATUS_E_DELETED == dwStatusThatRow)
  66. {
  67. hr = DB_E_DELETEDROW;
  68. }
  69. }
  70. else
  71. if(hThisRow == hThatRow)
  72. {
  73. hr = S_OK;
  74. }
  75. else
  76. {
  77. m_pObj->GetInstanceKey(hThisRow,&strKeyThisRow);
  78. m_pObj->GetInstanceKey(hThatRow,&strKeyThatRow);
  79. // NTRaid:111813
  80. // 06/07/00
  81. if(!strKeyThisRow || !strKeyThatRow)
  82. {
  83. hr = S_FALSE;
  84. }
  85. else
  86. // If the key of both the instances are same then
  87. // both the rows are referring to the same row
  88. if( wbem_wcsicmp(strKeyThisRow,strKeyThisRow) == 0)
  89. {
  90. hr = S_OK;
  91. }
  92. else
  93. {
  94. hr = S_FALSE;
  95. }
  96. SysFreeString(strKeyThisRow);
  97. SysFreeString(strKeyThatRow);
  98. }
  99. }
  100. else
  101. {
  102. hr = DB_E_BADROWHANDLE;
  103. }
  104. }
  105. hr = hr == S_OK ? hr :g_pCError->PostHResult(hr,&IID_IRowsetIdentity);
  106. CATCH_BLOCK_HRESULT(hr,L"IRowsetIdentity::IsSameRow");
  107. return hr;
  108. }