OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::RestoreTableStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RestoreTableStmt:
+ Collaboration diagram for Parser::RestoreTableStmt:

Public Member Functions

 RestoreTableStmt (std::string *tab, std::string *path, std::list< NameValueAssign * > *options)
 
 RestoreTableStmt (const rapidjson::Value &payload)
 
void execute (const Catalog_Namespace::SessionInfo &session, bool read_only_mode) override
 
- Public Member Functions inherited from Parser::DumpRestoreTableStmtBase
 DumpRestoreTableStmtBase (std::string *tab, std::string *path, std::list< NameValueAssign * > *options, const bool is_restore)
 
 DumpRestoreTableStmtBase (const rapidjson::Value &payload, const bool is_restore)
 
CompressionType defaultCompression (bool is_restore)
 
CompressionType validateCompression (const std::string &compression, const bool is_restore)
 
std::string tarCompressionStr (CompressionType compression, const bool is_restore)
 
const std::string * getTable () const
 
const std::string * getPath () const
 
const CompressionType getCompression () const
 
- Public Member Functions inherited from Parser::DDLStmt
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Additional Inherited Members

- Public Types inherited from Parser::DumpRestoreTableStmtBase
enum  CompressionType { CompressionType::kGZIP, CompressionType::kLZ4, CompressionType::kNONE }
 
- Protected Attributes inherited from Parser::DumpRestoreTableStmtBase
std::unique_ptr< std::string > table_
 
std::unique_ptr< std::string > path_
 
CompressionType compression_
 

Detailed Description

Definition at line 1502 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::RestoreTableStmt::RestoreTableStmt ( std::string *  tab,
std::string *  path,
std::list< NameValueAssign * > *  options 
)
inline

Definition at line 1504 of file ParserNode.h.

1507  : DumpRestoreTableStmtBase(tab, path, options, true) {}
DumpRestoreTableStmtBase(std::string *tab, std::string *path, std::list< NameValueAssign * > *options, const bool is_restore)
Definition: ParserNode.h:1426
Parser::RestoreTableStmt::RestoreTableStmt ( const rapidjson::Value &  payload)

Definition at line 6876 of file ParserNode.cpp.

6877  : DumpRestoreTableStmtBase(payload, true) {}
DumpRestoreTableStmtBase(std::string *tab, std::string *path, std::list< NameValueAssign * > *options, const bool is_restore)
Definition: ParserNode.h:1426

Member Function Documentation

void Parser::RestoreTableStmt::execute ( const Catalog_Namespace::SessionInfo session,
bool  read_only_mode 
)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 6879 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), Parser::DumpRestoreTableStmtBase::compression_, AccessPrivileges::CREATE_TABLE, Catalog_Namespace::SessionInfo::getCatalog(), Catalog_Namespace::Catalog::getMetadataForTable(), Parser::DumpRestoreTableStmtBase::path_, TableArchiver::restoreTable(), Parser::DumpRestoreTableStmtBase::table_, TableDBObjectType, and Parser::DumpRestoreTableStmtBase::tarCompressionStr().

Referenced by heavydb.cursor.Cursor::executemany().

6880  {
6881  if (read_only_mode) {
6882  throw std::runtime_error("RESTORE TABLE invalid in read only mode.");
6883  }
6884  auto& catalog = session.getCatalog();
6885  const TableDescriptor* td = catalog.getMetadataForTable(*table_, false);
6886  if (td) {
6887  // TODO: v1.0 simply throws to avoid accidentally overwrite target table.
6888  // Will add a REPLACE TABLE to explictly replace target table.
6889  // catalog.restoreTable(session, td, *path, compression_);
6890  // TODO (yoonmin): if the above feature is delivered, we have to invalidate cached
6891  // items for the table
6892  throw std::runtime_error("Table " + *table_ + " exists.");
6893  } else {
6894  // check access privileges
6897  throw std::runtime_error("Table " + *table_ +
6898  " will not be restored. User has no create privileges.");
6899  }
6900  TableArchiver table_archiver(&catalog);
6901  table_archiver.restoreTable(
6902  session, *table_, *path_, tarCompressionStr(compression_, true));
6903  }
6904 }
std::string tarCompressionStr(CompressionType compression, const bool is_restore)
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1484
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:158
std::unique_ptr< std::string > path_
Definition: ParserNode.h:1485
Catalog & getCatalog() const
Definition: SessionInfo.h:75
bool checkDBAccessPrivileges(const DBObjectType &permissionType, const AccessPrivileges &privs, const std::string &objectName="") const
Definition: SessionInfo.cpp:24

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: