1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-12-17 01:02:23 +03:00
Files
mariadb-columnstore-engine/src/TruncateTask.cpp
Ben Thompson b3f8a5ed47 add SMLogging.
2019-03-04 11:41:25 -06:00

60 lines
1.1 KiB
C++

#include "TruncateTask.h"
#include <errno.h>
#include "messageFormat.h"
#include "SMLogging.h"
using namespace std;
namespace storagemanager
{
TruncateTask::TruncateTask(int sock, uint len) : PosixTask(sock, len)
{
}
TruncateTask::~TruncateTask()
{
}
#define check_error(msg, ret) \
if (!success) \
{ \
handleError(msg, errno); \
return ret; \
}
bool TruncateTask::run()
{
SMLogging* logger = SMLogging::get();
bool success;
uint8_t buf[1024] = {0};
if (getLength() > 1023) {
handleError("TruncateTask read", ENAMETOOLONG);
return false;
}
success = read(buf, getLength());
check_error("TruncateTask read", false);
truncate_cmd *cmd = (truncate_cmd *) buf;
#ifdef SM_TRACE
logger->log(LOG_DEBUG,"truncate %s newlength %i.",cmd->filename,cmd->length);
#endif
int err = ioc->truncate(cmd->filename, cmd->length);
if (err)
{
handleError("TruncateTask truncate", errno);
return true;
}
sm_response *resp = (sm_response *) buf;
resp->returnCode = 0;
success = write(*resp, 0);
return success;
}
}