Added support for more SQL statements.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@622 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
dsandersoremutah
2006-06-30 21:46:17 +00:00
parent fce94ee1f0
commit 44b49ffdeb
2 changed files with 435 additions and 1 deletions

View File

@@ -4256,6 +4256,118 @@ Exit:
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
RCODE F_Rfl::logDropTable(
F_Db * pDb,
FLMUINT uiTableNum)
{
RCODE rc = NE_SFLM_OK;
FLMUINT uiPacketBodyLen;
FLMBYTE * pucPacketBody;
FLMBYTE * pucPacketStart;
flmAssert( pDb->m_uiFlags & FDB_HAS_FILE_LOCK);
// Do nothing if logging is disabled.
if( !isLoggingEnabled())
{
goto Exit;
}
// Better be in the middle of a transaction.
flmAssert( m_ui64CurrTransID);
// Increment the operation count
m_uiOperCount++;
// Make sure we have space in the RFL buffer for a complete packet. NOTE:
// this is calculating the maximum packet body length that would be needed.
if( !haveBuffSpace( FLM_MAX_SEN_LEN + RFL_PACKET_OVERHEAD))
{
if( RC_BAD( rc = flush( pDb, m_pCurrentBuf)))
{
goto Exit;
}
}
// Get a pointer to where we will be laying down the packet body.
pucPacketBody = pucPacketStart = getPacketBodyPtr();
// Output the table number
f_encodeSEN( uiTableNum, &pucPacketBody);
// Finish the packet - calculate the actual packet body length.
uiPacketBodyLen = (FLMUINT)(pucPacketBody - pucPacketStart);
flmAssert( uiPacketBodyLen <= FLM_MAX_SEN_LEN);
if (RC_BAD( rc = finishPacket( pDb, RFL_DROP_TABLE_PACKET,
uiPacketBodyLen, FALSE)))
{
goto Exit;
}
Exit:
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
RCODE F_Rfl::recovDropTable(
F_Db * pDb,
const FLMBYTE * pucPacketBody,
FLMUINT uiPacketBodyLen,
eRestoreAction * peAction)
{
RCODE rc = NE_SFLM_OK;
FLMUINT uiTableNum;
const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen;
// Get the table number from the packet
if (RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiTableNum)))
{
goto Exit;
}
if (m_pRestoreStatus)
{
if( RC_BAD( rc = m_pRestoreStatus->reportDropTable(
peAction, uiTableNum)))
{
goto Exit;
}
if( *peAction == SFLM_RESTORE_ACTION_STOP)
{
m_ui64CurrTransID = 0;
goto Exit;
}
}
if( RC_BAD( rc = pDb->dropTable( uiTableNum)))
{
goto Exit;
}
Exit:
m_tmpPool.poolReset( NULL);
m_ui64CurrTransID = 0;
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
@@ -4616,6 +4728,118 @@ Exit:
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
RCODE F_Rfl::logDropIndex(
F_Db * pDb,
FLMUINT uiIndexNum)
{
RCODE rc = NE_SFLM_OK;
FLMUINT uiPacketBodyLen;
FLMBYTE * pucPacketBody;
FLMBYTE * pucPacketStart;
flmAssert( pDb->m_uiFlags & FDB_HAS_FILE_LOCK);
// Do nothing if logging is disabled.
if( !isLoggingEnabled())
{
goto Exit;
}
// Better be in the middle of a transaction.
flmAssert( m_ui64CurrTransID);
// Increment the operation count
m_uiOperCount++;
// Make sure we have space in the RFL buffer for a complete packet. NOTE:
// this is calculating the maximum packet body length that would be needed.
if( !haveBuffSpace( FLM_MAX_SEN_LEN + RFL_PACKET_OVERHEAD))
{
if( RC_BAD( rc = flush( pDb, m_pCurrentBuf)))
{
goto Exit;
}
}
// Get a pointer to where we will be laying down the packet body.
pucPacketBody = pucPacketStart = getPacketBodyPtr();
// Output the index number
f_encodeSEN( uiIndexNum, &pucPacketBody);
// Finish the packet - calculate the actual packet body length.
uiPacketBodyLen = (FLMUINT)(pucPacketBody - pucPacketStart);
flmAssert( uiPacketBodyLen <= FLM_MAX_SEN_LEN);
if (RC_BAD( rc = finishPacket( pDb, RFL_DROP_INDEX_PACKET,
uiPacketBodyLen, FALSE)))
{
goto Exit;
}
Exit:
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
RCODE F_Rfl::recovDropIndex(
F_Db * pDb,
const FLMBYTE * pucPacketBody,
FLMUINT uiPacketBodyLen,
eRestoreAction * peAction)
{
RCODE rc = NE_SFLM_OK;
FLMUINT uiIndexNum;
const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen;
// Get the index number from the packet
if (RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiIndexNum)))
{
goto Exit;
}
if (m_pRestoreStatus)
{
if( RC_BAD( rc = m_pRestoreStatus->reportDropIndex(
peAction, uiIndexNum)))
{
goto Exit;
}
if( *peAction == SFLM_RESTORE_ACTION_STOP)
{
m_ui64CurrTransID = 0;
goto Exit;
}
}
if( RC_BAD( rc = pDb->dropIndex( uiIndexNum)))
{
goto Exit;
}
Exit:
m_tmpPool.poolReset( NULL);
m_ui64CurrTransID = 0;
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
@@ -5020,7 +5244,7 @@ RCODE F_Rfl::logInsertRow(
// Finish the packet - calculate the actual packet body length.
uiPacketBodyLen = (FLMUINT)(pucPacketBody - pucPacketStart);
flmAssert( uiPacketBodyLen <= FLM_MAX_SEN_LEN * 2);
flmAssert( uiPacketBodyLen <= FLM_MAX_SEN_LEN);
if (RC_BAD( rc = finishPacket( pDb, RFL_INSERT_ROW_PACKET,
uiPacketBodyLen, FALSE)))
@@ -5337,6 +5561,131 @@ Exit:
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
RCODE F_Rfl::logDeleteRow(
F_Db * pDb,
FLMUINT uiTableNum,
FLMUINT64 ui64RowId)
{
RCODE rc = NE_SFLM_OK;
FLMUINT uiPacketBodyLen;
FLMBYTE * pucPacketBody;
FLMBYTE * pucPacketStart;
flmAssert( pDb->m_uiFlags & FDB_HAS_FILE_LOCK);
// Do nothing if logging is disabled.
if( !isLoggingEnabled())
{
goto Exit;
}
// Better be in the middle of a transaction.
flmAssert( m_ui64CurrTransID);
// Increment the operation count
m_uiOperCount++;
// Make sure we have space in the RFL buffer for a complete packet. NOTE:
// this is calculating the maximum packet body length that would be needed.
if( !haveBuffSpace( FLM_MAX_SEN_LEN * 2 + RFL_PACKET_OVERHEAD))
{
if( RC_BAD( rc = flush( pDb, m_pCurrentBuf)))
{
goto Exit;
}
}
// Get a pointer to where we will be laying down the packet body.
pucPacketBody = pucPacketStart = getPacketBodyPtr();
// Output the table number
f_encodeSEN( uiTableNum, &pucPacketBody);
// Output the row ID
f_encodeSEN( ui64RowId, &pucPacketBody);
// Finish the packet - calculate the actual packet body length.
uiPacketBodyLen = (FLMUINT)(pucPacketBody - pucPacketStart);
flmAssert( uiPacketBodyLen <= FLM_MAX_SEN_LEN * 2);
if (RC_BAD( rc = finishPacket( pDb, RFL_DELETE_ROW_PACKET,
uiPacketBodyLen, FALSE)))
{
goto Exit;
}
Exit:
return( rc);
}
/********************************************************************
Desc:
*********************************************************************/
RCODE F_Rfl::recovDeleteRow(
F_Db * pDb,
const FLMBYTE * pucPacketBody,
FLMUINT uiPacketBodyLen,
eRestoreAction * peAction)
{
RCODE rc = NE_SFLM_OK;
FLMUINT uiTableNum;
FLMUINT64 ui64RowId;
const FLMBYTE * pucEnd = pucPacketBody + uiPacketBodyLen;
// Get the table number from the packet
if (RC_BAD( rc = f_decodeSEN( &pucPacketBody, pucEnd, &uiTableNum)))
{
goto Exit;
}
// Get the row ID from the packet
if (RC_BAD( rc = f_decodeSEN64( &pucPacketBody, pucEnd, &ui64RowId)))
{
goto Exit;
}
if (m_pRestoreStatus)
{
if( RC_BAD( rc = m_pRestoreStatus->reportDeleteRow(
peAction, uiTableNum, ui64RowId)))
{
goto Exit;
}
if( *peAction == SFLM_RESTORE_ACTION_STOP)
{
m_ui64CurrTransID = 0;
goto Exit;
}
}
if( RC_BAD( rc = pDb->deleteRow( uiTableNum, ui64RowId, FALSE)))
{
goto Exit;
}
Exit:
m_tmpPool.poolReset( NULL);
m_ui64CurrTransID = 0;
return( rc);
}
/********************************************************************
Desc: Make room in the RFL buffer for the additional bytes.
This is done by flushing the log buffer and shifting down
@@ -6675,6 +7024,23 @@ Finish_Transaction:
break;
}
case RFL_DROP_TABLE_PACKET:
{
if( RC_BAD( rc = recovDropTable( pDb,
pucPacketBody, uiPacketBodyLen, &eAction)))
{
goto Exit;
}
if( eAction == SFLM_RESTORE_ACTION_STOP)
{
bLastTransEndedAtFileEOF = FALSE;
goto Finish_Recovery;
}
break;
}
case RFL_CREATE_INDEX_PACKET:
{
if( RC_BAD( rc = recovCreateIndex( pDb,
@@ -6692,6 +7058,23 @@ Finish_Transaction:
break;
}
case RFL_DROP_INDEX_PACKET:
{
if( RC_BAD( rc = recovDropIndex( pDb,
pucPacketBody, uiPacketBodyLen, &eAction)))
{
goto Exit;
}
if( eAction == SFLM_RESTORE_ACTION_STOP)
{
bLastTransEndedAtFileEOF = FALSE;
goto Finish_Recovery;
}
break;
}
case RFL_INDEX_SET_PACKET:
{
if( RC_BAD( rc = recovIndexSet( pDb,
@@ -6726,6 +7109,23 @@ Finish_Transaction:
break;
}
case RFL_DELETE_ROW_PACKET:
{
if( RC_BAD( rc = recovDeleteRow( pDb,
pucPacketBody, uiPacketBodyLen, &eAction)))
{
goto Exit;
}
if( eAction == SFLM_RESTORE_ACTION_STOP)
{
bLastTransEndedAtFileEOF = FALSE;
goto Finish_Recovery;
}
break;
}
default:
{
// Should not be getting other packet types at this