Esempio n. 1
0
static void TRANSACTION_ChangeState (
    unsigned long txHigh, 
    unsigned long txLow, 
    CString& strOperation,
    CTypedPtrList < CObList, CaTableTransactionItemData* >& ls)
{
	unsigned long lLow, lHigh;
	CaTableTransactionItemData* pObj = NULL;
	POSITION pos = ls.GetHeadPosition();
	while (pos != NULL)
	{
		pObj = ls.GetNext (pos);
		pObj->GetTransactionID (lHigh, lLow);
		if (txHigh == lHigh && txLow == lLow)
		{
			if (strOperation.CompareNoCase (_T("COMMIT")) == 0)
			{
				pObj->SetCommit  (TRUE);
				pObj->SetJournal (TRUE);
			}
			else
			if (strOperation.CompareNoCase (_T("ABORT")) == 0)
			{
				pObj->SetCommit  (FALSE);
				pObj->SetJournal (TRUE);
			}
			else
			if (strOperation.CompareNoCase (_T("COMMITNJ")) == 0)
			{
				pObj->SetCommit  (TRUE);
				pObj->SetJournal (FALSE);
			}
			else
			if (strOperation.CompareNoCase (_T("ABORTNJ")) == 0)
			{
				pObj->SetCommit  (FALSE);
				pObj->SetJournal (FALSE);
			}
			else
			{
				//
				// String in OPERATION in not in ('commit', 'abort', 'commitnj', 'abortnj')
				ASSERT (FALSE);
			}
		}
	}
}
Esempio n. 2
0
static CaTableTransactionItemData* TRANSACTION_Find (
    unsigned long txHigh, 
    unsigned long txLow, 
    CTypedPtrList < CObList, CaTableTransactionItemData* >& ls)
{
	unsigned long lLow, lHigh;
	CaTableTransactionItemData* pObj = NULL;
	POSITION pos = ls.GetHeadPosition();
	while (pos != NULL)
	{
		pObj = ls.GetNext (pos);
		pObj->GetTransactionID (lHigh, lLow);
		if (txHigh == lHigh && txLow == lLow)
			return pObj;
	}

	return NULL;
}
Esempio n. 3
0
void CuDlgIjaTable::GetSelectedTransactions (CTypedPtrList < CObList, CaBaseTransactionItemData* >& ltr)
{
	int i, nCount;
	int nFound = -1;
	CaTableTransactionItemData* pItemTable= NULL;
	CString strTable;
	CString strTableOwner;
	CString strData;

	m_queryTransactionInfo.GetTable (strTable, strTableOwner);

	nCount = m_cListCtrl.GetItemCount();
	for (i=0; i<nCount; i++)
	{
		if (m_cListCtrl.GetItemState (i, LVIS_SELECTED) & LVIS_SELECTED)
		{
			pItemTable = (CaTableTransactionItemData*)m_cListCtrl.GetItemData (i);
			if (!pItemTable)
				continue;
			unsigned long ltr1L, ltr1H;
			unsigned long ltr2L, ltr2H;

			for (int j=0; j<nCount; j++)
			{
				CaTableTransactionItemData* pItem = (CaTableTransactionItemData*)m_cListCtrl.GetItemData(j);
				if (!pItem)
					continue;

				pItem->GetTransactionID(ltr1H, ltr1L);
				pItemTable->GetTransactionID(ltr2H, ltr2L);

				if (ltr1H == ltr2H && ltr1L == ltr2L)
				{
					pItem->SetTable (strTable);
					pItem->SetTableOwner (strTableOwner);
					if (ltr.Find(pItem) == NULL)
						ltr.AddTail (pItem);
				}
			}
		}
	}
}
Esempio n. 4
0
BOOL IJA_llQueryTableTransaction (
    CaQueryTransactionInfo* pQueryInfo,
    CTypedPtrList<CObList, CaColumn*>* pListColumn,
    CTypedPtrList < CObList, CaTableTransactionItemData* >& listTransaction)
{
	CString strDatabase;
	CString strDatabaseOwner;
	CString strTable;
	CString strTableOwner;
	CString strStatement;

	pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner);
	pQueryInfo->GetTable (strTable, strTableOwner);

	//
	// Open the session:
	CaTemporarySession session (pQueryInfo->GetNode(), strDatabase);
	if (!session.IsConnected())
	{
		//
		// Failedto get Session.
		CString strMsg;
		strMsg.LoadString (IDS_FAIL_TO_GETSESSION);
		AfxMessageBox (strMsg);
		return FALSE;
	}

	CString strTempTable = _T("");
	CString csGranteeList = _T(""); /* no grantee list required here */
	BOOL bOK = IJA_TableAuditdbOutput (pQueryInfo, &session, strTempTable, pListColumn, csGranteeList);
	if (!bOK) {
		session.Release(SESSION_ROLLBACK);
		return FALSE;
	}
	BOOL bOnLocal = session.IsLocalNode();
	//
	// STEP 1: Select row that are INSERT, DELETE, REPOLD, REPNEW
	// Select the rows (table transactions) from the newly created Table:
	CString strSessionPrefix = _T("");
	if (bOnLocal)
		strSessionPrefix = _T("session.");

	strStatement.Format (
		_T("select * from %s%s where operation  in ('repold', 'repnew', 'append', 'insert', 'delete')"),
		(LPCTSTR)strSessionPrefix,
		(LPCTSTR)strTempTable);
	CaIjaCursor cursor(1, strStatement);
	if (cursor.Open())
	{
		int nCount = 0;
		CStringList listData;
		CString strItem1;
		CString strItem2;

		while (cursor.Fetch(listData, nCount))
		{
			CaTableTransactionItemData* pTran = new CaTableTransactionItemData();

			POSITION pos = listData.GetHeadPosition();
			ASSERT (listData.GetCount() >= 10); // At least 10 columns;
			if (listData.GetCount() < 10)
			{
				delete pTran;
				return FALSE;
			}
			pTran->SetTable (strTable);
			pTran->SetTableOwner (strTableOwner);

			if (pos != NULL)
			{
				// LSN:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				pTran->SetLsn (_ttoul(strItem1), _ttoul(strItem2));
				// TID:
				strItem1 = listData.GetNext (pos); 
				pTran->SetTid(_ttol(strItem1));
				// Date:
				strItem1 = listData.GetNext (pos);
				pTran->SetDate(strItem1);
				// User Name:
				strItem1 = listData.GetNext (pos);
				pTran->SetUser (strItem1);
				// Operation:
				strItem1 = listData.GetNext (pos);
				if (strItem1.CompareNoCase (_T("insert")) == 0 || strItem1.CompareNoCase (_T("append")) == 0)
					pTran->SetOperation (T_INSERT);
				else
				if (strItem1.CompareNoCase (_T("delete")) == 0)
					pTran->SetOperation (T_DELETE);
				else
				if (strItem1.CompareNoCase (_T("repold")) == 0)
					pTran->SetOperation (T_BEFOREUPDATE);
				else
				if (strItem1.CompareNoCase (_T("repnew")) == 0)
					pTran->SetOperation (T_AFTERUPDATE);
				else
				{
					ASSERT (FALSE);
					pTran->SetOperation (T_UNKNOWN);
				}
				// Transaction:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				pTran->SetTransactionID (_ttoul(strItem1), _ttoul(strItem2));
				// Ignore:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
			}
			pTran->SetCommit  (TRUE);
			pTran->SetJournal (TRUE);

			CStringList& listAuditedData = pTran->GetListData();
			while (pos != NULL)
			{
				strItem1 = listData.GetNext (pos);
				listAuditedData.AddTail(strItem1);
			}

			listTransaction.AddTail (pTran);
			listData.RemoveAll();
		}

		cursor.Close();
	}

	//
	// STEP 2: Select rows that are COMMIT, ABORT, COMMITNJ, ABORTNJ
	//         to update the previous select result if the rows are commit, abort, ...
	// Select the rows (table transactions) from the newly created Table:
	strStatement.Format (
		_T("select * from %s%s where operation  in ('commit', 'abort', 'commitnj', 'abortnj')"),
		(LPCTSTR)strSessionPrefix,
		(LPCTSTR)strTempTable);

	CaIjaCursor cursor2(2, strStatement);
	if (cursor2.Open())
	{
		CaTableTransactionItemData* pFound = NULL;
		int nCount = 0;
		CStringList listData;
		CString strItem1;
		CString strItem2;
		CString strOperation;

		while (cursor2.Fetch(listData, nCount))
		{
			POSITION pos = listData.GetHeadPosition();
			ASSERT (listData.GetCount() >= 10); // At least 10 columns;
			if (listData.GetCount() < 10)
				return FALSE;

			if (pos != NULL)
			{
				// LSN:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				// Ignore:
				strItem1 = listData.GetNext (pos); 
				// Date:
				strItem1 = listData.GetNext (pos);
				// User Name:
				strItem1 = listData.GetNext (pos);
				// Operation:
				strOperation = listData.GetNext (pos);

				// Transaction:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
				TRANSACTION_ChangeState (_ttoul(strItem1), _ttoul(strItem2), strOperation, listTransaction);
				// Ignore:
				strItem1 = listData.GetNext (pos);
				strItem2 = listData.GetNext (pos);
			}
			listData.RemoveAll();
		}

		cursor2.Close();
	}

	//
	// Make sure that the temporary table has been destroyed:
	if (!bOnLocal && bOK && !strTempTable.IsEmpty()) 
	{
		strStatement.Format ( _T("drop table %s"), (LPCTSTR)strTempTable);
		CaLowlevelAddAlterDrop param (pQueryInfo->GetNode(), strDatabase, strStatement);
		param.NeedSession(FALSE); // Use the current open session.
		param.SetStatement(strStatement);
		if (!param.ExecuteStatement(NULL))
		{
			CString strMsg;
			strMsg.LoadString(IDS_FAIL_DROP_TEMP_TABLE);
			AfxMessageBox(strMsg);
		}
	}

	session.Release(); // Release session and commit.
	return TRUE;
}
Esempio n. 5
0
void CuDlgIjaTable::DisplayMainTransaction()
{
	//
	// DIsplay Transactions:
	int idx, nCount = 0, nImage = 0;
	POSITION pos = m_listMainTrans.GetHeadPosition();
	while (pos !=  NULL)
	{
		CaTableTransactionItemData* pItem = m_listMainTrans.GetNext (pos);
		//
		// Check to see if this transaction matchs the filter
		// if not just skip it.
		if (!m_bAbortedTransaction && !pItem->GetCommit())
			continue; // Skip the rollback transaction

		if (!m_bCommittedTransaction && pItem->GetCommit())
			continue; // Skip the commit transaction
		
		if (m_strUser.CompareNoCase(theApp.m_strAllUser) != 0 && m_strUser.CompareNoCase (pItem->GetUser()) != 0)
			continue;

		nCount = m_cListCtrl.GetItemCount();
		nImage = pItem->GetImageId();

		idx = m_cListCtrl.InsertItem (nCount, _T(""), nImage);
		if (idx != -1)
		{
			switch (pItem->GetAction())
			{
			case T_DELETE:
				IJA_ColorItem(&m_cListCtrl, idx, theApp.m_property.TRGB_DELETE());
				break;
			case T_INSERT:
				IJA_ColorItem(&m_cListCtrl, idx, theApp.m_property.TRGB_INSERT());
				break;
			case T_BEFOREUPDATE:
				IJA_ColorItem(&m_cListCtrl, idx, theApp.m_property.TRGB_BEFOREUPDATE());
				break;
			case T_AFTERUPDATE:
				IJA_ColorItem(&m_cListCtrl, idx, theApp.m_property.TRGB_AFTEREUPDATE());
				break;
			case T_CREATETABLE:
			case T_ALTERTABLE:
			case T_DROPTABLE:
			case T_RELOCATE:
			case T_MODIFY:
			case T_INDEX:
				IJA_ColorItem(&m_cListCtrl, idx, theApp.m_property.TRGB_OTHERS());
				break;
			default:
				break;
			}
			m_cListCtrl.SetItemData (idx, (DWORD)pItem);

			m_cListCtrl.SetItemText (idx, 0, pItem->GetStrTransactionID());
			m_cListCtrl.SetItemText (idx, 1, pItem->GetLsn());
			m_cListCtrl.SetItemText (idx, 2, pItem->GetDateLocale());
			m_cListCtrl.SetItemText (idx, 3, pItem->GetUser());
			m_cListCtrl.SetItemText (idx, 4, pItem->GetStrOperation());
#if defined (SIMULATION)
			m_cListCtrl.SetItemText (idx, 5, pItem->GetName());
#else
			//
			// Display the real data:
			CStringList& listdata = pItem->GetListData();
			POSITION p = listdata.GetHeadPosition();
			int nCounter = 0;
			while (p != NULL && nCounter < m_nColumnHeaderCount)
			{
				CString strItem = listdata.GetNext (p);
				m_cListCtrl.SetItemText (idx, nHeader + nCounter, strItem);

				nCounter++;
			}
#endif
		}
	}
}