fix: xmlagg function oom

This commit is contained in:
obdev
2023-05-29 03:23:04 +00:00
committed by ob-robot
parent 556644291e
commit 9211f9025b
2 changed files with 41 additions and 4 deletions

View File

@ -1436,7 +1436,12 @@ TEST_F(TestXmlBin, test_print_ns)
{ {
int ret = 0; int ret = 0;
ObCollationType type = CS_TYPE_UTF8MB4_GENERAL_CI; ObCollationType type = CS_TYPE_UTF8MB4_GENERAL_CI;
common::ObString xml_text("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"/\"><note>test</note></xsl:template></xsl:stylesheet>"); common::ObString xml_text(
"<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
"<xsl:template match=\"/\">"
"<note>test</note>"
"</xsl:template>"
"</xsl:stylesheet>");
ObArenaAllocator allocator(ObModIds::TEST); ObArenaAllocator allocator(ObModIds::TEST);
ObXmlDocument* doc = nullptr; ObXmlDocument* doc = nullptr;
@ -1447,7 +1452,9 @@ TEST_F(TestXmlBin, test_print_ns)
ObStringBuffer buf_str(&allocator); ObStringBuffer buf_str(&allocator);
ObXmlBin bin(ctx); ObXmlBin bin(ctx);
doc->print_document(buf_str, type, ObXmlFormatType::NO_FORMAT); ret = doc->print_document(buf_str, type, ObXmlFormatType::NO_FORMAT);
ASSERT_EQ(ret, 0);
ObStringBuffer buf_str_bin(&allocator); ObStringBuffer buf_str_bin(&allocator);
ASSERT_EQ(bin.parse_tree(doc), 0); ASSERT_EQ(bin.parse_tree(doc), 0);
@ -1624,6 +1631,36 @@ TEST_F(TestXmlBin, read_by_key)
} }
TEST_F(TestXmlBin, print_empty_element)
{
int ret = 0;
ObCollationType type = CS_TYPE_UTF8MB4_GENERAL_CI;
common::ObString xml_text(
"<></>"
);
ObArenaAllocator allocator(ObModIds::TEST);
ObMulModeMemCtx* ctx = nullptr;
ASSERT_EQ(ObXmlUtil::create_mulmode_tree_context(&allocator, ctx), OB_SUCCESS);
ObXmlDocument root(M_UNPARSED, ctx);
ObXmlElement child1(M_UNPARSED, ctx);
ASSERT_EQ(root.add_element(&child1), 0);
ObXmlDocument* doc = &root;
{
ObXmlBin xbin(ctx);
ObArray<ObIMulModeBase*> result1;
ASSERT_EQ(xbin.parse_tree(doc), 0);
ASSERT_EQ(xbin.set_child_at(0), 0);
ObStringBuffer buf_str_bin(&allocator);
ASSERT_EQ(xbin.print_xml(buf_str_bin, 0, 0 ,0), 0);
cout << buf_str_bin.ptr() << endl;
}
}
} // common } // common
} // oceanbase } // oceanbase

View File

@ -130,7 +130,7 @@ public:
ObString get_prefix() { return ObString(); } ObString get_prefix() { return ObString(); }
ObString get_encoding() { return ObString(); } ObString get_encoding() { return ObString(); }
uint16_t get_standalone() { return 0; } uint16_t get_standalone() { return 0; }
ObIMulModeBase* attribute_at(int64_t pos) { return nullptr; } ObIMulModeBase* attribute_at(int64_t pos, ObIMulModeBase* buffer = nullptr) { return nullptr; }
bool has_flags(ObMulModeNodeFlag flag) { return false; } bool has_flags(ObMulModeNodeFlag flag) { return false; }
bool get_unparse() { return false; } bool get_unparse() { return false; }
bool get_is_empty() { return false; } bool get_is_empty() { return false; }
@ -218,7 +218,7 @@ public:
return ret; return ret;
} }
virtual ObIMulModeBase* at(int64_t pos) virtual ObIMulModeBase* at(int64_t pos, ObIMulModeBase* buffer = nullptr)
{ {
ObLibTreeNodeBase* tmp = ObLibContainerNode::member(pos); ObLibTreeNodeBase* tmp = ObLibContainerNode::member(pos);
TXmlNodeBase* res = nullptr; TXmlNodeBase* res = nullptr;