| 151 | } |
| 152 | |
| 153 | StringVal StringFunctions::Space(FunctionContext* context, const BigIntVal& len) { |
| 154 | if (len.is_null) return StringVal::null(); |
| 155 | if (len.val <= 0) return StringVal(); |
| 156 | if (len.val > StringVal::MAX_LENGTH) { |
| 157 | context->SetError(Substitute(ERROR_CHARACTER_LIMIT_EXCEEDED, |
| 158 | "space() result", |
| 159 | PrettyPrinter::Print(StringVal::MAX_LENGTH, TUnit::BYTES)).c_str()); |
| 160 | return StringVal::null(); |
| 161 | } |
| 162 | StringVal result(context, len.val); |
| 163 | if (UNLIKELY(result.is_null)) return StringVal::null(); |
| 164 | memset(result.ptr, ' ', len.val); |
| 165 | return result; |
| 166 | } |
| 167 | |
| 168 | StringVal StringFunctions::Repeat( |
| 169 | FunctionContext* context, const StringVal& str, const BigIntVal& n) { |
nothing calls this directly
no test coverage detected