OmniSciDB  2e3a973ef4
StringTransform.h File Reference
#include <boost/config.hpp>
#include <boost/regex.hpp>
#include <optional>
#include <string_view>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <cxxabi.h>
#include <type_traits>
+ 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.

Classes

struct  anonymous_namespace{StringTransform.h}::has_toString< T, typename >
 
struct  anonymous_namespace{StringTransform.h}::has_toString< T, decltype(std::declval< T >().toString(), void())>
 
struct  anonymous_namespace{StringTransform.h}::get_has_toString< T, typename >
 
struct  anonymous_namespace{StringTransform.h}::declval< T >().get() ->toString(), void())>
 

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)
 
std::optional< size_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...
 
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...
 
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)
 
template<typename T >
std::string typeName (const T *v)
 
template<typename T >
std::string toString (const T &v)
 
template<typename T >
std::string toString (const std::pair< T, T > &v)
 
template<typename T >
std::string toString (const std::vector< T > &v)
 

Variables

template<class T >
constexpr bool anonymous_namespace{StringTransform.h}::has_toString_v = has_toString<T>::value
 
template<class T >
constexpr bool anonymous_namespace{StringTransform.h}::get_has_toString_v = get_has_toString<T>::value
 

Function Documentation

◆ apply_shim()

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 29 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().

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

◆ cat()

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

Definition at line 40 of file StringTransform.h.

References run_benchmark_import::args, find_string_literals(), hide_sensitive_data_from_query(), and inside_string_literal().

