MCPcopy Create free account
hub / github.com/apache/impala / EscapeSql

Function EscapeSql

be/src/util/sql-util.cc:38–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36};
37
38const string EscapeSql(const string& sql, const int64_t& max_escaped_len) noexcept {
39 stringstream ret;
40 function<bool()> pred;
41
42 if (max_escaped_len == 0) {
43 return ""; // <-- Note: early return
44 }
45
46 for (const auto& c : sql) {
47 switch(c) {
48 case '\n':
49 ret << '\\';
50 ret << 'n';
51 break;
52 case '\\':
53 case '\'':
54 case ';':
55 ret << '\\';
56 default:
57 ret << c;
58 break;
59 }
60
61 if (UNLIKELY(max_escaped_len > 0
62 && static_cast<size_t>(ret.tellp() >= max_escaped_len))) {
63 break;
64 }
65 }
66
67 return ret.str();
68} // function EscapeSql
69
70} // namespace impala

Callers 2

TESTFunction · 0.85

Calls 1

strMethod · 0.45

Tested by 1

TESTFunction · 0.68