forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_multi_parser.cpp
More file actions
94 lines (79 loc) · 2.55 KB
/
Copy pathtest_multi_parser.cpp
File metadata and controls
94 lines (79 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Copyright (c) 2025 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define USING_LOG_PREFIX SQL
#include "../test_sql_utils.h"
using namespace oceanbase::common;
using namespace oceanbase::sql;
namespace test
{
class TestMultiParser: public TestSqlUtils, public ::testing::Test
{
public:
TestMultiParser();
virtual ~TestMultiParser();
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
DISALLOW_COPY_AND_ASSIGN(TestMultiParser);
protected:
// data members
ObArenaAllocator allocator_;
};
TestMultiParser::TestMultiParser() : allocator_(ObModIds::TEST)
{
}
TestMultiParser::~TestMultiParser()
{
}
void TestMultiParser::SetUp()
{
}
void TestMultiParser::TearDown()
{
}
TEST_F(TestMultiParser, basic_test)
{
int ret = OB_SUCCESS;
ObSQLMode mode = SMO_DEFAULT;
/*
const char *query_str = "alter system bootstrap ZONE 'zone1' SERVER '100.81.152.44:19518'";
const char *query_str = "create database if not exists rongxuan default character set = 'utf8' default collate = 'default_collate'";
const char *query_str = "select * from d.t1 PARTITION(p1, p2);";
const char *query_str = "update d.t1 PARTITION (p2) SET id = 2 WHERE name = 'Jill';";
const char *query_str = "delete from d.t1 PARTITION(p0, p1);";
*/
//const char *query_str = "select '12', '11', '11', '11'";
//const char *query_str = "alter system bootstrap ZONE 'zone1' SERVER '100.81.152.44:19518';select 3;select '23';create table t1 (i int) ;;;; ";
const char *query_str = "";
//const char *query_str = "select 1";
ObString query = ObString::make_string(query_str);
ObSEArray<ObString, 4> queries;
ObParser parser(allocator_, mode);
ObMPParseStat parse_stat;
ret = parser.split_multiple_stmt(query, queries, parse_stat);
LOG_INFO("YES. multi query", K(query), K(queries));
ASSERT_EQ(OB_SUCCESS, ret);
ASSERT_EQ(1, queries.count());
}
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc,argv);
OB_LOGGER.set_log_level("INFO");
test::parse_cmd_line_param(argc, argv, test::clp);
return RUN_ALL_TESTS();
}