You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-15 12:09:09 +03:00
55 lines
994 B
C++
55 lines
994 B
C++
|
|
#include "TruncateTask.h"
|
|
#include <errno.h>
|
|
#include "messageFormat.h"
|
|
|
|
using namespace std;
|
|
|
|
namespace storagemanager
|
|
{
|
|
|
|
TruncateTask::TruncateTask(int sock, uint len) : PosixTask(sock, len)
|
|
{
|
|
}
|
|
|
|
TruncateTask::~TruncateTask()
|
|
{
|
|
}
|
|
|
|
#define check_error(msg) \
|
|
if (!success) \
|
|
{ \
|
|
handleError(msg, errno); \
|
|
return; \
|
|
}
|
|
|
|
void TruncateTask::run()
|
|
{
|
|
bool success;
|
|
uint8_t buf[1024] = {0};
|
|
|
|
if (getLength() > 1023) {
|
|
handleError("TruncateTask read", ENAMETOOLONG);
|
|
return;
|
|
}
|
|
|
|
success = read(buf, getLength());
|
|
check_error("TruncateTask read");
|
|
truncate_cmd *cmd = (truncate_cmd *) buf;
|
|
|
|
int err = ioc->truncate(cmd->filename, cmd->length);
|
|
if (err)
|
|
{
|
|
handleError("TruncateTask truncate", errno);
|
|
return;
|
|
}
|
|
|
|
sm_msg_resp *resp = (sm_msg_resp *) buf;
|
|
resp->type = SM_MSG_START;
|
|
resp->payloadLen = 4;
|
|
resp->returnCode = 0;
|
|
write(buf, sizeof(sm_msg_resp));
|
|
}
|
|
|
|
}
|