OmniSciDB  2e3a973ef4
TableArchiver.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include <algorithm>
20 #include <boost/filesystem.hpp>
21 #include <boost/process.hpp>
22 #include <boost/range/combine.hpp>
23 #include <cerrno>
24 #include <cstdio>
25 #include <cstring>
26 #include <exception>
27 #include <list>
28 #include <memory>
29 #include <regex>
30 #include <set>
31 #include <sstream>
32 #include <system_error>
33 
35 #include "LockMgr/LockMgr.h"
36 #include "Logger/Logger.h"
37 #include "Parser/ParseDDL.h"
38 #include "Shared/File.h"
39 #include "Shared/StringTransform.h"
41 #include "Shared/measure.h"
42 #include "Shared/thread_count.h"
43 
44 extern bool g_cluster;
46 
47 constexpr static char const* table_schema_filename = "_table.sql";
48 constexpr static char const* table_oldinfo_filename = "_table.oldinfo";
49 constexpr static char const* table_epoch_filename = "_table.epoch";
50 
51 namespace std {
52 
53 template <typename T, typename U>
54 struct tuple_size<boost::tuples::cons<T, U>>
55  : boost::tuples::length<boost::tuples::cons<T, U>> {};
56 template <size_t I, typename T, typename U>
57 struct tuple_element<I, boost::tuples::cons<T, U>>
58  : boost::tuples::element<I, boost::tuples::cons<T, U>> {};
59 
60 } // namespace std
61 
62 namespace {
63 
64 inline auto simple_file_closer = [](FILE* f) { std::fclose(f); };
65 
66 inline std::string abs_path(const File_Namespace::GlobalFileMgr* global_file_mgr) {
67  return boost::filesystem::canonical(global_file_mgr->getBasePath()).string();
68 }
69 
70 inline std::string run(const std::string& cmd, const std::string& chdir = "") {
71  VLOG(3) << "running cmd: " << cmd;
72  int rcode;
73  std::error_code ec;
74  std::string output, errors;
75  const auto time_ms = measure<>::execution([&]() {
76  using namespace boost::process;
77  ipstream stdout, stderr;
78  if (!chdir.empty()) {
79  rcode = system(cmd, std_out > stdout, std_err > stderr, ec, start_dir = chdir);
80  } else {
81  rcode = system(cmd, std_out > stdout, std_err > stderr, ec);
82  }
83  std::ostringstream ss_output, ss_errors;
84  stdout >> ss_output.rdbuf();
85  stderr >> ss_errors.rdbuf();
86  output = ss_output.str();
87  errors = ss_errors.str();
88  });
89  if (rcode || ec) {
90  LOG(ERROR) << "failed cmd: " << cmd;
91  LOG(ERROR) << "exit code: " << rcode;
92  LOG(ERROR) << "error code: " << ec.value() << " - " << ec.message();
93  LOG(ERROR) << "stdout: " << output;
94  LOG(ERROR) << "stderr: " << errors;
95 #if defined(__APPLE__)
96  // osx bsdtar options "--use-compress-program" and "--fast-read" together
97  // run into pipe write error after tar extracts the first occurrence of a
98  // file and closes the read end while the decompression program still writes
99  // to the pipe. bsdtar doesn't handle this situation well like gnu tar does.
100  if (1 == rcode && cmd.find("--fast-read") &&
101  (errors.find("cannot write decoded block") != std::string::npos ||
102  errors.find("Broken pipe") != std::string::npos)) {
103  // ignore this error, or lose speed advantage of "--fast-read" on osx.
104  LOG(ERROR) << "tar error ignored on osx for --fast-read";
105  } else
106 #endif
107  // circumvent tar warning on reading file that is "changed as we read it".
108  // this warning results from reading a table file under concurrent inserts
109  if (1 == rcode && errors.find("changed as we read") != std::string::npos) {
110  LOG(ERROR) << "tar error ignored under concurrent inserts";
111  } else {
112  throw std::runtime_error("Failed to run command: " + cmd +
113  "\nexit code: " + std::to_string(rcode) + "\nerrors:\n" +
114  (rcode ? errors : ec.message()));
115  }
116  } else {
117  VLOG(3) << "finished cmd: " << cmd;
118  VLOG(3) << "time: " << time_ms << " ms";
119  VLOG(3) << "stdout: " << output;
120  }
121  return output;
122 }
123 
124 inline std::string simple_file_cat(const std::string& archive_path,
125  const std::string& file_name,
126  const std::string& compression) {
129 #if defined(__APPLE__)
130  constexpr static auto opt_occurrence = "--fast-read";
131 #else
132  constexpr static auto opt_occurrence = "--occurrence=1";
133 #endif
134  boost::filesystem::path temp_dir =
135  boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
136  boost::filesystem::create_directories(temp_dir);
137  run("tar " + compression + " -xvf " + get_quoted_string(archive_path) + " " +
138  opt_occurrence + " " + file_name,
139  temp_dir.string());
140  const auto output = run("cat " + (temp_dir / file_name).string());
141  boost::filesystem::remove_all(temp_dir);
142  return output;
143 }
144 
145 inline std::string get_table_schema(const std::string& archive_path,
146  const std::string& table,
147  const std::string& compression) {
148  const auto schema_str =
149  simple_file_cat(archive_path, table_schema_filename, compression);
150  std::regex regex("@T");
151  return std::regex_replace(schema_str, regex, table);
152 }
153 
154 // Adjust column ids in chunk keys in a table's data files under a temp_data_dir,
155 // including files of all shards of the table. Can be slow for big files but should
156 // be scale faster than refragmentizing. Table altering should be rare for olap.
157 void adjust_altered_table_files(const std::string& temp_data_dir,
158  const std::unordered_map<int, int>& column_ids_map) {
159  boost::filesystem::path base_path(temp_data_dir);
160  boost::filesystem::recursive_directory_iterator end_it;
162  for (boost::filesystem::recursive_directory_iterator fit(base_path); fit != end_it;
163  ++fit) {
164  if (boost::filesystem::is_regular_file(fit->status())) {
165  const std::string file_path = fit->path().string();
166  const std::string file_name = fit->path().filename().string();
167  std::vector<std::string> tokens;
168  boost::split(tokens, file_name, boost::is_any_of("."));
169  // ref. FileMgr::init for hint of data file name layout
170  if (tokens.size() > 2 && MAPD_FILE_EXT == "." + tokens[2]) {
171  thread_controller.startThread([file_name, file_path, tokens, &column_ids_map] {
172  const auto page_size = boost::lexical_cast<int64_t>(tokens[1]);
173  const auto file_size = boost::filesystem::file_size(file_path);
174  std::unique_ptr<FILE, decltype(simple_file_closer)> fp(
175  std::fopen(file_path.c_str(), "r+"), simple_file_closer);
176  if (!fp) {
177  throw std::runtime_error("Failed to open " + file_path +
178  " for update: " + std::strerror(errno));
179  }
180  // ref. FileInfo::openExistingFile for hint of chunk header layout
181  for (size_t page = 0; page < file_size / page_size; ++page) {
182  int ints[8];
183  if (0 != std::fseek(fp.get(), page * page_size, SEEK_SET)) {
184  throw std::runtime_error("Failed to seek to page# " + std::to_string(page) +
185  file_path + " for read: " + std::strerror(errno));
186  }
187  if (1 != fread(ints, sizeof ints, 1, fp.get())) {
188  throw std::runtime_error("Failed to read " + file_path + ": " +
189  std::strerror(errno));
190  }
191  if (ints[0] > 0) { // header size
192  auto cit = column_ids_map.find(ints[3]);
193  CHECK(cit != column_ids_map.end());
194  if (ints[3] != cit->second) {
195  ints[3] = cit->second;
196  if (0 != std::fseek(fp.get(), page * page_size, SEEK_SET)) {
197  throw std::runtime_error("Failed to seek to page# " +
198  std::to_string(page) + file_path +
199  " for write: " + std::strerror(errno));
200  }
201  if (1 != fwrite(ints, sizeof ints, 1, fp.get())) {
202  throw std::runtime_error("Failed to write " + file_path + ": " +
203  std::strerror(errno));
204  }
205  }
206  }
207  }
208  });
209  thread_controller.checkThreadsStatus();
210  }
211  }
212  }
213  thread_controller.finish();
214 }
215 
217  const std::string& temp_data_dir,
218  const std::vector<std::string>& target_paths,
219  const std::string& name_prefix) {
220  boost::filesystem::path base_path(temp_data_dir);
221  boost::filesystem::directory_iterator end_it;
222  int target_path_index = 0;
223  for (boost::filesystem::directory_iterator fit(base_path); fit != end_it; ++fit) {
224  if (!boost::filesystem::is_regular_file(fit->status())) {
225  const std::string file_path = fit->path().string();
226  const std::string file_name = fit->path().filename().string();
227  if (boost::istarts_with(file_name, name_prefix)) {
228  const std::string target_path =
229  abs_path(global_file_mgr) + "/" + target_paths[target_path_index++];
230  if (std::rename(file_path.c_str(), target_path.c_str())) {
231  throw std::runtime_error("Failed to rename file " + file_path + " to " +
232  target_path + ": " + std::strerror(errno));
233  }
234  }
235  }
236  }
237 }
238 
239 } // namespace
240 
242  const std::string& archive_path,
243  const std::string& compression) {
246  if (g_cluster) {
247  throw std::runtime_error("DUMP/RESTORE is not supported yet on distributed setup.");
248  }
249  if (boost::filesystem::exists(archive_path)) {
250  throw std::runtime_error("Archive " + archive_path + " already exists.");
251  }
253  throw std::runtime_error("Dumping view or temporary table is not supported.");
254  }
255  // collect paths of files to archive
256  const auto global_file_mgr = cat_->getDataMgr().getGlobalFileMgr();
257  std::vector<std::string> file_paths;
258  auto file_writer = [&file_paths, global_file_mgr](const std::string& file_name,
259  const std::string& file_type,
260  const std::string& file_data) {
261  const auto file_path = abs_path(global_file_mgr) + "/" + file_name;
262  std::unique_ptr<FILE, decltype(simple_file_closer)> fp(
263  std::fopen(file_path.c_str(), "w"), simple_file_closer);
264  if (!fp) {
265  throw std::runtime_error("Failed to create " + file_type + " file '" + file_path +
266  "': " + std::strerror(errno));
267  }
268  if (std::fwrite(file_data.data(), 1, file_data.size(), fp.get()) < file_data.size()) {
269  throw std::runtime_error("Failed to write " + file_type + " file '" + file_path +
270  "': " + std::strerror(errno));
271  }
272  file_paths.push_back(file_name);
273  };
274  // Prevent modification of the table schema during a dump operation, while allowing
275  // concurrent inserts.
276  auto table_read_lock =
278  const auto table_name = td->tableName;
279  {
280  // - gen schema file
281  const auto schema_str = cat_->dumpSchema(td);
282  file_writer(table_schema_filename, "table schema", schema_str);
283  // - gen column-old-info file
284  const auto cds = cat_->getAllColumnMetadataForTable(td->tableId, true, true, true);
285  std::vector<std::string> column_oldinfo;
286  std::transform(cds.begin(),
287  cds.end(),
288  std::back_inserter(column_oldinfo),
289  [&](const auto cd) -> std::string {
290  return cd->columnName + ":" + std::to_string(cd->columnId) + ":" +
291  cat_->getColumnDictDirectory(cd);
292  });
293  const auto column_oldinfo_str = boost::algorithm::join(column_oldinfo, " ");
294  file_writer(table_oldinfo_filename, "table old info", column_oldinfo_str);
295  // - gen table epoch
296  const auto epoch = cat_->getTableEpoch(cat_->getCurrentDB().dbId, td->tableId);
297  file_writer(table_epoch_filename, "table epoch", std::to_string(epoch));
298  // - collect table data file paths ...
299  const auto data_file_dirs = cat_->getTableDataDirectories(td);
300  file_paths.insert(file_paths.end(), data_file_dirs.begin(), data_file_dirs.end());
301  // - collect table dict file paths ...
302  const auto dict_file_dirs = cat_->getTableDictDirectories(td);
303  file_paths.insert(file_paths.end(), dict_file_dirs.begin(), dict_file_dirs.end());
304  // tar takes time. release cat lock to yield the cat to concurrent CREATE statements.
305  }
306  // run tar to archive the files ... this may take a while !!
307  run("tar " + compression + " -cvf " + get_quoted_string(archive_path) + " " +
308  boost::algorithm::join(file_paths, " "),
309  abs_path(global_file_mgr));
310 }
311 
312 // Restore data and dict files of a table from a tgz archive.
314  const TableDescriptor* td,
315  const std::string& archive_path,
316  const std::string& compression) {
319  if (g_cluster) {
320  throw std::runtime_error("DUMP/RESTORE is not supported yet on distributed setup.");
321  }
322  if (!boost::filesystem::exists(archive_path)) {
323  throw std::runtime_error("Archive " + archive_path + " does not exist.");
324  }
326  throw std::runtime_error("Restoring view or temporary table is not supported.");
327  }
328  // Obtain table schema read lock to prevent modification of the schema during
329  // restoration
330  const auto table_read_lock =
332  // prevent concurrent inserts into table during restoration
333  const auto insert_data_lock =
335 
336  // untar takes time. no grab of cat lock to yield to concurrent CREATE stmts.
337  const auto global_file_mgr = cat_->getDataMgr().getGlobalFileMgr();
338  // dirs where src files are untarred and dst files are backed up
339  constexpr static const auto temp_data_basename = "_data";
340  constexpr static const auto temp_back_basename = "_back";
341  const auto temp_data_dir = abs_path(global_file_mgr) + "/" + temp_data_basename;
342  const auto temp_back_dir = abs_path(global_file_mgr) + "/" + temp_back_basename;
343  // clean up tmp dirs and files in any case
344  auto tmp_files_cleaner = [&](void*) {
345  run("rm -rf " + temp_data_dir + " " + temp_back_dir);
346  run("rm -f " + abs_path(global_file_mgr) + "/" + table_schema_filename);
347  run("rm -f " + abs_path(global_file_mgr) + "/" + table_oldinfo_filename);
348  run("rm -f " + abs_path(global_file_mgr) + "/" + table_epoch_filename);
349  };
350  std::unique_ptr<decltype(tmp_files_cleaner), decltype(tmp_files_cleaner)> tfc(
351  &tmp_files_cleaner, tmp_files_cleaner);
352  // extract & parse schema
353  const auto schema_str = get_table_schema(archive_path, td->tableName, compression);
354  const auto create_table_stmt =
355  Parser::parseDDL<Parser::CreateTableStmt>("table schema", schema_str);
356  // verify compatibility between source and destination schemas
357  TableDescriptor src_td;
358  std::list<ColumnDescriptor> src_columns;
359  std::vector<Parser::SharedDictionaryDef> shared_dict_defs;
360  create_table_stmt->executeDryRun(session, src_td, src_columns, shared_dict_defs);
361  // - sanity check table-level compatibility
362  if (src_td.hasDeletedCol != td->hasDeletedCol) {
363  // TODO: allow the case, in which src data enables vacuum while
364  // dst doesn't, by simply discarding src $deleted column data.
365  throw std::runtime_error("Incompatible table VACCUM option");
366  }
367  if (src_td.nShards != td->nShards) {
368  // TODO: allow different shard numbers if they have a "GCD",
369  // by splitting/merging src data files before drop into dst.
370  throw std::runtime_error("Unmatched number of table shards");
371  }
372  // - sanity check column-level compatibility (based on column names)
373  const auto dst_columns =
374  cat_->getAllColumnMetadataForTable(td->tableId, false, false, false);
375  if (dst_columns.size() != src_columns.size()) {
376  throw std::runtime_error("Unmatched number of table columns");
377  }
378  for (const auto& [src_cd, dst_cd] : boost::combine(src_columns, dst_columns)) {
379  if (src_cd.columnType.get_type_name() != dst_cd->columnType.get_type_name() ||
380  src_cd.columnType.get_compression_name() !=
381  dst_cd->columnType.get_compression_name()) {
382  throw std::runtime_error("Incompatible types on column " + src_cd.columnName);
383  }
384  }
385  // extract src table column ids (ALL columns incl. system/virtual/phy geo cols)
386  const auto all_src_oldinfo_str =
387  simple_file_cat(archive_path, table_oldinfo_filename, compression);
388  std::vector<std::string> src_oldinfo_strs;
389  boost::algorithm::split(src_oldinfo_strs,
390  all_src_oldinfo_str,
391  boost::is_any_of(" "),
392  boost::token_compress_on);
393  auto all_dst_columns =
394  cat_->getAllColumnMetadataForTable(td->tableId, true, true, true);
395  if (src_oldinfo_strs.size() != all_dst_columns.size()) {
396  throw std::runtime_error("Source table has a unmatched number of columns: " +
397  std::to_string(src_oldinfo_strs.size()) + " vs " +
398  std::to_string(all_dst_columns.size()));
399  }
400  // build a map of src column ids and dst column ids, just in case src table has been
401  // ALTERed before and chunk keys of src table needs to be adjusted accordingly.
402  // note: this map is used only for the case of migrating a table and not for restoring
403  // a table. When restoring a table, the two tables must have the same column ids.
404  //
405  // also build a map of src dict paths and dst dict paths for relocating src dicts
406  std::unordered_map<int, int> column_ids_map;
407  std::unordered_map<std::string, std::string> dict_paths_map;
408  // sort inputs of transform in lexical order of column names for correct mappings
409  std::list<std::vector<std::string>> src_oldinfo_tokens;
410  std::transform(
411  src_oldinfo_strs.begin(),
412  src_oldinfo_strs.end(),
413  std::back_inserter(src_oldinfo_tokens),
414  [](const auto& src_oldinfo_str) -> auto {
415  std::vector<std::string> tokens;
417  tokens, src_oldinfo_str, boost::is_any_of(":"), boost::token_compress_on);
418  return tokens;
419  });
420  src_oldinfo_tokens.sort(
421  [](const auto& lhs, const auto& rhs) { return lhs[0].compare(rhs[0]) < 0; });
422  all_dst_columns.sort(
423  [](auto a, auto b) { return a->columnName.compare(b->columnName) < 0; });
424  // transform inputs into the maps
425  std::transform(src_oldinfo_tokens.begin(),
426  src_oldinfo_tokens.end(),
427  all_dst_columns.begin(),
428  std::inserter(column_ids_map, column_ids_map.end()),
429  [&](const auto& tokens, const auto& cd) -> std::pair<int, int> {
430  VLOG(3) << boost::algorithm::join(tokens, ":") << " ==> "
431  << cd->columnName << ":" << cd->columnId;
432  dict_paths_map[tokens[2]] = cat_->getColumnDictDirectory(cd);
433  return {boost::lexical_cast<int>(tokens[1]), cd->columnId};
434  });
435  bool was_table_altered = false;
436  std::for_each(column_ids_map.begin(), column_ids_map.end(), [&](auto& it) {
437  was_table_altered = was_table_altered || it.first != it.second;
438  });
439  VLOG(3) << "was_table_altered = " << was_table_altered;
440  // extract all data files to a temp dir. will swap with dst table dir after all set,
441  // otherwise will corrupt table in case any bad thing happens in the middle.
442  run("rm -rf " + temp_data_dir);
443  run("mkdir -p " + temp_data_dir);
444  run("tar " + compression + " -xvf " + get_quoted_string(archive_path), temp_data_dir);
445  // if table was ever altered after it was created, update column ids in chunk headers.
446  if (was_table_altered) {
447  const auto time_ms = measure<>::execution(
448  [&]() { adjust_altered_table_files(temp_data_dir, column_ids_map); });
449  VLOG(3) << "adjust_altered_table_files: " << time_ms << " ms";
450  }
451  // finally,,, swap table data/dict dirs!
452  const auto data_file_dirs = cat_->getTableDataDirectories(td);
453  const auto dict_file_dirs = cat_->getTableDictDirectories(td);
454  // move current target dirs, if exists, to backup dir
455  std::vector<std::string> both_file_dirs;
456  std::merge(data_file_dirs.begin(),
457  data_file_dirs.end(),
458  dict_file_dirs.begin(),
459  dict_file_dirs.end(),
460  std::back_inserter(both_file_dirs));
461  bool backup_completed = false;
462  try {
463  run("rm -rf " + temp_back_dir);
464  run("mkdir -p " + temp_back_dir);
465  for (const auto& dir : both_file_dirs) {
466  const auto dir_full_path = abs_path(global_file_mgr) + "/" + dir;
467  if (boost::filesystem::is_directory(dir_full_path)) {
468  run("mv " + dir_full_path + " " + temp_back_dir);
469  }
470  }
471  backup_completed = true;
472  // accord src data dirs to dst
474  cat_->getDataMgr().getGlobalFileMgr(), temp_data_dir, data_file_dirs, "table_");
475  // accord src dict dirs to dst
476  for (const auto& dit : dict_paths_map) {
477  if (!dit.first.empty() && !dit.second.empty()) {
478  const auto src_dict_path = temp_data_dir + "/" + dit.first;
479  const auto dst_dict_path = abs_path(global_file_mgr) + "/" + dit.second;
480  run("mv " + src_dict_path + " " + dst_dict_path);
481  }
482  }
483  // throw if sanity test forces a rollback
485  throw std::runtime_error("lol!");
486  }
487  } catch (...) {
488  // once backup is completed, whatever in abs_path(global_file_mgr) is the "src"
489  // dirs that are to be rolled back and discarded
490  if (backup_completed) {
491  run("rm -rf " + boost::algorithm::join(both_file_dirs, " "),
492  abs_path(global_file_mgr));
493  }
494  // complete rollback by recovering original "dst" table dirs from backup dir
495  boost::filesystem::path base_path(temp_back_dir);
496  boost::filesystem::directory_iterator end_it;
497  for (boost::filesystem::directory_iterator fit(base_path); fit != end_it; ++fit) {
498  run("mv " + fit->path().string() + " .", abs_path(global_file_mgr));
499  }
500  throw;
501  }
502  // set for reloading table from the restored/migrated files
503  const auto epoch = simple_file_cat(archive_path, table_epoch_filename, compression);
504  cat_->setTableEpoch(
505  cat_->getCurrentDB().dbId, td->tableId, boost::lexical_cast<int>(epoch));
506 }
507 
508 // Migrate a table, which doesn't exist in current db, from a tar ball to the db.
509 // This actually creates the table and restores data/dict files from the tar ball.
511  const std::string& table_name,
512  const std::string& archive_path,
513  const std::string& compression) {
514  // replace table name and drop foreign dict references
515  const auto schema_str = get_table_schema(archive_path, table_name, compression);
516  Parser::parseDDL<Parser::CreateTableStmt>("table schema", schema_str)->execute(session);
517  try {
518  restoreTable(
519  session, cat_->getMetadataForTable(table_name), archive_path, compression);
520  } catch (...) {
521  Parser::parseDDL<Parser::DropTableStmt>("statement",
522  "DROP TABLE IF EXISTS " + table_name + ";")
523  ->execute(session);
524  throw;
525  }
526 }
std::string getBasePath() const
std::string get_table_schema(const std::string &archive_path, const std::string &table, const std::string &compression)
static ReadLock getReadLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:164
static constexpr char const * table_schema_filename
std::string tableName
std::string abs_path(const File_Namespace::GlobalFileMgr *global_file_mgr)
#define LOG(tag)
Definition: Logger.h:188
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
void adjust_altered_table_files(const std::string &temp_data_dir, const std::unordered_map< int, int > &column_ids_map)
std::string join(T const &container, std::string const &delim)
#define MAPD_FILE_EXT
Definition: File.h:25
static constexpr char const * table_oldinfo_filename
void restoreTable(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td, const std::string &archive_path, const std::string &compression)
std::string to_string(char const *&&v)
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings
std::string get_quoted_string(const std::string &filename, char quote, char escape)
Quote a string while escaping any existing quotes in the string.
bool g_cluster
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t const int64_t int32_t * error_code
void rename_table_directories(const File_Namespace::GlobalFileMgr *global_file_mgr, const std::string &temp_data_dir, const std::vector< std::string > &target_paths, const std::string &name_prefix)
void validate_allowed_file_path(const std::string &file_path, const DataTransferType data_transfer_type, const bool allow_wildcards)
Definition: DdlUtils.cpp:611
void startThread(FuncType &&func, Args &&... args)
Data_Namespace::MemoryLevel persistenceLevel
static constexpr char const * table_epoch_filename
#define CHECK(condition)
Definition: Logger.h:197
static TimeT::rep execution(F func, Args &&... args)
Definition: sample.cpp:29
static bool run
specifies the content in-memory of a row in the table metadata table
std::string simple_file_cat(const std::string &archive_path, const std::string &file_name, const std::string &compression)
int cpu_threads()
Definition: thread_count.h:24
void dumpTable(const TableDescriptor *td, const std::string &archive_path, const std::string &compression)
A selection of helper methods for File I/O.
#define VLOG(n)
Definition: Logger.h:291
bool g_test_rollback_dump_restore
size_t file_size(const int fd)
Definition: omnisci_fs.cpp:31