yiguolei commented on code in PR #58656:
URL: https://github.com/apache/doris/pull/58656#discussion_r2595881454


##########
be/src/util/jsonb_document.h:
##########
@@ -1042,6 +1042,19 @@ struct ArrayVal : public ContainerVal {
 inline Status JsonbDocument::checkAndCreateDocument(const char* pb, size_t 
size,
                                                     JsonbDocument** doc) {
     *doc = nullptr;
+    // Fix Issue #58523: Tolerate empty data from legacy versions.
+    // If size is 0, we return a static valid "Null" document.
+    if (size == 0) {
+        // 手动构造一个合法的 Null 文档二进制数据
+        // 第1个字节:Version = 1 (JSONB_VER)
+        // 第2个字节:Type    = 0 (T_Null)
+        static char s_null_buf[] = {1, 0};

Review Comment:
   1. 在beut 里增加一个case,验证一下 这种构造方式构造出的jsonbdocument 的version = 1 and type = T 
NULL。防止未来有人重构代码,把jsonb的bytes 结构改乱了。
   2. 在beut 中还要验证一下把这个null jsonb document 转成一个bytes 
数组,然后可以checkAndCreateDocument 再创建出这个null jsonb document。 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to