Referenced by AlterForeignServerCommand::changeForeignServerOwner(), DBHandler::check_table_load_privileges(), Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), Catalog_Namespace::Catalog::checkedGet(), 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(), DBHandler::create_query_state(), Catalog_Namespace::SysCatalog::createDatabase(), dateTimeParse< kTIME >(), dateTimeParse< kTIMESTAMP >(), DBHandler::delete_dashboards(), anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), Catalog_Namespace::SysCatalog::dropDatabase(), RefreshForeignTablesCommand::execute(), 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_table_epochs(), DBHandler::get_tables_meta_impl(), DBHandler::get_valid_groups(), Calcite::getCompletionHints(), QueryRunner::QueryRunner::getLoader(), ColumnFetcher::getOneTableColumnFragment(), QueryRunner::QueryRunner::getParsedQueryHintofQuery(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getReadLockForTable(), Catalog_Namespace::Catalog::getSqliteConnector(), 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(), Catalog_Namespace::SysCatalog::name(), normalize_column_pair(), normalize_column_pairs(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_literal(), 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(), DBHandler::set_table_epochs(), AlterForeignServerCommand::setForeignServerDataWrapper(), AlterForeignServerCommand::setForeignServerOptions(), DBHandler::sql_execute_impl(), DBHandler::switch_database(), Catalog_Namespace::SysCatalog::switchDatabase(), anonymous_namespace{QueryMemoryDescriptor.cpp}::target_expr_proj_indices(), RexAbstractInput::toString(), RexLiteral::toString(), RexOperator::toString(), toString(), RexSubQuery::toString(), RexInput::toString(), RexCase::toString(), RexFunctionOperator::toString(), SortField::toString(), RexWindowFunctionOperator::toString(), RexRef::toString(), RexAgg::toString(), RelScan::toString(), RelProject::toString(), RelAggregate::toString(), RelJoin::toString(), RelFilter::toString(), RelCompound::toString(), RelSort::toString(), RelModify::toString(), RelTableFunction::toString(), RelLogicalUnion::toString(), anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources_for_update(), anonymous_namespace{DateTimeParser.cpp}::unixTime(), DateTimeParser::updateDateTimeAndStr(), DBHandler::user_can_access_table(), and DBHandler::validateDashboardIdsForSharing().

40  {
41  std::ostringstream oss;
42  (oss << ... << std::forward<Ts>(args));
43  return oss.str();
44 }
+ Here is the call graph for this function:

◆ concat()

template<typename... Types>
std::string concat ( Types &&...  parms)

Definition at line 163 of file StringTransform.h.

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

Referenced by SQLTypeInfo::to_string().

163  {
164  struct Joiner {
165  Joiner() {}
166 
167  std::string txt;
168 
169  void append(std::string_view moretxt) { txt += moretxt; }
170  }; // struct Joiner
171  Joiner j{};
172  (j.append(stringlike(std::forward<Types>(parms))), ...);
173  return std::move(j.txt);
174 }
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:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ concat_with()

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

Definition at line 177 of file StringTransform.h.

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

177  {
178  struct JoinerWith {
179  JoinerWith(std::string_view join) : join(join), first(true) {}
180 
181  std::string_view join;
182  bool first;
183  std::string txt;
184 
185  void append(std::string_view moretxt) {
186  if (!first) {
187  txt += join;
188  } else {
189  first = false;
190  }
191  txt += moretxt;
192  }
193  }; // struct JoinerWith
194  JoinerWith j{with};
195  (j.append(stringlike(std::forward<Types>(parms))), ...);
196  return std::move(j.txt);
197 }
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:140
+ Here is the call graph for this function:

◆ find_string_literals()

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

Definition at line 53 of file StringTransform.cpp.

References CHECK_GT.

Referenced by apply_shim(), and cat().

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

◆ generate_random_string()

std::string generate_random_string ( const size_t  len)

Definition at line 95 of file StringTransform.cpp.

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

95  {
96  static char charset[] =
97  "0123456789"
98  "abcdefghijklmnopqrstuvwxyz"
99  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
100 
101  static std::mt19937 prng{std::random_device{}()};
102  static std::uniform_int_distribution<size_t> dist(0, strlen(charset) - 1);
103 
104  std::string str;
105  str.reserve(len);
106  for (size_t i = 0; i < len; i++) {
107  str += charset[dist(prng)];
108  }
109  return str;
110 }
+ Here is the caller graph for this function:

◆ get_quoted_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.

Definition at line 229 of file StringTransform.cpp.

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

229  {
230  std::stringstream ss;
231  ss << std::quoted(filename, quote, escape); // TODO: prevents string_view Jun 2020
232  return ss.str();
233 }
std::string filename(char const *path)
Definition: Logger.cpp:62
+ Here is the caller graph for this function:

◆ hide_sensitive_data_from_query()

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

Definition at line 72 of file StringTransform.cpp.

Referenced by cat(), and query_state::StdLog::log().

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

◆ inside_string_literal()

std::optional<size_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 174 of file StringTransform.cpp.

References parse_ast::end.

Referenced by apply_shim(), and cat().

177  {
178  const auto end = start + length;
179  for (const auto& literal_position : literal_positions) {
180  if (literal_position.first <= start && end <= literal_position.second) {
181  return literal_position.second;
182  }
183  }
184  return std::nullopt;
185 }
+ Here is the caller graph for this function:

◆ join()

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

Definition at line 60 of file StringTransform.h.

Referenced by Executor::buildJoinLoops(), 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::eraseFromTemporaryTables(), 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(), threadpool::FuturesThreadPool< T, std::enable_if_t< std::is_object< T >::value > >::join(), anonymous_namespace{SerializeToSql.cpp}::join_condition_to_string(), org.apache.calcite.rel.rules.DynamicFilterJoinRule::onMatch(), org.apache.calcite.rel.rules.OuterJoinOptViaNullRejectionRule::onMatch(), operator<<(), 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(), 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(), DBHandler::validateDashboardIdsForSharing(), foreign_storage::ForeignServer::validateDataWrapperType(), foreign_storage::ForeignServer::validateRecognizedOption(), foreign_storage::ForeignServer::validateStorageParameters(), 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().

60  {
61  std::stringstream ss;
62  if (!container.empty()) {
63  ss << container.front();
64  for (auto itr = std::next(container.cbegin()); itr != container.cend(); ++itr) {
65  ss << delim << *itr;
66  }
67  }
68  return ss.str();
69 }

◆ remove_unquoted_newlines_linefeeds_and_tabs_from_sql_string()

bool remove_unquoted_newlines_linefeeds_and_tabs_from_sql_string ( std::string &  str)
noexcept

sanitize an SQL string

Definition at line 189 of file StringTransform.cpp.

Referenced by to_lower().

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

◆ split()

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 116 of file StringTransform.cpp.

References run_benchmark_import::result.

Referenced by anonymous_namespace{TableArchiver.cpp}::adjust_altered_table_files(), create_table.SyntheticTable::createDataAndImportTable(), anonymous_namespace{DBHandler.cpp}::extract_projection_tokens_for_completion(), get_qualified_column_hints(), AutomaticIRMetadataGuard::makeBaseFilename(), AutomaticIRMetadataGuard::makeQueryEngineFilename(), Data_Namespace::ProcBuddyinfoParser::ProcBuddyinfoParser(), TrackingProcessor::process(), Data_Namespace::ProcMeminfoParser::ProcMeminfoParser(), run_benchmark::read_query_files(), TableArchiver::restoreTable(), QueryRunner::QueryRunner::runMultipleStatements(), anonymous_namespace{NativeCodegen.cpp}::serialize_llvm_metadata_footnotes(), Parser::splitObjectHierName(), and to_lower().

118  {
119  std::vector<std::string> result;
120 
121  // Use an explicit delimiter.
122  if (!delim.empty()) {
123  std::string::size_type i = 0, j = 0;
124  while ((i = str.find(delim, i)) != std::string::npos &&
125  (!maxsplit || result.size() < maxsplit.value())) {
126  result.emplace_back(str, j, i - j);
127  i += delim.size();
128  j = i;
129  }
130  result.emplace_back(str, j, std::string::npos);
131  return result;
132 
133  // Treat any number of consecutive whitespace characters as a delimiter.
134  } else {
135  bool prev_ws = true;
136  std::string::size_type i = 0, j = 0;
137  for (; i < str.size(); ++i) {
138  if (prev_ws) {
139  if (!isspace(str[i])) {
140  // start of word
141  prev_ws = false;
142  j = i;
143  }
144  } else {
145  if (isspace(str[i])) {
146  // start of space
147  result.emplace_back(str, j, i - j);
148  prev_ws = true;
149  j = i;
150  if ((maxsplit && result.size() == maxsplit.value())) {
151  // stop early if maxsplit was reached
152  result.emplace_back(str, j, std::string::npos);
153  return result;
154  }
155  }
156  }
157  }
158  if (!prev_ws) {
159  result.emplace_back(str, j, std::string::npos);
160  }
161  return result;
162  }
163 }
+ Here is the caller graph for this function:

◆ strip()

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

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

Definition at line 165 of file StringTransform.cpp.

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

165  {
166  std::string::size_type i, j;
167  for (i = 0; i < str.size() && std::isspace(str[i]); ++i) {
168  }
169  for (j = str.size(); j > i && std::isspace(str[j - 1]); --j) {
170  }
171  return std::string(str.substr(i, j - i));
172 }
+ Here is the caller graph for this function:

◆ to_lower()

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

Definition at line 96 of file StringTransform.h.

References logger::filename(), generate_random_string(), get_quoted_string(), remove_unquoted_newlines_linefeeds_and_tabs_from_sql_string(), split(), and strip().

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

96  {
97  auto str_lc = str;
98  std::transform(str_lc.begin(), str_lc.end(), str_lc.begin(), ::tolower);
99  return str_lc;
100 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ to_string() [1/3]

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

Definition at line 72 of file StringTransform.h.

Referenced by anonymous_namespace{StringTransform.h}::stringlike(), and toString().

72  {
73  std::ostringstream oss;
74  oss << v;
75  return oss.str();
76 }
+ Here is the caller graph for this function:

◆ to_string() [2/3]

template<>
std::string to_string ( char const *&&  v)

Definition at line 86 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(), foreign_storage::ParquetFixedLengthArrayEncoder::appendNullArrayOrCheckArraySize(), Archive::archive_error(), import_export::DataStreamSink::archivePlumber(), import_export::QueryExporterGDAL::beginExport(), Catalog_Namespace::Catalog::buildMaps(), Catalog_Namespace::SysCatalog::buildObjectDescriptorMap(), ResultSetReductionJIT::cacheKey(), Parser::CaseExpr::CaseExpr(), Executor::castToFP(), Catalog_Namespace::Catalog::changeForeignServerOwner(), foreign_storage::SingleFileReader::checkForMoreRows(), 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(), Executor::compileBody(), Executor::compileWorkUnit(), 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(), foreign_storage::anonymous_namespace{CsvReaderS3.cpp}::create_request(), 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::anonymous_namespace{SysCatalog.cpp}::deleteObjectPrivileges(), DecimalOverflowValidator::do_validate(), Catalog_Namespace::Catalog::dropColumn(), Catalog_Namespace::SysCatalog::dropDatabase(), Catalog_Namespace::Catalog::dropForeignServer(), Catalog_Namespace::Catalog::dropTable(), Catalog_Namespace::SysCatalog::dropUser(), ChunkMetadata::dump(), 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(), import_export::delimited_parser::find_end(), ProxyTHttpClient::flush(), import_export::anonymous_namespace{GDAL.cpp}::gdal_error_handler(), anonymous_namespace{JoinLoopTest.cpp}::generate_descriptors(), TableFunctionCompilationContext::generateEntryPoint(), Catalog_Namespace::Catalog::generatePhysicalTableName(), Geospatial::GeoPoint::GeoPoint(), Parser::SelectEntry::get_alias(), Parser::InExpr::get_arg(), Parser::CardinalityExpr::get_arg(), Parser::FunctionRef::get_arg(), anonymous_namespace{ArrowResultSetConverter.cpp}::get_arrow_type(), Parser::CharLengthExpr::get_calc_encoded_length(), Parser::ColumnRef::get_column(), 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(), get_device_parameters(), Parser::LikeExpr::get_escape_string(), Parser::RegexpExpr::get_escape_string(), DateTimeUtils::get_extract_timestamp_precision_scale(), Parser::QuerySpec::get_having_clause(), import_export::Detector::get_headers(), Parser::IsNullExpr::get_is_not(), Parser::LikelihoodExpr::get_likelihood(), DBHandler::get_link_view(), ThriftClientConnection::get_protocol(), Parser::SubqueryExpr::get_query(), Parser::ExistsExpr::get_query(), Parser::TableRef::get_range_var(), Parser::OperExpr::get_right(), HitTestTypes::get_rowid_regex(), Parser::InSubquery::get_subquery(), anonymous_namespace{Execute.cpp}::get_table_name(), DateTimeUtils::get_timestamp_precision_scale(), SQLTypeInfo::get_type_name(), Parser::BetweenExpr::get_upper(), DBHandler::get_valid_groups(), Parser::ArrayLiteral::get_value_list(), Parser::InValues::get_value_list(), 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(), S3Archive::init_for_read(), anonymous_namespace{JoinHashTableInterface.cpp}::innerToString(), Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::insertOrUpdateObjectPrivileges(), Executor::interrupt(), ResultSet::isGeoColOnGpu(), TableFunctionExecutionContext::launchCpuCode(), QueryExecutionContext::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(), Geospatial::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{Types.cpp}::process_poly_ring(), DictionaryValueConverter< TARGET_TYPE >::processBuffer(), foreign_storage::ParquetGeospatialEncoder::processGeoElement(), query_template_impl(), ra_exec_unit_desc_for_caching(), foreign_storage::SingleFileReader::readRegion(), Catalog_Namespace::Catalog::recordOwnershipOfObjectsInObjectPermissions(), Executor::redeclareFilterFunction(), ResultSetReductionJIT::reduceOneEntryBaseline(), ResultSetReductionJIT::reduceOneEntryTargetsNoCollisions(), QueryMemoryDescriptor::reductionKey(), Executor::registerActiveModule(), BaselineJoinHashTable::reifyForDevice(), AutomaticIRMetadataGuard::rememberOurInstructions(), 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(), anonymous_namespace{NativeCodegen.cpp}::set_row_func_argnames(), Catalog_Namespace::Catalog::setColumnDictionary(), Catalog_Namespace::Catalog::setColumnSharedDictionary(), Catalog_Namespace::Catalog::setForeignServerProperty(), foreign_storage::ForeignStorageCache::setLimit(), Executor::skipFragment(), start_calcite_server_as_daemon(), query_state::StdLogData::StdLogData(), 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(), QueryMemoryDescriptor::toString(), RexInput::toString(), Analyzer::UOper::toString(), SortField::toString(), RexRef::toString(), RexAgg::toString(), Analyzer::InIntegerSet::toString(), Analyzer::LikelihoodExpr::toString(), RelAggregate::toString(), RelJoin::toString(), Analyzer::ExtractExpr::toString(), RelLeftDeepInnerJoin::toString(), Analyzer::DateaddExpr::toString(), Analyzer::DatediffExpr::toString(), RelCompound::toString(), Analyzer::DatetruncExpr::toString(), RelSort::toString(), Analyzer::OrderEntry::toString(), RelModify::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::updateForeignTableRefreshTimes(), 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::anonymous_namespace{LazyParquetImporter.cpp}::validate_equal_schema(), foreign_storage::anonymous_namespace{LazyParquetChunkLoader.cpp}::validate_max_repetition_and_definition_level(), foreign_storage::anonymous_namespace{LazyParquetImporter.cpp}::validate_parquet_metadata(), foreign_storage::ParquetDataWrapper::validateAndGetStringWithLength(), foreign_storage::CsvDataWrapper::validateAndGetStringWithLength(), and ScalarExprToSql::visitUOper().

86  {
87  return std::string(v);
88 }

◆ to_string() [3/3]

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

Definition at line 91 of file StringTransform.cpp.

91  {
92  return std::move(v);
93 }

◆ to_upper()

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

Definition at line 90 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::Catalog::getStringDictionaryHosts(), Catalog_Namespace::Catalog::instantiateFragmenter(), 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(), CreateForeignTableCommand::setRefreshOptions(), should_suggest_column_hints(), StringToDatum(), Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider(), and Catalog_Namespace::SysCatalog::updateUserRoleName().

90  {
91  auto str_uc = str;
92  std::transform(str_uc.begin(), str_uc.end(), str_uc.begin(), ::toupper);
93  return str_uc;
94 }
+ Here is the caller graph for this function:

◆ toString() [1/3]

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

Definition at line 244 of file StringTransform.h.

References to_string(), and typeName().

Referenced by toString().

244  {
245  if constexpr (std::is_same_v<T, std::string>) {
246  return "\"" + v + "\"";
247  } else if constexpr (std::is_arithmetic_v<T>) {
248  return std::to_string(v);
249  } else if constexpr (has_toString_v<T>) {
250  return v.toString();
251  } else if constexpr (get_has_toString_v<T>) {
252  return v.get()->toString();
253  } else if constexpr (std::is_same_v<T, void*>) {
254  std::ostringstream ss;
255  ss << std::hex << (uintptr_t)v;
256  return "0x" + ss.str();
257  } else if constexpr (std::is_pointer_v<T>) {
258  return (v == NULL ? "NULL" : "&" + toString(*v));
259  } else {
260  return typeName(&v);
261  }
262 }
std::string toString(const T &v)
std::string typeName(const T *v)
std::string to_string(T &&v)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString() [2/3]

template<typename T >
std::string toString ( const std::pair< T, T > &  v)

Definition at line 265 of file StringTransform.h.

References cat(), and toString().

265  {
266  return cat("(", toString(v.first), ", ", toString(v.second), ")");
267 }
std::string toString(const T &v)
std::string cat(Ts &&... args)
+ Here is the call graph for this function:

◆ toString() [3/3]

template<typename T >
std::string toString ( const std::vector< T > &  v)

Definition at line 270 of file StringTransform.h.

References run_benchmark_import::result, and toString().

270  {
271  auto result = std::string("[");
272  for (size_t i = 0; i < v.size(); ++i) {
273  if (i) {
274  result += ", ";
275  }
276  result += toString(v[i]);
277  }
278  result += "]";
279  return result;
280 }
std::string toString(const T &v)
+ Here is the call graph for this function:

◆ typeName()

template<typename T >
std::string typeName ( const T *  v)

Definition at line 214 of file StringTransform.h.

Referenced by com.omnisci.jdbc.OmniSciConnection::createArrayOf(), RexAbstractInput::toString(), TableFunctionExecutionUnit::toString(), RexLiteral::toString(), toString(), RexOperator::toString(), RexSubQuery::toString(), RexInput::toString(), RexCase::toString(), RexFunctionOperator::toString(), SortField::toString(), RexWindowFunctionOperator::toString(), RexRef::toString(), RexAgg::toString(), RelScan::toString(), RelProject::toString(), RelAggregate::toString(), RelJoin::toString(), RelFilter::toString(), RelCompound::toString(), RelSort::toString(), RelModify::toString(), RelTableFunction::toString(), RelLogicalValues::toString(), and RelLogicalUnion::toString().

214  {
215  std::stringstream stream;
216  int status;
217  char* demangled = abi::__cxa_demangle(typeid(T).name(), 0, 0, &status);
218  stream << std::string(demangled);
219  free(demangled);
220  return stream.str();
221 }
+ Here is the caller graph for this function: