@@ -79,48 +79,35 @@ String *TypeEncoder::encode(const String &from, bool &is_valid) {
7979 vdf_->vdf (&ctx_, &vdf_args_, &vdf_result_);
8080
8181 if (vdf_result_.type != VEF_RESULT_VALUE) {
82- // TODO(villagesql-beta): handle errors
82+ // TODO(villagesql-beta): log warnings for errors
8383 is_valid = false ;
8484 return nullptr ;
8585 }
8686
87- const size_t actual_len = vdf_result_.actual_len ;
88-
8987 if (alt_bin_buf_ != nullptr ) {
90- // VDF used its own buffer (output exceeded buffer_size_). Grow
91- // overflow_buf_ if needed and reuse it across rows.
92- if (actual_len > overflow_buf_size_) {
93- auto *new_buf = new (mem_root_) uchar[actual_len];
94- if (should_assert_if_null (new_buf)) {
95- my_error (ER_OUTOFMEMORY, MYF (ME_FATALERROR), actual_len);
96- return nullptr ;
97- }
98- overflow_buf_ = new_buf;
99- overflow_buf_size_ = actual_len;
100- }
101- if (actual_len > 0 ) memcpy (overflow_buf_, alt_bin_buf_, actual_len);
102- overflow_result_.set (pointer_cast<const char *>(overflow_buf_),
103- actual_len, &my_charset_bin);
104- return &overflow_result_;
88+ // TODO(villagesql-beta): support the extension returning alternate buffers
89+ is_valid = false ;
90+ return nullptr ;
10591 }
10692
10793 // TODO(villagesql-beta): report an error or warning when the VDF overruns
108- // the buffer rather than silently returning invalid.
109- if (should_assert_if_false (actual_len <= buffer_size_)) {
94+ // the buffer rather than silently returning invalid
95+ const size_t actual_len = vdf_result_.actual_len ;
96+ if (actual_len > buffer_size_) {
11097 is_valid = false ;
11198 return nullptr ;
11299 }
100+
113101 result_.set (buffer_, actual_len, &my_charset_bin);
114102 } else {
103+ // TODO(villagesql-beta): Remove suport for these raw functions
115104 assert (fn_ != nullptr );
116105 size_t actual_length = 0 ;
117106 if (fn_ (pointer_cast<uchar *>(buffer_), buffer_size_, from.ptr (),
118107 from.length (), &actual_length)) {
119108 is_valid = false ;
120109 return nullptr ;
121110 }
122- // TODO(villagesql-beta): report an error or warning when the fn_ overruns
123- // the buffer rather than silently returning invalid.
124111 if (should_assert_if_false (actual_length <= buffer_size_)) {
125112 is_valid = false ;
126113 return nullptr ;
0 commit comments