OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StringTransform.h File Reference
#include "Logger.h"
#include <boost/config.hpp>
#include <boost/regex.hpp>
#include <optional>
#include <string_view>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
+ Include dependency graph for StringTransform.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 anonymous_namespace{StringTransform.h}
 

Functions

void apply_shim (std::string &result, const boost::regex &reg_expr, const std::function< void(std::string &, const boost::smatch &)> &shim_fn)
 
template<typename... Ts>
std::string cat (Ts &&...args)
 
std::vector< std::pair< size_t,
size_t > > 
find_string_literals (const std::string &query)
 
std::string hide_sensitive_data_from_query (std::string const &query_str)
 
ssize_t inside_string_literal (const size_t start, const size_t length, const std::vector< std::pair< size_t, size_t >> &literal_positions)
 
template<typename T >
std::string join (T const &container, std::string const &delim)
 
template<typename T >
std::string to_string (T &&v)
 
template<>
std::string to_string (char const *&&v)
 
template<>
std::string to_string (std::string &&v)
 
std::string to_upper (const std::string &str)
 
std::string to_lower (const std::string &str)
 
std::string generate_random_string (const size_t len)
 
std::vector< std::string > split (std::string_view str, std::string_view delim={}, std::optional< size_t > maxsplit=std::nullopt)
 split apart a string into a vector of substrings More...
 
std::string strip (std::string_view str)
 trim any whitespace from the left and right ends of a string More...
 
bool remove_unquoted_newlines_linefeeds_and_tabs_from_sql_string (std::string &str) noexcept
 sanitize an SQL string More...
 
bool unquote (std::string &)
 
std::string get_quoted_string (const std::string &filename, char quote= '"', char escape = '\\')
 Quote a string while escaping any existing quotes in the string. More...
 
void filename_security_check (const std::string &filename)
 Throw exception if security problems found in a filename. More...
 
template<typename T >
decltype(auto) anonymous_namespace{StringTransform.h}::stringlike (T &&parm)
 
template<typename... Types>
std::string concat (Types &&...parms)
 
template<typename... Types>
std::string concat_with (std::string_view with, Types &&...parms)
 

Function Documentation

void apply_shim ( std::string &  result,
const boost::regex &  reg_expr,
const std::function< void(std::string &, const boost::smatch &)> &  shim_fn 
)

Definition at line 28 of file StringTransform.cpp.

References find_string_literals(), and inside_string_literal().

Referenced by QueryRunner::apply_copy_to_shim(), DBHandler::apply_copy_to_shim(), and anonymous_namespace{CalciteAdapter.cpp}::pg_shim_impl().

30  {
31  boost::smatch what;
32  std::vector<std::pair<size_t, size_t>> lit_pos = find_string_literals(result);
33  auto start_it = result.cbegin();
34  auto end_it = result.cend();
35  while (true) {
36  if (!boost::regex_search(start_it, end_it, what, reg_expr)) {
37  break;
38  }
39  const auto next_start =
40  inside_string_literal(what.position(), what.length(), lit_pos);
41  if (next_start >= 0) {
42  start_it = result.cbegin() + next_start;
43  } else {
44  shim_fn(result, what);
45  lit_pos = find_string_literals(result);
46  start_it = result.cbegin();
47  end_it = result.cend();
48  }
49  }
50 }
ssize_t inside_string_literal(const size_t start, const size_t length, const std::vector< std::pair< size_t, size_t >> &literal_positions)
std::vector< std::pair< size_t, size_t > > find_string_literals(const std::string &query)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename... Ts>
std::string cat ( Ts &&...  args)

Definition at line 42 of file StringTransform.h.

References run_benchmark_import::args.

