You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-30 14:21:11 +03:00
MCOL-311 Add findObjectFile command to mcsadmin
This commit is contained in:
@@ -29,7 +29,12 @@
|
|||||||
<Name>AVAILABLE</Name>
|
<Name>AVAILABLE</Name>
|
||||||
</Cmd4>
|
</Cmd4>
|
||||||
<Cmd5>
|
<Cmd5>
|
||||||
<Name>AVAILABLE</Name>
|
<Name>findObjectFile</Name>
|
||||||
|
<Desc1>Get the name of the directory containing the first file of the object</Desc1>
|
||||||
|
<Arg1>Object ID (OID) of object</Arg1>
|
||||||
|
<Arg2>Schema</Arg2>
|
||||||
|
<Arg3>Table</Arg3>
|
||||||
|
<Arg4>Column</Arg4>
|
||||||
</Cmd5>
|
</Cmd5>
|
||||||
<Cmd6>
|
<Cmd6>
|
||||||
<Name>getModuleTypeConfig</Name>
|
<Name>getModuleTypeConfig</Name>
|
||||||
|
@@ -8,7 +8,7 @@ set(mcsadmin_SRCS mcsadmin.cpp)
|
|||||||
|
|
||||||
add_executable(mcsadmin ${mcsadmin_SRCS})
|
add_executable(mcsadmin ${mcsadmin_SRCS})
|
||||||
|
|
||||||
target_link_libraries(mcsadmin ${ENGINE_LDFLAGS} readline ncurses ${ENGINE_EXEC_LIBS})
|
target_link_libraries(mcsadmin ${ENGINE_LDFLAGS} readline ncurses ${ENGINE_EXEC_LIBS} ${ENGINE_WRITE_LIBS})
|
||||||
|
|
||||||
install(TARGETS mcsadmin DESTINATION ${ENGINE_BINDIR} COMPONENT platform)
|
install(TARGETS mcsadmin DESTINATION ${ENGINE_BINDIR} COMPONENT platform)
|
||||||
|
|
||||||
|
@@ -32,13 +32,15 @@ extern int h_errno;
|
|||||||
#include "boost/tokenizer.hpp"
|
#include "boost/tokenizer.hpp"
|
||||||
#include "sessionmanager.h"
|
#include "sessionmanager.h"
|
||||||
#include "dbrm.h"
|
#include "dbrm.h"
|
||||||
|
#include "we_config.h" // for findObjectFile
|
||||||
|
#include "we_fileop.h" // for findObjectFile
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
|
||||||
using namespace alarmmanager;
|
using namespace alarmmanager;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace oam;
|
using namespace oam;
|
||||||
using namespace config;
|
using namespace config;
|
||||||
|
using namespace execplan;
|
||||||
#include "installdir.h"
|
#include "installdir.h"
|
||||||
|
|
||||||
// Variables shared in both main and functions
|
// Variables shared in both main and functions
|
||||||
@@ -707,8 +709,95 @@ int processCommand(string* arguments)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // Available
|
case 5: // findObjectFile
|
||||||
{
|
{
|
||||||
|
unsigned maxDBRoot = WriteEngine::Config::DBRootCount();
|
||||||
|
if (maxDBRoot < 1)
|
||||||
|
{
|
||||||
|
cout << endl << "getDatafileName fails because there are no dbroots defined for this server" << endl;
|
||||||
|
break;;
|
||||||
|
}
|
||||||
|
if (arguments[1] == "")
|
||||||
|
{
|
||||||
|
cout << endl << "getDatafileName requires one of" << endl;
|
||||||
|
cout << "a) oid of column for which file name is to be retrieved" << endl;
|
||||||
|
cout << "b) schema, table and column for which file name is to be retrieved" << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
char* endchar;
|
||||||
|
int oid = strtol(arguments[1].c_str(), &endchar, 0);
|
||||||
|
// test to see if not all numeric
|
||||||
|
if (endchar < &(*arguments[1].end()))
|
||||||
|
{
|
||||||
|
oid = 0;
|
||||||
|
}
|
||||||
|
if (oid == 0)
|
||||||
|
{
|
||||||
|
// Need to convert the arguments to oid
|
||||||
|
boost::shared_ptr<execplan::CalpontSystemCatalog> systemCatalogPtr =
|
||||||
|
execplan::CalpontSystemCatalog::makeCalpontSystemCatalog(0);
|
||||||
|
CalpontSystemCatalog::TableColName columnName;
|
||||||
|
columnName.schema = arguments[1];
|
||||||
|
if (arguments[2] == "")
|
||||||
|
{
|
||||||
|
cout << endl << "getDatafileName requires a table and column for schema " << arguments[1] << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
columnName.table = arguments[2];
|
||||||
|
if (arguments[3] == "")
|
||||||
|
{
|
||||||
|
// No column was given. Use the first column in the table.
|
||||||
|
CalpontSystemCatalog::TableName tableName;
|
||||||
|
tableName.schema = arguments[1];
|
||||||
|
tableName.table = arguments[2];
|
||||||
|
CalpontSystemCatalog::RIDList rdlist = systemCatalogPtr->columnRIDs(tableName);
|
||||||
|
oid = rdlist.front().objnum;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
columnName.column = arguments[3];
|
||||||
|
oid = systemCatalogPtr->lookupOID(columnName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use writeengine code to get the filename
|
||||||
|
WriteEngine::FileOp fileOp;
|
||||||
|
char fileName[WriteEngine::FILE_NAME_SIZE];
|
||||||
|
memset(fileName, 0, WriteEngine::FILE_NAME_SIZE);
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if (oid < 1000)
|
||||||
|
rc = fileOp.getVBFileName(oid, fileName);
|
||||||
|
else
|
||||||
|
rc = fileOp.oid2DirName(oid, fileName);
|
||||||
|
cout << "file name for oid " << oid << ":" << endl;
|
||||||
|
if (strlen(fileName) > 0)
|
||||||
|
{
|
||||||
|
cout << fileName;
|
||||||
|
}
|
||||||
|
if (rc == WriteEngine::NO_ERROR)
|
||||||
|
{
|
||||||
|
// Success. No more output.
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
else if (rc == WriteEngine::ERR_FILE_NOT_EXIST)
|
||||||
|
{
|
||||||
|
if (strlen(fileName) == 0)
|
||||||
|
{
|
||||||
|
// We couldn't get a name
|
||||||
|
cout << "Error: Filename could not be determined" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We got a name, but the file doesn't exist
|
||||||
|
cout << " (OID directory not found)" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Something broke
|
||||||
|
cerr << "WriteEngine::FileOp::oid2DirName() error. rc=" << rc << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user