patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -14,28 +14,25 @@
#include <gtest/gtest.h>
#include "lib/allocator/page_arena.h"
#include "sql/ob_sql_utils.h"
namespace oceanbase {
namespace oceanbase
{
using namespace oceanbase::sql;
using namespace oceanbase::common;
namespace test {
class ObSQLUtilsTest : public ::testing::Test {
public:
ObSQLUtilsTest()
{}
virtual ~ObSQLUtilsTest()
{}
virtual void SetUp()
{}
virtual void TearDown()
{}
private:
// disallow copy
ObSQLUtilsTest(const ObSQLUtilsTest& other);
ObSQLUtilsTest& operator=(const ObSQLUtilsTest& other);
private:
// data members
namespace test
{
class ObSQLUtilsTest: public ::testing::Test
{
public:
ObSQLUtilsTest(){}
virtual ~ObSQLUtilsTest(){}
virtual void SetUp(){}
virtual void TearDown(){}
private:
// disallow copy
ObSQLUtilsTest(const ObSQLUtilsTest &other);
ObSQLUtilsTest& operator=(const ObSQLUtilsTest &other);
private:
// data members
};
TEST_F(ObSQLUtilsTest, make_field_name)
{
@ -45,60 +42,53 @@ TEST_F(ObSQLUtilsTest, make_field_name)
ASSERT_EQ(OB_INVALID_ARGUMENT, ObSQLUtils::make_field_name(NULL, 0, CS_TYPE_UTF8MB4_GENERAL_CI, NULL, name));
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(NULL, 0, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_TRUE(name.empty());
const char* buf1 = "adf";
const char *buf1 = "adf";
int64_t len1 = 3;
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(buf1, len1, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_EQ(name, ObString::make_string("adf"));
ASSERT_EQ(name.length(), 3);
buf1 = " adf";
len1 = 5;
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(buf1, len1, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_EQ(name, ObString::make_string("adf"));
ASSERT_EQ(name.length(), 3);
buf1 = "\t\r\naaa";
len1 = 6;
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(buf1, len1, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_EQ(name, ObString::make_string("aaa"));
ASSERT_EQ(name.length(), 3);
buf1 = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111";
buf1 = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111";
len1 = 255;
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(buf1, len1, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_EQ(name, ObString::make_string(buf1));
printf("prt:%s, len:%d\n", name.ptr(), name.length());
printf("prt:%s, len:%d\n", name.ptr(), name.length());
ASSERT_EQ(name.length(), 255);
const char* buf2 = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111111111111111111111111111122222";
const char *buf2 = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122222";
int64_t len2 = 261;
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(buf2, len2, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_EQ(name, ObString::make_string(buf1));
ASSERT_EQ(name.length(), 255);
buf2 = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111222222";
buf2 = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222";
len2 = 272;
const char* buf3 = "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
"1111111111111111111111111111111111111111111111111111111111222";
const char *buf3 = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222";
ASSERT_EQ(OB_SUCCESS, ObSQLUtils::make_field_name(buf2, len2, CS_TYPE_UTF8MB4_GENERAL_CI, &allocator, name));
ASSERT_EQ(name, ObString::make_string(buf3));
ASSERT_EQ(name.length(), 255);
printf("prt:%s, len:%d\n", name.ptr(), name.length());
printf("prt:%s, len:%d\n", name.ptr(), name.length());
}
} // namespace test
} // namespace oceanbase
int main(int argc, char** argv)
}
}
int main(int argc, char **argv)
{
oceanbase::common::ObLogger::get_logger().set_log_level("DEBUG");
OB_LOGGER.set_log_level("DEBUG");
::testing::InitGoogleTest(&argc, argv);
::testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}