Skip to content

Commit

Permalink
Special logic to cancel DROP COLUMN
Browse files Browse the repository at this point in the history
This change introduces a new static function to check whether
the parent query has been canceled. It is called by during an
ALTER TABLE .. DROP COLUMN statement.

Closes-Bug: 1439505

Change-Id: I8342488821e719320273aa343cab3ba5b9a93444
  • Loading branch information
mikehanlonathpdotcom committed Apr 3, 2015
1 parent fc7325a commit 2053000
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
38 changes: 34 additions & 4 deletions sql/exp/ExpHbaseInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@
****************************************************************************
*/

#include "Platform.h"
#include "ex_stdh.h"
#include "ExpHbaseInterface.h"
#include "str.h"
#include "NAStringDef.h"
#include "ex_ex.h"
#include "ExStats.h"
#include "Globals.h"
#include "SqlStats.h"
#include "CmpCommon.h"
#include "CmpContext.h"

extern Int64 getTransactionIDFromContext();

Expand Down Expand Up @@ -75,6 +80,32 @@ ExpHbaseInterface* ExpHbaseInterface::newInstance(CollHeap* heap,
debugPort, debugTimeout); // This is the transactional interface
}

NABoolean isParentQueryCanceled()
{
NABoolean isCanceled = FALSE;
CliGlobals *cliGlobals = GetCliGlobals();
StatsGlobals *statsGlobals = cliGlobals->getStatsGlobals();
const char *parentQid = CmpCommon::context()->sqlSession()->getParentQid();
if (statsGlobals && parentQid)
{
short savedPriority, savedStopMode;
statsGlobals->getStatsSemaphore(cliGlobals->getSemId(),
cliGlobals->myPin(), savedPriority, savedStopMode,
FALSE /*shouldTimeout*/);
StmtStats *ss = statsGlobals->getMasterStmtStats(parentQid,
strlen(parentQid), RtsQueryId::ANY_QUERY_);
if (ss)
{
ExMasterStats *masterStats = ss->getMasterStats();
if (masterStats && masterStats->getCanceledTime() != -1)
isCanceled = TRUE;
}
statsGlobals->releaseStatsSemaphore(cliGlobals->getSemId(),
cliGlobals->myPin(), savedPriority, savedStopMode);
}
return isCanceled;
}

Int32 ExpHbaseInterface_JNI::deleteColumns(
HbaseStr &tblName,
HbaseStr& column)
Expand All @@ -99,8 +130,7 @@ Int32 ExpHbaseInterface_JNI::deleteColumns(

NABoolean done = FALSE;
HbaseStr rowID;
while (NOT done)
{
do {
// Added the for loop to consider using deleteRows
// to delete the column for all rows in the batch
for (int rowNo = 0; rowNo < numReqRows; rowNo++)
Expand All @@ -124,7 +154,7 @@ Int32 ExpHbaseInterface_JNI::deleteColumns(
break;
}
}
} // while NOT done
} while (!(done || isParentQueryCanceled()));
scanClose();
if (retcode == HTC_DONE)
return HBASE_ACCESS_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion sql/runtimestats/SqlStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ ExStatisticsArea *StatsGlobals::getStatsArea(char *queryId, Lng32 queryIdLen)
}
// LCOV_EXCL_STOP

StmtStats *StatsGlobals::getMasterStmtStats(char *queryId, Lng32 queryIdLen, short activeQueryNum)
StmtStats *StatsGlobals::getMasterStmtStats(const char *queryId, Lng32 queryIdLen, short activeQueryNum)
{
StmtStats *ss;
ExMasterStats *masterStats;
Expand Down
2 changes: 1 addition & 1 deletion sql/runtimestats/SqlStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class StatsGlobals
void checkForDeadProcesses(pid_t myPid);
SyncHashQueue *getStmtStatsList() { return stmtStatsList_; }
ExStatisticsArea *getStatsArea(char *queryId, Lng32 queryIdLen);
StmtStats *getMasterStmtStats(char *queryId, Lng32 queryIdLen, short activeQueryNum);
StmtStats *getMasterStmtStats(const char *queryId, Lng32 queryIdLen, short activeQueryNum);
StmtStats *getStmtStats(char *queryId, Lng32 queryIdLen);
StmtStats *getStmtStats(pid_t pid, short activeQueryNum);
StmtStats *getStmtStats(short activeQueryNum);
Expand Down

0 comments on commit 2053000

Please sign in to comment.