Referenced by AlterForeignServerCommand::changeForeignServerOwner(), DBHandler::check_table_load_privileges(), Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), DBHandler::checkpoint(), DBHandler::clone_session(), anonymous_namespace{InputMetadata.cpp}::collect_table_infos(), QueryCompilationDescriptor::compile(), DBHandler::connect(), Fragmenter_Namespace::copyDataOfShard(), DBHandler::create_dashboard(), DBHandler::create_link(), Catalog_Namespace::SysCatalog::createDatabase(), DBHandler::delete_dashboards(), anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), Catalog_Namespace::SysCatalog::dropDatabase(), DBHandler::execute_rel_alg(), DBHandler::execute_rel_alg_df(), anonymous_namespace{GroupByAndAggregate.cpp}::expr_is_rowid(), Executor::fetchChunks(), Executor::fetchUnionChunks(), DBHandler::get_dashboard(), DBHandler::get_dashboard_grantees(), DBHandler::get_dashboards(), DBHandler::get_db_object_privs(), DBHandler::get_link_view(), DBHandler::get_table_details_impl(), DBHandler::get_table_epoch(), DBHandler::get_table_epoch_by_name(), DBHandler::get_tables_meta_impl(), DBHandler::get_valid_groups(), Calcite::getCompletionHints(), QueryRunner::QueryRunner::getLoader(), ColumnFetcher::getOneTableColumnFragment(), QueryRunner::QueryRunner::getParsedQueryHintofQuery(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getReadLockForTable(), InputTableInfoCache::getTableInfo(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), DBHandler::has_object_privilege(), DBHandler::hasTableAccessPrivileges(), DBHandler::import_geo_table(), DBHandler::import_table(), QueryRunner::ImportDriver::importGeoTable(), DBHandler::insert_data(), Fragmenter_Namespace::InsertDataLoader::insertData(), DBHandler::internal_connect(), DBHandler::interrupt(), DBHandler::load_table(), DBHandler::load_table_binary(), DBHandler::load_table_binary_columnar(), main(), migrations::MigrationMgr::migrateDateInDaysMetadata(), normalize_column_pair(), normalize_column_pairs(), DBHandler::parse_to_ra(), DBHandler::prepare_columnar_loader(), Calcite::processImpl(), QueryRunner::QueryRunner::QueryRunner(), AlterForeignServerCommand::renameForeignServer(), DBHandler::replace_dashboard(), QueryRewriter::rewriteColumnarUpdate(), QueryRunner::anonymous_namespace{QueryRunner.cpp}::run_select_query_with_filter_push_down(), QueryRunner::QueryRunner::runSelectQuery(), QueryRunner::QueryRunner::runSQLWithAllowingInterrupt(), import_export::RenderGroupAnalyzer::seedFromExistingTableContents(), Catalog_Namespace::Catalog::set(), DBHandler::set_table_epoch(), DBHandler::set_table_epoch_by_name(), AlterForeignServerCommand::setForeignServerDataWrapper(), AlterForeignServerCommand::setForeignServerOptions(), DBHandler::sql_execute_impl(), DBHandler::switch_database(), Catalog_Namespace::SysCatalog::switchDatabase(), anonymous_namespace{QueryMemoryDescriptor.cpp}::target_expr_proj_indices(), RelLogicalUnion::toString(), anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources_for_update(), DBHandler::user_can_access_table(), and DBHandler::validateDashboardIdsForSharing().

42  {
43  std::ostringstream oss;
44 #ifdef BOOST_NO_CXX17_FOLD_EXPRESSIONS
45  (void)(int[]){0, ((void)(oss << std::forward<Ts>(args)), 0)...};
46 #else
47  (oss << ... << std::forward<Ts>(args));
48 #endif
49  return oss.str();
50 }
template<typename... Types>
std::string concat ( Types &&...  parms)

Definition at line 175 of file StringTransform.h.

References File_Namespace::append(), and anonymous_namespace{StringTransform.h}::stringlike().

Referenced by SQLTypeInfo::to_string().

175  {
176  struct Joiner {
177  Joiner() {}
178 
179  std::string txt;
180 
181  void append(std::string_view moretxt) { txt += moretxt; }
182  }; // struct Joiner
183  Joiner j{};
184  (j.append(stringlike(std::forward<Types>(parms))), ...);
185  return std::move(j.txt);
186 }
size_t append(FILE *f, const size_t size, int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
Definition: File.cpp:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename... Types>
std::string concat_with ( std::string_view  with,
Types &&...  parms 
)

Definition at line 189 of file StringTransform.h.

References File_Namespace::append(), join(), and anonymous_namespace{StringTransform.h}::stringlike().

189  {
190  struct JoinerWith {
191  JoinerWith(std::string_view join) : join(join), first(true) {}
192 
193  std::string_view join;
194  bool first;
195  std::string txt;
196 
197  void append(std::string_view moretxt) {
198  if (!first) {
199  txt += join;
200  } else {
201  first = false;
202  }
203  txt += moretxt;
204  }
205  }; // struct JoinerWith
206  JoinerWith j{with};
207  (j.append(stringlike(std::forward<Types>(parms))), ...);
208  return std::move(j.txt);
209 }
std::string join(T const &container, std::string const &delim)
size_t append(FILE *f, const size_t size, int8_t *buf)
Appends the specified number of bytes to the end of the file f from buf.
Definition: File.cpp:135
bool g_enable_smem_group_by true

+ Here is the call graph for this function:

void filename_security_check ( const std::string &  filename)

Throw exception if security problems found in a filename.

Definition at line 243 of file StringTransform.cpp.

References error_code.

Referenced by TableArchiver::dumpTable(), TableArchiver::restoreTable(), and anonymous_namespace{TableArchiver.cpp}::simple_file_cat().

243  {
244  // We can always relax some of these rules later.
245 
246  // Canonicalize the filename, rejecting it if this basic step fails.
248  auto can = boost::filesystem::weakly_canonical(
249  filename, ec); // TODO: prevents string_view Jun 2020
250  if (ec) {
251  throw std::runtime_error("invalid filename: " + filename);
252  }
253 
254  // Reject any filenames containing whitespace for now.
255  for (const auto& ch : filename) {
256  if (std::isspace(ch)) {
257  throw std::runtime_error("invalid filename (whitespace): " + filename);
258  }
259  }
260 
261  // Reject any punctuation characters except for a few safe ones.
262  static const std::string safe_punctuation{"./_+-=:"};
263  for (const auto& ch : filename) {
264  if (std::ispunct(ch) && safe_punctuation.find(ch) == std::string::npos) {
265  throw std::runtime_error("invalid filename (punctuation): " + filename);
266  }
267  }
268 
269  // Reject any blacklisted filenames.
270  static const std::vector<std::string> blacklisted_filenames = {
271  "/etc/passwd", "/etc/passwd-", "/etc/shadow", "/etc/shadow-"};
272  if (std::find(blacklisted_filenames.begin(),
273  blacklisted_filenames.end(),
274  can.string()) != blacklisted_filenames.end()) {
275  throw std::runtime_error("invalid filename (blacklist): " + filename);
276  }
277 }
std::string filename(char const *path)
Definition: Logger.cpp:62
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

+ Here is the caller graph for this function:

std::vector<std::pair<size_t, size_t> > find_string_literals ( const std::string &  query)

Definition at line 52 of file StringTransform.cpp.

References CHECK_GT.

Referenced by apply_shim().

52  {
53  boost::regex literal_string_regex{R"(([^']+)('(?:[^']+|'')+'))", boost::regex::perl};
54  boost::smatch what;
55  auto it = query.begin();
56  auto prev_it = it;
57  std::vector<std::pair<size_t, size_t>> positions;
58  while (true) {
59  if (!boost::regex_search(it, query.end(), what, literal_string_regex)) {
60  break;
61  }
62  CHECK_GT(what[1].length(), 0);
63  prev_it = it;
64  it += what.length();
65  positions.emplace_back(prev_it + what[1].length() - query.begin(),
66  it - query.begin());
67  }
68  return positions;
69 }
#define CHECK_GT(x, y)
Definition: Logger.h:209

+ Here is the caller graph for this function:

std::string generate_random_string ( const size_t  len)

Definition at line 107 of file StringTransform.cpp.

Referenced by DBHandler::create_new_session(), DBHandler::createInMemoryCalciteSession(), Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider(), and Catalog_Namespace::SysCatalog::updateBlankPasswordsToRandom().

107  {
108  static char charset[] =
109  "0123456789"
110  "abcdefghijklmnopqrstuvwxyz"
111  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
112 
113  static std::mt19937 prng{std::random_device{}()};
114  static std::uniform_int_distribution<size_t> dist(0, strlen(charset) - 1);
115 
116  std::string str;
117  str.reserve(len);
118  for (size_t i = 0; i < len; i++) {
119  str += charset[dist(prng)];
120  }
121  return str;
122 }

+ Here is the caller graph for this function:

std::string get_quoted_string ( const std::string &  filename,
char  quote = '"',
char  escape = '\\' 
)

Quote a string while escaping any existing quotes in the string.

Definition at line 237 of file StringTransform.cpp.

Referenced by TableArchiver::dumpTable(), TableArchiver::restoreTable(), and anonymous_namespace{TableArchiver.cpp}::simple_file_cat().

237  {
238  std::stringstream ss;
239  ss << std::quoted(filename, quote, escape); // TODO: prevents string_view Jun 2020
240  return ss.str();
241 }
std::string filename(char const *path)
Definition: Logger.cpp:62

+ Here is the caller graph for this function:

std::string hide_sensitive_data_from_query ( std::string const &  query_str)

Definition at line 71 of file StringTransform.cpp.

Referenced by query_state::StdLog::log().

71  {
72  constexpr std::regex::flag_type flags =
73  std::regex::ECMAScript | std::regex::icase | std::regex::optimize;
74  static const std::initializer_list<std::pair<std::regex, std::string>> rules{
75  {std::regex(R"(\b((?:password|s3_access_key|s3_secret_key)\s*=\s*)'.+?')", flags),
76  "$1'XXXXXXXX'"},
77  {std::regex(R"((\\set_license\s+)\S+)", flags), "$1XXXXXXXX"}};
78  return std::accumulate(
79  rules.begin(), rules.end(), query_str, [](auto& str, auto& rule) {
80  return std::regex_replace(str, rule.first, rule.second);
81  });
82 }

+ Here is the caller graph for this function:

ssize_t inside_string_literal ( const size_t  start,
const size_t  length,
const std::vector< std::pair< size_t, size_t >> &  literal_positions 
)

Definition at line 84 of file StringTransform.cpp.

Referenced by apply_shim().

87  {
88  const auto end = start + length;
89  for (const auto& literal_position : literal_positions) {
90  if (literal_position.first <= start && end <= literal_position.second) {
91  return literal_position.second;
92  }
93  }
94  return -1;
95 }

+ Here is the caller graph for this function:

template<typename T >
std::string join ( T const &  container,
std::string const &  delim 
)

Definition at line 64 of file StringTransform.h.

Referenced by ResultSetReductionJIT::cacheKey(), anonymous_namespace{Execute.cpp}::checkWorkUnitWatchdog(), concat_with(), DBHandler::connect_impl(), org.apache.calcite.sql2rel.SqlToRelConverter::convertFrom(), org.apache.calcite.sql2rel.SqlToRelConverter::convertMerge(), anonymous_namespace{RelLeftDeepInnerJoin.cpp}::create_left_deep_join(), DBHandler::create_table(), datum_to_string(), Catalog_Namespace::Catalog::dumpCreateTable(), Catalog_Namespace::Catalog::dumpSchema(), TableArchiver::dumpTable(), RelAlgExecutor::executeRelAlgQueryNoRetry(), ProxyTHttpClient::flush(), anonymous_namespace{SerializeToSql.cpp}::from_to_string(), generate_loop_ref::generate(), create_table.SyntheticTable::generateData(), anonymous_namespace{RelAlgExecutor.cpp}::get_data_sink(), anonymous_namespace{RelAlgOptimizer.cpp}::get_field_name(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_source_used_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), get_left_deep_join_root(), anonymous_namespace{RelAlgOptimizer.cpp}::get_live_ins(), run_benchmark::get_machine_info(), get_qualified_column_hints(), anonymous_namespace{RelAlgOptimizer.cpp}::get_visible_projects(), ExtensionFunctionsWhitelist::getLLVMDeclarations(), anonymous_namespace{SerializeToSql.cpp}::group_by_to_string(), hoist_filter_cond_to_cross_join(), QueryRunner::ImportDriver::importGeoTable(), anonymous_namespace{RelAlgDagBuilder.cpp}::isRenamedInput(), anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string(), org.apache.calcite.rel.rules.DynamicFilterJoinRule::onMatch(), org.apache.calcite.rel.rules.OuterJoinOptViaNullRejectionRule::onMatch(), operator<<(), org.apache.calcite.rel.rules.DynamicFilterJoinRule::performSelectivePushDown(), anonymous_namespace{RelAlgOptimizer.cpp}::pick_always_live_col_idx(), anonymous_namespace{RelAlgOptimizer.cpp}::propagate_input_renumbering(), anonymous_namespace{RelAlgOptimizer.cpp}::redirect_inputs_of(), QueryMemoryDescriptor::reductionKey(), org.apache.calcite.sql2rel.SqlToRelConverter.Blackboard::register(), TableArchiver::restoreTable(), com.mapd.calcite.parser.MapDParser::rewriteSimpleUpdateAsSelect(), logger::LogOptions::set_options(), sink_projected_boolean_expr_to_join(), org.apache.calcite.sql2rel.SqlToRelConverter::substituteSubQuery(), Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider(), anonymous_namespace{SerializeToSql.cpp}::targets_to_string(), org.apache.calcite.sql2rel.SqlToRelConverter::translateIn(), foreign_storage::ForeignServer::validate(), DBHandler::validateDashboardIdsForSharing(), RelAlgVisitor< std::unordered_set< int > >::visit(), ScalarExprToSql::visitFunctionOper(), anonymous_namespace{RelAlgOptimizer.cpp}::RexProjectInputRedirector::visitInput(), anonymous_namespace{RelAlgOptimizer.cpp}::RexInputCollector::visitInput(), anonymous_namespace{RelAlgOptimizer.cpp}::RexInputRedirector::visitInput(), ScalarExprToSql::visitInValues(), anonymous_namespace{RelAlgOptimizer.cpp}::RexRebindInputsVisitor::visitNode(), ScalarExprToSql::visitWindowFunction(), anonymous_namespace{ExternalExecutor.cpp}::vt_create(), and anonymous_namespace{SerializeToSql.cpp}::where_to_string().

64  {
65  std::stringstream ss;
66  if (!container.empty()) {
67  ss << container.front();
68  for (auto itr = std::next(container.cbegin()); itr != container.cend(); ++itr) {
69  ss << delim << *itr;
70  }
71  }
72  return ss.str();
73 }
bool remove_unquoted_newlines_linefeeds_and_tabs_from_sql_string ( std::string &  str)
noexcept

sanitize an SQL string

Definition at line 187 of file StringTransform.cpp.

188  {
189  char inside_quote = 0;
190  bool previous_c_was_backslash = false;
191  for (auto& c : str) {
192  // if this character is a quote of either type
193  if (c == '\'' || c == '\"') {
194  // ignore if previous character was a backslash
195  if (!previous_c_was_backslash) {
196  // start or end of a quoted region
197  if (inside_quote == c) {
198  // end region
199  inside_quote = 0;
200  } else if (inside_quote == 0) {
201  // start region
202  inside_quote = c;
203  }
204  }
205  } else if (inside_quote == 0) {
206  // outside quoted region
207  if (c == '\n' || c == '\t' || c == '\r') {
208  // replace these with space
209  c = ' ';
210  }
211  // otherwise leave alone, including quotes of a different type
212  }
213  // handle backslashes, except for double backslashes
214  if (c == '\\') {
215  previous_c_was_backslash = !previous_c_was_backslash;
216  } else {
217  previous_c_was_backslash = false;
218  }
219  }
220  // if we didn't end a region, there were unclosed or mixed-nested quotes
221  // accounting for backslashes should mean that this should only be the
222  // case with truly malformed strings which Calcite will barf on anyway
223  return (inside_quote == 0);
224 }
std::vector<std::string> split ( std::string_view  str,
std::string_view  delim = {},
std::optional< size_t >  maxsplit = std::nullopt 
)

split apart a string into a vector of substrings

Definition at line 128 of file StringTransform.cpp.

References run_benchmark_import::result.

Referenced by anonymous_namespace{TableArchiver.cpp}::adjust_altered_table_files(), create_table.SyntheticTable::createDataAndImportTable(), com.omnisci.jdbc.OmniSciStatement::executeQuery(), anonymous_namespace{DBHandler.cpp}::extract_projection_tokens_for_completion(), get_qualified_column_hints(), TrackingProcessor::process(), Data_Namespace::ProcMeminfoParser::ProcMeminfoParser(), run_benchmark::read_query_files(), TableArchiver::restoreTable(), QueryRunner::QueryRunner::runMultipleStatements(), Parser::splitObjectHierName(), and com.mapd.parser.server.ExtensionFunctionSignatureParser::toSignature().

130  {
131  std::vector<std::string> result;
132 
133  // Use an explicit delimiter.
134  if (!delim.empty()) {
135  std::string::size_type i = 0, j = 0;
136  while ((i = str.find(delim, i)) != std::string::npos &&
137  (!maxsplit || result.size() < maxsplit.value())) {
138  result.emplace_back(str, j, i - j);
139  i += delim.size();
140  j = i;
141  }
142  result.emplace_back(str, j, std::string::npos);
143  return result;
144 
145  // Treat any number of consecutive whitespace characters as a delimiter.
146  } else {
147  bool prev_ws = true;
148  std::string::size_type i = 0, j = 0;
149  for (; i < str.size(); ++i) {
150  if (prev_ws) {
151  if (!isspace(str[i])) {
152  // start of word
153  prev_ws = false;
154  j = i;
155  }
156  } else {
157  if (isspace(str[i])) {
158  // start of space
159  result.emplace_back(str, j, i - j);
160  prev_ws = true;
161  j = i;
162  if ((maxsplit && result.size() == maxsplit.value())) {
163  // stop early if maxsplit was reached
164  result.emplace_back(str, j, std::string::npos);
165  return result;
166  }
167  }
168  }
169  }
170  if (!prev_ws) {
171  result.emplace_back(str, j, std::string::npos);
172  }
173  return result;
174  }
175 }

+ Here is the caller graph for this function:

std::string strip ( std::string_view  str)

trim any whitespace from the left and right ends of a string

Definition at line 177 of file StringTransform.cpp.

Referenced by Data_Namespace::ProcMeminfoParser::ProcMeminfoParser(), and QueryRunner::QueryRunner::runMultipleStatements().

177  {
178  std::string::size_type i, j;
179  for (i = 0; i < str.size() && std::isspace(str[i]); ++i) {
180  }
181  for (j = str.size(); j > i && std::isspace(str[j - 1]); --j) {
182  }
183  return std::string(str.substr(i, j - i));
184 }

+ Here is the caller graph for this function:

std::string to_lower ( const std::string &  str)
inline

Definition at line 100 of file StringTransform.h.

Referenced by TableFunctionCompilationContext::generateEntryPoint(), table_functions::TableFunctionsFactory::get(), lower_encoded(), Data_Namespace::ProcMeminfoParser::ProcMeminfoParser(), and anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitLower().

100  {
101  auto str_lc = str;
102  std::transform(str_lc.begin(), str_lc.end(), str_lc.begin(), ::tolower);
103  return str_lc;
104 }

+ Here is the caller graph for this function:

template<typename T >
std::string to_string ( T &&  v)

Definition at line 76 of file StringTransform.h.

76  {
77  std::ostringstream oss;
78  oss << v;
79  return oss.str();
80 }
template<>
std::string to_string ( char const *&&  v)

Definition at line 98 of file StringTransform.cpp.

Referenced by lockmgr::TableSchemaLockContainer< ReadLock >::acquireTableDescriptor(), lockmgr::TableSchemaLockContainer< WriteLock >::acquireTableDescriptor(), import_export::TypedImportBuffer::add_value(), Catalog_Namespace::Catalog::addColumn(), Catalog_Namespace::Catalog::addFrontendViewToMapNoLock(), Catalog_Namespace::Catalog::addLinkToMap(), Catalog_Namespace::Catalog::addReferenceToForeignDict(), CgenState::addStringConstant(), anonymous_namespace{TableArchiver.cpp}::adjust_altered_table_files(), anonymous_namespace{TargetExprBuilder.cpp}::agg_fn_base_names(), Catalog_Namespace::SysCatalog::alterUser(), query_state::StdLog::appendNameValuePairs(), Archive::archive_error(), import_export::QueryExporterGDAL::beginExport(), Catalog_Namespace::Catalog::buildMaps(), Catalog_Namespace::SysCatalog::buildObjectDescriptorMap(), ResultSetReductionJIT::cacheKey(), Executor::castToFP(), Catalog_Namespace::Catalog::changeForeignServerOwner(), anonymous_namespace{Execute.cpp}::checkWorkUnitWatchdog(), anonymous_namespace{GpuSharedMemoryUtils.cpp}::codegen_smem_dest_slot_ptr(), GroupByAndAggregate::codegenAggColumnPtr(), TargetExprCodegen::codegenAggregate(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenHoistedConstantsLoads(), CodeGenerator::codegenHoistedConstantsPlaceholders(), BaselineJoinHashTable::codegenMatchingSet(), GroupByAndAggregate::codegenOutputSlot(), BaselineJoinHashTable::codegenSlot(), CodeGenerator::codgenAdjustFixedEncNull(), CodeGenerator::colByteStream(), BloscCompressor::compress(), geospatial::compress_coords(), OverlapsJoinHashTable::computeBucketSizes(), DBHandler::convert_rows(), DBHandler::convert_target_metainfo(), File_Namespace::create(), DBHandler::create_dashboard(), create_dev_group_by_buffers(), DBHandler::create_table(), Catalog_Namespace::Catalog::createDashboard(), Catalog_Namespace::Catalog::createDashboardSystemRoles(), Catalog_Namespace::SysCatalog::createDatabase(), Catalog_Namespace::Catalog::createForeignServerNoLocks(), Catalog_Namespace::Catalog::createLink(), Catalog_Namespace::Catalog::createTable(), RelAlgExecutor::createTableFunctionWorkUnit(), Catalog_Namespace::SysCatalog::createUser(), anonymous_namespace{ArrowImporter.h}::data_conversion_error(), datum_to_string(), DatumToString(), ArrowResultSet::deallocateArrowResultBuffer(), BloscCompressor::decompress(), Catalog_Namespace::Catalog::delDictionary(), Catalog_Namespace::Catalog::deleteMetadataForDashboards(), Catalog_Namespace::SysCatalog::deleteObjectDescriptorMap(), Catalog_Namespace::deleteObjectPrivileges(), DecimalOverflowValidator::do_validate(), Catalog_Namespace::Catalog::dropColumn(), Catalog_Namespace::SysCatalog::dropDatabase(), Catalog_Namespace::Catalog::dropForeignServer(), Catalog_Namespace::Catalog::dropTable(), Catalog_Namespace::SysCatalog::dropUser(), Catalog_Namespace::Catalog::dumpCreateTable(), Catalog_Namespace::Catalog::dumpSchema(), TableArchiver::dumpTable(), anonymous_namespace{ResultSetReductionJIT.cpp}::emit_write_projection(), FixedLengthEncoder< T, V >::encodeDataAndUpdateStats(), anonymous_namespace{ArrowImporter.h}::error_context(), CudaMgr_Namespace::errorMessage(), Parser::CopyTableStmt::execute(), Catalog_Namespace::Catalog::executeDropTableSqliteQueries(), RelAlgExecutor::executeRelAlgQueryNoRetry(), RelAlgExecutor::executeSimpleInsert(), File_Namespace::FileMgr::FileMgr(), ProxyTHttpClient::flush(), import_export::anonymous_namespace{GDAL.cpp}::gdal_error_handler(), anonymous_namespace{JoinLoopTest.cpp}::generate_descriptors(), TableFunctionCompilationContext::generateEntryPoint(), Catalog_Namespace::Catalog::generatePhysicalTableName(), Geo_namespace::GeoPoint::GeoPoint(), anonymous_namespace{ArrowResultSetConverter.cpp}::get_arrow_type(), DBHandler::get_dashboard(), DBHandler::get_dashboard_grantees(), DateTimeUtils::get_dateadd_high_precision_adjusted_scale(), DateTimeUtils::get_dateadd_timestamp_precision_scale(), DBHandler::get_db_object_privs(), DateTimeUtils::get_extract_timestamp_precision_scale(), import_export::Detector::get_headers(), DBHandler::get_link_view(), TimeGM::get_overflow_underflow_safe_epoch(), ThriftClientConnection::get_protocol(), HitTestTypes::get_rowid_regex(), anonymous_namespace{Execute.cpp}::get_table_name(), DateTimeUtils::get_timestamp_precision_scale(), SQLTypeInfo::get_type_name(), DBHandler::get_valid_groups(), getArrowImportType(), Fragmenter_Namespace::InsertOrderFragmenter::getChunkMetadata(), Parser::LocalConnector::getColumnDescriptors(), getCurrentStackTrace(), CudaMgr_Namespace::CudaMgr::getDeviceProperties(), RelAlgExecutor::getErrorMessageFromCode(), Catalog_Namespace::Catalog::getForeignServersForUser(), Catalog_Namespace::SysCatalog::getGranteesOfSharedDashboards(), Catalog_Namespace::Catalog::getMetadataForDashboard(), Catalog_Namespace::SysCatalog::getMetadataForDBById(), Catalog_Namespace::SysCatalog::getMetadataForObject(), Catalog_Namespace::SysCatalog::getMetadataForUserById(), Catalog_Namespace::SysCatalog::getMetadataWithDefaultDB(), Catalog_Namespace::SysCatalog::getRoles(), DBHandler::has_object_privilege(), DBHandler::import_geo_table(), import_export::import_thread_delimited(), import_export::import_thread_shapefile(), File_Namespace::FileMgr::init(), anonymous_namespace{JoinHashTableInterface.cpp}::innerToString(), Catalog_Namespace::insertOrUpdateObjectPrivileges(), Executor::interrupt(), ResultSet::isGeoColOnGpu(), TableFunctionExecutionContext::launchCpuCode(), QueryExecutionContext::launchGpuCode(), DBHandler::load_table(), DBObject::loadKey(), anonymous_namespace{ExtensionFunctionsBinding.cpp}::match_arguments(), migrations::MigrationMgr::migrateDateInDaysMetadata(), Catalog_Namespace::SysCatalog::migrateDBAccessPrivileges(), numeric_type_name(), import_export::ogr_to_type(), Geo_namespace::GeoTypesError::OGRErrorToStr(), File_Namespace::open(), anonymous_namespace{ArrowImporter.h}::ArrowValue< float >::operator const std::string(), anonymous_namespace{ArrowImporter.h}::ArrowValue< double >::operator const std::string(), anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator const std::string(), logger::JsonEncoder::operator()(), operator<<(), OutOfMemory::parse_error_str(), parse_numeric(), import_export::delimited_parser::parse_string_array(), DBHandler::prepare_columnar_loader(), foreign_storage::csv_file_buffer_parser::process_geo_column(), anonymous_namespace{geo_types.cpp}::process_poly_ring(), DictionaryValueConverter< TARGET_TYPE >::processBuffer(), query_template_impl(), ra_exec_unit_desc_for_caching(), Catalog_Namespace::Catalog::recordOwnershipOfObjectsInObjectPermissions(), ResultSetReductionJIT::reduceOneEntryBaseline(), ResultSetReductionJIT::reduceOneEntryTargetsNoCollisions(), QueryMemoryDescriptor::reductionKey(), Executor::registerActiveModule(), BaselineJoinHashTable::reifyForDevice(), Catalog_Namespace::Catalog::renameColumn(), Catalog_Namespace::SysCatalog::renameDatabase(), File_Namespace::renameForDelete(), Catalog_Namespace::SysCatalog::renameObjectsInDescriptorMap(), Catalog_Namespace::Catalog::renamePhysicalTable(), Catalog_Namespace::Catalog::replaceDashboard(), TableArchiver::restoreTable(), ArrowResultSet::resultSetArrowLoopback(), Catalog_Namespace::SysCatalog::revokeAllOnDatabase_unsafe(), QueryRewriter::rewriteColumnarUpdate(), anonymous_namespace{TableArchiver.cpp}::run(), ExecutionKernel::runImpl(), import_export::QueryExporter::safeColumnName(), import_export::RenderGroupAnalyzer::seedFromExistingTableContents(), serialize_column_ref(), serialize_table_ref(), Catalog_Namespace::Catalog::setColumnDictionary(), Catalog_Namespace::Catalog::setColumnSharedDictionary(), Catalog_Namespace::Catalog::setForeignServerProperty(), Executor::skipFragment(), start_calcite_server_as_daemon(), query_state::StdLogData::StdLogData(), anonymous_namespace{StringTransform.h}::stringlike(), anonymous_namespace{ResultSetReductionJIT.cpp}::target_info_key(), DBHandler::thrift_to_copyparams(), logger::JsonEncoder::timer(), Parser::InSubquery::to_string(), Parser::InValues::to_string(), RexAbstractInput::toString(), ColSlotContext::toString(), JoinHashTableInterface::toString(), DBObject::toString(), Analyzer::ColumnVar::toString(), RexOperator::toString(), Analyzer::Var::toString(), RexSubQuery::toString(), QueryMemoryDescriptor::toString(), RexInput::toString(), Analyzer::UOper::toString(), SortField::toString(), RexRef::toString(), RexAgg::toString(), Analyzer::InIntegerSet::toString(), RelScan::toString(), RelProject::toString(), Analyzer::LikelihoodExpr::toString(), RelAggregate::toString(), RelJoin::toString(), RelFilter::toString(), Analyzer::ExtractExpr::toString(), RelLeftDeepInnerJoin::toString(), Analyzer::DateaddExpr::toString(), Analyzer::DatediffExpr::toString(), RelCompound::toString(), Analyzer::DatetruncExpr::toString(), Analyzer::OrderEntry::toString(), RelSort::toString(), RelModify::toString(), RelTableFunction::toString(), RelLogicalValues::toString(), anonymous_namespace{JoinHashTableInterface.cpp}::toStringFlat(), RelAlgTranslator::translateArrayFunction(), RelAlgTranslator::translateGeoFunctionArg(), RelAlgTranslator::translateHPTLiteral(), Executor::unregisterActiveModule(), Catalog_Namespace::SysCatalog::updateBlankPasswordsToRandom(), Fragmenter_Namespace::InsertOrderFragmenter::updateColumn(), Catalog_Namespace::Catalog::updateDeletedColumnIndicator(), Catalog_Namespace::Catalog::updateDictionaryNames(), Catalog_Namespace::Catalog::updateFixlenArrayColumns(), Catalog_Namespace::Catalog::updateGeoColumns(), Catalog_Namespace::Catalog::updateLogicalToPhysicalTableMap(), Catalog_Namespace::SysCatalog::updateObjectDescriptorMap(), Catalog_Namespace::Catalog::updatePageSize(), Catalog_Namespace::SysCatalog::updateSupportUserDeactivation(), Catalog_Namespace::Catalog::updateTableDescriptorSchema(), DateDaysOverflowValidator::validate(), CommandLineOptions::validate(), foreign_storage::ParquetDataWrapper::validateAndGetStringWithLength(), foreign_storage::CsvDataWrapper::validateAndGetStringWithLength(), and ScalarExprToSql::visitUOper().

98  {
99  return std::string(v);
100 }
template<>
std::string to_string ( std::string &&  v)

Definition at line 103 of file StringTransform.cpp.

103  {
104  return std::move(v);
105 }
std::string to_upper ( const std::string &  str)
inline

Definition at line 94 of file StringTransform.h.

Referenced by Catalog_Namespace::Catalog::addColumn(), ExtensionFunctionsWhitelist::addCommon(), Catalog_Namespace::Catalog::addTableToMap(), Catalog_Namespace::Catalog::buildMaps(), Catalog_Namespace::SysCatalog::buildRoleMap(), Catalog_Namespace::SysCatalog::createDatabase(), Catalog_Namespace::SysCatalog::createRole_unsafe(), Catalog_Namespace::Catalog::dropColumn(), Catalog_Namespace::Catalog::dropFsiSchemasAndTables(), Catalog_Namespace::SysCatalog::dropRole_unsafe(), CreateForeignServerCommand::execute(), anonymous_namespace{DBHandler.cpp}::extract_projection_tokens_for_completion(), ExtensionFunctionsWhitelist::get(), DBHandler::get_completion_hints(), ExtensionFunctionsWhitelist::get_ext_funcs(), DBHandler::get_uc_compatible_table_names_by_column(), ExtensionFunctionsWhitelist::get_udf(), Catalog_Namespace::Catalog::getDictionary(), Catalog_Namespace::SysCatalog::getGrantee(), Catalog_Namespace::is_reserved_sql_keyword(), just_whitelisted_keyword_hints(), parseStorageType(), foreign_storage::OptionsContainer::populateOptionsMap(), Catalog_Namespace::Catalog::removeTableFromMap(), Catalog_Namespace::Catalog::renameColumn(), Catalog_Namespace::SysCatalog::renameDatabase(), Catalog_Namespace::Catalog::renamePhysicalTable(), Catalog_Namespace::Catalog::roll(), Catalog_Namespace::Catalog::setForeignServerDataWrapper(), should_suggest_column_hints(), StringToDatum(), Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider(), and Catalog_Namespace::SysCatalog::updateUserRoleName().

94  {
95  auto str_uc = str;
96  std::transform(str_uc.begin(), str_uc.end(), str_uc.begin(), ::toupper);
97  return str_uc;
98 }

+ Here is the caller graph for this function:

bool unquote ( std::string &  )

Definition at line 226 of file StringTransform.cpp.

Referenced by logger::operator>>().

226  {
227  if (1 < str.size() && (str.front() == '\'' || str.front() == '"') &&
228  str.front() == str.back()) {
229  str.erase(str.size() - 1, 1);
230  str.erase(0, 1);
231  return true;
232  }
233  return false;
234 }

+ Here is the caller graph for this function: