OmniSciDB  eb3a3d0a03
 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) 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)
 
void validateCompression (std::string &compression, const bool is_restore)
 
const std::string * getTable () const
 
const std::string * getPath () const
 
const std::string 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

- Protected Attributes inherited from Parser::DumpRestoreTableStmtBase
std::unique_ptr< std::string > table_
 
std::unique_ptr< std::string > path_
 
std::string compression_
 

Detailed Description

Definition at line 1458 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1460 of file ParserNode.h.

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

Definition at line 6280 of file ParserNode.cpp.

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

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6283 of file ParserNode.cpp.

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

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

6283  {
6284  auto& catalog = session.getCatalog();
6285  const TableDescriptor* td = catalog.getMetadataForTable(*table_, false);
6286  if (td) {
6287  // TODO: v1.0 simply throws to avoid accidentally overwrite target table.
6288  // Will add a REPLACE TABLE to explictly replace target table.
6289  // catalog.restoreTable(session, td, *path, compression_);
6290  throw std::runtime_error("Table " + *table_ + " exists.");
6291  } else {
6292  // check access privileges
6295  throw std::runtime_error("Table " + *table_ +
6296  " will not be restored. User has no create privileges.");
6297  }
6298  TableArchiver table_archiver(&catalog);
6299  table_archiver.restoreTable(session, *table_, *path_, compression_);
6300  }
6301 }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1441
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:160
std::unique_ptr< std::string > path_
Definition: ParserNode.h:1442
Catalog & getCatalog() const
Definition: SessionInfo.h:67
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: