init push

This commit is contained in:
oceanbase-admin
2021-05-31 22:56:52 +08:00
commit cea7de1475
7020 changed files with 5689869 additions and 0 deletions

2
unittest/sql/resolver/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/log
/out

View File

@ -0,0 +1,8 @@
sql_unittest(test_raw_expr_print_visitor expr/test_raw_expr_print_visitor.cpp)
sql_unittest(test_raw_expr_to_str expr/test_raw_expr_to_str.cpp)
sql_unittest(test_raw_expr_hash expr/test_raw_expr_hash.cpp)
sql_unittest(test_raw_expr_resolver expr/test_raw_expr_resolver.cpp)
sql_unittest(test_raw_expr_canonicalizer expr/test_raw_expr_canonicalizer.cpp)
sql_unittest(test_sql_bitset)
sql_unittest(ddl_resolver)
#sql_unittest(test_resolver)

View File

@ -0,0 +1,176 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include "sql/ob_sql_init.h"
#include <iterator>
#include <sys/time.h>
#include "sql/resolver/dml/ob_select_stmt.h"
#include "sql/resolver/dml/ob_insert_stmt.h"
#include "sql/resolver/dml/ob_update_stmt.h"
#include "sql/resolver/dml/ob_delete_stmt.h"
#include "sql/resolver/tcl/ob_start_trans_stmt.h"
#include "sql/resolver/tcl/ob_end_trans_stmt.h"
#include "sql/resolver/dcl/ob_create_user_stmt.h"
#include "sql/resolver/dcl/ob_grant_stmt.h"
#include "sql/resolver/dcl/ob_revoke_stmt.h"
#include "sql/resolver/dcl/ob_drop_user_stmt.h"
#include "sql/resolver/dcl/ob_rename_user_stmt.h"
#include "sql/resolver/dcl/ob_set_password_stmt.h"
#include "sql/ob_sql_define.h"
#include "lib/string/ob_sql_string.h"
#include "../test_sql_utils.h"
using namespace oceanbase::obrpc;
namespace test {
const char* SQL_DIR = "sql";
const char* RESULT_DIR = "result";
struct SqlAndError {
std::string sql;
int64_t expect_error;
};
class TestResolver : public TestSqlUtils, public ::testing::Test {
public:
TestResolver();
virtual ~TestResolver()
{}
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
DISALLOW_COPY_AND_ASSIGN(TestResolver);
};
TestResolver::TestResolver()
{
memcpy(schema_file_path_, "./test_resolver.schema", sizeof("./test_resolver.schema"));
}
void TestResolver::SetUp()
{
init();
}
void TestResolver::TearDown()
{
destroy();
}
TEST_F(TestResolver, basic_test)
{
// for rongxuan.test input sql in command line
const char* postfix[] = {"test", "tmp", "result"};
int64_t sql_postfix_len = strlen(postfix[0]);
int64_t tmp_postfix_len = strlen(postfix[1]);
int64_t result_postfix_len = strlen(postfix[2]);
char file_name[3][FILE_PATH_LEN];
for (int32_t i = 0; i < clp.file_count; ++i) {
if (i > 0) {
destroy();
init();
}
int64_t sql_file_len = strlen(clp.file_names_vector[i]);
snprintf(file_name[0],
strlen(SQL_DIR) + sql_file_len + sql_postfix_len + 4,
"./%s/%s%s",
SQL_DIR,
// clp.file_names[i],
clp.file_names_vector[i],
postfix[0]);
snprintf(file_name[1],
strlen(RESULT_DIR) + sql_file_len + tmp_postfix_len + 4,
"./%s/%s%s",
RESULT_DIR,
// clp.file_names[i],
clp.file_names_vector[i],
postfix[1]);
snprintf(file_name[2],
strlen(RESULT_DIR) + sql_file_len + result_postfix_len + 4,
"./%s/%s%s",
RESULT_DIR,
// clp.file_names[i],
clp.file_names_vector[i],
postfix[2]);
_OB_LOG(INFO, "%s\t%s\t%s\t%s", clp.file_names_vector[i], file_name[0], file_name[1], file_name[2]);
std::ifstream if_sql(file_name[0]);
if (!if_sql.is_open()) {
_OB_LOG(ERROR, "file %s not exist!", file_name[0]);
continue;
}
ASSERT_TRUE(if_sql.is_open());
ObStmt* stmt = NULL;
// std::ofstream of_tmp(file_name[1]);
// ASSERT_TRUE(of_tmp.is_open()) << file_name[1];
// if (!of_tmp.is_open()) {
// _OB_LOG(ERROR,"file %s not exist!", file_name[1]);
// continue;
//}
std::string line;
std::vector<SqlAndError> sql_vector;
bool is_print = false;
int64_t expect_error = 0;
int64_t use_time = 0;
char* w;
char* p;
timeval start, end;
while (std::getline(if_sql, line)) {
if (line.size() <= 0)
continue;
if (line.at(0) == '#')
continue;
if (strncmp(line.c_str(), "--error", strlen("--error")) == 0) {
p = const_cast<char*>(line.c_str());
w = strsep(&p, " ");
expect_error = atol(p);
continue;
}
if (line.at(0) == '\r' || line.at(0) == '\n')
continue;
// stmt = NULL;
SqlAndError sql_error;
sql_error.sql = line;
sql_error.expect_error = expect_error;
sql_vector.push_back(sql_error);
expect_error = 0;
}
UNUSED(w);
if_sql.close();
const char* file_name = clp.file_names_vector[i];
int64_t length = strlen(file_name);
std::string name(file_name + 14, file_name + length - 1);
gettimeofday(&start, NULL);
std::vector<SqlAndError>::iterator iter = sql_vector.begin();
for (; iter != sql_vector.end(); iter++) {
stmt = NULL;
do_load_sql(iter->sql.c_str(), stmt, is_print, TREE_FORMAT, iter->expect_error);
}
gettimeofday(&end, NULL);
use_time = (long int)(end.tv_sec - start.tv_sec) * 1000000 + (long int)(end.tv_usec - start.tv_usec);
;
std::cout << name << " use time :" << use_time << std::endl;
}
}
} // namespace test
int main(int argc, char** argv)
{
test::clp.test_input_from_cmd = false;
test::clp.print_schema_detail_info = false;
test::clp.record_test_result = false;
// argc = 1;
::testing::InitGoogleTest(&argc, argv);
test::parse_cmd_line_param(argc, argv, test::clp);
OB_LOGGER.set_log_level("DEBUG");
OB_LOGGER.set_file_name("ddl_resolver.log", true);
init_sql_factories();
std::cout << "clp:record_test_result:::" << test::clp.record_test_result << std::endl;
return RUN_ALL_TESTS();
}

View File

@ -0,0 +1,8 @@
mysql> update rongxuan.t1 vt1 set c2=rongxuan.t1.c1+1 where rongxuan.t1.c1 > 1 order by rongxuan.t1.c1 desc;
ERROR 1054 (42S22): Unknown column 'rongxuan.t1.c1' in 'where clause'
mysql> update rongxuan.t1 vt1 set c2=rongxuan.t1.c1+1 where c1 > 1 order by rongxuan.t1.c1 desc;
ERROR 1054 (42S22): Unknown column 'rongxuan.t1.c1' in 'order clause'
mysql> update rongxuan.t1 vt1 set c2=rongxuan.t1.c1+1 where c1 > 1 order by c1 desc;
ERROR 1054 (42S22): Unknown column 'rongxuan.t1.c1' in 'field list'
mysql> update rongxuan.t1 rongxuan.vt1 set c2=c1+1 where c1 > 1 order by c1 desc;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.vt1 set c2=c1+1 where c1 > 1 order by c1 desc' at line 1

View File

@ -0,0 +1,120 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include "sql/test_sql_utils.h"
#include "sql/resolver/expr/ob_raw_expr_canonicalizer_impl.h"
#include <gtest/gtest.h>
#include "lib/utility/ob_test_util.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
#include "sql/resolver/ob_stmt.h"
#include "sql/ob_sql_context.h"
#include "lib/json/ob_json_print_utils.h"
#include <fstream>
#include <iterator>
using namespace oceanbase::common;
using namespace oceanbase::sql;
class TestRawExprCanonicalizer : public ::testing::Test {
public:
TestRawExprCanonicalizer();
virtual ~TestRawExprCanonicalizer();
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
DISALLOW_COPY_AND_ASSIGN(TestRawExprCanonicalizer);
protected:
// function members
void canon(const char* expr, const char*& canon_expr);
protected:
// data members
};
TestRawExprCanonicalizer::TestRawExprCanonicalizer()
{}
TestRawExprCanonicalizer::~TestRawExprCanonicalizer()
{}
void TestRawExprCanonicalizer::SetUp()
{}
void TestRawExprCanonicalizer::TearDown()
{}
void TestRawExprCanonicalizer::canon(const char* expr, const char*& canon_expr)
{
ObArray<ObQualifiedName> columns;
ObArray<ObVarInfo> sys_vars;
ObArray<ObSubQueryInfo> sub_query_info;
ObArray<ObAggFunRawExpr*> aggr_exprs;
ObArray<ObWinFunRawExpr*> win_exprs;
const char* expr_str = expr;
ObArenaAllocator allocator(ObModIds::TEST);
ObRawExprFactory expr_factory(allocator);
ObTimeZoneInfo tz_info;
ObStmt stmt;
ObQueryCtx query_ctx;
ObNameCaseMode case_mode = OB_NAME_CASE_INVALID;
ObExprResolveContext ctx(expr_factory, &tz_info, case_mode);
stmt.query_ctx_ = &query_ctx;
ctx.connection_charset_ = ObCharset::get_default_charset();
ctx.dest_collation_ = ObCharset::get_default_collation(ctx.connection_charset_);
ctx.stmt_ = &stmt;
ObSQLSessionInfo session;
session.set_use_static_typing_engine(false);
ctx.session_info_ = &session;
ObRawExpr* raw_expr = NULL;
OK(ObRawExprUtils::make_raw_expr_from_str(
expr_str, strlen(expr_str), ctx, raw_expr, columns, sys_vars, &sub_query_info, aggr_exprs, win_exprs));
_OB_LOG(DEBUG, "================================================================");
_OB_LOG(DEBUG, "%s", expr);
_OB_LOG(DEBUG, "%s", CSJ(raw_expr));
ObRawExprCanonicalizerImpl canon(ctx);
OK(canon.canonicalize(raw_expr));
canon_expr = CSJ(raw_expr);
_OB_LOG(DEBUG, "canon_expr=%s", canon_expr);
}
TEST_F(TestRawExprCanonicalizer, basic_test)
{
std::ifstream if_tests("./expr/test_raw_expr_canonicalizer.test");
ASSERT_TRUE(if_tests.is_open());
std::string line;
const char* canon_expr = NULL;
std::ofstream of_result("./expr/test_raw_expr_canonicalizer.tmp");
ASSERT_TRUE(of_result.is_open());
while (std::getline(if_tests, line)) {
of_result << line << std::endl;
canon(line.c_str(), canon_expr);
of_result << canon_expr << std::endl;
}
of_result.close();
std::ifstream if_result("./expr/test_raw_expr_canonicalizer.tmp");
ASSERT_TRUE(if_result.is_open());
std::istream_iterator<std::string> it_result(if_result);
std::ifstream if_expected("./expr/test_raw_expr_canonicalizer.result");
ASSERT_TRUE(if_expected.is_open());
std::istream_iterator<std::string> it_expected(if_expected);
ASSERT_TRUE(std::equal(it_result, std::istream_iterator<std::string>(), it_expected));
std::remove("./test_raw_expr_canonicalizer.tmp");
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
not (10 > 5 and 100 < 9)
not not a > b
not a > b
not a = b
not a < b
not a is true
not a between 1 and 100
(1 and 2) and (3 and 4) and 5
(1 or 2) or (3 or 4 or 5)
(1 and 2) or (3 and 1)
not(not(a))
A or (A And B) or (A And C)
(A and B) or (A and C and D)
(A and B) or (A and C)
(A and B and C) or (A and B and D)

View File

@ -0,0 +1,105 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_OPTIMIZER
#include <gtest/gtest.h>
#include "lib/json/ob_json.h"
#include "lib/allocator/ob_mod_define.h"
#include "lib/allocator/page_arena.h"
#include "lib/oblog/ob_log.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
#include "sql/engine/expr/ob_expr_operator.h"
using namespace oceanbase::sql;
using namespace oceanbase::common;
namespace test {
#define MAKE_RAW_EXPR_FROM_STR(str, expr) \
({ \
ret = ObRawExprUtils::make_raw_expr_from_str( \
str, strlen(str), ctx, expr, columns, sys_vars, &sub_query_info, aggr_exprs, win_exprs); \
ret; \
})
class TestRawExprToStr : public ::testing::Test {
public:
TestRawExprToStr()
{}
virtual ~TestRawExprToStr()
{}
virtual void SetUp()
{}
virtual void TearDown()
{}
private:
// disallow copy and assign
TestRawExprToStr(const TestRawExprToStr& other);
TestRawExprToStr& operator=(const TestRawExprToStr& ohter);
};
#define T(expr1) \
do { \
MAKE_RAW_EXPR_FROM_STR(expr1, expr); \
EXPECT_TRUE(OB_SUCC(ret)); \
uint64_t hash = expr->hash(0); \
_OB_LOG(INFO, "hash(%s) = %lu", expr1, hash); \
} while (0)
TEST_F(TestRawExprToStr, basic)
{
int ret = OB_SUCCESS;
// ObExprOperatorGFactory::get_instance()->init();
// mock params
// stmts
ObArenaAllocator allocator(ObModIds::TEST);
ObRawExprFactory expr_factory(allocator);
ObArray<ObQualifiedName> columns;
ObArray<ObVarInfo> sys_vars;
ObArray<ObSubQueryInfo> sub_query_info;
ObArray<ObAggFunRawExpr*> aggr_exprs;
ObArray<ObWinFunRawExpr*> win_exprs;
ObTimeZoneInfo tz_info;
ObNameCaseMode case_mode = OB_NAME_CASE_INVALID;
ObExprResolveContext ctx(expr_factory, &tz_info, case_mode);
ctx.connection_charset_ = ObCharset::get_default_charset();
ctx.dest_collation_ = ObCharset::get_default_collation(ctx.connection_charset_);
ctx.is_extract_param_type_ = false;
ObSQLSessionInfo session;
session.set_use_static_typing_engine(false);
ctx.session_info_ = &session;
// const int64_t buf_len = 1024;
// int64_t pos = 0;
// char buf[buf_len];
ObRawExpr* expr = NULL;
// const char* inner_offset = "1+c1 > ? and 'abc' || c2 = 'def'";
// const char* expr1 = "1+c1 > ? and SUM(1) OR 2 >= 1";
// const char* expr2 = "CASE WHEN 10>=2 THEN 1+2 ELSE 0 END";
// const char* expr3 = "CASE WHEN 10>=2 THEN 10-2 ELSE SUM(10-2) END";
T("1+c1 > ? and SUM(1) OR 2 >= 1");
T("CASE WHEN 10>=2 THEN 1+2 ELSE 0 END");
T("1");
T("100");
T("sum(1)");
T("c1");
}
} // namespace test
int main(int argc, char** argv)
{
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -0,0 +1,172 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include <gtest/gtest.h>
#include "lib/utility/ob_test_util.h"
#include "sql/resolver/expr/ob_raw_expr_print_visitor.h"
using namespace oceanbase::common;
using namespace oceanbase::sql;
class TestRawExprPrintVisitor : public ::testing::Test {
public:
TestRawExprPrintVisitor();
virtual ~TestRawExprPrintVisitor();
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
DISALLOW_COPY_AND_ASSIGN(TestRawExprPrintVisitor);
protected:
// function members
protected:
// data members
};
TestRawExprPrintVisitor::TestRawExprPrintVisitor()
{}
TestRawExprPrintVisitor::~TestRawExprPrintVisitor()
{}
void TestRawExprPrintVisitor::SetUp()
{}
void TestRawExprPrintVisitor::TearDown()
{}
TEST_F(TestRawExprPrintVisitor, const_test)
{
{
ObObj obj;
obj.set_int(123);
ObConstRawExpr expr(obj, T_INT);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
{
ObString str = ObString::make_string("abcd");
ObObj obj;
obj.set_varchar(str);
ObConstRawExpr expr(obj, T_VARCHAR);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
{
ObObj obj;
obj.set_null();
ObConstRawExpr expr(obj, T_NULL);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
{
ObObj obj;
obj.set_int(3);
ObConstRawExpr expr(obj, T_QUESTIONMARK);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
{
number::ObNumber nmb;
ObArenaAllocator allocator(ObModIds::TEST);
nmb.from(9000000000L, allocator);
ObObj obj;
obj.set_number(nmb);
ObConstRawExpr expr(obj, T_NUMBER);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
{
ObString var = ObString::make_string("sql_mode");
ObObj obj;
obj.set_varchar(var);
ObConstRawExpr expr(obj, T_SYSTEM_VARIABLE);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
}
TEST_F(TestRawExprPrintVisitor, unary_ref_test)
{
ObQueryRefRawExpr expr(1, T_REF_QUERY);
_OB_LOG(INFO, "unary=%s", S(ObRawExprPrintVisitor(expr)));
}
TEST_F(TestRawExprPrintVisitor, binary_ref_test)
{
ObColumnRefRawExpr expr(3, 7, T_REF_COLUMN);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
TEST_F(TestRawExprPrintVisitor, multi_op_test)
{
ObObj obj;
obj.set_int(123);
ObConstRawExpr const_expr1(obj, T_INT);
ObConstRawExpr const_expr2(obj, T_INT);
ObConstRawExpr const_expr3(obj, T_INT);
ObConstRawExpr const_expr4(obj, T_INT);
ObOpRawExpr expr;
expr.set_expr_type(T_OP_ROW);
OK(expr.add_param_expr(&const_expr1));
OK(expr.add_param_expr(&const_expr2));
OK(expr.add_param_expr(&const_expr3));
OK(expr.add_param_expr(&const_expr4));
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
TEST_F(TestRawExprPrintVisitor, case_op_test)
{
ObObj obj;
obj.set_int(123);
ObConstRawExpr const_expr1(obj, T_INT);
ObConstRawExpr const_expr2(obj, T_INT);
ObConstRawExpr const_expr3(obj, T_INT);
ObConstRawExpr const_expr4(obj, T_INT);
ObCaseOpRawExpr expr;
expr.set_arg_param_expr(&const_expr1);
OK(expr.add_when_param_expr(&const_expr2));
OK(expr.add_then_param_expr(&const_expr3));
expr.set_default_param_expr(&const_expr4);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
TEST_F(TestRawExprPrintVisitor, agg_op_test)
{
ObObj obj;
obj.set_int(123);
ObConstRawExpr const_expr1(obj, T_INT);
ObSEArray<ObRawExpr*, 1, ModulePageAllocator, true> real_param_exprs1;
OK(real_param_exprs1.push_back(&const_expr1));
ObAggFunRawExpr expr(real_param_exprs1, true, T_FUN_MAX);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
ObSEArray<ObRawExpr*, 1, ModulePageAllocator, true> real_param_exprs2;
ObAggFunRawExpr expr2(real_param_exprs2, false, T_FUN_COUNT);
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr2)));
}
TEST_F(TestRawExprPrintVisitor, sys_fun_test)
{
ObObj obj;
obj.set_int(123);
ObConstRawExpr const_expr1(obj, T_INT);
ObConstRawExpr const_expr2(obj, T_INT);
ObSysFunRawExpr expr;
expr.set_func_name(ObString::make_string("myfunc"));
OK(expr.add_param_expr(&const_expr1));
OK(expr.add_param_expr(&const_expr2));
_OB_LOG(INFO, "%s", S(ObRawExprPrintVisitor(expr)));
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -0,0 +1,134 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#include <gtest/gtest.h>
#include "sql/test_sql_utils.h"
#include "lib/utility/ob_test_util.h"
#include "sql/resolver/expr/ob_raw_expr_resolver_impl.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
#include "sql/resolver/expr/ob_raw_expr_print_visitor.h"
#include "sql/ob_sql_init.h"
#include "lib/json/ob_json_print_utils.h"
#include <fstream>
using namespace oceanbase::common;
using namespace oceanbase::sql;
using namespace oceanbase::lib;
using namespace oceanbase;
class TestRawExprResolver : public ::testing::Test {
public:
TestRawExprResolver();
virtual ~TestRawExprResolver();
virtual void SetUp();
virtual void TearDown();
private:
// disallow copy
DISALLOW_COPY_AND_ASSIGN(TestRawExprResolver);
protected:
// function members
void resolve(const char* expr, const char*& json_expr);
protected:
// data members
};
TestRawExprResolver::TestRawExprResolver()
{}
TestRawExprResolver::~TestRawExprResolver()
{}
void TestRawExprResolver::SetUp()
{}
void TestRawExprResolver::TearDown()
{}
void TestRawExprResolver::resolve(const char* expr, const char*& json_expr)
{
ObArray<ObQualifiedName> columns;
ObArray<ObVarInfo> sys_vars;
ObArray<ObSubQueryInfo> sub_query_info;
ObArray<ObAggFunRawExpr*> aggr_exprs;
ObArray<ObWinFunRawExpr*> win_exprs;
const char* expr_str = expr;
ObIAllocator& allocator = CURRENT_CONTEXT.get_arena_allocator();
ObRawExprFactory expr_factory(allocator);
ObTimeZoneInfo tz_info;
ObNameCaseMode case_mode = OB_NAME_CASE_INVALID;
ObExprResolveContext ctx(expr_factory, &tz_info, case_mode);
ctx.connection_charset_ = ObCharset::get_default_charset();
ctx.dest_collation_ = ObCharset::get_default_collation(ctx.connection_charset_);
ctx.is_extract_param_type_ = false;
ObSQLSessionInfo session;
session.set_use_static_typing_engine(false);
ctx.session_info_ = &session;
ObRawExpr* raw_expr = NULL;
OK(ObRawExprUtils::make_raw_expr_from_str(
expr_str, strlen(expr_str), ctx, raw_expr, columns, sys_vars, &sub_query_info, aggr_exprs, win_exprs));
_OB_LOG(DEBUG, "================================================================");
_OB_LOG(DEBUG, "%s", expr);
_OB_LOG(DEBUG, "%s", CSJ(raw_expr));
OK(raw_expr->extract_info());
// OK(raw_expr->deduce_type());
json_expr = CSJ(raw_expr);
}
TEST_F(TestRawExprResolver, all)
{
static const char* test_file = "./expr/test_raw_expr_resolver.test";
static const char* tmp_file = "./expr/test_raw_expr_resolver.tmp";
static const char* result_file = "./expr/test_raw_expr_resolver.result";
std::ifstream if_tests(test_file);
ASSERT_TRUE(if_tests.is_open());
std::string line;
const char* json_expr = NULL;
std::ofstream of_result(tmp_file);
ASSERT_TRUE(of_result.is_open());
int64_t case_id = 0;
while (std::getline(if_tests, line)) {
of_result << '[' << case_id++ << "] " << line << std::endl;
resolve(line.c_str(), json_expr);
of_result << json_expr << std::endl;
}
of_result.close();
// verify results
fprintf(stderr, "If tests failed, use `diff %s %s' to see the differences. \n", result_file, tmp_file);
std::ifstream if_result(tmp_file);
ASSERT_TRUE(if_result.is_open());
std::istream_iterator<std::string> it_result(if_result);
std::ifstream if_expected(result_file);
ASSERT_TRUE(if_expected.is_open());
std::istream_iterator<std::string> it_expected(if_expected);
ASSERT_TRUE(std::equal(it_result, std::istream_iterator<std::string>(), it_expected));
std::remove(tmp_file);
}
int main(int argc, char** argv)
{
int ret = 0;
::testing::InitGoogleTest(&argc, argv);
system("rm -rf test_optimizer.log");
OB_LOGGER.set_log_level("INFO");
OB_LOGGER.set_file_name("test_raw_expr_resolver.log", true);
ContextParam param;
param.set_mem_attr(1001, 0, ObCtxIds::WORK_AREA).set_page_size(OB_MALLOC_BIG_BLOCK_SIZE);
init_sql_factories();
CREATE_WITH_TEMP_CONTEXT(param)
{
ret = RUN_ALL_TESTS();
}
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
1 like 1.0
'1' like '1'
2 in (1, 2, 3)
2 not in (1, 2, 3)
1 or 1
100 and 0
100 or 0 and 100
case name when 'sam' then 'yong' when 'lee' then 'handsome' else 'good' end
case when 1>0 then 'true' else 'false' end
now()
utc_timestamp()
floor(3.14)
count(*)
max(c1)
c1 in (select t1 from table1)
1=(select c1 from table1 where c2>20)
(t1,t2)=(select c1, c2 from table1)
10
@@auto_increment_increment
@a
c1
10+10
not 10
c1+c2=c3+c4
c1=3
c1>1
c1 > c2
c1 in (1,2,3,4)
c1 between 2 and 10
10+10+c1
c1 = 1 + 2
c1 between 10+10 and 30
1+c1 > ? and 'abc' || c2 = 'def'
binary binary 'abc' collate utf8_general_ci collate utf8_bin
X not like Y
Z not regexp A

View File

@ -0,0 +1,120 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_OPTIMIZER
#include <gtest/gtest.h>
#include "lib/json/ob_json.h"
#include "lib/allocator/ob_mod_define.h"
#include "lib/allocator/page_arena.h"
#include "lib/oblog/ob_log.h"
#include "sql/resolver/expr/ob_raw_expr_util.h"
#include "sql/engine/expr/ob_expr_operator.h"
using namespace oceanbase::sql;
using namespace oceanbase::common;
namespace test {
#define MAKE_RAW_EXPR_FROM_STR(str, expr) \
({ \
ret = ObRawExprUtils::make_raw_expr_from_str( \
str, strlen(str), ctx, expr, columns, sys_vars, &sub_query_info, aggr_exprs, win_exprs); \
ret; \
})
class TestRawExprToStr : public ::testing::Test {
public:
TestRawExprToStr()
{}
virtual ~TestRawExprToStr()
{}
virtual void SetUp()
{}
virtual void TearDown()
{}
private:
// disallow copy and assign
TestRawExprToStr(const TestRawExprToStr& other);
TestRawExprToStr& operator=(const TestRawExprToStr& ohter);
};
TEST_F(TestRawExprToStr, basic)
{
int ret = OB_SUCCESS;
// mock params
// stmts
ObArenaAllocator allocator(ObModIds::TEST);
ObRawExprFactory expr_factory(allocator);
ObArray<ObQualifiedName> columns;
ObArray<ObVarInfo> sys_vars;
ObArray<ObSubQueryInfo> sub_query_info;
ObArray<ObAggFunRawExpr*> aggr_exprs;
ObArray<ObWinFunRawExpr*> win_exprs;
ObTimeZoneInfo tz_info;
ObNameCaseMode case_mode = OB_NAME_CASE_INVALID;
ObExprResolveContext ctx(expr_factory, &tz_info, case_mode);
ctx.connection_charset_ = ObCharset::get_default_charset();
ctx.dest_collation_ = ObCharset::get_default_collation(ctx.connection_charset_);
ctx.is_extract_param_type_ = false;
ObSQLSessionInfo session;
session.set_use_static_typing_engine(false);
ctx.session_info_ = &session;
const int64_t buf_len = 1024;
int64_t pos = 0;
char buf[buf_len];
ObRawExpr* expr = NULL;
// const char* inner_offset = "1+c1 > ? and 'abc' || c2 = 'def'";
const char* expr1 = "1+c1 > ? and SUM(1) OR 2 >= 1";
const char* expr2 = "CASE WHEN 10>=2 THEN 1+2 ELSE 0 END";
const char* expr3 = "CASE WHEN 10>=2 THEN 10-2 ELSE SUM(10-2) END";
const char* expr4 = "1/2";
MAKE_RAW_EXPR_FROM_STR(expr1, expr);
EXPECT_TRUE(OB_SUCC(ret));
pos = 0;
ret = expr->get_name(buf, buf_len, pos);
EXPECT_TRUE(OB_SUCC(ret));
_OB_LOG(INFO, "%.*s", static_cast<int32_t>(pos), buf);
pos = 0;
MAKE_RAW_EXPR_FROM_STR(expr2, expr);
EXPECT_TRUE(OB_SUCC(ret));
ret = expr->get_name(buf, buf_len, pos);
EXPECT_TRUE(OB_SUCC(ret));
_OB_LOG(INFO, "%.*s", static_cast<int32_t>(pos), buf);
pos = 0;
MAKE_RAW_EXPR_FROM_STR(expr3, expr);
EXPECT_TRUE(OB_SUCC(ret));
ret = expr->get_name(buf, buf_len, pos);
EXPECT_TRUE(OB_SUCC(ret));
_OB_LOG(INFO, "%.*s", static_cast<int32_t>(pos), buf);
pos = 0;
MAKE_RAW_EXPR_FROM_STR(expr4, expr);
EXPECT_TRUE(OB_SUCC(ret));
ret = expr->get_name(buf, buf_len, pos);
EXPECT_TRUE(OB_SUCC(ret));
_OB_LOG(INFO, "%.*s", static_cast<int32_t>(pos), buf);
}
} // namespace test
int main(int argc, char** argv)
{
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,59 @@
c1 = 1 + 2
c1 = 1 - 2
c1 = 1 * 2
c1 = 1 / 2
c1 = 1 % 2
c1 = 1 div 2
c1 = (1 <= 2)
c1 = (1 < 2)
c1 = 2
c1 = (1 >= 2)
c1 = (1 > 2)
c1 = (1 != 2)
c1 = (1 and 0)
c1 = (1 or 0)
c1 in (select * from t1)
c1 = last_insert_id(c1 + 1)
c1 = locate("bar", "foobarbar")
c1 = locate("bar", "foobarbar", 4)
c1 = round(2.55)
c1 = round(2.55, 2)
-(1.5)
-(1)
c1 like '//' escape '/'
c1 like '//' escape 2
c1 like '//' escape '//'
c1 like '_'
c1 like 2
c1 in (select t1 from table1)
1=(select c1 from table1 where c2>20)
(t1,t2)=(select c1, c2 from table1)
exists (select c1 from t1)
not (not (not exists (select c1 from t1)))
(select c1 from t1 where (c1, c2) in ((1, 2), (2, 3))) in (select c1 from t1)
case name when 'sam' then 'yong' when 'lee' then 'handsome' else 'good' end
case when 1>0 then 'true' else 'false' end
now()
utc_timestamp()
floor(3.14)
count(*)
max(c1)
c1 in (select t1 from table1)
1=(select c1 from table1 where c2>20)
(t1,t2)=(select c1, c2 from table1)
10
@@auto_increment_increment
@a
c1
10+10
not 10
c1+c2=c3+c4
c1=3
c1>1
c1 > c2
c1 in (1,2,3,4)
c1 between 2 and 10
10+10+c1
c1 = 1 + 2
c1 between 10+10 and 30
1+c1 > ? and 'abc' || c2 = 'def'

View File

@ -0,0 +1,714 @@
*************** Case 1 ***************
before : create view v1 as select * from t2;
after : create view v1 as select `rongxuan`.`t2`.`c1` AS `c1`,`rongxuan`.`t2`.`c2` AS `c2`,`rongxuan`.`t2`.`c3` AS `c3` from `rongxuan`.`t2`
*************** Case 2 ***************
before : create view v as select 1, true, false, '', 'test', null, 10.123;
after : create view v as select 1 AS `1`,1 AS `true`,0 AS `false`,'' AS ``,'test' AS `test`,NULL AS `null`,10.123 AS `10.123`
*************** Case 3 ***************
before : create view v as select 1 from DUAL;
after : create view v as select 1 AS `1`
*************** Case 4 ***************
before : create view v as select 1 from DUAL where 2>1;
after : create view v as select 1 AS `1` from DUAL where (2 > 1)
*************** Case 5 ***************
before : create view v as select c1 from t1 where c1 group by c2 having c1 order by c2 limit 1, 10;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where `rongxuan`.`t1`.`c1` group by `rongxuan`.`t1`.`c2` having `rongxuan`.`t1`.`c1` order by `rongxuan`.`t1`.`c2` limit 1,10
*************** Case 6 ***************
before : create view v as (select c1 from t1) union (select c2 from t2) order by c1 limit 1
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` union select `rongxuan`.`t2`.`c2` AS `c2` from `rongxuan`.`t2` order by `c1` limit 1
*************** Case 7 ***************
before : create view v as select * from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 8 ***************
before : create view v as select t1.* from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 9 ***************
before : create view v as select t1.*,view_table_2.* from t1, view_table_2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2`,`rongxuan`.`view_table_2`.`a` AS `a`,`rongxuan`.`view_table_2`.`b` AS `b` from `rongxuan`.`t1`,`rongxuan`.`view_table_2`
*************** Case 10 ***************
before : create view v(a,b) as select c1,c2 from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `a`,`rongxuan`.`t1`.`c2` AS `b` from `rongxuan`.`t1`
*************** Case 11 ***************
before : create view v(a,b) as select c1,c2 from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `a`,`rongxuan`.`t1`.`c2` AS `b` from `rongxuan`.`t1`
*************** Case 12 ***************
before : create view v(a,b) as select c1 as alias1, c2 from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `a`,`rongxuan`.`t1`.`c2` AS `b` from `rongxuan`.`t1`
*************** Case 13 ***************
before : create view v as select distinct c1, c2 from t1;
after : create view v as select distinct `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 14 ***************
before : create view v as select all c1, c2 from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 15 ***************
before : create view v as select * from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 16 ***************
before : create view v as select * from t1 a;
after : create view v as select `rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2` from `rongxuan`.`t1` `a`
*************** Case 17 ***************
before : create view v as select * from t1 as a;
after : create view v as select `rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2` from `rongxuan`.`t1` `a`
*************** Case 18 ***************
before : create view v as select * from t1 partition(p0,p1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` partition(p0,p1)
*************** Case 19 ***************
before : create view v as select * from t1 partition(p0,p1) a;
after : create view v as select `rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2` from `rongxuan`.`t1` partition(p0,p1) `a`
*************** Case 20 ***************
before : create view v as select * from t1 partition(p0,p1) join t2 partition(p1) a;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2`,`rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2`,`rongxuan`.`a`.`c3` AS `c3` from (`rongxuan`.`t1` partition(p0,p1) join `rongxuan`.`t2` partition(p1) `a`)
*************** Case 21 ***************
before : create view v as select * from v1;
after : create view v as select `rongxuan`.`v1`.`c1` AS `c1`,`rongxuan`.`v1`.`c2` AS `c2`,`rongxuan`.`v1`.`c3` AS `c3` from `rongxuan`.`v1`
*************** Case 22 ***************
before : create view v as select * from v1 a;
after : create view v as select `rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2`,`rongxuan`.`a`.`c3` AS `c3` from `rongxuan`.`v1` a
*************** Case 23 ***************
before : create view v as select * from v1 as a;
after : create view v as select `rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2`,`rongxuan`.`a`.`c3` AS `c3` from `rongxuan`.`v1` a
*************** Case 24 ***************
before : create view v as select t1.c1 from t1,t2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 25 ***************
before : create view v as select t1.c1 from t1,t2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 26 ***************
before : create view v as select t1.c1 from t1 join t2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2`)
*************** Case 27 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1 = t2.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`)))
*************** Case 28 ***************
before : create view v as select t1.c1 from t1 inner join t2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2`)
*************** Case 29 ***************
before : create view v as select t1.c1 from t1 inner join t2 on t1.c1 = t2.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`)))
*************** Case 30 ***************
before : create view v as select t1.c1 from t1 left join t2 on t1.c1 = t2.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` left join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`)))
*************** Case 31 ***************
before : create view v as select t1.c1 from t1 right join t2 on t1.c1 = t2.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` right join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`)))
*************** Case 32 ***************
before : create view v as select t1.c1 from t1 full join t2 on t1.c1 = t2.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` full join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`)))
*************** Case 33 ***************
before : create view v as select * from t1 ,t2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2`,`rongxuan`.`t2`.`c1` AS `c1`,`rongxuan`.`t2`.`c2` AS `c2`,`rongxuan`.`t2`.`c3` AS `c3` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 34 ***************
before : create view v as select * from t1 where c1=1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = 1)
*************** Case 35 ***************
before : create view v as select * from t1 where c1=1 and c2 = 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = 1) and (`rongxuan`.`t1`.`c2` = 1)
*************** Case 36 ***************
before : create view v as select * from t1 where c1=1 and c2 =1 and true;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = 1) and (`rongxuan`.`t1`.`c2` = 1) and 1
*************** Case 37 ***************
before : create view v as select * from t1 where c1=1 and (c2 =1 and true);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = 1) and (`rongxuan`.`t1`.`c2` = 1) and 1
*************** Case 38 ***************
before : create view v as select * from t1 where c1=1 or c2 = 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1` = 1) or (`rongxuan`.`t1`.`c2` = 1))
*************** Case 39 ***************
before : create view v as select * from t1 where c1=1 or (c2 =1 or true);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1` = 1) or (`rongxuan`.`t1`.`c2` = 1) or 1)
*************** Case 40 ***************
before : create view v as select * from t1 group by c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 41 ***************
before : create view v as select * from t1 group by c1,c2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`
*************** Case 42 ***************
before : create view v as select * from t1 group by c1 and c2;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` group by (`rongxuan`.`t1`.`c1` and `rongxuan`.`t1`.`c2`)
*************** Case 43 ***************
before : create view v as select * from t1 having c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` having `rongxuan`.`t1`.`c1`
*************** Case 44 ***************
before : create view v as select * from t1 having c1 and c2 and 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` having `rongxuan`.`t1`.`c1` and `rongxuan`.`t1`.`c2` and 1
*************** Case 45 ***************
before : create view v as select * from t1 having c1 and (c2 and true);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` having `rongxuan`.`t1`.`c1` and `rongxuan`.`t1`.`c2` and 1
*************** Case 46 ***************
before : create view v as select * from t1 order by c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` order by `rongxuan`.`t1`.`c1`
*************** Case 47 ***************
before : create view v as select * from t1 order by 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` order by `rongxuan`.`t1`.`c1`
*************** Case 48 ***************
before : create view v as select * from t1 order by c1 asc;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` order by `rongxuan`.`t1`.`c1`
*************** Case 49 ***************
before : create view v as select * from t1 order by c1 desc;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` order by `rongxuan`.`t1`.`c1`desc
*************** Case 50 ***************
before : create view v as select * from t1 order by c1 desc, c2 asc;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` order by `rongxuan`.`t1`.`c1`desc,`rongxuan`.`t1`.`c2`
*************** Case 51 ***************
before : create view v as select * from t1 order by 1 desc, c2 asc;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` order by `rongxuan`.`t1`.`c1`desc,`rongxuan`.`t1`.`c2`
*************** Case 52 ***************
before : create view v as select * from t1 limit 10;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` limit 10
*************** Case 53 ***************
before : create view v as select * from t1 limit 1, 10;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` limit 1,10
*************** Case 54 ***************
before : create view v as (select c1 from t1) union (select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` union select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2`
*************** Case 55 ***************
before : create view v as (select c1 from t1) union (select c1 from t2) union (select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` union select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2` union select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2` `t2`
*************** Case 56 ***************
before : create view v as (select c1 from t1) union (select c1 from t2) order by c1 limit 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` union select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2` order by `c1` limit 1
*************** Case 57 ***************
before : create view v as (select c1 from t1) intersect (select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` intersect select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2`
*************** Case 58 ***************
before : create view v as (select c1 from t1) intersect (select c1 from t2) order by c1 limit 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` intersect select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2` order by `c1` limit 1
*************** Case 59 ***************
before : create view v as (select c1 from t1) except (select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` except select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2`
*************** Case 60 ***************
before : create view v as (select c1 from t1) except (select c1 from t2) order by c1 limit 1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` except select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2` order by `c1` limit 1
*************** Case 61 ***************
before : create view v as select null, 1, +2, -10, 1.9, 'fdf', true, false;
after : create view v as select NULL AS `null`,1 AS `1`,2 AS `+2`,-10 AS `-10`,1.9 AS `1.9`,'fdf' AS `fdf`,1 AS `true`,0 AS `false`
*************** Case 62 ***************
before : create view v as select c1 from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1`
*************** Case 63 ***************
before : create view v as select rongxuan2.t1.c1 from t1, rongxuan2.t1;
after : create view v as select `rongxuan2`.`t1`.`c1` AS `c1` from `rongxuan`.`t1`,`rongxuan2`.`t1`
*************** Case 64 ***************
before : create view rongxuan2.v as select c1 from rongxuan.t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1`
*************** Case 65 ***************
before : create view v as select c1 and c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` and `rongxuan`.`t1`.`c2`) AS `c1 and c2` from `rongxuan`.`t1`
*************** Case 66 ***************
before : create view v as select c1 && c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` and `rongxuan`.`t1`.`c2`) AS `c1 && c2` from `rongxuan`.`t1`
*************** Case 67 ***************
before : create view v as select c1 or c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` or `rongxuan`.`t1`.`c2`) AS `c1 or c2` from `rongxuan`.`t1`
*************** Case 68 ***************
before : create view v as select c1 || c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` or `rongxuan`.`t1`.`c2`) AS `c1 || c2` from `rongxuan`.`t1`
*************** Case 69 ***************
before : create view v as select c1+c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`) AS `c1+c2` from `rongxuan`.`t1`
*************** Case 70 ***************
before : create view v as select c1-c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` - `rongxuan`.`t1`.`c2`) AS `c1-c2` from `rongxuan`.`t1`
*************** Case 71 ***************
before : create view v as select c1*c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` * `rongxuan`.`t1`.`c2`) AS `c1*c2` from `rongxuan`.`t1`
*************** Case 72 ***************
before : create view v as select c1/c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` / `rongxuan`.`t1`.`c2`) AS `c1/c2` from `rongxuan`.`t1`
*************** Case 73 ***************
before : create view v as select pow(c1,c2) from t1;
after : create view v as select pow(`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`) AS `pow(c1,c2)` from `rongxuan`.`t1`
*************** Case 74 ***************
before : create view v as select c1^c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` ^ `rongxuan`.`t1`.`c2`) AS `c1^c2` from `rongxuan`.`t1`
*************** Case 75 ***************
before : create view v as select c1%c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` % `rongxuan`.`t1`.`c2`) AS `c1%c2` from `rongxuan`.`t1`
*************** Case 76 ***************
before : create view v as select c1 div c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` div `rongxuan`.`t1`.`c2`) AS `c1 div c2` from `rongxuan`.`t1`
*************** Case 77 ***************
before : create view v as select c1<=c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` <= `rongxuan`.`t1`.`c2`) AS `c1<=c2` from `rongxuan`.`t1`
*************** Case 78 ***************
before : create view v as select c1<c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` < `rongxuan`.`t1`.`c2`) AS `c1<c2` from `rongxuan`.`t1`
*************** Case 79 ***************
before : create view v as select c1=c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` = `rongxuan`.`t1`.`c2`) AS `c1=c2` from `rongxuan`.`t1`
*************** Case 80 ***************
before : create view v as select c1<=>c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` <=> `rongxuan`.`t1`.`c2`) AS `c1<=>c2` from `rongxuan`.`t1`
*************** Case 81 ***************
before : create view v as select c1>=c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` >= `rongxuan`.`t1`.`c2`) AS `c1>=c2` from `rongxuan`.`t1`
*************** Case 82 ***************
before : create view v as select c1>c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` > `rongxuan`.`t1`.`c2`) AS `c1>c2` from `rongxuan`.`t1`
*************** Case 83 ***************
before : create view v as select c1%c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` % `rongxuan`.`t1`.`c2`) AS `c1%c2` from `rongxuan`.`t1`
*************** Case 84 ***************
before : create view v as select c1<>c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` <> `rongxuan`.`t1`.`c2`) AS `c1<>c2` from `rongxuan`.`t1`
*************** Case 85 ***************
before : create view v as select c1!=c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` <> `rongxuan`.`t1`.`c2`) AS `c1!=c2` from `rongxuan`.`t1`
*************** Case 86 ***************
before : create view v as select c1|c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` | `rongxuan`.`t1`.`c2`) AS `c1|c2` from `rongxuan`.`t1`
*************** Case 87 ***************
before : create view v as select c1&c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` & `rongxuan`.`t1`.`c2`) AS `c1&c2` from `rongxuan`.`t1`
*************** Case 88 ***************
before : create view v as select !c1 from t1;
after : create view v as select not(`rongxuan`.`t1`.`c1`) AS `!c1` from `rongxuan`.`t1`
*************** Case 89 ***************
before : create view v as select !!c1 from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1`
*************** Case 90 ***************
before : create view v as select c1 mod c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` % `rongxuan`.`t1`.`c2`) AS `c1 mod c2` from `rongxuan`.`t1`
*************** Case 91 ***************
before : create view v as select c1 div c2 from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` div `rongxuan`.`t1`.`c2`) AS `c1 div c2` from `rongxuan`.`t1`
*************** Case 92 ***************
before : create view v as select "fdsfds" regexp "fds*" from t1;
after : create view v as select ('fdsfds' regexp 'fds*') AS `"fdsfds" regexp "fds*"` from `rongxuan`.`t1`
*************** Case 93 ***************
before : create view v as select "fdsfds" not regexp "fds*" from t1;
after : create view v as select not(('fdsfds' regexp 'fds*')) AS `"fdsfds" not regexp "fds*"` from `rongxuan`.`t1`
*************** Case 94 ***************
before : create view v as select c1 from t1 where exists (select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where exists((select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 95 ***************
before : create view v as select c1 from t1 where c1 = any(select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = any (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 96 ***************
before : create view v as select c1 from t1 where c1+c2 > any(select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`) > any (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 97 ***************
before : create view v as select c1 from t1 where c1 = some(select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = any (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 98 ***************
before : create view v as select c1 from t1 where c1+c2 > some(select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`) > any (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 99 ***************
before : create view v as select c1 from t1 where c1 = all(select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = all (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 100 ***************
before : create view v as select c1 from t1 where c1+c2 > all(select c1 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`) > all (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))
*************** Case 101 ***************
before : create view v as select c1 is true from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is true) AS `c1 is true` from `rongxuan`.`t1`
*************** Case 102 ***************
before : create view v as select c1 is false from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is false) AS `c1 is false` from `rongxuan`.`t1`
*************** Case 103 ***************
before : create view v as select c1 is not true from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is not true) AS `c1 is not true` from `rongxuan`.`t1`
*************** Case 104 ***************
before : create view v as select c1 is not false from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is not false) AS `c1 is not false` from `rongxuan`.`t1`
*************** Case 105 ***************
before : create view v as select c1 is null from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is null) AS `c1 is null` from `rongxuan`.`t1`
*************** Case 106 ***************
before : create view v as select c1 is not null from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is not null) AS `c1 is not null` from `rongxuan`.`t1`
*************** Case 107 ***************
before : create view v as select c1 is unknown from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is null) AS `c1 is unknown` from `rongxuan`.`t1`
*************** Case 108 ***************
before : create view v as select c1 is not unknown from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is not null) AS `c1 is not unknown` from `rongxuan`.`t1`
*************** Case 109 ***************
before : create view v as select c1 from t1 where (c1,c2) in (select c1,c2 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`) = any (select `rongxuan`.`t2`.`c1`,`rongxuan`.`t2`.`c2` from `rongxuan`.`t2`))
*************** Case 110 ***************
before : create view v as select c1 from t1 where (c1,c2) in ((1,2),(2,3));
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`) in ((1,2),(2,3)))
*************** Case 111 ***************
before : create view v as select c1 from t1 where c1 in ((1),2,3);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` in (1,2,3))
*************** Case 112 ***************
before : create view v as select c1 from t1 where (c1,c2) in ((1,2),(2,3));
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`) in ((1,2),(2,3)))
*************** Case 113 ***************
before : create view v as select c1 from t1 where (c1,c2) not in (select c1,c2 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`) <> all (select `rongxuan`.`t2`.`c1`,`rongxuan`.`t2`.`c2` from `rongxuan`.`t2`))
*************** Case 114 ***************
before : create view v as select c1 from t1 where (c1,c2) not in (select c1,c2 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`) <> all (select `rongxuan`.`t2`.`c1`,`rongxuan`.`t2`.`c2` from `rongxuan`.`t2`))
*************** Case 115 ***************
before : create view v as select * from t1 where c1 like '%fhlds%';
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` like '%fhlds%')
*************** Case 116 ***************
before : create view v as select * from t1 where c1 not like '%fhlds%';
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where not((`rongxuan`.`t1`.`c1` like '%fhlds%'))
*************** Case 117 ***************
before : create view v as select * from t1 where c1 between 1 and 10;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` between 1 and 10)
*************** Case 118 ***************
before : create view v as select * from t1 where c1 not between 1 and 10;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` not between 1 and 10)
*************** Case 119 ***************
before : create view v as select if(c1>10,1,2) from t1;
after : create view v as select (case when (`rongxuan`.`t1`.`c1` > 10) then 1 else 2 end) AS `if(c1>10,1,2)` from `rongxuan`.`t1`
*************** Case 120 ***************
before : create view v as select now() from t1;
after : create view v as select now() AS `now()` from `rongxuan`.`t1`
*************** Case 121 ***************
before : create view v as select now(0) from t1;
after : create view v as select now() AS `now(0)` from `rongxuan`.`t1`
*************** Case 122 ***************
before : create view v as select now(3) from t1;
after : create view v as select now() AS `now(3)` from `rongxuan`.`t1`
*************** Case 123 ***************
before : create view v as select current_timestamp() from t1;
after : create view v as select now() AS `current_timestamp()` from `rongxuan`.`t1`
*************** Case 124 ***************
before : create view v as select current_timestamp(0) from t1;
after : create view v as select now() AS `current_timestamp(0)` from `rongxuan`.`t1`
*************** Case 125 ***************
before : create view v as select current_timestamp(3) from t1;
after : create view v as select now() AS `current_timestamp(3)` from `rongxuan`.`t1`
*************** Case 126 ***************
before : create view v as select localtime() from t1;
after : create view v as select now() AS `localtime()` from `rongxuan`.`t1`
*************** Case 127 ***************
before : create view v as select localtime(0) from t1;
after : create view v as select now() AS `localtime(0)` from `rongxuan`.`t1`
*************** Case 128 ***************
before : create view v as select localtime(3) from t1;
after : create view v as select now() AS `localtime(3)` from `rongxuan`.`t1`
*************** Case 129 ***************
before : create view v as select localtimestamp() from t1;
after : create view v as select now() AS `localtimestamp()` from `rongxuan`.`t1`
*************** Case 130 ***************
before : create view v as select localtimestamp(0) from t1;
after : create view v as select now() AS `localtimestamp(0)` from `rongxuan`.`t1`
*************** Case 131 ***************
before : create view v as select localtimestamp(3) from t1;
after : create view v as select now() AS `localtimestamp(3)` from `rongxuan`.`t1`
*************** Case 132 ***************
before : create view v as select curtime() from t1;
after : create view v as select curtime() AS `curtime()` from `rongxuan`.`t1`
*************** Case 133 ***************
before : create view v as select curtime(0) from t1;
after : create view v as select curtime() AS `curtime(0)` from `rongxuan`.`t1`
*************** Case 134 ***************
before : create view v as select curtime(3) from t1;
after : create view v as select curtime() AS `curtime(3)` from `rongxuan`.`t1`
*************** Case 135 ***************
before : create view v as select current_time from t1;
after : create view v as select curtime() AS `current_time` from `rongxuan`.`t1`
*************** Case 136 ***************
before : create view v as select current_time() from t1;
after : create view v as select curtime() AS `current_time()` from `rongxuan`.`t1`
*************** Case 137 ***************
before : create view v as select current_time(0) from t1;
after : create view v as select curtime() AS `current_time(0)` from `rongxuan`.`t1`
*************** Case 138 ***************
before : create view v as select current_time(3) from t1;
after : create view v as select curtime() AS `current_time(3)` from `rongxuan`.`t1`
*************** Case 139 ***************
before : create view v as select curdate() from t1;
after : create view v as select curdate() AS `curdate()` from `rongxuan`.`t1`
*************** Case 140 ***************
before : create view v as select current_date from t1;
after : create view v as select curdate() AS `current_date` from `rongxuan`.`t1`
*************** Case 141 ***************
before : create view v as select current_date() from t1;
after : create view v as select curdate() AS `current_date()` from `rongxuan`.`t1`
*************** Case 142 ***************
before : create view v as SELECT DATE_ADD('1999-01-01', INTERVAL 1 DAY);
after : create view v as select ('1999-01-01' + interval 1 day) AS `DATE_ADD('1999-01-01', INTERVAL 1 DAY)`
*************** Case 143 ***************
before : create view v as select date_add(current_date(), interval 2 day) from t1;
after : create view v as select (curdate() + interval 2 day) AS `date_add(current_date(), interval 2 day)` from `rongxuan`.`t1`
*************** Case 144 ***************
before : create view v as SELECT DATE_sub('1999-01-01', INTERVAL 1 DAY);
after : create view v as select ('1999-01-01' - interval 1 day) AS `DATE_sub('1999-01-01', INTERVAL 1 DAY)`
*************** Case 145 ***************
before : create view v as select date_sub(current_date(), interval 2 day) from t1;
after : create view v as select (curdate() - interval 2 day) AS `date_sub(current_date(), interval 2 day)` from `rongxuan`.`t1`
*************** Case 146 ***************
before : create view v as SELECT TIMESTAMPDIFF(MONTH,'2009-12-01','2009-09-01');
after : create view v as select timestampdiff(month,'2009-12-01','2009-09-01') AS `TIMESTAMPDIFF(MONTH,'2009-12-01','2009-09-01')`
*************** Case 147 ***************
before : create view v as SELECT extract(MONTH from '2009-12-01');
after : create view v as select extract(month from '2009-12-01') AS `extract(MONTH from '2009-12-01')`
*************** Case 148 ***************
before : create view v as select current_date() from t1;
after : create view v as select curdate() AS `current_date()` from `rongxuan`.`t1`
*************** Case 149 ***************
before : create view v as select utc_timestamp() from t1;
after : create view v as select utc_timestamp() AS `utc_timestamp()` from `rongxuan`.`t1`
*************** Case 150 ***************
before : create view v as select utc_timestamp(3) from t1;
after : create view v as select utc_timestamp(3) AS `utc_timestamp(3)` from `rongxuan`.`t1`
*************** Case 151 ***************
before : create view v as select date(c1) from t1;
after : create view v as select date(`rongxuan`.`t1`.`c1`) AS `date(c1)` from `rongxuan`.`t1`
*************** Case 152 ***************
before : create view v as select month(c1) from t1;
after : create view v as select month(`rongxuan`.`t1`.`c1`) AS `month(c1)` from `rongxuan`.`t1`
*************** Case 153 ***************
before : create view v as SELECT TRIM(leading "a" from ' barbar ');
after : create view v as select trim(leading 'a' from ' barbar ') AS `TRIM(leading "a" from ' barbar ')`
*************** Case 154 ***************
before : create view v as select substring("fdfdsaf" from 2 for 3);
after : create view v as select substr('fdfdsaf',2,3) AS `substring("fdfdsaf" from 2 for 3)`
*************** Case 155 ***************
before : create view v as select coalesce(null, "fdfdsaf");
after : create view v as select coalesce(NULL,'fdfdsaf') AS `coalesce(null, "fdfdsaf")`
*************** Case 156 ***************
before : create view v as select cast(c1 as binary) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as binary(4194303)) AS `cast(c1 as binary)` from `rongxuan`.`t1`
*************** Case 157 ***************
before : create view v as select cast(c1 as binary(10)) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as binary(10)) AS `cast(c1 as binary(10))` from `rongxuan`.`t1`
*************** Case 158 ***************
before : create view v as select cast(c1 as character) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as character(4194303)) AS `cast(c1 as character)` from `rongxuan`.`t1`
*************** Case 159 ***************
before : create view v as select cast(c1 as character(10)) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as character(10)) AS `cast(c1 as character(10))` from `rongxuan`.`t1`
*************** Case 160 ***************
before : create view v as select cast(c1 as char) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as character(4194303)) AS `cast(c1 as char)` from `rongxuan`.`t1`
*************** Case 161 ***************
before : create view v as select cast(c1 as char(10)) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as character(10)) AS `cast(c1 as char(10))` from `rongxuan`.`t1`
*************** Case 162 ***************
before : create view v as select convert(1, binary);
after : create view v as select cast(1 as binary(4194303)) AS `convert(1, binary)`
*************** Case 163 ***************
before : create view v as select convert(1, binary(10));
after : create view v as select cast(1 as binary(10)) AS `convert(1, binary(10))`
*************** Case 164 ***************
before : create view v as select convert(1, character);
after : create view v as select cast(1 as character(4194303)) AS `convert(1, character)`
*************** Case 165 ***************
before : create view v as select convert(1, character(10));
after : create view v as select cast(1 as character(10)) AS `convert(1, character(10))`
*************** Case 166 ***************
before : create view v as select convert(1, char);
after : create view v as select cast(1 as character(4194303)) AS `convert(1, char)`
*************** Case 167 ***************
before : create view v as select convert(1, char(10));
after : create view v as select cast(1 as character(10)) AS `convert(1, char(10))`
*************** Case 168 ***************
before : create view v as select convert(1 using binary);
after : create view v as select convert(1 using 'binary') AS `convert(1 using binary)`
*************** Case 169 ***************
before : create view v as select convert(1 using utf8mb4);
after : create view v as select convert(1 using 'utf8mb4') AS `convert(1 using utf8mb4)`
*************** Case 170 ***************
before : create view v as select cast(c1 as number(3,2)) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as number(3,2)) AS `cast(c1 as number(3,2))` from `rongxuan`.`t1`
*************** Case 171 ***************
before : create view v as select cast(c1 as datetime) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as datetime) AS `cast(c1 as datetime)` from `rongxuan`.`t1`
*************** Case 172 ***************
before : create view v as select cast(c1 as date) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as date) AS `cast(c1 as date)` from `rongxuan`.`t1`
*************** Case 173 ***************
before : create view v as select cast(c1 as time) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as time) AS `cast(c1 as time)` from `rongxuan`.`t1`
*************** Case 174 ***************
before : create view v as select cast(c1 as signed) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as signed) AS `cast(c1 as signed)` from `rongxuan`.`t1`
*************** Case 175 ***************
before : create view v as select cast(c1 as unsigned) from t1;
after : create view v as select cast(`rongxuan`.`t1`.`c1` as unsigned) AS `cast(c1 as unsigned)` from `rongxuan`.`t1`
*************** Case 176 ***************
before : create view v as select concat(c1,c2,'fds') from t1
after : create view v as select concat(`rongxuan`.`t1`.`c1`,`rongxuan`.`t1`.`c2`,'fds') AS `concat(c1,c2,'fds')` from `rongxuan`.`t1`
*************** Case 177 ***************
before : create view v as select binary c1+c2 from t1;
after : create view v as select (cast(`rongxuan`.`t1`.`c1` as binary(4194303)) + `rongxuan`.`t1`.`c2`) AS `binary c1+c2` from `rongxuan`.`t1`
*************** Case 178 ***************
before : create view v as select isnull(c1) from t1;
after : create view v as select (`rongxuan`.`t1`.`c1` is null) AS `isnull(c1)` from `rongxuan`.`t1`
*************** Case 179 ***************
before : create view v as select hex(c1) from t1;
after : create view v as select hex(`rongxuan`.`t1`.`c1`) AS `hex(c1)` from `rongxuan`.`t1`
*************** Case 180 ***************
before : create view v as select unhex(c1) from t1;
after : create view v as select unhex(`rongxuan`.`t1`.`c1`) AS `unhex(c1)` from `rongxuan`.`t1`
*************** Case 181 ***************
before : create view v as select count(*) from t1 group by c1;
after : create view v as select count(0) AS `count(*)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 182 ***************
before : create view v as select count(c1) from t1 group by c1;
after : create view v as select count(`rongxuan`.`t1`.`c1`) AS `count(c1)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 183 ***************
before : create view v as select count(c1+10) from t1;
after : create view v as select count((`rongxuan`.`t1`.`c1` + 10)) AS `count(c1+10)` from `rongxuan`.`t1`
*************** Case 184 ***************
before : create view v as select count(distinct c1+10,c2-10) from t1;
after : create view v as select count(distinct (`rongxuan`.`t1`.`c1` + 10),(`rongxuan`.`t1`.`c2` - 10)) AS `count(distinct c1+10,c2-10)` from `rongxuan`.`t1`
*************** Case 185 ***************
before : create view v as select sum(c1+c2) from t1 group by c1;
after : create view v as select sum((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `sum(c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 186 ***************
before : create view v as select sum(all c1+c2) from t1 group by c1;
after : create view v as select sum((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `sum(all c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 187 ***************
before : create view v as select sum(distinct c1+c2) from t1 group by c1;
after : create view v as select sum(distinct (`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `sum(distinct c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 188 ***************
before : create view v as select min(c1+c2) from t1 group by c1;
after : create view v as select min((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `min(c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 189 ***************
before : create view v as select min(all c1+c2) from t1 group by c1;
after : create view v as select min((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `min(all c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 190 ***************
before : create view v as select min(distinct c1+c2) from t1 group by c1;
after : create view v as select min(distinct (`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `min(distinct c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 191 ***************
before : create view v as select max(c1+c2) from t1 group by c1;
after : create view v as select max((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `max(c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 192 ***************
before : create view v as select max(all c1+c2) from t1 group by c1;
after : create view v as select max((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `max(all c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 193 ***************
before : create view v as select max(distinct c1+c2) from t1 group by c1;
after : create view v as select max(distinct (`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `max(distinct c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 194 ***************
before : create view v as select avg(c1+c2) from t1 group by c1;
after : create view v as select avg((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `avg(c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 195 ***************
before : create view v as select avg(all c1+c2) from t1 group by c1;
after : create view v as select avg((`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `avg(all c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 196 ***************
before : create view v as select avg(distinct c1+c2) from t1 group by c1;
after : create view v as select avg(distinct (`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`)) AS `avg(distinct c1+c2)` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 197 ***************
before : create view v as select group_concat(distinct c1+c2,c2 order by c2, 1 desc separator ',') from t1 group by c1;
after : create view v as select group_concat(distinct (`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`),`rongxuan`.`t1`.`c2`,`rongxuan`.`t1`.`c2`,(`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`) order by `rongxuan`.`t1`.`c2`,(`rongxuan`.`t1`.`c1` + `rongxuan`.`t1`.`c2`) desc separator ',') AS `group_concat(distinct c1+c2,c2 order by c2, 1 desc separator ',')` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1`
*************** Case 198 ***************
before : create view v as select case when c1 > 3 then 1 when c1 > 2 then 2 else 1 end from t1;
after : create view v as select (case when (`rongxuan`.`t1`.`c1` > 3) then 1 when (`rongxuan`.`t1`.`c1` > 2) then 2 else 1 end) AS `case when c1 > 3 then 1 when c1 > 2 then 2 else 1 end` from `rongxuan`.`t1`
*************** Case 199 ***************
before : create view v as select c1 from t1 where (select c1) = (select c1 from t2 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where ((select `rongxuan`.`t1`.`c1`) = (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2` limit 1))
*************** Case 200 ***************
before : create view v as select c1 from t1 order by (select c1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` order by (select `rongxuan`.`t1`.`c1`)
*************** Case 201 ***************
before : create view v as select c1 from t1 group by (select c1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` group by (select `rongxuan`.`t1`.`c1`)
*************** Case 202 ***************
before : create view v as select c1 from t1 having (select c1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` having (select `rongxuan`.`t1`.`c1`)
*************** Case 203 ***************
before : create view v as select t1.c1 from t1 full join t2 on t1.c1 = (select c2 from t2 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` full join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = (select `rongxuan`.`t2`.`c2` from `rongxuan`.`t2` `t2` limit 1))))
*************** Case 204 ***************
before : create view v as select t1.c1 from t1 left join t2 on t1.c1 = (select c2 from t2 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` left join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = (select `rongxuan`.`t2`.`c2` from `rongxuan`.`t2` `t2` limit 1))))
*************** Case 205 ***************
before : create view v as select t1.c1 from t1 right join t2 on t1.c1 = any(select c2 from t2);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` right join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = any (select `rongxuan`.`t2`.`c2` from `rongxuan`.`t2` `t2`))))
*************** Case 206 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`)))
*************** Case 207 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1= t2.c1 or t1.c1 > (select 10);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2` on (((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`) or (`rongxuan`.`t1`.`c1` > (select 10)))))
*************** Case 208 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1 join t3 on t1.c1=0;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from ((`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`))) join `rongxuan`.`t3` on ((`rongxuan`.`t1`.`c1` = 0)))
*************** Case 209 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1 inner join t3 on t1.c1=0 left join t4 on t1.c1 > t4.c1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (((`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`))) join `rongxuan`.`t3` on ((`rongxuan`.`t1`.`c1` = 0))) left join `rongxuan`.`t4` on ((`rongxuan`.`t1`.`c1` > `rongxuan`.`t4`.`c1`)))
*************** Case 210 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1 join t3 on t1.c1=0;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from ((`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`))) join `rongxuan`.`t3` on ((`rongxuan`.`t1`.`c1` = 0)))
*************** Case 211 ***************
before : create view v as select t1.c1 from t1 join t2 a on t1.c1=a.c1 join t3 b on a.c1 != 10;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from ((`rongxuan`.`t1` join `rongxuan`.`t2` `a` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`a`.`c1`))) join `rongxuan`.`t3` `b` on ((`rongxuan`.`a`.`c1` <> 10)))
*************** Case 212 ***************
before : create view v as select c2 from t1 where c1 > all((select c1 from t1) union (select c1 from t2));
after : create view v as select `rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > all ((select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` `t1`) union (select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2`)))
*************** Case 213 ***************
before : create view v as select c2 from t1 where c1 > all((select c1 from t1) except (select c1 from t2));
after : create view v as select `rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > all ((select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` `t1`) except (select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2`)))
*************** Case 214 ***************
before : create view v as select c1 from t1 where c1 > (select c2 from t1 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > (select `rongxuan`.`t1`.`c2` from `rongxuan`.`t1` `t1` limit 1))
*************** Case 215 ***************
before : create view v as select c1 from t1 where c1 > (select c2 from t2 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > (select `rongxuan`.`t2`.`c2` from `rongxuan`.`t2` limit 1))
*************** Case 216 ***************
before : create view v as select c1 from t1 where c1 > (select c2 from t1 tt limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > (select `rongxuan`.`tt`.`c2` from `rongxuan`.`t1` `tt` limit 1))
*************** Case 217 ***************
before : create view v as select c1 from t1 where c1 > (select c2 from t1 as tt limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > (select `rongxuan`.`tt`.`c2` from `rongxuan`.`t1` `tt` limit 1))
*************** Case 218 ***************
before : create view v as select t1.c1 from t1 join t2 on t1.c1 > (select c2 from t2 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` > (select `rongxuan`.`t2`.`c2` from `rongxuan`.`t2` `t2` limit 1))))
*************** Case 219 ***************
before : create view v as select c1 from t1 group by c1 having c1 > (select c1 from t2 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` group by `rongxuan`.`t1`.`c1` having (`rongxuan`.`t1`.`c1` > (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2` limit 1))
*************** Case 220 ***************
before : create view v as select c1 from t1 where c1 > (select t1.c2 from t1 join t2 on t1.c1 = t2.c1 limit 1);
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` > (select `rongxuan`.`t1`.`c2` from (`rongxuan`.`t1` `t1` join `rongxuan`.`t2` on ((`rongxuan`.`t1`.`c1` = `rongxuan`.`t2`.`c1`))) limit 1))
*************** Case 221 ***************
before : create view v as select c1, (select c2 from t2 limit 1) from t1;
after : create view v as select `rongxuan`.`t1`.`c1` AS `c1`,(select `rongxuan`.`t2`.`c2` from `rongxuan`.`t2` limit 1) AS `(select c2 from t2 limit 1)` from `rongxuan`.`t1`
*************** Case 222 ***************
before : create view v as select /*+ NO_REWRITE */ * from t1;
after : create view v as select /*+ NO_REWRITE */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 223 ***************
before : create view v as select /*+ READ_CONSISTENCY(frozen) */ * from t1;
after : create view v as select /*+ READ_CONSISTENCY(FROZEN) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 224 ***************
before : create view v as select /*+ READ_CONSISTENCY(weak) */ * from t1;
after : create view v as select /*+ READ_CONSISTENCY(WEAK) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 225 ***************
before : create view v as select /*+ READ_CONSISTENCY(strong) */ * from t1;
after : create view v as select /*+ READ_CONSISTENCY(STRONG) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 226 ***************
before : create view v as select /*+ INDEX(t1 c1) */ * from t1;
after : create view v as select /*+ INDEX(t1 c1) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 227 ***************
before : create view v as select /*+ FULL(t1) */ * from t1;
after : create view v as select /*+ FULL(t1) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 228 ***************
before : create view v as select /*+ QUERY_TIMEOUT(100000) */ * from t1;
after : create view v as select /*+ QUERY_TIMEOUT(100000) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 229 ***************
before : create view v as select /*+ LEADING(t1,t2) */ t1.* from t1,t2;
after : create view v as select /*+ LEADING(t1 t2) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 230 ***************
before : create view v as select /*+ USE_MERGE(t1,t2) */ t1.* from t1,t2;
after : create view v as select /*+ USE_MERGE(t1 t2) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 231 ***************
before : create view v as select /*+ USE_HASH(t1,t2) */ t1.* from t1,t2;
after : create view v as select /*+ USE_HASH(t1 t2) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 232 ***************
before : create view v as select /*+ USE_NL(t1,t2) */ t1.* from t1,t2;
after : create view v as select /*+ USE_NL(t1 t2) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 233 ***************
before : create view v as select /*+ USE_PLAN_CACHE(default) */ * from t1;
after : create view v as select /*+ USE_PLAN_CACHE(default) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 234 ***************
before : create view v as select /*+ USE_PLAN_CACHE(exact) */ * from t1;
after : create view v as select /*+ USE_PLAN_CACHE(exact) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 235 ***************
before : create view v as select /*+ ORDERED */ * from t1;
after : create view v as select /*+ ORDERED */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 236 ***************
before : create view v as select /*+ NO_REWRITE, READ_CONSISTENCY(weak), index(t1 c1), full(t1), QUERY_TIMEOUT(1000000), LEADING(t1), USE_MERGE(t1), USE_HASH(t1),USE_NL(t1), USE_PLAN_CACHE(default), ORDERED */ * from t1;
after : create view v as select /*+ NO_REWRITE READ_CONSISTENCY(WEAK) QUERY_TIMEOUT(1000000) USE_PLAN_CACHE(default) ORDERED INDEX(t1 c1) FULL(t1) LEADING(t1) USE_MERGE(t1) USE_HASH(t1) USE_NL(t1) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 237 ***************
before : create view v as select /*+ USE_HASH(@sel1 t1,t2) */ t1.* from t1,t2;
after : create view v as select /*+ USE_HASH(@sel1 t1 t2) */`rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`,`rongxuan`.`t2`
*************** Case 238 ***************
before : create view v as select t1.c1 from t1 where c1 in (select/*+FULL(@sel1 t1)*/ c1 from t2);
after : create view v as select /*+ FULL(@sel1 t1) */`rongxuan`.`t1`.`c1` AS `c1` from `rongxuan`.`t1` where (`rongxuan`.`t1`.`c1` = any (select `rongxuan`.`t2`.`c1` from `rongxuan`.`t2`))

View File

@ -0,0 +1,12 @@
*************** Case 1 ***************
before : select * from t1;
after : select `rongxuan`.`t1`.`c1` AS `c1`,`rongxuan`.`t1`.`c2` AS `c2` from `rongxuan`.`t1`
*************** Case 2 ***************
before : select * from (select * from t2) a;
after : select `a`.`c1` AS `c1`,`a`.`c2` AS `c2`,`a`.`c3` AS `c3` from (select `rongxuan`.`t2`.`c1` AS `c1`,`rongxuan`.`t2`.`c2` AS `c2`,`rongxuan`.`t2`.`c3` AS `c3` from `rongxuan`.`t2`) a
*************** Case 3 ***************
before : select a.*, b.*, c.alias + 10 from t1 a, (select c1 from t2) b, (select c3 as alias from t3) c;
after : select `rongxuan`.`a`.`c1` AS `c1`,`rongxuan`.`a`.`c2` AS `c2`,`b`.`c1` AS `c1`,(`c`.`alias` + 10) AS `c.alias + 10` from `rongxuan`.`t1` `a`,(select `rongxuan`.`t2`.`c1` AS `c1` from `rongxuan`.`t2`) b,(select `rongxuan`.`t3`.`c3` AS `alias` from `rongxuan`.`t3`) c
*************** Case 4 ***************
before : select t1.c1 from t1 join (select t2.c1 from t2 join (select * from t3) a) b;
after : select `rongxuan`.`t1`.`c1` AS `c1` from (`rongxuan`.`t1` join (select `rongxuan`.`t2`.`c1` AS `c1` from (`rongxuan`.`t2` join (select `rongxuan`.`t3`.`c3` AS `c3`,`rongxuan`.`t3`.`c4` AS `c4` from `rongxuan`.`t3`) a)) b)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,585 @@
*************** Case 1 ***************
drop database if exists altersystem;
{
"drop_database_arg":"tenant_id",
"database_name":"altersystem",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database altersystem;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"altersystem",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use altersystem;
{
"stmt_type":97
}
*************** Case 4 ***************
alter system switch replica leader server = '127.0.0.1:80'
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":-1,
"partition_id":-1,
"part_idx":268435455,
"subpart_idx":268435455
},
"server":"127.0.0.1:80",
"zone":"",
"tenant_name":""
}
}
*************** Case 5 ***************
alter system switch replica leader zone = '127.0.0.1:80'
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":-1,
"partition_id":-1,
"part_idx":268435455,
"subpart_idx":268435455
},
"server":"0.0.0.0",
"zone":"127.0.0.1:80",
"tenant_name":""
}
}
*************** Case 6 ***************
alter system switch replica leader partition_id = '1 % 3 @ 4' server = '127.0.0.1:80'
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":4,
"partition_id":1,
"part_cnt":3
},
"server":"127.0.0.1:80",
"zone":"",
"tenant_name":""
}
}
*************** Case 7 ***************
alter system switch replica leader zone = 'z1';
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":-1,
"partition_id":-1,
"part_idx":268435455,
"subpart_idx":268435455
},
"server":"0.0.0.0",
"zone":"z1",
"tenant_name":""
}
}
*************** Case 8 ***************
alter system switch replica leader server = '127.0.0.1:80';
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":-1,
"partition_id":-1,
"part_idx":268435455,
"subpart_idx":268435455
},
"server":"127.0.0.1:80",
"zone":"",
"tenant_name":""
}
}
*************** Case 9 ***************
alter system switch replica leader partition_id = '1%8@3001' server = '127.0.0.1:80';
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"",
"tenant_name":""
}
}
*************** Case 10 ***************
alter system switch replica leader partition_id '1%8@3001' server '127.0.0.1:80';
{
"stmt_type":100,
"rpc_arg": {
"role":1,
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"",
"tenant_name":""
}
}
*************** Case 11 ***************
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80';
{
"stmt_type":101,
"rpc_arg": {
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"",
"create_timestamp":0,
"force_cmd":false
}
}
*************** Case 12 ***************
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80' create_timestamp = 1;
{
"stmt_type":101,
"rpc_arg": {
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"",
"create_timestamp":1,
"force_cmd":false
}
}
*************** Case 13 ***************
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80' zone = 'z1';
{
"stmt_type":101,
"rpc_arg": {
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"z1",
"create_timestamp":0,
"force_cmd":false
}
}
*************** Case 14 ***************
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80' create_timestamp = 1 zone = 'z1';
{
"stmt_type":101,
"rpc_arg": {
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"z1",
"create_timestamp":1,
"force_cmd":false
}
}
*************** Case 15 ***************
alter system drop replica partition_id '1%8@3001' server '127.0.0.1:80' create_timestamp 1 zone 'z1';
{
"stmt_type":101,
"rpc_arg": {
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"server":"127.0.0.1:80",
"zone":"z1",
"create_timestamp":1,
"force_cmd":false
}
}
*************** Case 16 ***************
alter system copy replica partition_id = '1%8@3001' source = '127.0.0.1:80' destination = '127.0.0.2:80';
{
"stmt_type":102,
"rpc_arg": {
"is_copy":true,
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"src":"127.0.0.1:80",
"dest":"127.0.0.2:80",
"force_cmd":false
}
}
*************** Case 17 ***************
alter system move replica partition_id = '1%8@3001' source = '127.0.0.1:80' destination = '127.0.0.2:80';
{
"stmt_type":102,
"rpc_arg": {
"is_copy":false,
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"src":"127.0.0.1:80",
"dest":"127.0.0.2:80",
"force_cmd":false
}
}
*************** Case 18 ***************
alter system move replica partition_id '1%8@3001' source '127.0.0.1:80' destination '127.0.0.2:80';
{
"stmt_type":102,
"rpc_arg": {
"is_copy":false,
"partition_key": {
"tid":3001,
"partition_id":1,
"part_cnt":8
},
"src":"127.0.0.1:80",
"dest":"127.0.0.2:80",
"force_cmd":false
}
}
*************** Case 19 ***************
alter system report replica;
{
"stmt_type":80,
"rpc_arg": {
"server":"0.0.0.0",
"zone":""
}
}
*************** Case 20 ***************
alter system report replica server = '127.0.0.1:80';
{
"stmt_type":80,
"rpc_arg": {
"server":"127.0.0.1:80",
"zone":""
}
}
*************** Case 21 ***************
alter system report replica zone = 'z1';
{
"stmt_type":80,
"rpc_arg": {
"server":"0.0.0.0",
"zone":"z1"
}
}
*************** Case 22 ***************
alter system recycle replica;
{
"stmt_type":103,
"rpc_arg": {
"server":"0.0.0.0",
"zone":""
}
}
*************** Case 23 ***************
alter system recycle replica server = '127.0.0.1:80';
{
"stmt_type":103,
"rpc_arg": {
"server":"127.0.0.1:80",
"zone":""
}
}
*************** Case 24 ***************
alter system recycle replica server '127.0.0.1:80';
{
"stmt_type":103,
"rpc_arg": {
"server":"127.0.0.1:80",
"zone":""
}
}
*************** Case 25 ***************
alter system recycle replica zone = 'z1';
{
"stmt_type":103,
"rpc_arg": {
"server":"0.0.0.0",
"zone":"z1"
}
}
*************** Case 26 ***************
alter system recycle replica zone 'z1';
{
"stmt_type":103,
"rpc_arg": {
"server":"0.0.0.0",
"zone":"z1"
}
}
*************** Case 27 ***************
alter system major freeze;
{
"stmt_type":84,
"major_freeze":true,
"opt_server_list_": [
],
"opt_tenant_ids_": [
],
"opt_partition_key_": {
"tid":-1,
"partition_id":-1,
"part_idx":268435455,
"subpart_idx":268435455
}
}
*************** Case 28 ***************
alter system start merge zone = 'z1';
{
"stmt_type":104,
"rpc_arg": {
"type":1,
"zone":"z1"
}
}
*************** Case 29 ***************
alter system suspend merge;
{
"stmt_type":104,
"rpc_arg": {
"type":2,
"zone":""
}
}
*************** Case 30 ***************
alter system suspend merge zone = 'z1';
{
"stmt_type":104,
"rpc_arg": {
"type":2,
"zone":"z1"
}
}
*************** Case 31 ***************
alter system resume merge;
{
"stmt_type":104,
"rpc_arg": {
"type":3,
"zone":""
}
}
*************** Case 32 ***************
alter system resume merge zone = 'z1';
{
"stmt_type":104,
"rpc_arg": {
"type":3,
"zone":"z1"
}
}
*************** Case 33 ***************
alter system clear roottable;
{
"stmt_type":94,
"rpc_arg": {
"tenant_name":""
}
}
*************** Case 34 ***************
alter system clear roottable tenant = 'test';
{
"stmt_type":94,
"rpc_arg": {
"tenant_name":"test"
}
}
*************** Case 35 ***************
alter system refresh schema;
{
"stmt_type":95,
"rpc_arg": {
"server":"0.0.0.0",
"zone":""
}
}
*************** Case 36 ***************
alter system refresh schema zone = 'test';
{
"stmt_type":95,
"rpc_arg": {
"server":"0.0.0.0",
"zone":"test"
}
}
*************** Case 37 ***************
alter system refresh schema server = '127.0.0.1:80';
{
"stmt_type":95,
"rpc_arg": {
"server":"127.0.0.1:80",
"zone":""
}
}
*************** Case 38 ***************
alter system set abc = 1, abd = 'xx' server = '127.0.0.1:80', def = true comment 'defxxx' tenant = 't1';
{
"stmt_type":175,
"rpc_arg": {
"items": [
{
"name":"abc",
"value":"1",
"comment":"",
"zone":"",
"server":"0.0.0.0",
"tenant_name":"",
"exec_tenant_id":1,
"tenant_ids": [
]
},
{
"name":"abd",
"value":"xx",
"comment":"",
"zone":"",
"server":"127.0.0.1:80",
"tenant_name":"",
"exec_tenant_id":1,
"tenant_ids": [
]
},
{
"name":"def",
"value":"1",
"comment":"defxxx",
"zone":"",
"server":"0.0.0.0",
"tenant_name":"t1",
"exec_tenant_id":1,
"tenant_ids": [
]
}
]
}
}
*************** Case 39 ***************
alter system modify zone 'z1'
{
"stmt_type":99
}
*************** Case 40 ***************
alter system modify zone 'z1' region = 'r1'
{
"stmt_type":99
}
*************** Case 41 ***************
alter system modify zone 'z1' idc = 'idc1'
{
"stmt_type":99
}
*************** Case 42 ***************
alter system modify zone 'z1' zone_type = 'ReadWrite'
{
"stmt_type":99
}
*************** Case 43 ***************
alter system modify zone 'z1' set idc 'idc1', region 'r1'
{
"stmt_type":99
}
*************** Case 44 ***************
alter system modify zone 'z1' set region 'r1', idc 'idc1'
{
"stmt_type":99
}
*************** Case 45 ***************
alter system modify zone 'z1' set zone_type 'ReadWrite', region 'r1'
{
"stmt_type":99
}
*************** Case 46 ***************
alter system modify zone 'z1' set region 'r1', zone_type 'ReadWrite'
{
"stmt_type":99
}
*************** Case 47 ***************
alter system modify zone 'z1' set idc 'idc1', zone_type 'ReadWrite'
{
"stmt_type":99
}
*************** Case 48 ***************
alter system modify zone 'z1' set zone_type 'ReadWrite', idc 'idc1'
{
"stmt_type":99
}
*************** Case 49 ***************
alter system modify zone 'z1' set zone_type 'ReadWrite', idc 'idc1', region 'r1'
{
"stmt_type":99
}
*************** Case 50 ***************
alter system modify zone 'z1' set zone_type 'ReadWrite', region 'r1', idc 'idc1'
{
"stmt_type":99
}
*************** Case 51 ***************
alter system modify zone 'z1' set idc 'idc1', zone_type 'ReadWrite', region 'r1'
{
"stmt_type":99
}
*************** Case 52 ***************
alter system modify zone 'z1' set idc 'idc1', region 'r1', zone_type 'ReadWrite'
{
"stmt_type":99
}
*************** Case 53 ***************
alter system modify zone 'z1' set region 'r1', idc 'idc1', zone_type 'ReadWrite'
{
"stmt_type":99
}
*************** Case 54 ***************
alter system modify zone 'z1' set region 'r1', zone_type 'ReadWrite', idc 'idc1'
{
"stmt_type":99
}
*************** Case 55 ***************
drop database altersystem;
{
"drop_database_arg":"tenant_id",
"database_name":"altersystem",
"if_exist":false,
"to_recyclebin":false
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,186 @@
*************** Case 1 ***************
drop database if exists database_test;
{
"drop_database_arg":"tenant_id",
"database_name":"database_test",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database if not exists database_test;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
alter database database_test CHARACTER SET UTF8;
{
"alter_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"invalid_type",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 4 ***************
alter database database_test collate utf8mb4_general_ci;
{
"alter_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":0,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 5 ***************
alter database database_test CHARACTER SET UTF8 collate utf8mb4_general_ci;
{
"alter_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 6 ***************
drop database database_test;
{
"drop_database_arg":"tenant_id",
"database_name":"database_test",
"if_exist":false,
"to_recyclebin":false
}
*************** Case 7 ***************
create database database_test CHARACTER SET UTF8;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"invalid_type",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 8 ***************
drop database database_test;
{
"drop_database_arg":"tenant_id",
"database_name":"database_test",
"if_exist":false,
"to_recyclebin":false
}
*************** Case 9 ***************
create database database_test collate utf8mb4_general_ci;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":0,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 10 ***************
drop database database_test;
{
"drop_database_arg":"tenant_id",
"database_name":"database_test",
"if_exist":false,
"to_recyclebin":false
}
*************** Case 11 ***************
create database database_test CHARACTER SET UTF8 collate utf8mb4_general_ci;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"database_test",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}

View File

@ -0,0 +1,387 @@
*************** Case 1 ***************
drop database if exists dbdcl;
{
"drop_database_arg":"tenant_id",
"database_name":"dbdcl",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database dbdcl;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"dbdcl",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use dbdcl;
{
"stmt_type":97
}
*************** Case 4 ***************
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t1", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":1, "part_option":{"part_func_type":0, "part_func_expr":"c1 + 1", "part_num":3, "partition_cnt_within_partition_table":-1, "max_used_part_id":2}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":3, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":1, "name":"p1", "high_bound_val":, "list_row_values":[], "part_idx":1}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":2, "name":"p2", "high_bound_val":, "list_row_values":[], "part_idx":2}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"dbdcl", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 5 ***************
create user 'hualong' identified by '123456'
{
"stmt_type":58,
"users_to_create": [
"hualong",
"%",
"123456",
"YES"
]
}
*************** Case 6 ***************
create user 'hualong' identified by '123456', '' identified by '123456'
{
"stmt_type":58,
"users_to_create": [
"hualong",
"%",
"123456",
"YES",
"",
"%",
"123456",
"YES"
]
}
*************** Case 7 ***************
drop user 'hualong'
{
"stmt_type":59,
"users": [
"hualong",
"%"
]
}
*************** Case 8 ***************
set password for 'hualong' = password('111111')
{
"stmt_type":60,
"user_pwd": [
"hualong",
"%",
"111111"
]
}
*************** Case 9 ***************
alter user 'hualong' identified by '111111'
{
"stmt_type":60,
"user_pwd": [
"hualong",
"%",
"111111"
]
}
*************** Case 10 ***************
rename user 'hualong' to 'hualong01'
{
"stmt_type":62,
"rename_infos": [
"hualong",
"%",
"hualong01",
"%"
]
}
*************** Case 11 ***************
alter user 'hualong','zdy' account lock
{
"stmt_type":61,
"tenant_id":1,
"user": [
"hualong",
"%",
"zdy",
"%"
],
"locked":true
}
*************** Case 12 ***************
alter user 'xiaohua','zdy' account unlock
{
"stmt_type":61,
"tenant_id":1,
"user": [
"xiaohua",
"%",
"zdy",
"%"
],
"locked":false
}
*************** Case 13 ***************
grant all privileges on * to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"DB_LEVEL",
"database":"dbdcl",
"table":"",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 14 ***************
grant all privileges on *.* to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_CREATE_USER,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW,PRIV_SHOW_DB,PRIV_SUPER,PRIV_PROCESS",
"grant_level":"USER_LEVEL",
"database":"",
"table":"",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 15 ***************
grant all privileges on rongxuan.* to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"DB_LEVEL",
"database":"rongxuan",
"table":"",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 16 ***************
grant all privileges on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 17 ***************
grant all privileges on t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"TABLE_LEVEL",
"database":"dbdcl",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 18 ***************
grant all privileges on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 19 ***************
grant alter on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_ALTER",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 20 ***************
grant create on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_CREATE",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 21 ***************
grant drop on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_DROP",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 22 ***************
grant select on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_SELECT",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 23 ***************
grant update on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_UPDATE",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 24 ***************
grant insert on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_INSERT",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 25 ***************
grant delete on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_DELETE",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 26 ***************
grant index on rongxuan.t1 to 'hualong'
{
"stmt_type":63,
"priv_set":"PRIV_INDEX",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
"hualong",
"%",
"",
"NO"
]
}
*************** Case 27 ***************
revoke all privileges on rongxuan.t1 from 'hualong'
{
"stmt_type":64,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"TABLE_LEVEL",
"database":"rongxuan",
"table":"t1",
"users": [
1000
],
"revoke_all":false
}
*************** Case 28 ***************
revoke all privileges, grant option from 'hualong'
{
"stmt_type":64,
"priv_set":"",
"grant_level":"USER_LEVEL",
"database":"",
"table":"",
"users": [
1000
],
"revoke_all":true
}
*************** Case 29 ***************
revoke all privileges on * from 'hualong'
{
"stmt_type":64,
"priv_set":"PRIV_ALTER,PRIV_CREATE,PRIV_DELETE,PRIV_DROP,PRIV_INSERT,PRIV_UPDATE,PRIV_SELECT,PRIV_INDEX,PRIV_CREATE_VIEW,PRIV_SHOW_VIEW",
"grant_level":"DB_LEVEL",
"database":"dbdcl",
"table":"",
"users": [
1000
],
"revoke_all":false
}
*************** Case 30 ***************
drop database dbdcl;
{
"drop_database_arg":"tenant_id",
"database_name":"dbdcl",
"if_exist":false,
"to_recyclebin":false
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,709 @@
*************** Case 1 ***************
drop database if exists enum_db;
{
"drop_database_arg":"tenant_id",
"database_name":"enum_db",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database enum_db;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"enum_db",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use enum_db;
{
"stmt_type":97
}
*************** Case 4 ***************
create table t1(c1 int primary key, c2 enum('a', 'b', 'c')) partition by hash(c1 + 1) partitions 3
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t1", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":1, "part_option":{"part_func_type":0, "part_func_expr":"c1 + 1", "part_num":3, "partition_cnt_within_partition_table":-1, "max_used_part_id":2}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":3, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":1, "name":"p1", "high_bound_val":, "list_row_values":[], "part_idx":1}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":2, "name":"p2", "high_bound_val":, "list_row_values":[], "part_idx":2}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"enum_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 5 ***************
create table t2(c1 int, c2 int, c3 enum('a', 'b', 'c'), primary key(c2, c3)) partition by key(c2, c3) partitions 3
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t2", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":1, "part_option":{"part_func_type":6, "part_func_expr":"c2, c3", "part_num":3, "partition_cnt_within_partition_table":-1, "max_used_part_id":2}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":3, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":1, "name":"p1", "high_bound_val":, "list_row_values":[], "part_idx":1}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":2, "name":"p2", "high_bound_val":, "list_row_values":[], "part_idx":2}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":2, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":17, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}, {"length":1, "column_id":18, "type":{"type":"ENUM", "collation":"utf8mb4_general_ci", "coercibility":"INVALID"}, "order":0, "fulltext_flag":false}], "capacity":2}, "partition_key_info":{"columns":[{"length":0, "column_id":17, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}, {"length":1, "column_id":18, "type":{"type":"ENUM", "collation":"utf8mb4_general_ci", "coercibility":"INVALID"}, "order":0, "fulltext_flag":false}], "capacity":2}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"enum_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 6 ***************
create table t22(c1 int, c2 int, c3 enum('a', 'b', 'c'), primary key(c2, c3)) partition by key(c2, c3) partitions 3
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t22", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":1, "part_option":{"part_func_type":6, "part_func_expr":"c2, c3", "part_num":3, "partition_cnt_within_partition_table":-1, "max_used_part_id":2}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":3, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":1, "name":"p1", "high_bound_val":, "list_row_values":[], "part_idx":1}, "mapping_pg_part_id":-1}, {"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":2, "name":"p2", "high_bound_val":, "list_row_values":[], "part_idx":2}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":2, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":17, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}, {"length":1, "column_id":18, "type":{"type":"ENUM", "collation":"utf8mb4_general_ci", "coercibility":"INVALID"}, "order":0, "fulltext_flag":false}], "capacity":2}, "partition_key_info":{"columns":[{"length":0, "column_id":17, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}, {"length":1, "column_id":18, "type":{"type":"ENUM", "collation":"utf8mb4_general_ci", "coercibility":"INVALID"}, "order":0, "fulltext_flag":false}], "capacity":2}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"enum_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 7 ***************
create table t3(c3 int primary key, c4 enum('a', 'b', 'c') default 'c')
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t3", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"enum_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 8 ***************
create table t4(c1 int primary key, c3 enum('a', 'b', 'c'))
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t4", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"enum_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 9 ***************
create table coll_table(c1 varchar(10) collate utf8_general_ci, c2 enum('a', 'b', 'c'), c3 varchar(10), primary key(c1, c2));
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"coll_table", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":2, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":10, "column_id":16, "type":{"type":"VARCHAR", "collation":"utf8mb4_general_ci", "coercibility":"INVALID"}, "order":0, "fulltext_flag":false}, {"length":1, "column_id":17, "type":{"type":"ENUM", "collation":"utf8mb4_general_ci", "coercibility":"INVALID"}, "order":0, "fulltext_flag":false}], "capacity":2}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"enum_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 10 ***************
insert into t3 values(1,2);
{
"stmt_type":2,
"table": [
{
"table_id":1099511677880,
"table_name":"t3",
"alias_name":"",
"synonym_name":"",
"table_type":0,
"ref_id":1099511677880,
"database_name":"enum_db",
"for_update":false,
"wait":-1,
"mock_id":-1,
"view_base_item":-1
}
],
"partition_express": [
],
"all_table_columns": [
{
"table_name":"t3",
"index_dml_infos": [
{
"table_id":1099511677880,
"index_tid":1099511677880,
"index_name":"t3",
"rowkey_cnt":1,
"part_cnt":1,
"column_exprs": [
{
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":16387,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
1
],
"table_id":1099511677880,
"column_id":16,
"database_name":"enum_db",
"table_name":"t3",
"synonym_name":"",
"column_name":"c3",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1,
"enum_set_values": [
],
"is_lob_column":false
},
{
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"ENUM",
"collation":"utf8mb4_general_ci",
"coercibility":"IMPLICIT"
},
"accuracy": {
"length":1,
"precision":-1,
"scale":-1
},
"flag":0,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"UNKNOWN",
"CNT_COLUMN",
"UNKNOWN"
],
"rel_id": [
1
],
"table_id":1099511677880,
"column_id":17,
"database_name":"enum_db",
"table_name":"t3",
"synonym_name":"",
"column_name":"c4",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1,
"enum_set_values": [
"a",
"b",
"c"
],
"is_lob_column":false
}
],
"assignments": [
]
}
]
}
],
"is_ignore":false,
"primary_key_ids": [
],
"column_conv": [
{
"item_type":"T_FUN_COLUMN_CONV",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"IMPLICIT"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_FUNC",
"CNT_CONST",
"CNT_COLUMN",
"CNT_FUNC"
],
"rel_id": [
],
"expr_levels": [
0
],
"func":"column_conv",
"children": [
{
"item_type":"T_INT32",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"INT":4
}
},
{
"item_type":"T_INT32",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"INT":63
}
},
{
"item_type":"T_INT",
"result_type": {
"meta": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"BIGINT":51539607551
}
},
{
"item_type":"T_TINYINT",
"result_type": {
"meta": {
"type":"TINYINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"TINYINT":0
}
},
{
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":16515,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
],
"table_id":1099511677880,
"column_id":16,
"database_name":"",
"table_name":"__values",
"synonym_name":"",
"column_name":"c3",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":false,
"explicited_ref_count":0,
"enum_set_values": [
],
"is_lob_column":false
}
],
"enum_set_values": [
]
},
{
"item_type":"T_FUN_COLUMN_CONV",
"result_type": {
"meta": {
"type":"ENUM",
"collation":"utf8mb4_general_ci",
"coercibility":"IMPLICIT"
},
"accuracy": {
"length":1,
"precision":-1,
"scale":-1
},
"flag":0,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_FUNC",
"CNT_CONST",
"CNT_COLUMN",
"CNT_FUNC",
"UNKNOWN"
],
"rel_id": [
],
"expr_levels": [
0
],
"func":"column_conv",
"children": [
{
"item_type":"T_INT32",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"INT":32
}
},
{
"item_type":"T_INT32",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"INT":45
}
},
{
"item_type":"T_INT",
"result_type": {
"meta": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"BIGINT":-4294967295
}
},
{
"item_type":"T_TINYINT",
"result_type": {
"meta": {
"type":"TINYINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":-1,
"scale":-1
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"TINYINT":1
}
},
{
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"ENUM",
"collation":"utf8mb4_general_ci",
"coercibility":"IMPLICIT"
},
"accuracy": {
"length":1,
"precision":-1,
"scale":-1
},
"flag":0,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"UNKNOWN",
"CNT_COLUMN",
"UNKNOWN"
],
"rel_id": [
],
"table_id":1099511677880,
"column_id":17,
"database_name":"",
"table_name":"__values",
"synonym_name":"",
"column_name":"c4",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":false,
"explicited_ref_count":0,
"enum_set_values": [
"a",
"b",
"c"
],
"is_lob_column":false
}
],
"enum_set_values": [
"a",
"b",
"c"
]
}
],
"hint": {
"read_static":false,
"no_rewrite":false,
"frozen_version":-1,
"topk_precision":-1,
"sharding_minimum_row_count":0,
"query_timeout":-1,
"hotspot":false,
"index": [
],
"read_consistency":-1,
"join_ordered":false,
"join_order": [
],
"merge_hint_ids": [
],
"hash_hint_ids": [
],
"no_hash_hint_ids": [
],
"nl_hint_ids": [
],
"part_hints": [
],
"use_late_materialization":-1,
"log_level":"",
"max_concurrent":-1,
"only_concurrent_hint":false,
"has_hint_exclude_concurrent":false,
"parallel":-1,
"use_px":0,
"use join filter":false,
"org_pq_distributes": [
],
"pq_distributes": [
]
},
"query_context": {
"param_num":2,
"fetch_cur_time":true,
"calculable_items": [
]
},
"value": [
{
"item_type":"T_QUESTIONMARK",
"result_type": {
"meta": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":1,
"precision":1,
"scale":0
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"IS_PARAM",
"CNT_CONST",
"CNT_PARAM"
],
"rel_id": [
],
"value": {
"UNKNOWN":0
}
},
{
"item_type":"T_QUESTIONMARK",
"result_type": {
"meta": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":1,
"precision":1,
"scale":0
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"IS_PARAM",
"CNT_CONST",
"CNT_PARAM"
],
"rel_id": [
],
"value": {
"UNKNOWN":1
}
}
]
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
*************** Case 1 ***************
drop database if exists generated_column_db;
{
"drop_database_arg":"tenant_id",
"database_name":"generated_column_db",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database generated_column_db;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"generated_column_db",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use generated_column_db;
{
"stmt_type":97
}
*************** Case 4 ***************
create table t1(c1 int primary key, c2 int as (c1 + 1));

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
*************** Case 1 ***************
purge table t1;
{
"stmt_type":136,
"purge_table_arg": {
"tenant_id":1,
"table_name":"t1"
}
}
*************** Case 2 ***************
purge database db1;
{
"stmt_type":135,
"purge_db_arg": {
"tenant_id":1,
"db_name":"db1"
}
}
*************** Case 3 ***************
purge schema db1;
{
"stmt_type":135,
"purge_db_arg": {
"tenant_id":1,
"db_name":"db1"
}
}
*************** Case 4 ***************
purge tenant tenant1;
{
"stmt_type":134,
"purge_tenant_arg": {
"tenant_id":1,
"tenant_name":"tenant1"
}
}

View File

@ -0,0 +1,121 @@
*************** Case 1 ***************
drop database if exists rename_db;
{
"drop_database_arg":"tenant_id",
"database_name":"rename_db",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
drop database if exists rename_to;
{
"drop_database_arg":"tenant_id",
"database_name":"rename_to",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 3 ***************
create database rename_db;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"rename_db",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 4 ***************
create database rename_to;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"rename_to",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 5 ***************
use rename_db;
{
"stmt_type":97
}
*************** Case 6 ***************
create table t1(c1 int primary key,c2 int);
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t1", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"rename_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 7 ***************
create table t2(c1 int primary key,c2 varchar(30));
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t2", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"rename_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 8 ***************
rename table t1 to test,t2 to test2;
{
"stmt_type":111,
"rename_table_arg": {
"tenant_id":1,
"rename_table_items": [
{
"origin_db_name":"rename_db",
"new_db_name":"rename_db",
"origin_table_name":"t1",
"new_table_name":"test"
},
{
"origin_db_name":"rename_db",
"new_db_name":"rename_db",
"origin_table_name":"t2",
"new_table_name":"test2"
}
]
}
}
*************** Case 9 ***************
rename table t1 to test,t2 to t1,test to t2;
{
"stmt_type":111,
"rename_table_arg": {
"tenant_id":1,
"rename_table_items": [
{
"origin_db_name":"rename_db",
"new_db_name":"rename_db",
"origin_table_name":"t1",
"new_table_name":"test"
},
{
"origin_db_name":"rename_db",
"new_db_name":"rename_db",
"origin_table_name":"t2",
"new_table_name":"t1"
},
{
"origin_db_name":"rename_db",
"new_db_name":"rename_db",
"origin_table_name":"test",
"new_table_name":"t2"
}
]
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,420 @@
*************** Case 1 ***************
create synonym syn_t1 for t1;
{
"create_synonym_arg": {
"synonym_info": {
"tenant_id":1,
"database_id":-1,
"synonym_id":-1,
"schema_version":0
},
"db_name":"rongxuan",
"obj_db_name":"rongxuan"
}
}
*************** Case 2 ***************
select * from t1;
{
"stmt_type":1,
"table": [
{
"table_id":1099511677777,
"table_name":"t1",
"alias_name":"",
"table_type":0,
"ref_id":1099511677777,
"database_name":"rongxuan",
"for_update":false,
"wait":-1,
"mock_id":-1
}
],
"joined_table": [
],
"partition_express": [
{
"table_id":1099511677777,
"partition_express": {
"item_type":"T_OP_ADD",
"result_type": {
"meta": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":12,
"scale":0
},
"flag":1,
"calc_type": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
}
},
"expr_info": [
"CNT_CONST",
"CNT_COLUMN"
],
"rel_id": [
],
"expr_levels": [
],
"children": [
{
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":16387,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
1
],
"table_id":1099511677777,
"column_id":16,
"database_name":"rongxuan",
"table_name":"t1",
"column_name":"c1",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1
},
{
"item_type":"T_INT",
"result_type": {
"meta": {
"type":"BIGINT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":1,
"precision":1,
"scale":0
},
"flag":1,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_CONST",
"CNT_CONST"
],
"rel_id": [
],
"value": {
"BIGINT":1
}
}
]
},
"partition_express":null
}
],
"column": [
{
"column_id":16,
"table_id":1099511677777,
"column":"c1",
"auto_filled_timestamp":false,
"default_value": {
"NULL":"NULL"
},
"expression": {
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":16387,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
1
],
"table_id":1099511677777,
"column_id":16,
"database_name":"rongxuan",
"table_name":"t1",
"column_name":"c1",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1
}
},
{
"column_id":17,
"table_id":1099511677777,
"column":"c2",
"auto_filled_timestamp":false,
"default_value": {
"NULL":"NULL"
},
"expression": {
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":0,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
1
],
"table_id":1099511677777,
"column_id":17,
"database_name":"rongxuan",
"table_name":"t1",
"column_name":"c2",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1
}
}
],
"select": [
{
"expression": {
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":16387,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
1
],
"table_id":1099511677777,
"column_id":16,
"database_name":"rongxuan",
"table_name":"t1",
"column_name":"c1",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1
},
"is_alias":false,
"alias_name":"c1",
"expr_name":"c1",
"default": {
"NULL":"NULL"
}
},
{
"expression": {
"item_type":"T_REF_COLUMN",
"result_type": {
"meta": {
"type":"INT",
"collation":"binary",
"coercibility":"NUMERIC"
},
"accuracy": {
"length":-1,
"precision":11,
"scale":0
},
"flag":0,
"calc_type": {
"type":"NULL",
"collation":"invalid_type",
"coercibility":"INVALID"
}
},
"expr_info": [
"IS_COLUMN",
"CNT_COLUMN"
],
"rel_id": [
1
],
"table_id":1099511677777,
"column_id":17,
"database_name":"rongxuan",
"table_name":"t1",
"column_name":"c2",
"expr_level":0,
"expr_levels": [
0
],
"column_flags":0,
"is_explicited_referece":true,
"explicited_ref_count":1
},
"is_alias":false,
"alias_name":"c2",
"expr_name":"c2",
"default": {
"NULL":"NULL"
}
}
],
"distinct":false,
"rollup":false,
"nocycle":false,
"from": [
{
"table_id":1099511677777,
"is_join":false
}
],
"start_with": [
],
"connect_by": [
],
"where": [
],
"group_by": [
],
"having": [
],
"aggr_func": [
],
"order_by": [
],
"limit":null,
"offset":null,
"show_stmt_ctx": {
"is_from_show_stmt":false,
"global_scope":false,
"tenant_id":-1,
"show_database_id":-1,
"show_table_id":-1,
"grants_user_id":-1
},
"hint": {
"read_static":false,
"no_rewrite":false,
"frozen_version":-1,
"topk_precision":-1,
"sharding_minimum_row_count":0,
"query_timeout":-1,
"hotspot":false,
"index": [
],
"read_consistency":-1,
"join_ordered":false,
"join_order": [
],
"merge_hint_ids": [
],
"hash_hint_ids": [
],
"no_hash_hint_ids": [
],
"nl_hint_ids": [
],
"part_hints": [
],
"use_late_materialization":-1,
"log_level":"",
"max_concurrent":-1,
"only_concurrent_hint":false,
"has_hint_exclude_concurrent":false,
"parallel":-1
},
"query_context": {
"param_num":0,
"fetch_cur_time":true,
"calculable_items": [
]
},
"extra_output_exprs": [
],
"current_level":0,
"equal_sets": [
],
"child_stmts": [
],
"has_transformed_for_hierarchical_query":false,
"is_hierarchical_query":false
}
*************** Case 3 ***************
select * from syn_t1;

View File

@ -0,0 +1,796 @@
*************** Case 1 ***************
drop database if exists tablegroup_db;
{
"drop_database_arg":"tenant_id",
"database_name":"tablegroup_db",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database tablegroup_db;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"tablegroup_db",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use tablegroup_db;
{
"stmt_type":97
}
*************** Case 4 ***************
create table t1(c1 int primary key, c2 int);
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t1", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"tablegroup_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 5 ***************
create table t2(c1 int primary key, c2 int, c3 varchar(32));
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t2", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"tablegroup_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 6 ***************
create table t3(c1 int primary key, c2 int, c3 varchar(32));
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t3", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"tablegroup_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 7 ***************
create tablegroup tg1;
{
"create_tablegroup_arg": {
"tablegroup_schema": {
"tenant_id":1,
"tablegroup_id":-1,
"schema_version":1,
"tablegroup_name":"tg1",
"comment":"",
"locality_info": {
"locality_str":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
]
},
"primary_zone_info": {
"primary_zone_str":"",
"primary_zone_array": [
]
},
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"part_func_expr_num":-1,
"sub_part_func_expr_num":-1,
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"error_ret":0,
"partition_status":0,
"partition_array":null,
"subpartition_array":null,
"previous_locality":"",
"binding":false
},
"if_not_exist":false,
"create_mode":1
}
}
*************** Case 8 ***************
create tablegroup tg2;
{
"create_tablegroup_arg": {
"tablegroup_schema": {
"tenant_id":1,
"tablegroup_id":-1,
"schema_version":1,
"tablegroup_name":"tg2",
"comment":"",
"locality_info": {
"locality_str":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
]
},
"primary_zone_info": {
"primary_zone_str":"",
"primary_zone_array": [
]
},
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"part_func_expr_num":-1,
"sub_part_func_expr_num":-1,
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"error_ret":0,
"partition_status":0,
"partition_array":null,
"subpartition_array":null,
"previous_locality":"",
"binding":false
},
"if_not_exist":false,
"create_mode":1
}
}
*************** Case 9 ***************
create tablegroup if not exists tg1;
{
"create_tablegroup_arg": {
"tablegroup_schema": {
"tenant_id":1,
"tablegroup_id":-1,
"schema_version":1,
"tablegroup_name":"tg1",
"comment":"",
"locality_info": {
"locality_str":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
]
},
"primary_zone_info": {
"primary_zone_str":"",
"primary_zone_array": [
]
},
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"part_func_expr_num":-1,
"sub_part_func_expr_num":-1,
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"error_ret":0,
"partition_status":0,
"partition_array":null,
"subpartition_array":null,
"previous_locality":"",
"binding":false
},
"if_not_exist":true,
"create_mode":1
}
}
*************** Case 10 ***************
alter tablegroup tg1 add table t1;
{
"alter_tablegroup_arg": {
"table_items": [
{
"database_name":"tablegroup_db",
"table_name":"t1"
}
],
"tenant_id":1,
"tablegroup_name":"tg1",
"create_mode":1,
"alter_tablegroup_schema": {
"tenant_id":-1,
"tablegroup_id":-1,
"schema_version":1,
"tablegroup_name":"",
"comment":"",
"locality_info": {
"locality_str":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
]
},
"primary_zone_info": {
"primary_zone_str":"",
"primary_zone_array": [
]
},
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"part_func_expr_num":-1,
"sub_part_func_expr_num":-1,
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"error_ret":0,
"partition_status":0,
"partition_array":null,
"subpartition_array":null,
"previous_locality":"",
"binding":false
}
}
}
*************** Case 11 ***************
alter tablegroup tg1 add table t2,t3;
{
"alter_tablegroup_arg": {
"table_items": [
{
"database_name":"tablegroup_db",
"table_name":"t2"
},
{
"database_name":"tablegroup_db",
"table_name":"t3"
}
],
"tenant_id":1,
"tablegroup_name":"tg1",
"create_mode":1,
"alter_tablegroup_schema": {
"tenant_id":-1,
"tablegroup_id":-1,
"schema_version":1,
"tablegroup_name":"",
"comment":"",
"locality_info": {
"locality_str":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
]
},
"primary_zone_info": {
"primary_zone_str":"",
"primary_zone_array": [
]
},
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"part_func_expr_num":-1,
"sub_part_func_expr_num":-1,
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"error_ret":0,
"partition_status":0,
"partition_array":null,
"subpartition_array":null,
"previous_locality":"",
"binding":false
}
}
}
*************** Case 12 ***************
alter table t1 tablegroup = 'tg1';
{
"ObTableStmt": {
"partition_fun_expr": [
],
"range_values_exprs": [
],
"list_values_exprs": [
],
"index_partition_resolve_results": [
],
"part_type":8
},
"stmt_type":22,
"alter_table_arg": {
"is_alter_columns":false,
"is_alter_indexs":false,
"is_alter_options":true,
"session_id":-1,
"index_arg_list": [
],
"alter_table_schema": {
"alter_type":"OB_INVALID_DDL_OP",
"origin_table_name":"t1",
"new_database_name":"tablegroup_db",
"origin_database_name":"tablegroup_db",
"split_partition_name":"",
"alter_table_schema": {
"simple_table_schema": {
"tenant_id":1,
"database_id":-1,
"tablegroup_id":-1,
"table_id":-1,
"table_name":"t1",
"replica_num":0,
"previous_locality_str":"",
"min_partition_id":0,
"session_id":0,
"index_type":0,
"table_type":3,
"data_table_id":0,
"name_casemode":-1,
"schema_version":0,
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"locality_str":"",
"zone_list": [
],
"primary_zone":"",
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"partition_array":null,
"subpartition_array":null,
"index_status":1,
"binding":false,
"duplicate_scope":0
},
"max_used_column_id":0,
"max_used_constraint_id":0,
"sess_active_time":0,
"rowkey_column_num":0,
"index_column_num":0,
"rowkey_split_pos":0,
"block_size":16384,
"is_use_bloomfilter":false,
"progressive_merge_num":0,
"tablet_size":-1,
"pctfree":10,
"load_type":0,
"index_using_type":0,
"def_type":1,
"charset_type":0,
"collation_type":0,
"create_mem_version":0,
"index_status":1,
"partition_status":0,
"code_version":1,
"last_modified_frozen_version":0,
"comment":"",
"pk_comment":"",
"create_host":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
],
"tablegroup_name":"tg1",
"compress_func_name":"",
"row_store_type":3,
"store_format":0,
"expire_info":"",
"view_schema": {
"view_definition":"",
"check_option":"none",
"is_updatable":"false",
"is_materialized":"false"
},
"autoinc_column_id":0,
"auto_increment":1,
"read_only":false,
"primary_zone_array": [
],
"index_tid_array": [
],
"mv_tid_array": [
],
"aux_vp_tid_array": [
],
"base_table_ids": [
],
"rowkey_info": {
"columns":null,
"capacity":0
},
"partition_key_info": {
"columns":null,
"capacity":0
},
"aux_vp_tid_array": [
]
}
},
"nls_formats": [
"",
"",
""
]
},
"index_arg_list": [
]
}
*************** Case 13 ***************
alter table t2 tablegroup = 'tg2';
{
"ObTableStmt": {
"partition_fun_expr": [
],
"range_values_exprs": [
],
"list_values_exprs": [
],
"index_partition_resolve_results": [
],
"part_type":8
},
"stmt_type":22,
"alter_table_arg": {
"is_alter_columns":false,
"is_alter_indexs":false,
"is_alter_options":true,
"session_id":-1,
"index_arg_list": [
],
"alter_table_schema": {
"alter_type":"OB_INVALID_DDL_OP",
"origin_table_name":"t2",
"new_database_name":"tablegroup_db",
"origin_database_name":"tablegroup_db",
"split_partition_name":"",
"alter_table_schema": {
"simple_table_schema": {
"tenant_id":1,
"database_id":-1,
"tablegroup_id":-1,
"table_id":-1,
"table_name":"t2",
"replica_num":0,
"previous_locality_str":"",
"min_partition_id":0,
"session_id":0,
"index_type":0,
"table_type":3,
"data_table_id":0,
"name_casemode":-1,
"schema_version":0,
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"locality_str":"",
"zone_list": [
],
"primary_zone":"",
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"partition_array":null,
"subpartition_array":null,
"index_status":1,
"binding":false,
"duplicate_scope":0
},
"max_used_column_id":0,
"max_used_constraint_id":0,
"sess_active_time":0,
"rowkey_column_num":0,
"index_column_num":0,
"rowkey_split_pos":0,
"block_size":16384,
"is_use_bloomfilter":false,
"progressive_merge_num":0,
"tablet_size":-1,
"pctfree":10,
"load_type":0,
"index_using_type":0,
"def_type":1,
"charset_type":0,
"collation_type":0,
"create_mem_version":0,
"index_status":1,
"partition_status":0,
"code_version":1,
"last_modified_frozen_version":0,
"comment":"",
"pk_comment":"",
"create_host":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
],
"tablegroup_name":"tg2",
"compress_func_name":"",
"row_store_type":3,
"store_format":0,
"expire_info":"",
"view_schema": {
"view_definition":"",
"check_option":"none",
"is_updatable":"false",
"is_materialized":"false"
},
"autoinc_column_id":0,
"auto_increment":1,
"read_only":false,
"primary_zone_array": [
],
"index_tid_array": [
],
"mv_tid_array": [
],
"aux_vp_tid_array": [
],
"base_table_ids": [
],
"rowkey_info": {
"columns":null,
"capacity":0
},
"partition_key_info": {
"columns":null,
"capacity":0
},
"aux_vp_tid_array": [
]
}
},
"nls_formats": [
"",
"",
""
]
},
"index_arg_list": [
]
}
*************** Case 14 ***************
alter table t2 drop tablegroup;
{
"ObTableStmt": {
"partition_fun_expr": [
],
"range_values_exprs": [
],
"list_values_exprs": [
],
"index_partition_resolve_results": [
],
"part_type":8
},
"stmt_type":22,
"alter_table_arg": {
"is_alter_columns":false,
"is_alter_indexs":false,
"is_alter_options":true,
"session_id":-1,
"index_arg_list": [
],
"alter_table_schema": {
"alter_type":"OB_INVALID_DDL_OP",
"origin_table_name":"t2",
"new_database_name":"tablegroup_db",
"origin_database_name":"tablegroup_db",
"split_partition_name":"",
"alter_table_schema": {
"simple_table_schema": {
"tenant_id":1,
"database_id":-1,
"tablegroup_id":-1,
"table_id":-1,
"table_name":"t2",
"replica_num":0,
"previous_locality_str":"",
"min_partition_id":0,
"session_id":0,
"index_type":0,
"table_type":3,
"data_table_id":0,
"name_casemode":-1,
"schema_version":0,
"part_level":0,
"part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"sub_part_option": {
"part_func_type":0,
"part_func_expr":"",
"part_num":1,
"partition_cnt_within_partition_table":-1,
"max_used_part_id":-1
},
"locality_str":"",
"zone_list": [
],
"primary_zone":"",
"part_num":0,
"subpart_num":0,
"partition_num":0,
"subpartition_num":0,
"partition_array":null,
"subpartition_array":null,
"index_status":1,
"binding":false,
"duplicate_scope":0
},
"max_used_column_id":0,
"max_used_constraint_id":0,
"sess_active_time":0,
"rowkey_column_num":0,
"index_column_num":0,
"rowkey_split_pos":0,
"block_size":16384,
"is_use_bloomfilter":false,
"progressive_merge_num":0,
"tablet_size":-1,
"pctfree":10,
"load_type":0,
"index_using_type":0,
"def_type":1,
"charset_type":0,
"collation_type":0,
"create_mem_version":0,
"index_status":1,
"partition_status":0,
"code_version":1,
"last_modified_frozen_version":0,
"comment":"",
"pk_comment":"",
"create_host":"",
"zone_replica_attr_array": [
],
"region_replica_num_array": [
],
"tablegroup_name":"",
"compress_func_name":"",
"row_store_type":3,
"store_format":0,
"expire_info":"",
"view_schema": {
"view_definition":"",
"check_option":"none",
"is_updatable":"false",
"is_materialized":"false"
},
"autoinc_column_id":0,
"auto_increment":1,
"read_only":false,
"primary_zone_array": [
],
"index_tid_array": [
],
"mv_tid_array": [
],
"aux_vp_tid_array": [
],
"base_table_ids": [
],
"rowkey_info": {
"columns":null,
"capacity":0
},
"partition_key_info": {
"columns":null,
"capacity":0
},
"aux_vp_tid_array": [
]
}
},
"nls_formats": [
"",
"",
""
]
},
"index_arg_list": [
]
}
*************** Case 15 ***************
drop tablegroup tg2;
{
"drop_tablegroup_arg": {
"tenant_id":1,
"tablegroup_name":"tg2",
"if_exist":false
}
}
*************** Case 16 ***************
drop tablegroup if exists tg2;
{
"drop_tablegroup_arg": {
"tenant_id":1,
"tablegroup_name":"tg2",
"if_exist":true
}
}
*************** Case 17 ***************
drop database tablegroup_db;
{
"drop_database_arg":"tenant_id",
"database_name":"tablegroup_db",
"if_exist":false,
"to_recyclebin":false
}

View File

@ -0,0 +1,97 @@
*************** Case 1 ***************
drop database if exists tcl_db;
{
"drop_database_arg":"tenant_id",
"database_name":"tcl_db",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database tcl_db;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"tcl_db",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use tcl_db;
{
"stmt_type":97
}
*************** Case 4 ***************
create table t1(c1 int primary key, c2 int);
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t1", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":17, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"tcl_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 5 ***************
create table t2(c1 int primary key, c2 int, c3 varchar(32));
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t2", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"tcl_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 6 ***************
start transaction
{
"stmt_type":69,
"read_only":false,
"with_consistent_snapshot":false
}
*************** Case 7 ***************
start transaction with consistent snapshot
{
"stmt_type":69,
"read_only":false,
"with_consistent_snapshot":true
}
*************** Case 8 ***************
begin
{
"stmt_type":69,
"read_only":false,
"with_consistent_snapshot":false
}
*************** Case 9 ***************
begin work
{
"stmt_type":69,
"read_only":false,
"with_consistent_snapshot":false
}
*************** Case 10 ***************
commit
{
"stmt_type":70
}
*************** Case 11 ***************
commit work
{
"stmt_type":70
}
*************** Case 12 ***************
rollback
{
"stmt_type":70
}
*************** Case 13 ***************
rollback work
{
"stmt_type":70
}
*************** Case 14 ***************
drop database tcl_db;
{
"drop_database_arg":"tenant_id",
"database_name":"tcl_db",
"if_exist":false,
"to_recyclebin":false
}

View File

@ -0,0 +1,40 @@
*************** Case 1 ***************
CREATE RESOURCE UNIT resource_test MAX_CPU=1, MIN_MEMORY=8589934592, MAX_MEMORY=17179869184, MAX_IOPS=10000, MAX_DISK_SIZE=10737418240, MAX_SESSION_NUM=9223372036854775807;
{
"stmt_type":17
}
*************** Case 2 ***************
CREATE RESOURCE POOL resource_zone unit='resource_test', unit_num=1, zone_list=('zone1');
{
"stmt_type":13
}
*************** Case 3 ***************
CREATE RESOURCE POOL resource_zone1 unit='resource_test', unit_num=1, zone_list=('zone1');
{
"stmt_type":13
}
*************** Case 4 ***************
CREATE TENANT if not exists tenant_test RESOURCE_POOL_LIST=('resource_zone'), LOCALITY='auto_locality_strategy', logonly_replica_num=1 set ob_tcp_invited_nodes='%';
{
"stmt_type":8
}
*************** Case 5 ***************
drop tenant tenant_test;
{
"stmt_type":9
}
*************** Case 6 ***************
drop RESOURCE POOL resource_zone1;
{
"stmt_type":14
}
*************** Case 7 ***************
drop RESOURCE POOL resource_zone;
{
"stmt_type":14
}
*************** Case 8 ***************
drop RESOURCE UNIT resource_test;
{
"stmt_type":19
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
*************** Case 1 ***************
drop database if exists wf_db;
{
"drop_database_arg":"tenant_id",
"database_name":"wf_db",
"if_exist":true,
"to_recyclebin":false
}
*************** Case 2 ***************
create database wf_db;
{
"create_database_arg":"database_schema",
"database_id":-1,
"schema_version":1,
"database_name":"wf_db",
"replica_num":0,
"zone_list": [
],
"primary_zone":"",
"charset_type":2,
"collation_type":"utf8mb4_general_ci",
"name_case_mode":-1,
"comment":"",
"read_only":false,
"default_tablegroup_id":-1,
"default_tablegroup_name":"",
"in_recyclebin":false,
"primary_zone_array": [
]
}
*************** Case 3 ***************
use wf_db;
{
"stmt_type":97
}
*************** Case 4 ***************
create table t1(c1 int primary key, c2 int, c3 datetime);
{"ObTableStmt":{"partition_fun_expr":[], "range_values_exprs":[], "list_values_exprs":[], "index_partition_resolve_results":[], "part_type":8}, "stmt_type":20, "create_table_arg":{"if_not_exist":false, "schema":{"simple_table_schema":{"tenant_id":1, "database_id":18446744073709551615, "tablegroup_id":1099511627777, "table_id":18446744073709551615, "table_name":"t1", "replica_num":0, "previous_locality_str":"", "min_partition_id":0, "session_id":0, "index_type":0, "table_type":3, "data_table_id":0, "name_casemode":-1, "schema_version":0, "part_level":0, "part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":0}, "sub_part_option":{"part_func_type":0, "part_func_expr":"", "part_num":1, "partition_cnt_within_partition_table":-1, "max_used_part_id":-1}, "locality_str":"", "zone_list":[], "primary_zone":"", "part_num":0, "subpart_num":0, "partition_num":1, "subpartition_num":0, "partition_array":[{"BasePartition":{"tenant_id":18446744073709551615, "table_id":18446744073709551615, "part_id":0, "name":"p0", "high_bound_val":, "list_row_values":[], "part_idx":0}, "mapping_pg_part_id":-1}], "subpartition_array":null, "index_status":1, "binding":false, "duplicate_scope":0}, "max_used_column_id":18, "max_used_constraint_id":0, "sess_active_time":0, "rowkey_column_num":1, "index_column_num":0, "rowkey_split_pos":0, "block_size":16384, "is_use_bloomfilter":false, "progressive_merge_num":0, "tablet_size":134217728, "pctfree":10, "load_type":0, "index_using_type":0, "def_type":1, "charset_type":2, "collation_type":45, "create_mem_version":0, "index_status":1, "partition_status":0, "code_version":1, "last_modified_frozen_version":0, "comment":"", "pk_comment":"", "create_host":"", "zone_replica_attr_array":[], "region_replica_num_array":[], "tablegroup_name":"", "compress_func_name":"zstd_1.0", "row_store_type":1, "store_format":3, "expire_info":"", "view_schema":{"view_definition":"", "check_option":"none", "is_updatable":"false", "is_materialized":"false"}, "autoinc_column_id":0, "auto_increment":1, "read_only":false, "primary_zone_array":[], "index_tid_array":[], "mv_tid_array":[], "aux_vp_tid_array":[], "base_table_ids":[], "rowkey_info":{"columns":[{"length":0, "column_id":16, "type":{"type":"INT", "collation":"binary", "coercibility":"NUMERIC"}, "order":0, "fulltext_flag":false}], "capacity":1}, "partition_key_info":{"columns":null, "capacity":0}, "aux_vp_tid_array":[]}, "index_arg_list":[], "constraint_list":[], "db_name":"wf_db", "last_replay_log_id":0, "foreign_key_arg_list":[], "vertical_partition_arg_list":[]}, "index_arg_list":[]}
*************** Case 5 ***************
drop database wf_db;
{
"drop_database_arg":"tenant_id",
"database_name":"wf_db",
"if_exist":false,
"to_recyclebin":false
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
create table t3(c1 int primary key, c2 int);
create table t2(c1 int primary key, c2 int);
create table t1(c3 int primary key, c4 int);
use d;
select c1, c3 from t3.t3 join t1 on c1=c3 where t3.c1>0 ===> OK
select t3.c1, t2.c2 from t3 join t2 on c1=c2 where t3.c1>0 ===>FAIL
ERROR 1052 (23000): Column 'c1' in on clause is ambiguous
insert into t3(d.t.*) values(1,2); ===>fail
insert into t3(d.*) values(1,2); ====>fail
use test;
create table feifei(feifei.c1 int primary key, c2 int);
create table feifei2(test.feifei2.c1 int primary key, c2 int);
create table feifei2(rongxuan.feifei2.c1 int primary key, c2 int);====>FAIL
ERROR 1102 (42000): Incorrect database name 'rongxuan'
mysql> create table feifei3(rongxuan.feifei2.c1 int primary key, c2 int);
ERROR 1102 (42000): Incorrect database name 'rongxuan'
mysql> create table feifei3(rongxuan.feifei3.* int primary key, c2 int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* int primary key, c2 int)' at line 1
alter table rongxuan add rongxuan.c3 int;
alter table rongxuan add test.rongxuan.c4 int;
alter table rongxuan add test.rongxuan.c5 int;
mysql> alter table rongxuan add test.rongxuan.* int;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* int' at line 1
mysql> alter table rongxuan add test.jinsong.c2 int;
ERROR 1103 (42000): Incorrect table name 'jinsong'
mysql> create table `` (c int primary key, c2 int);
ERROR 1103 (42000): Incorrect table name ''

View File

@ -0,0 +1,348 @@
#
#################################schema##############################
#
create table view_table_2(a int, b int);
create view v1 as select * from t2;
create database rongxuan2;
create table rongxuan2.t1(c1 int);
#
##############################select clause###########################
#
#
##basic
#
create view v as select 1, true, false, '', 'test', null, 10.123;
create view v as select 1 from DUAL;
create view v as select 1 from DUAL where 2>1;
create view v as select c1 from t1 where c1 group by c2 having c1 order by c2 limit 1, 10;
create view v as (select c1 from t1) union (select c2 from t2) order by c1 limit 1
create view v as select * from t1;
create view v as select t1.* from t1;
create view v as select t1.*,view_table_2.* from t1, view_table_2;
#
## column_list
#
create view v(a,b) as select c1,c2 from t1;
create view v(a,b) as select c1,c2 from t1;
create view v(a,b) as select c1 as alias1, c2 from t1;
#
##distinct/all
#
create view v as select distinct c1, c2 from t1;
create view v as select all c1, c2 from t1;
#
##from
#
##base table
create view v as select * from t1;
create view v as select * from t1 a;
create view v as select * from t1 as a;
create view v as select * from t1 partition(p0,p1);
create view v as select * from t1 partition(p0,p1) a;
create view v as select * from t1 partition(p0,p1) join t2 partition(p1) a;
##view_table
create view v as select * from v1;
create view v as select * from v1 a;
create view v as select * from v1 as a;
##join_table
create view v as select t1.c1 from t1,t2;
create view v as select t1.c1 from t1,t2;
create view v as select t1.c1 from t1 join t2;
create view v as select t1.c1 from t1 join t2 on t1.c1 = t2.c1;
create view v as select t1.c1 from t1 inner join t2;
create view v as select t1.c1 from t1 inner join t2 on t1.c1 = t2.c1;
create view v as select t1.c1 from t1 left join t2 on t1.c1 = t2.c1;
create view v as select t1.c1 from t1 right join t2 on t1.c1 = t2.c1;
create view v as select t1.c1 from t1 full join t2 on t1.c1 = t2.c1;
##generated table cannot appear in view
##table_references
create view v as select * from t1 ,t2;
#
##where
#
create view v as select * from t1 where c1=1;
create view v as select * from t1 where c1=1 and c2 = 1;
create view v as select * from t1 where c1=1 and c2 =1 and true;
create view v as select * from t1 where c1=1 and (c2 =1 and true);
create view v as select * from t1 where c1=1 or c2 = 1;
create view v as select * from t1 where c1=1 or (c2 =1 or true);
#
##group by
#
create view v as select * from t1 group by c1;
create view v as select * from t1 group by c1,c2;
create view v as select * from t1 group by c1 and c2;
#
##having
#
create view v as select * from t1 having c1;
create view v as select * from t1 having c1 and c2 and 1;
create view v as select * from t1 having c1 and (c2 and true);
#
#order by
#
create view v as select * from t1 order by c1;
create view v as select * from t1 order by 1;
create view v as select * from t1 order by c1 asc;
create view v as select * from t1 order by c1 desc;
create view v as select * from t1 order by c1 desc, c2 asc;
create view v as select * from t1 order by 1 desc, c2 asc;
#
##limit
#
create view v as select * from t1 limit 10;
create view v as select * from t1 limit 1, 10;
#
##set_op
#
create view v as (select c1 from t1) union (select c1 from t2);
create view v as (select c1 from t1) union (select c1 from t2) union (select c1 from t2);
create view v as (select c1 from t1) union (select c1 from t2) order by c1 limit 1;
create view v as (select c1 from t1) intersect (select c1 from t2);
create view v as (select c1 from t1) intersect (select c1 from t2) order by c1 limit 1;
create view v as (select c1 from t1) except (select c1 from t2);
create view v as (select c1 from t1) except (select c1 from t2) order by c1 limit 1;
#
####################################expr##################################
#
#
##const
#
create view v as select null, 1, +2, -10, 1.9, 'fdf', true, false;
#
##binary
#
create view v as select c1 from t1;
#from tables cross db
create view v as select rongxuan2.t1.c1 from t1, rongxuan2.t1;
#view cross db
create view rongxuan2.v as select c1 from rongxuan.t1;
#
##op
#
create view v as select c1 and c2 from t1;
create view v as select c1 && c2 from t1;
create view v as select c1 or c2 from t1;
create view v as select c1 || c2 from t1;
create view v as select c1+c2 from t1;
create view v as select c1-c2 from t1;
create view v as select c1*c2 from t1;
create view v as select c1/c2 from t1;
create view v as select pow(c1,c2) from t1;
create view v as select c1^c2 from t1;
create view v as select c1%c2 from t1;
create view v as select c1 div c2 from t1;
create view v as select c1<=c2 from t1;
create view v as select c1<c2 from t1;
create view v as select c1=c2 from t1;
create view v as select c1<=>c2 from t1;
create view v as select c1>=c2 from t1;
create view v as select c1>c2 from t1;
create view v as select c1%c2 from t1;
create view v as select c1<>c2 from t1;
create view v as select c1!=c2 from t1;
create view v as select c1|c2 from t1;
create view v as select c1&c2 from t1;
create view v as select !c1 from t1;
create view v as select !!c1 from t1;
create view v as select c1 mod c2 from t1;
create view v as select c1 div c2 from t1;
create view v as select "fdsfds" regexp "fds*" from t1;
create view v as select "fdsfds" not regexp "fds*" from t1;
create view v as select c1 from t1 where exists (select c1 from t2);
create view v as select c1 from t1 where c1 = any(select c1 from t2);
create view v as select c1 from t1 where c1+c2 > any(select c1 from t2);
create view v as select c1 from t1 where c1 = some(select c1 from t2);
create view v as select c1 from t1 where c1+c2 > some(select c1 from t2);
create view v as select c1 from t1 where c1 = all(select c1 from t2);
create view v as select c1 from t1 where c1+c2 > all(select c1 from t2);
#not support now
#create view v as select c1 xor c2 from t1;
create view v as select c1 is true from t1;
create view v as select c1 is false from t1;
create view v as select c1 is not true from t1;
create view v as select c1 is not false from t1;
create view v as select c1 is null from t1;
create view v as select c1 is not null from t1;
create view v as select c1 is unknown from t1;
create view v as select c1 is not unknown from t1;
create view v as select c1 from t1 where (c1,c2) in (select c1,c2 from t2);
create view v as select c1 from t1 where (c1,c2) in ((1,2),(2,3));
create view v as select c1 from t1 where c1 in ((1),2,3);
create view v as select c1 from t1 where (c1,c2) in ((1,2),(2,3));
create view v as select c1 from t1 where (c1,c2) not in (select c1,c2 from t2);
create view v as select c1 from t1 where (c1,c2) not in (select c1,c2 from t2);
create view v as select * from t1 where c1 like '%fhlds%';
create view v as select * from t1 where c1 not like '%fhlds%';
create view v as select * from t1 where c1 between 1 and 10;
create view v as select * from t1 where c1 not between 1 and 10;
#
##sysfun
#
create view v as select if(c1>10,1,2) from t1;
create view v as select now() from t1;
create view v as select now(0) from t1;
create view v as select now(3) from t1;
create view v as select current_timestamp() from t1;
create view v as select current_timestamp(0) from t1;
create view v as select current_timestamp(3) from t1;
create view v as select localtime() from t1;
create view v as select localtime(0) from t1;
create view v as select localtime(3) from t1;
create view v as select localtimestamp() from t1;
create view v as select localtimestamp(0) from t1;
create view v as select localtimestamp(3) from t1;
create view v as select curtime() from t1;
create view v as select curtime(0) from t1;
create view v as select curtime(3) from t1;
create view v as select current_time from t1;
create view v as select current_time() from t1;
create view v as select current_time(0) from t1;
create view v as select current_time(3) from t1;
create view v as select curdate() from t1;
create view v as select current_date from t1;
create view v as select current_date() from t1;
create view v as SELECT DATE_ADD('1999-01-01', INTERVAL 1 DAY);
create view v as select date_add(current_date(), interval 2 day) from t1;
create view v as SELECT DATE_sub('1999-01-01', INTERVAL 1 DAY);
create view v as select date_sub(current_date(), interval 2 day) from t1;
create view v as SELECT TIMESTAMPDIFF(MONTH,'2009-12-01','2009-09-01');
create view v as SELECT extract(MONTH from '2009-12-01');
create view v as select current_date() from t1;
create view v as select utc_timestamp() from t1;
create view v as select utc_timestamp(3) from t1;
create view v as select date(c1) from t1;
#create view v as select time(c1) from t1;
create view v as select month(c1) from t1;
create view v as SELECT TRIM(leading "a" from ' barbar ');
create view v as select substring("fdfdsaf" from 2 for 3);
create view v as select coalesce(null, "fdfdsaf");
#cast && convert
create view v as select cast(c1 as binary) from t1;
create view v as select cast(c1 as binary(10)) from t1;
create view v as select cast(c1 as character) from t1;
create view v as select cast(c1 as character(10)) from t1;
create view v as select cast(c1 as char) from t1;
create view v as select cast(c1 as char(10)) from t1;
create view v as select convert(1, binary);
create view v as select convert(1, binary(10));
create view v as select convert(1, character);
create view v as select convert(1, character(10));
create view v as select convert(1, char);
create view v as select convert(1, char(10));
create view v as select convert(1 using binary);
create view v as select convert(1 using utf8mb4);
create view v as select cast(c1 as number(3,2)) from t1;
create view v as select cast(c1 as datetime) from t1;
create view v as select cast(c1 as date) from t1;
create view v as select cast(c1 as time) from t1;
create view v as select cast(c1 as signed) from t1;
create view v as select cast(c1 as unsigned) from t1;
create view v as select concat(c1,c2,'fds') from t1
create view v as select binary c1+c2 from t1;
create view v as select isnull(c1) from t1;
create view v as select hex(c1) from t1;
create view v as select unhex(c1) from t1;
#
##aggfunc
#
create view v as select count(*) from t1 group by c1;
create view v as select count(c1) from t1 group by c1;
create view v as select count(c1+10) from t1;
create view v as select count(distinct c1+10,c2-10) from t1;
create view v as select sum(c1+c2) from t1 group by c1;
create view v as select sum(all c1+c2) from t1 group by c1;
create view v as select sum(distinct c1+c2) from t1 group by c1;
create view v as select min(c1+c2) from t1 group by c1;
create view v as select min(all c1+c2) from t1 group by c1;
create view v as select min(distinct c1+c2) from t1 group by c1;
create view v as select max(c1+c2) from t1 group by c1;
create view v as select max(all c1+c2) from t1 group by c1;
create view v as select max(distinct c1+c2) from t1 group by c1;
create view v as select avg(c1+c2) from t1 group by c1;
create view v as select avg(all c1+c2) from t1 group by c1;
create view v as select avg(distinct c1+c2) from t1 group by c1;
create view v as select group_concat(distinct c1+c2,c2 order by c2, 1 desc separator ',') from t1 group by c1;
#
##caseop
#
create view v as select case when c1 > 3 then 1 when c1 > 2 then 2 else 1 end from t1;
#
##unary
#
create view v as select c1 from t1 where (select c1) = (select c1 from t2 limit 1);
create view v as select c1 from t1 order by (select c1);
create view v as select c1 from t1 group by (select c1);
create view v as select c1 from t1 having (select c1);
#
##others
#
create view v as select t1.c1 from t1 full join t2 on t1.c1 = (select c2 from t2 limit 1);
create view v as select t1.c1 from t1 left join t2 on t1.c1 = (select c2 from t2 limit 1);
create view v as select t1.c1 from t1 right join t2 on t1.c1 = any(select c2 from t2);
create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1;
create view v as select t1.c1 from t1 join t2 on t1.c1= t2.c1 or t1.c1 > (select 10);
create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1 join t3 on t1.c1=0;
create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1 inner join t3 on t1.c1=0 left join t4 on t1.c1 > t4.c1;
create view v as select t1.c1 from t1 join t2 on t1.c1=t2.c1 join t3 on t1.c1=0;
create view v as select t1.c1 from t1 join t2 a on t1.c1=a.c1 join t3 b on a.c1 != 10;
create view v as select c2 from t1 where c1 > all((select c1 from t1) union (select c1 from t2));
create view v as select c2 from t1 where c1 > all((select c1 from t1) except (select c1 from t2));
create view v as select c1 from t1 where c1 > (select c2 from t1 limit 1);
create view v as select c1 from t1 where c1 > (select c2 from t2 limit 1);
create view v as select c1 from t1 where c1 > (select c2 from t1 tt limit 1);
create view v as select c1 from t1 where c1 > (select c2 from t1 as tt limit 1);
create view v as select t1.c1 from t1 join t2 on t1.c1 > (select c2 from t2 limit 1);
create view v as select c1 from t1 group by c1 having c1 > (select c1 from t2 limit 1);
create view v as select c1 from t1 where c1 > (select t1.c2 from t1 join t2 on t1.c1 = t2.c1 limit 1);
create view v as select c1, (select c2 from t2 limit 1) from t1;
#
## hint
#
create view v as select /*+ NO_REWRITE */ * from t1;
create view v as select /*+ READ_CONSISTENCY(frozen) */ * from t1;
create view v as select /*+ READ_CONSISTENCY(weak) */ * from t1;
create view v as select /*+ READ_CONSISTENCY(strong) */ * from t1;
create view v as select /*+ INDEX(t1 c1) */ * from t1;
create view v as select /*+ FULL(t1) */ * from t1;
create view v as select /*+ QUERY_TIMEOUT(100000) */ * from t1;
create view v as select /*+ LEADING(t1,t2) */ t1.* from t1,t2;
create view v as select /*+ USE_MERGE(t1,t2) */ t1.* from t1,t2;
create view v as select /*+ USE_HASH(t1,t2) */ t1.* from t1,t2;
create view v as select /*+ USE_NL(t1,t2) */ t1.* from t1,t2;
create view v as select /*+ USE_PLAN_CACHE(default) */ * from t1;
create view v as select /*+ USE_PLAN_CACHE(exact) */ * from t1;
create view v as select /*+ ORDERED */ * from t1;
create view v as select /*+ NO_REWRITE, READ_CONSISTENCY(weak), index(t1 c1), full(t1), QUERY_TIMEOUT(1000000), LEADING(t1), USE_MERGE(t1), USE_HASH(t1),USE_NL(t1), USE_PLAN_CACHE(default), ORDERED */ * from t1;
create view v as select /*+ USE_HASH(@sel1 t1,t2) */ t1.* from t1,t2;
create view v as select t1.c1 from t1 where c1 in (select/*+FULL(@sel1 t1)*/ c1 from t2);
#
#################################clear schema##############################
#
drop table view_table_2;
drop view v1;
drop table rongxuan2.t1;
drop database rongxuan2;

View File

@ -0,0 +1,4 @@
select * from t1;
select * from (select * from t2) a;
select a.*, b.*, c.alias + 10 from t1 a, (select c1 from t2) b, (select c3 as alias from t3) c;
select t1.c1 from t1 join (select t2.c1 from t2 join (select * from t3) a) b;

View File

@ -0,0 +1,23 @@
drop database if exists alias;
create database alias;
use alias;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3;
select c1, c1 from t1 order by c1;
select c1, (c1) from t1 order by c1;
select c1, c1 as c1 from t1 order by c1;
--error 5207
select c1, c2 as c1 from t1 order by c1;
--error 5207
select c1, c2+3 as c1 from t1 order by c1;
--error 5207
select c1, c2+c1 as c1 from t1 order by c1;
select "cc1", c1 from t1 order by c1;
--error 5207
select "cccc1" as c1, c1 from t1 order by c1;
select X.c1 from t1 AS X group by X.c2 having (X.c2 = 1);
select X.c1 from t1 AS X group by X.c2 having (c2 = 1);
select c1 as cc from t1 having c1 > 0;
drop database alias;

View File

@ -0,0 +1,36 @@
drop database if exists alias1;
create database alias1;
use alias1;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3;
# having #
select c1, c1 from t1 having c1 is null;
select c1, c1 from t1 having c1 is null;
select c1, (c1) from t1 having c1 is null;
select c1, c1 as c1 from t1 having c1 is null;
--error 5207
select c1, c2 as c1 from t1 having c1 is null;
--error 5207
select c1, c2+3 as c1 from t1 having c1 is null;
--error 5207
select c1, c2+c1 as c1 from t1 having c1 is null;
select "cc1", c1 from t1 having c1 is null;
--error 5207
select "cccc1" as c1, c1 from t1 having c1 is null;
# order by#
select c1, c1 from t1 order by c1;
select c1, (c1) from t1 order by c1;
select c1, c1 as c1 from t1 order by c1;
--error 5207
select c1, c2 as c1 from t1 order by c1;
--error 5207
select c1, c2+3 as c1 from t1 order by c1;
--error 5207
select c1, c2+c1 as c1 from t1 order by c1;
select "cc1", c1 from t1 order by c1;
--error 5207
select "cccc1" as c1, c1 from t1 order by c1;
drop database alias1;

View File

@ -0,0 +1,57 @@
drop database if exists altersystem;
create database altersystem;
use altersystem;
alter system switch replica leader server = '127.0.0.1:80'
alter system switch replica leader zone = '127.0.0.1:80'
alter system switch replica leader partition_id = '1 % 3 @ 4' server = '127.0.0.1:80'
alter system switch replica leader zone = 'z1';
alter system switch replica leader server = '127.0.0.1:80';
alter system switch replica leader partition_id = '1%8@3001' server = '127.0.0.1:80';
alter system switch replica leader partition_id '1%8@3001' server '127.0.0.1:80';
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80';
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80' create_timestamp = 1;
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80' zone = 'z1';
alter system drop replica partition_id = '1%8@3001' server = '127.0.0.1:80' create_timestamp = 1 zone = 'z1';
alter system drop replica partition_id '1%8@3001' server '127.0.0.1:80' create_timestamp 1 zone 'z1';
alter system copy replica partition_id = '1%8@3001' source = '127.0.0.1:80' destination = '127.0.0.2:80';
alter system move replica partition_id = '1%8@3001' source = '127.0.0.1:80' destination = '127.0.0.2:80';
alter system move replica partition_id '1%8@3001' source '127.0.0.1:80' destination '127.0.0.2:80';
alter system report replica;
alter system report replica server = '127.0.0.1:80';
alter system report replica zone = 'z1';
alter system recycle replica;
alter system recycle replica server = '127.0.0.1:80';
alter system recycle replica server '127.0.0.1:80';
alter system recycle replica zone = 'z1';
alter system recycle replica zone 'z1';
alter system major freeze;
alter system start merge zone = 'z1';
alter system suspend merge;
alter system suspend merge zone = 'z1';
alter system resume merge;
alter system resume merge zone = 'z1';
alter system clear roottable;
alter system clear roottable tenant = 'test';
alter system refresh schema;
alter system refresh schema zone = 'test';
alter system refresh schema server = '127.0.0.1:80';
alter system set abc = 1, abd = 'xx' server = '127.0.0.1:80', def = true comment 'defxxx' tenant = 't1';
alter system modify zone 'z1'
alter system modify zone 'z1' region = 'r1'
alter system modify zone 'z1' idc = 'idc1'
alter system modify zone 'z1' zone_type = 'ReadWrite'
alter system modify zone 'z1' set idc 'idc1', region 'r1'
alter system modify zone 'z1' set region 'r1', idc 'idc1'
alter system modify zone 'z1' set zone_type 'ReadWrite', region 'r1'
alter system modify zone 'z1' set region 'r1', zone_type 'ReadWrite'
alter system modify zone 'z1' set idc 'idc1', zone_type 'ReadWrite'
alter system modify zone 'z1' set zone_type 'ReadWrite', idc 'idc1'
alter system modify zone 'z1' set zone_type 'ReadWrite', idc 'idc1', region 'r1'
alter system modify zone 'z1' set zone_type 'ReadWrite', region 'r1', idc 'idc1'
alter system modify zone 'z1' set idc 'idc1', zone_type 'ReadWrite', region 'r1'
alter system modify zone 'z1' set idc 'idc1', region 'r1', zone_type 'ReadWrite'
alter system modify zone 'z1' set region 'r1', idc 'idc1', zone_type 'ReadWrite'
alter system modify zone 'z1' set region 'r1', zone_type 'ReadWrite', idc 'idc1'
drop database altersystem;

View File

@ -0,0 +1,178 @@
drop database if exists altertable;
create database altertable;
use altertable;
create table ta(c1 int primary key, c2 int auto_increment) comment='test', auto_increment= 5;
create table alter_table1(c1 int primary key, c2 varchar(11) not null default 'c2', c3 tinyint default 3, c4 char(11)) partition by hash(c1) partitions 3;
create index idx_c1 on alter_table1(c1) LOCAL;
create table test(c1 int , c2 int, c3 varchar(50), c4 varchar(50), c5 int , c6 double, c7 int, primary key(c1, c2, c3));
create index test_indx on test(c4, c5);
### add new column
alter table alter_table1 add column nc3 int null default 0
alter table alter_table1 add (nc3 int null default 0, nc4 varchar(11))
###key or index
alter table alter_table1 add key(c2)
alter table alter_table1 add index(c2)
### specify order
alter table alter_table1 add index idx2(c2 DESC)
###multiple column
alter table alter_table1 add index idx1(c1,c2)
alter table alter_table1 add index idx1(c1,c2 DESC)
alter table alter_table1 add index idx1(c1 ASC, c2 DESC)
###multiple index
--error 4200
alter table alter_table1 add index idx1(c1), add index idx2(c2)
###index option
alter table alter_table1 add index idx1(c1) GLOBAL COMMENT 'string' BLOCK_SIZE 16384 STORING(c3, c4)
alter table alter_table1 add index idx1(c1) GLOBAL COMMENT 'string' BLOCK_SIZE = 16384 STORING(c3, c4)
###unique
alter table alter_table1 add unique index uidx1(c1)
alter table alter_table1 add unique uidx1(c1)
###alter column
alter table alter_table1 alter column c3 set default 13
alter table alter_table1 alter column c3 drop default
###change column
alter table alter_table1 change column c4 nc4 char(20)
###modify column
alter table alter_table1 modify c3 tinyint default 33
###drop column
alter table alter_table1 drop column c3
###drop index
#alter table alter_table1 drop index idx_c1
###rename index
alter table alter_table1 rename index idx_c1 to idx_2
alter table alter_table1 rename index idx_2 to idx_c1
###table rename
alter table alter_table1 rename to alter_t1
###alter table option
#character set
#alter table alter_table1 character set = 'utf8mb4'
#comment
alter table alter_table1 set comment = 'hahaha'
#compression
alter table alter_table1 set compression = 'none'
#expire info
ALTER TABLE test SET EXPIRE_INFO (c1 > 9)
#alter table alter_table1 set EXPIRE_INFO = (thedate < date_sub(merging_frozen_time(), INTERVAL 1 DAY))
#replica num
alter table alter_table1 replica_num = 3
#Partition block size
alter table alter_table1 set block_size = 16384
#BloomFilter
alter table alter_table1 set use_bloom_filter = true
#step merge num range(1~64)
alter table alter_table1 set progressive_merge_num = 1
#table group
alter table alter_table1 tablegroup = 'tp1'
alter table alter_table1 drop tablegroup
#zone list
#alter table alter_table1 zone_list = ('z1', 'z2')
#primary zone
alter table alter_table1 primary_zone = 'z1'
#autoincrement
alter table alter_table1 auto_increment = 1
##tablegroup
alter table alter_table1 drop tablegroup
###error
#duplicate column c3
#--error 5008
#alter table alter_table1 add c3 int, alter c3 drop default;
#duplicate column c1
#--error 5008
#alter table alter_table1 add column c1 int;
#add duplicate column
#--error 5019
#alter table stu add column c8 int, add column c8 int;
#multiple operation on the same column c8
#--error 5019
#alter table stu add column c8 int, drop c8;
#column not exist
#--error 5217
#alter table alter_table1 change column abcd acd char(11);
#modify primary key
#--error 5057
#alter table alter_table1 add column c7 int primary key;
#--error 5057
#alter table alter_table1 change column c2 c2 varchar(12) not null primary key;
#drop primary key
#--error 5217
#alter table alter_table1 drop id;
#--error 5057
#alter table alter_table1 add primary key (c2);
#--error 5057
#alter table alter_table1 add primary key (c2) GLOBAL COMMENT 'string' COMPRESSION 'lz4_1.0' BLOCK_SIZE 1024 STORING(c3, c4);
#table not exist
#--error 5019
#alter table alter_table2 rename TO t5
#--error 5019
#alter table t_student set progressive_merge_num=1;
#not support
#--error 5006
#alter table test alter c2 set not null
#rename to exist column
#--error 5008
#alter table alter_table1 change c2 c1 varchar(20);
#modify column type
#--error 4007
#alter table alter_table1 modify column c2 int;
#modify varchar length to smaller
#--error 4007
#alter table alter_table1 modify column c2 varchar(10);
#modify char length to smaller
#--error 4007
#alter table alter_table1 modify column c4 char(10);
##prefix key
#--error 4007
#alter table test add unique (c3(11), c1);
#--error 5190
#alter table test add unique (c3(60));
#--error 5190
#alter table test add unique (c1(1));
--error 5191
alter table test add unique (c3(0));
--error 5191
alter table test add unique (xxx(0));
##rename
--error 5163
alter table test rename to ``
--error 5163
alter table test rename to ` `
#using hash/btree(only syntax support)
alter table test add index using btree(c1) using hash;
alter table test add unique index using btree(c1) using hash;
--error 4200
alter table test add index using hash(c1), add index using btree(c2)
##constraint for unique key
create table wang_01(c1 int, c2 varchar(30), c3 bigint, c4 timestamp, c5 decimal(7,3), c6 varbinary(1024), c7 char(32), c8 tinyint);
alter table wang_01 add constraint unique key(c2);
alter table wang_01 add constraint const_name unique key(c3);
alter table wang_01 add constraint const_name unique key uk_name_1(c4);
alter table wang_01 add constraint cons_name_1 unique key(c5);
alter table wang_01 add constraint unique key uk_name_2(c6);
alter table wang_01 add constraint cons_name unique key uk_name_3(c7);
alter table wang_01 add constraint unique key uk_name_4(c8);
# cleanup
drop database altertable;

View File

@ -0,0 +1,31 @@
drop database if exists ambiguous;
create database ambiguous;
use ambiguous;
drop table if exists t1, t2, t3;
create table t1(c1 int primary key, c2 int);
create table t2(c1 int primary key, c2 int);
create table t3(c1 int primary key, c2 int);
--error 5206
select c1, sum(c2) from t1 group by 2;
--error 5207
select * from t1 join t2 using(c1) join t3 using(c2);
--error 5208
select * from t1 join t2 using(c1) join t1 using(c2);
--error 5207
select c2 from t1 join t2 using(c1) join t3 using(c1);
SELECT * FROM t1 RIGHT JOIN (SELECT * FROM t2) as at2 USING (c1)
--error 5207
SELECT 12 AS c1, c1 FROM t1 GROUP BY c1;
SELECT COUNT(c1) AS c2 FROM t1 GROUP BY c2 HAVING c2 = 2;
select X.c1 from t1 AS X group by X.c2 having (X.c2 = 1);
select * from (select * from t1) t join t2 using(c1)
SELECT * FROM t1 LEFT JOIN t2 USING (c1) WHERE c1 IS NULL;
select c2 from t1 left join t2 using(c2);
drop database ambiguous;

View File

@ -0,0 +1,127 @@
drop database if exists dbcmd;
create database dbcmd;
use dbcmd;
#create database oceanbase
#use oceanbase
### show character set [like 'pattern' | where expr]
#show character set where charset = 'utf8mb4'
#show character set like 'utf8%'
### show collation [like 'pattern | where 'expr']
#show collation like 'utf8mb4_bin%'
#show collation where chearset = 'utf8mb4'
#### show [FULL] columns {from|in} tb1_name [{from|in} db_name] [like 'pattern' | where expr]
#support view
#show full columns from t1 from rongxuan
#show columns from t1 from rongxuan like 'c%'
show columns from rongxuan.t1
#show columns from rongxuan.t1 where c1 like 'c%'
#show columns in rongxuan.t1 like 'c%'
#show columns in t1 in rongxuan where type = 'int(11)'
### show create {database | schema } [if not exists] db_name
#show create database oceanbase
#show create schema oceanbase
#show create database if not exist oceanbase
### show create table table_name
#support view
#show create table __all__database
### show create view view_name
#show create view vt1 from rongxuan
### show {databases | schemas } [like 'pattern' | where expr]
show databases
show databases like 'ocean%'
#show databases where
#show schemas
#show schemas like 'ocean%'
### show errors [limit [offset,] row_count]
#show errors
#show errors limit 10
#show errors limit 2, 8
### show warnings [limit [offset,] row_count]
#show count(*) warnings
#show warnings limit 10
#show warnings limit 3, 10
#show count(*) warnings
### show grants [for user]
#show grants
###??show grants for root@localhost
### show {index | indexes |keys} {from | in} table_name [{from | in} db_name] [where expr]
#show index from rongxuan.t1
#show indexes from rongxuan.t1
#show keys from rongxuan.t1
#show index from t1 from rongxuan
#show index in t1 in rongxuan
##show index from rongxuan.t1 where ???
### show privileges
#show privileges
### show [full] processlist
#show processlist
#show full processlist
### show [global | session] status [like 'pattern' |where expr]
#show status
#show session status
#show global session
#show status where Variable_name = 'Aborted_clients';
#show status like '%table%'
### show table status [{from | in} db_name] [like 'pattern' | where expr]
#support view
#show table status
#show table status from rongxuan
#show table status in rongxuan
#show table status from rongxuan like 't%'
#show table status from rongxuan where Name='t1'
### show [full] tables [{from | in } db_name] [like 'pattern' | where expr]
#support view
show tables
#show tables from rongxuan
#show tables in rongxuan
#show full tables from hualong where Table_type = 'BASE_TABLE'
#show tables from rongxuan like 't%'
### show [global | session ] variables [like 'pattern' | where expr]
show variables
#show global variables
#show session variables
#show variables like '%auto%'
#show variables where value = 'on'
### show parameters [like 'pattern' | where expr]
#show parameters like '%sql%'
#show parameters where value = 'off'
### show create tenant
#show create tenant sys_tenant
### show tenant
#show tenant
# set names
set names latin1;
set names utf8 collate 'utf8_general_ci';
set charset utf8;
drop database dbcmd;
alter system bootstrap REGION 'sys_region' ZONE 'zone1' SERVER '10.101.74.122:41425';
alter system bootstrap CLUSTER primary REGION 'sys_region' ZONE 'zone1' SERVER '10.101.74.122:41425';
alter system bootstrap cluster standby REGION 'sys_region' ZONE 'zone1' SERVER '10.101.74.122:41425';
alter system set cluster_id = 3;
alter system COMMIT TO SWITCHOVER TO PRIMARY;
alter system COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
alter system remove cluster tt cluster_id = 4;
alter system add cluster verify;

View File

@ -0,0 +1,10 @@
## test for create outline
create outline outline_name on select * from t1;
create or replace outline outline_name on select * from t1;
create or replace outline outline_name on insert into t1 values (1, 2);
create outline outline_name on update t1 set c1=100 where c1=1;
create outline outline_name on delete from t1 where c1=1;
## test for drop outline
drop outline outline_name;
drop outline rongxuan.outline_name;

View File

@ -0,0 +1,449 @@
drop database if exists createtable;
create database createtable;
use createtable;
#create table
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
#create table locality
create table wenduo(pk int primary key) locality = "f@zone1, f,l@region1";
#index scope when partition_num > 1
##create table
create table ad1(c1 int primary key, c2 int, index(c2))partition by key(c1) partitions 2;
create table ad2(c1 int primary key, c2 int, index(c2) GLOBAL)partition by key(c1) partitions 2;
create table ad3(c1 int primary key, c2 int, index(c2) LOCAL)partition by key(c1) partitions 2;
create table ad4(c1 int primary key, c2 int, index(c2))partition by key(c1) partitions 1;
create table ad5(c1 int primary key, c2 int, index(c2) GLOBAL)partition by key(c1) partitions 1;
create table ad6(c1 int primary key, c2 int, index(c2) LOCAL)partition by key(c1) partitions 1;
##create index
#create table ad7(c1 int primary key, c2 int) partition by key(c1) partitions 2;
#--error 4016
#create index __idx1_ad7 on ad7(c1);
#--error 4016
#create index __idx2_ad7 on ad7(c1) GLOBAL;
#create index __idx3_ad7 on ad7(c1) LOCAL;
create table ad8(c1 int primary key, c2 int) partition by key(c1) partitions 1;
create index __idx1_ad8 on ad8(c1);
create index __idx2_ad8 on ad8(c1) GLOBAL;
create index __idx3_ad8 on ad8(c1) LOCAL;
#table exist
--error 5020
create table t1(c1 int primary key);
#unique [key]
create table ac1(c1 int primary key, c2 int unique);
create table ac2(c1 int primary key, c2 int unique key);
create table ac3(c1 int primary key, c2 int, index c3(c2), c3 int unique);
create table ac4(c1 int primary key unique);
create table ac5(c1 int primary key unique key);
#index on varchar
create table ab1(c1 int primary key,c2 varchar(4096),index(c2))
--error 5196
create table ab2(c1 int primary key,c2 varchar(4097),index(c2))
#Uppercase and lowercase
CREATE TABLE z001 ( id varchar(34) NOT NULL, primary key (ID) );
CREATE TABLE Z002 ( C1 varchar(34) NOT NULL, C2 int, primary key (c1) );
#duplicate primary key
--error 5024
create table s001(c1 int primary key,c2 int, primary key(c2));
#INTEGER_PRECISION_OVERFLOW
--error 5173
create table s002(c1 decimal(5,3) default 512.3476, c2 int, primary key(c2))
##INVALID DEFAULT VALUE
--error 5173
CREATE TABLE s003(c1 int primary key default 'a' not null);
##if not exists
CREATE TABLE if not exists b001 (c1 int primary key)
##date type
##int
create table w001(c1 int primary key, c2 tinyint, c3 smallint, c4 mediumint, c5 int, c6 integer, c7 bigint);
create table w002(c1 int primary key, c2 tinyint(5) unsigned zerofill, c3 smallint(5) unsigned zerofill, c4 mediumint(5) unsigned zerofill, c5 int(5) unsigned zerofill, c6 integer(5) unsigned zerofill, c7 bigint(5) unsigned zerofill);
create table w003(c1 int primary key, c2 tinyint(5) unsigned zerofill, c3 smallint(5) unsigned zerofill, c4 mediumint(5) unsigned zerofill, c5 int(5) unsigned zerofill, c6 integer(5) unsigned zerofill, c7 bigint(5) unsigned zerofill);
##double
create table w011(c1 int primary key, c2 real, c3 double, c4 float, c5 decimal, c6 numeric);
create table w012(c1 int primary key, c2 real(5,2), c3 double(5,2), c4 float(5,2), c5 decimal(5,2), c6 numeric(5,2));
create table w013(c1 int primary key, c2 real(5,2) unsigned zerofill, c3 double(5,2) unsigned zerofill, c4 float(5,2) unsigned zerofill, c5 decimal(5,2) unsigned zerofill, c6 numeric(5,2) unsigned zerofill);
##time
create table w021(c1 int primary key,c2 date, c3 year, c4 time, c5 timestamp, c6 datetime);
create table w022(c1 int primary key,c2 date, c3 year(4), c4 time(3), c5 timestamp(6), c6 datetime(6));
##char
create table w031(c1 int primary key,c2 char, c3 char(10), c4 varchar(10));
--error 5143
create table w032(c1 int primary key,c2 char CHARACTER SET 'utf8' collate 'cla',c3 varchar(10) CHARACTER SET 'utf8' collate 'cla');
##binary
create table w041(c1 int primary key, c2 binary, c3 binary(10), c4 varbinary(10));
##null && not null
CREATE TABLE x001 (c1 int primary key, c2 varchar(50) NOT NULL)
CREATE TABLE x002 (c1 int primary key, c2 varchar(50) NULL)
##default value
CREATE TABLE y001 (c1 int primary key, c2 tinyint default 0, c3 smallint default 0, c4 mediumint default 0, c5 int default 0, c6 integer default 0, c7 bigint default 0)
CREATE TABLE y002 (c1 int primary key, c2 real default 123.45, c3 double default 99.3, c4 float default 10.33, c5 decimal default 10.43430, c6 numeric default 3443)
create table y005 (c1 decimal(5,3) default 12.34, c2 int, primary key(c2))
##default value of date and year not support
##CREATE TABLE y003 (c1 int primary key, c2 date default '2012-10-12', c3 year default '2015', c4 time default '10:11:12', c5 timestamp DEFAULT '15-12-31 23:59:59.000000', c6 datetime default '2015-12-31 23:59:59.000000')
CREATE TABLE y003 (c1 int primary key, c4 time default '10:11:12', c5 timestamp DEFAULT '15-12-31 23:59:59.000000', c6 datetime default '2015-12-31 23:59:59.000000')
CREATE TABLE y004 (c1 int primary key, c2 binary default 'f', c3 binary(10) default 1323, c4 varbinary(50) DEFAULT 'fffdfdfd')
create table y013(c1 date default date'2015.11.11');
create table y006(c1 varchar(100) default date'2015.11.11');
create table y007(c1 time default time'10:12:10');
create table y008(c1 varchar(100) default time'10:12:10');
create table y009(c1 timestamp default timestamp'2015.11.11 10:12:10');
create table y010(c1 varchar(100) default timestamp'2015.11.11 10:12:10');
##auto_increment
CREATE TABLE d001 (c1 int primary key AUTO_INCREMENT, c2 varchar(50))
--error 5165
CREATE TABLE d002 (c1 int primary key, c2 varchar(50) AUTO_INCREMENT)
##key
##without index_name
CREATE TABLE s001 (c1 int primary key, c2 varchar(50), c3 int,key(c1))
CREATE TABLE s002 (c1 int primary key, c2 varchar(50), c3 int,key (c1))
##with index_name
CREATE TABLE s003 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1))
##specify order
CREATE TABLE s004 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1 DESC))
##mul cols
CREATE TABLE s005 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1,c2))
CREATE TABLE s006 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1,c2 DESC))
CREATE TABLE s007 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1 ASC,c2 DESC))
##mul indexs
CREATE TABLE s008 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1), key k2(c2))
##index_option
CREATE TABLE s009 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1) GLOBAL)
CREATE TABLE s010 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1) GLOBAL COMMENT 'string' BLOCK_SIZE 16384 STORING(c1,c2))
CREATE TABLE s011 (c1 int primary key, c2 varchar(50), c3 int,key k1(c1) GLOBAL COMMENT 'string' BLOCK_SIZE = 16384 STORING(c1,c2))
##complex
CREATE TABLE s012 (c1 int primary key, c2 varchar(50), c3 int,c4 int, key k1(c1 DESC,c2) COMMENT 'string' BLOCK_SIZE 16384 STORING(c1,c2), key k2(c3), key(c4))
##index naming
CREATE TABLE s013 (c1 int primary key, c2 varchar(50), c3 int,c4 int, key (c1), key (c1,c2), key (c1,c3))
create table s014 (a int primary key, b int, c int, key(b), key(b, c), key(c));
#index option should not specify compress method
CREATE TABLE s015 (c1 int primary key, index idx(c1))compression='lz4_1.0';
##index
##without index_name
CREATE TABLE t001 (c1 int primary key, c2 varchar(50), c3 int,index(c1))
CREATE TABLE t002 (c1 int primary key, c2 varchar(50), c3 int,index (c1))
##with index_name
CREATE TABLE t003 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1))
##specify order
CREATE TABLE t004 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1 DESC))
##mul cols
CREATE TABLE t005 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1,c2))
CREATE TABLE t006 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1,c2 DESC))
CREATE TABLE t007 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1 ASC,c2 DESC))
##mul indexs
CREATE TABLE t008 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1), index idx2(c2))
##index_option
CREATE TABLE t009 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1) GLOBAL)
CREATE TABLE t010 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1) GLOBAL COMMENT 'string' BLOCK_SIZE 16384 STORING(c1,c2))
CREATE TABLE t011 (c1 int primary key, c2 varchar(50), c3 int,index idx1(c1) GLOBAL COMMENT 'string' BLOCK_SIZE = 16384 STORING(c1,c2))
##complex
CREATE TABLE t012 (c1 int primary key, c2 varchar(50), c3 int,c4 int, index idx1(c1 DESC,c2) COMMENT 'string' BLOCK_SIZE 16384 STORING(c1,c2), index idx2(c3), index(c4))
##unique key
CREATE TABLE u001 (c1 int primary key, c2 varchar(50), c3 int,unique key uk1(c1))
CREATE TABLE u002 (c1 int primary key, c2 varchar(50), c3 int,unique uk1(c1))
CREATE TABLE u003 (c1 int primary key, c2 varchar(50), c3 int,unique(c1))
CREATE TABLE u004 (c1 int primary key, c2 varchar(50), c3 int,unique (c1))
CREATE TABLE u005 (c1 int primary key, c2 varchar(50), c3 int,c4 int, unique key uk1(c1 DESC,c2) GLOBAL COMMENT 'string' BLOCK_SIZE 16384 STORING(c1,c2), unique uk2(c3), unique(c4))
##unique index
CREATE TABLE v001 (c1 int primary key, c2 varchar(50), c3 int,unique index uidx1(c1))
CREATE TABLE v002 (c1 int primary key, c2 varchar(50), c3 int,unique uidx1(c1))
CREATE TABLE v003 (c1 int primary key, c2 varchar(50), c3 int,unique(c1))
CREATE TABLE v004 (c1 int primary key, c2 varchar(50), c3 int,unique (c1),unique(c2))
CREATE TABLE v005 (c1 int primary key, c2 varchar(50), c3 int,c4 int, unique index uidx1(c1 DESC,c2) GLOBAL COMMENT 'string' BLOCK_SIZE 16384 STORING(c1,c2), unique uidx2(c3), unique(c4))
##primary key
CREATE TABLE a001 (c1 int primary key)
CREATE TABLE a002 (c1 int primary key, c2 varchar(50))
CREATE TABLE a003 (c1 int, c2 varchar(50), primary key(c1))
CREATE TABLE a004 (c1 int, c2 varchar(50), c3 int , primary key(c1,c2))
## [primary] key and unique [key]
# primary key
create table a011(c1 int primary key);
create table a012(c1 int key);
# unqiue key
create table a013(c1 int unique);
create table a014(c1 int unique key);
# primary key + unique key
create table a015(c1 int primary key unique key);
create table a016(c1 int key unique key);
create table a017(c1 int key unique);
# unique key + primary key
create table a018(c1 int unique key primary key);
create table a019(c1 int unique primary key);
##comment(on column)
CREATE TABLE e001 (c1 int primary key, c2 varchar(50) comment 'the column of c2')
##table_option
CREATE TABLE f001 (c1 int primary key, c2 varchar(50)) CHARACTER SET = 'utf8'
CREATE TABLE f002 (c1 int primary key, c2 varchar(50)) DEFAULT CHARACTER SET = 'utf8'
CREATE TABLE f003 (c1 int primary key, c2 varchar(50)) CHARACTER SET 'utf8'
CREATE TABLE f004 (c1 int primary key, c2 varchar(50)) DEFAULT CHARACTER SET 'utf8'
CREATE TABLE f005 (c1 int primary key, c2 varchar(50)) CHARSET = 'utf8'
CREATE TABLE f006 (c1 int primary key, c2 varchar(50)) DEFAULT CHARSET = 'utf8'
CREATE TABLE f007 (c1 int primary key, c2 varchar(50)) CHARSET 'utf8'
CREATE TABLE f008 (c1 int primary key, c2 varchar(50)) DEFAULT CHARSET 'utf8'
##comment (on table)
CREATE TABLE g001 (c1 int primary key, c2 varchar(50))COMMENT = 'the table_name of tt1'
CREATE TABLE g002 (c1 int primary key, c2 varchar(50))COMMENT 'the table_name of tt1'
CREATE TABLE h001 (c1 int primary key, c2 varchar(50))COMPRESSION = 'none'
CREATE TABLE h002 (c1 int primary key, c2 varchar(50))COMPRESSION 'none'
CREATE TABLE h003 (c1 int primary key, c2 varchar(50))COMPRESSION 'lz4_1.0'
CREATE TABLE h004 (c1 int primary key, c2 varchar(50))COMPRESSION 'LZ4_1.0'
--error 4002
CREATE TABLE h005 (c1 int primary key, c2 varchar(50))COMPRESSION 'abc'
##CONSISTENT_MODE static,frozen,weak,strong
#CREATE TABLE t021 (c1 int primary key, c2 varchar(50))CONSISTENT_MODE = 'static'
##EXPIRE_INFO
#--error 4007
#CREATE TABLE i001 (c1 int primary key, c2 varchar(50))EXPIRE_INFO = (c1<100)
#--error 4007
#CREATE TABLE i002 (c1 int primary key, c2 varchar(50))EXPIRE_INFO (c1<100)
##REPLICA_NUM
CREATE TABLE j001 (c1 int primary key, c2 varchar(50))REPLICA_NUM = 3
CREATE TABLE j002 (c1 int primary key, c2 varchar(50))REPLICA_NUM 3
##TABLE_ID
CREATE TABLE k001 (c1 int primary key, c2 varchar(50))TABLE_ID = 4000
CREATE TABLE k002 (c1 int primary key, c2 varchar(50))TABLE_ID 4000
##BLOCK_SIZE
CREATE TABLE l001 (c1 int primary key, c2 varchar(50))BLOCK_SIZE = 16384
CREATE TABLE l002 (c1 int primary key, c2 varchar(50))BLOCK_SIZE 16384
##USE_BLOOM_FILTER
CREATE TABLE m001 (c1 int primary key, c2 varchar(50))USE_BLOOM_FILTER = false
CREATE TABLE m002 (c1 int primary key, c2 varchar(50))USE_BLOOM_FILTER false
##progressive_merge_num
CREATE TABLE n001 (c1 int primary key, c2 varchar(50))progressive_merge_num = 5
CREATE TABLE n002 (c1 int primary key, c2 varchar(50))progressive_merge_num 5
##AUTO_INCREMENT
CREATE TABLE o001 (c1 int primary key, c2 varchar(50))AUTO_INCREMENT = 1
CREATE TABLE o002 (c1 int primary key, c2 varchar(50))AUTO_INCREMENT 1
##TABLEGROUP
CREATE TABLE p001 (c1 int primary key, c2 varchar(50))tablegroup = 'tablegroup_name'
CREATE TABLE p002 (c1 int primary key, c2 varchar(50))tablegroup 'tablegroup_name'
##ZONE_LIST
#CREATE TABLE q001 (c1 int primary key, c2 varchar(50))ZONE_LIST = ('a','b','c')
#CREATE TABLE q002 (c1 int primary key, c2 varchar(50))ZONE_LIST ('a','b','c')
##PRIMARY_ZONE
CREATE TABLE r001 (c1 int primary key, c2 varchar(50))PRIMARY_ZONE = 'a'
CREATE TABLE r002 (c1 int primary key, c2 varchar(50))PRIMARY_ZONE 'a'
#PARTITION
CREATE TABLE r003 (c1 int not null primary key, c2 char(30)) PARTITION BY hash(c1) PARTITIONS 3;
CREATE TABLE r004 (c1 int not null primary key, c2 float) PARTITION BY hash(c1+3);
CREATE TABLE r005 (c1 int not null primary key, c2 varchar(30)) PARTITION BY KEY();
CREATE TABLE r006 (c1 int not null, c2 varchar(11) not null, c3 char(11), primary key(c1,c2)) PARTITION BY KEY() PARTITIONS 2;
--error 5188
CREATE TABLE r007 (c1 int primary key, c2 int) PARTITION BY KEY(C1) PARTITIONS 10000000000;
--error 5189
CREATE TABLE r008 (c1 int primary key, c2 int) PARTITION BY KEY(C1) PARTITIONS 0;
#prefix key
--error 5190
CREATE TABLE r009 (a varchar(11) primary key, b int, UNIQUE (a(20), b));
--error 5190
CREATE TABLE r009 (a varchar(11) primary key, b int, UNIQUE (a, b(20)));
CREATE TABLE r010 (a varchar(11) primary key, b int, UNIQUE (a(5), b));
--error 5191
CREATE TABLE r009 (a varchar(11) primary key, b int, UNIQUE (a(0)));
--error 5191
CREATE TABLE r009 (a varchar(11) primary key, b int, UNIQUE (x(0)));
##boolean type
create table r011(a int primary key, b boolean);
create table r012(a int primary key, b bool);
##
## Boundary testing start
##
#database name length
create database tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt;
--error 5179
create database tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1;
#table name length
create table tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt(c1 int primary key);
--error 5179
create table tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1(c1 int primary key);
#column name length
create table t005_(c1 int primary key,tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt int);
--error 5179
create table t006_(c1 int primary key,tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt11 int);
#index name length(create table)
create table t007_(c1 int primary key,c2 int,index tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt(c2));
--error 5179
create table t008_(c1 int primary key,c2 int, index tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt11(c2));
#index name lenth(create index)
create index tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt on t1(c2) LOCAL;
--error 5179
create index ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1 on t1(c2) LOCAL;
#view name length
create view vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv as select * from t1;
--error 5179
create view vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv as select * from t1;
#alias_name length
select c1 as tttttttttttttttttttttttttttttttttttttttttttt from t1;
#tablegroup name length
create tablegroup tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt;
--error 5179
create tablegroup tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt1;
#pk data length
create table r017(c1 int,c2 varchar(4096) primary key);
--error 5196
create table r017_(c1 int,c2 varchar(4097) primary key);
create table r018(c1 int,c2 varchar(4000), c3 varchar(96), primary key(c2, c3));
--error 5196
create table r018_(c1 int,c2 varchar(4000), c3 varchar(97), primary key(c2, c3));
#index data length
create table r019(c1 int primary key,c2 varchar(4096) unique key);
--error 5196
create table r019_(c1 int primary key,c2 varchar(4097) unique key);
create table r020(c1 int primary key, c2 varchar(4000), c3 varchar(96), index(c2, c3));
--error 5196
create table r020_(c1 int primary key, c2 varchar(4000), c3 varchar(97), index(c2, c3));
#char max length
create table r22(c1 int primary key,c2 char(256))
--error 5198
create table r22_(c1 int primary key,c2 char(257))
#varchar max length
create table r24(c1 int primary key,c2 varchar(262144))
--error 5198
create table r24_(c1 int primary key,c2 varchar(262145))
#binary max length
create table r23(c1 int primary key,c2 binary(256))
--error 5198
create table r23_(c1 int primary key,c2 binary(257))
--error 5208
drop table t1,t1;
##
## Boundary testing end
##
##
##charset and collate
##
#table charset and collate
create table r25(c1 varchar(2))charset=utf8, collate=utf8mb4_general_ci;
create table r26(c1 varchar(2))charset=utf8mb4, collate=utf8mb4_general_ci;
create table r27(c1 varchar(2))charset=utf8mb4;
create table r28(c1 varchar(2))collate=utf8mb4_general_ci;
create table r29(c1 varchar(2))charset=utf8mb4, collate=utf8mb4_bin;
create table r30(c1 varchar(2))collate=utf8mb4_bin;
--error 5142
create table r31(c1 varchar(2))charset=test;
--error 5143
create table r32(c1 varchar(2))charset=utf8mb4, collate=test;
--error 5143
create table r33(c1 varchar(2))collate=test;
--error 5142
create table r34(c1 varchar(2))charset=test, collate=test;
#column charset and collate
create table r35(c1 varchar(2));
create table r36(c1 varchar(2) charset utf8 collate utf8mb4_general_ci);
create table r37(c1 varchar(2) charset utf8mb4 collate utf8mb4_general_ci);
create table r38(c1 varchar(2) charset utf8mb4);
create table r39(c1 varchar(2) collate utf8mb4_general_ci);
create table r40(c1 varchar(2) charset utf8mb4 collate utf8mb4_bin);
create table r41(c1 varchar(2) collate utf8mb4_bin);
--error 5142
create table r42(c1 varchar(2)) charset test;
--error 5143
create table r43(c1 varchar(2) collate test);
--error 5143
create table r44(c1 varchar(2) charset utf8mb4 collate test);
--error 5142
create table r45(c1 varchar(2) charset test collate test);
#together
create table r46(c1 varchar(2) charset utf8mb4)charset=utf8mb4, collate=utf8mb4_general_ci;
create table r47(c1 varchar(2) collate utf8mb4_general_ci)charset=utf8mb4;
create table r48(c1 varchar(2) collate utf8mb4_bin)charset=utf8mb4;
create table r49(c1 varchar(2) charset utf8)collate=utf8mb4_general_ci;
create table r50(c1 varchar(3) default 'abc');
create table r51(c1 varchar(3) default '支付宝');
create table r52(c1 varchar(4) default 'a支付宝');
--error 5173
create table r53(c1 varchar(3) default 'abcd');
--error 5173
create table r54(c1 varchar(3) default '支付宝d');
--error 5173
create table r55(c1 varchar(4) default 'a支付宝d');
##binary
create table r56(c1 varchar(3) binary);
create table r57(c1 varchar(3) binary charset utf8mb4);
create table r58(c1 varchar(3) binary charset utf8mb4 collate utf8mb4_general_ci);
#using hash/btree(only syntax support)
create table r59(c1 int primary key,c2 int ,index idx using btree(c1) using hash);
create table r60(c1 int primary key,c2 int ,unique index uidx using btree(c1) using hash);
create table r61(c1 int primary key, c2 int, index idx using hash(c1), index idx2(c2) using btree);
create table r62(c1 int, primary key using hash (c1));
create table t_bit_1(c1 bit);
create table t_bit_2(c1 bit(1));
create table t_bit_3(c1 bit(63));
####################### test for synonym ###############################
create synonym stbit for t_bit_1;
drop synonym stbit;
#constraint for primary key and unique key
create table wang_01(c1 int, c2 varchar(30), primary key(c2));
create table wang_02(c1 int, c2 varchar(30), constraint primary key(c2));
create table wang_03(c1 int, c2 varchar(30), constraint cons_name primary key(c2));
create table wang_04(c1 int, c2 varchar(30), unique key(c2));
create table wang_05(c1 int, c2 varchar(30), constraint unique key(c2));
create table wang_06(c1 int, c2 varchar(30), constraint cons_name unique key(c2));
create table wang_07(c1 int, c2 varchar(30), constraint unique key (c2));
create table wang_08(c1 int, c2 varchar(30), constraint unique key uk_name(c2));
create table wang_09(c1 int, c2 varchar(30), constraint cons_name unique key (c2));
create table wang_10(c1 int, c2 varchar(30), constraint cons_name unique key uk_name(c2));
create table wang_11(c1 int, c2 varchar(30), constraint primary key(c1), constraint unique key uk_name(c2));
create table wang_12(c1 int, c2 varchar(30), constraint cons_name primary key(c1), constraint cons_name unique key uk_name(c2));
create table wang_13(c1 int, c2 varchar(30), primary key(c1), unique key (c2));
drop database createtable;

View File

@ -0,0 +1,100 @@
#---
#schema
#---
#drop database if exists cte_db;
#create database cte_db;
#use cte_db;
#create table emp(id int, name varchar(20), leaderid int);
#create table t1(c1 int, c2 int, c3 int);
#create table t2(c1 int, c2 int);
#create table t3(c3 int primary key, c4 int);
#
#
##---
##basic cte
##---
#with cte(a) as (select count(c1) from t2 group by c2 limit 5) select * from cte;
#WITH cte1 AS (SELECT c1, c2 FROM t1) select c1 from cte1;
#WITH cte1 AS (SELECT c1, c2 FROM t1) select c1 from cte1;
#WITH cte1 (name1, name2) AS (select c1, c2 from t1) select name1 from cte1;
#WITH cte1 AS (SELECT c1, c2 FROM t1), cte2 AS (SELECT c1, c2 FROM t2) select c1 from cte2;
#WITH cte1 AS (select * from t1) select c1, c2 from cte1;
#WITH cte1 (c1)AS(select c1 from t1), cte2 AS (select * from t1) select c1, c2 from cte2;
#WITH cte0 AS ( select * from t1) select * from cte0 for update;
#with cte as (select count(*) from t1) select * from cte;
#with cte as (select count(*) as k from t1) select * from cte where k = 1;
#with cte (k1) as (select count(*) as k from t1) select * from cte where k1 = 1;
#with cte1 (c22, c21) AS (select c1, c2 from t1) select c22 as c21, c21 from cte1 where c21 = 12;
#with cte1 AS( select * from t1)select * from cte1 left join t2 on cte1.c1=t2.c1 having not (t2.c1 <=> cte1.c1) order by cte1.c1;
#WITH cte1 (a, b) AS (SELECT c1, c2 FROM t1), cte2 (c, d) AS (SELECT c1, c2 FROM t2) select * from (with cte2 as(select * from t3) select c3 as c11, c4 from cte2) cte1 join cte2 on cte1.c11=cte2.c;
#WITH cte1 (a, b) AS (SELECT c1, c2 FROM t1), cte2 (c, d) AS (SELECT c1, c2 FROM t2) select * from cte1 left join cte2 on cte1.a=cte2.c having not (cte1.b <=> cte2.d) order by cte1.a;
#
##---
##recursive cte
##---
#WITH cte(hello) AS (SELECT c1 FROM t1 UNION ALL select hello from cte) search depth first by hello set abc select hello, abc from cte;
#WITH cte(n) AS (SELECT c1 FROM t1 UNION ALL select n+1 from cte where n < 10) search depth first by n set a select n from cte;
#with cte(n) as (select 1 from dual union all select n+1 from cte where n < 2) select n from cte;
#with cte(n) as (select 1 from dual union all select n+1 from cte where n < 2) search depth first by n set abc select n,abc from cte;
#explain with cte (a,b,c) as ( select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a ) search depth first by a set sad select * from cte;
#WITH cte(n) AS (SELECT c1 FROM t1 UNION ALL select n from cte) search depth first by n set a_name cycle n set iscyc to 'n' default 'y' select n from cte;
#WITH cte(n) AS (SELECT c1 FROM t1 UNION ALL select n from cte) search depth first by n set a_name select n from cte;
#WITH cte(n) AS (SELECT c1 FROM t1 UNION ALL select n from cte) select n from cte;
#WITH fibonacci (n, fib_n, next_fib_n) AS ( SELECT 1, 0, 1 from dual UNION ALL SELECT n + 1, next_fib_n, fib_n + next_fib_n FROM fibonacci WHERE n < 10 ) SELECT * FROM fibonacci;
#WITH cte(hello) AS (SELECT c1 FROM t1 UNION ALL select hello from cte) search depth first by hello set abc select hello, abc from cte;
#WITH cte(hello) AS (SELECT c1 FROM t1 UNION ALL select hello from cte) search depth first by hello set abc select * from cte;
#WITH cte(hello) AS (SELECT c1 FROM t1 UNION ALL select hello+1 from cte where hello < 5) search depth first by hello set abc select hello, abc from cte;
#with cte (a,b,c) as (select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a) search breadth first by a set sad select * from cte;
#with cte (a,b,c) as (select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a) cycle a set iscyc to 'n' default 'y' select * from cte;
#explain with cte (a,b,c) as ( select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a ) cycle a set iscyc to 'n' default 'y' select * from cte;
#with cte (a,b,c) as ( select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a ) cycle c set iscyc to 'n' default 'y' select * from cte;
##with cte (a,b,c) as ( select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a ) search breadth first by a set abc cycle a set iscyc to 'y' default 'n' select max(a) from cte start with a =1 connect by prior a = c group by level;
#with cte(n) as (select 1 from dual) search depth first by n set abc select * from cte;
#WITH cte1 AS (SELECT c1, c2 FROM t1) select c1 from cte1;
#with cte(a) as (select 1 from dual union all select 2 from dual), cte_1(b) as (select 1 from dual union all select * from cte) select * from cte_1;
#WITH cte1 (a, b) AS (SELECT c1, c2 FROM t1), cte2 (c, d) AS (SELECT c1, c2 FROM t2) select * from (with cte2 as(select * from t3) select c3 as c11, c4 from cte2) cte1 join cte2 on cte1.c11=cte2.c;
#--error 5217
#with cte(n) as ( select 1 from dual union all select n+1 from cte where n < 10 ) search depth first by a set abc select * from cte;
#with cte(n) as (select 1 from dual) search depth first by n set abc select * from cte;
#with cte(a,b,c) as (select * from emp) search depth first by a set abc select * from cte;
#--error 4002
#with cte(n, x) as (select * from t1) cycle n set iscyc to 'y' default 'n' select * from cte;
#
#### common ###
#with cte(n) as (select 1 union all select n+1 from cte where n < 23) select n from cte;
#--error 4007
#with cte(n) AS ( select 1 from cte) select * from cte;
#--error 4007
#with cte(n) AS (select 1 from dual UNION ALL select n+1 from (select * from cte) ct1 where n < 3) select * from cte;
#--error 4007
#with cte(n) AS ( select 1 from dual UNION ALL select sum(n+1) from cte) select * from cte;
#--error 4007
#with cte(n) as (select 1 from dual union all select c1 from t1 union all (with cte(n) as (select c1 from t1) select * from cte)) select * from cte;
#--error 4007
#with cte(n) AS (select 1 from dual UNION ALL select n+1 from cte where n < 3 union all select n+1 from cte where n < 2) select * from cte;
#--error 4007
#with cte(n) as (select n from (select 1 from dual union all select n+1 from cte) tmp) select * from cte;
#--error 4007
#with cte(n) AS (select 1 from cte UNION all select n+1 from cte where n < 3) select * from cte;
#--error 4007
#with cte(n) as (select n+1 from cte where n < 5 union all select c1 from t1) select * from cte;
#--error 4007
#with cte(n) as (select 1 from dual union all select * from (select n from cte where n < 5) tmp) select * from cte;
#--error 4007
#with cte(n) AS (select 1 from dual UNION ALL select n+1 from cte where n < 3 order by n ) select * from cte;
#with cte_recursive (a,b,c) as ( select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte_recursive where emp.leaderid = cte_recursive.A ) search depth first by a set sad cycle b set iscyc to 'y' default 'n', cte as (select * from cte_recursive) select * from cte;
#--error 5019
#select * from (with cte as (select * from t2) select * from cte) t3, cte where t3.c21 = cte.c1;
#--error 5019
#with cte(a,b,c) as ( select c1,c2,c3 from not_exist where not_exist.c1 < 20 union all select c1,c2,c3 from not_exist, cte where cte.a = not_exist.c1 and cte.c < 10 ) select * from cte;
#--error 4007
#with cte(n) AS (select c1 from t1 UNION ALL select n+1 from cte right join t2 on cte.n < 3 and t2.c1 < 22) select * from cte;
#--error 4007
#with cte(n) AS (select c1 from t1 UNION ALL select n+1 from t2 left join cte on cte.n < 3 and t2.c1 < 22) select * from cte;
#--error 4007
#with cte(n) AS (select c1 from t1 UNION ALL select n+1 from t2 full join cte on cte.n < 3 and t2.c1 < 22) select * from cte;
#--error 4007
#with cte(n) AS (select c1 from t1 UNION ALL select n+1 from cte full join t2 on cte.n < 3 and t2.c1 < 22) select * from cte;
#--error 4002
#with cte (a,b,c) as (select id, name, leaderid from emp where emp.id = 1 union all select emp.id ,emp.name, emp.leaderid from emp, cte where emp.leaderid = cte.a) search depth first by a set abc cycle a set abc to 'y' default 'n' select * from cte;

View File

@ -0,0 +1,12 @@
drop database if exists database_test;
create database if not exists database_test;
alter database database_test CHARACTER SET UTF8;
alter database database_test collate utf8mb4_general_ci;
alter database database_test CHARACTER SET UTF8 collate utf8mb4_general_ci;
drop database database_test;
create database database_test CHARACTER SET UTF8;
drop database database_test;
create database database_test collate utf8mb4_general_ci;
drop database database_test;
create database database_test CHARACTER SET UTF8 collate utf8mb4_general_ci;

View File

@ -0,0 +1,57 @@
drop database if exists dbdcl;
create database dbdcl;
use dbdcl;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
### create
create user 'hualong' identified by '123456'
#create user 'hualong' identified by password '123456'
create user 'hualong' identified by '123456', '' identified by '123456'
### drop
drop user 'hualong'
### set password
#set password '111111'
set password for 'hualong' = password('111111')
alter user 'hualong' identified by '111111'
### rename
rename user 'hualong' to 'hualong01'
###lock user
alter user 'hualong','zdy' account lock
alter user 'xiaohua','zdy' account unlock
###grant
#### to
grant all privileges on * to 'hualong'
grant all privileges on *.* to 'hualong'
grant all privileges on rongxuan.* to 'hualong'
grant all privileges on rongxuan.t1 to 'hualong'
grant all privileges on t1 to 'hualong'
#### table priviledge
grant all privileges on rongxuan.t1 to 'hualong'
grant alter on rongxuan.t1 to 'hualong'
grant create on rongxuan.t1 to 'hualong'
grant drop on rongxuan.t1 to 'hualong'
grant select on rongxuan.t1 to 'hualong'
grant update on rongxuan.t1 to 'hualong'
grant insert on rongxuan.t1 to 'hualong'
grant delete on rongxuan.t1 to 'hualong'
grant index on rongxuan.t1 to 'hualong'
#grant show databases on rongxuan.t1 to 'hualong'
###revoke
revoke all privileges on rongxuan.t1 from 'hualong'
revoke all privileges, grant option from 'hualong'
revoke all privileges on * from 'hualong'
###show grants
#show grants for 'hualong'
drop database dbdcl;

View File

@ -0,0 +1,63 @@
drop database if exists defaultvalue;
create database defaultvalue;
use defaultvalue;
drop table if exists default_t1;
create table if not exists default_t1 (a int, b int primary key);
ALTER TABLE default_t1 ADD i1 int;
ALTER TABLE default_t1 ADD i2 int not null;
ALTER TABLE default_t1 ADD i3 int not null default 5;
ALTER TABLE default_t1 ADD f1 float;
ALTER TABLE default_t1 ADD f2 float not null;
ALTER TABLE default_t1 ADD f3 float not null default 5.0;
ALTER TABLE default_t1 ADD d1 double;
ALTER TABLE default_t1 ADD d2 double not null;
ALTER TABLE default_t1 ADD d3 double not null default 5.0000
ALTER TABLE default_t1 ADD v1 varchar(500);
ALTER TABLE default_t1 ADD v2 varchar(500) not null;
ALTER TABLE default_t1 ADD v3 varchar(500) not null default '@varchar500';
--error 5173
ALTER TABLE default_t1 ADD v3 varchar(500) not null default null;
#ALTER TABLE default_t1 ADD ts1 timestamp;
# disable as result is changed
# ALTER TABLE default_t1 ADD ts2 timestamp not null;
ALTER TABLE default_t1 ADD ts3 timestamp not null default '2015-7-16';
ALTER TABLE default_t1 ADD y1 year;
ALTER TABLE default_t1 ADD y2 year not null;
ALTER TABLE default_t1 ADD y3 year not null default 1983
ALTER TABLE default_t1 ADD t1 time;
ALTER TABLE default_t1 ADD t2 time not null;
ALTER TABLE default_t1 ADD t3 time not null default 10;
ALTER TABLE default_t1 ADD d1 date;
ALTER TABLE default_t1 ADD d2 date not null;
ALTER TABLE default_t1 ADD d3 date not null default '2015-07-16';
ALTER TABLE default_t1 ADD dt1 datetime;
ALTER TABLE default_t1 ADD dt2 datetime not null;
ALTER TABLE default_t1 ADD dt3 datetime not null default '2015-07-16 10:10:30';
ALTER TABLE default_t1 ADD n1 number;
ALTER TABLE default_t1 ADD n2 number not null;
ALTER TABLE default_t1 ADD n3 number not null default 1111;
ALTER TABLE default_t1 ADD c1 char;
ALTER TABLE default_t1 ADD c2 char not null;
ALTER TABLE default_t1 ADD c3 char not null default 'x';
ALTER TABLE default_t1 ADD b1 binary;
ALTER TABLE default_t1 ADD b2 binary not null;
ALTER TABLE default_t1 ADD b3 binary not null default '@binary'
ALTER TABLE default_t1 ADD vb1 varbinary(1000);
ALTER TABLE default_t1 ADD vb2 varbinary(1000) not null;
ALTER TABLE default_t1 ADD vb3 varbinary(1000) not null default '@varbinary@1000';
drop database defaultvalue;

View File

@ -0,0 +1,61 @@
drop database if exists delete_db;
create database delete_db;
use delete_db;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
create table t2(c1 int, c2 int, c3 varchar(32), primary key(c2, c3)) partition by key(c2, c3) partitions 3
#create index idx1 on t1(c2)
create table test(c1 int , c2 int, c3 varchar(50), c4 varchar(50), c5 int , c6 double, c7 int, primary key(c1, c2, c3))
create index test_indx on test(c4, c5)
###common
delete from t1 where c2 > 10 order by c1 limit 0, 1
delete from t1 where c1 = 1
###where
delete from t1 partition(p0) where c1 = 1
#### question mark
delete from t1 where 2 = 1
delete from t1 where c1 = 0
delete from t1 where 1 = 1
### order by
#### asc, desc
delete from t2 order by c1, c2 desc, c3 asc
#### function or expression
delete from t2 order by c2/2
delete from t1 order by 1+1
#delete from t1 order by 1 //not support
### limit
#### const
delete from t1 limit 10
delete from t1 limit 2, 10
delete from t1 limit 2 offset 10
#### question mark
delete from t1 limit 1
delete from t1 limit 1,0
delete from t1 limit 2,10
delete from t1 limit 1,10
### hintkkk
delete /*+ INDEX(t1 idx1)*/ from t1 where c1 =1
### partition
delete from t1 partition (p1)
### multiple table
#delete from t1,t2 where t1.c1 = t2.c1 //not support
### not contain the index's rowkey
delete from test where c1 = 1
#test truncate
truncate table test;
truncate table t1;
drop database delete_db;

View File

@ -0,0 +1,13 @@
drop database if exists enum_db;
create database enum_db;
use enum_db;
#schema
create table t1(c1 int primary key, c2 enum('a', 'b', 'c')) partition by hash(c1 + 1) partitions 3
create table t2(c1 int, c2 int, c3 enum('a', 'b', 'c'), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t22(c1 int, c2 int, c3 enum('a', 'b', 'c'), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t3(c3 int primary key, c4 enum('a', 'b', 'c') default 'c')
create table t4(c1 int primary key, c3 enum('a', 'b', 'c'))
create table coll_table(c1 varchar(10) collate utf8_general_ci, c2 enum('a', 'b', 'c'), c3 varchar(10), primary key(c1, c2));
insert into t3 values(1,2);

View File

@ -0,0 +1,13 @@
drop database if exists equalset_db;
create database equalset_db;
use equalset_db;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
select * from t1 where c1=1 and c2=1;
select * from t1 where c1=c2 and c2=1;
select * from t1 where c1=1 and c2=1 and c1=c2;
select * from t1 where c1=c1;
select * from t1 where 1=1;
drop database equalset_db;

View File

@ -0,0 +1,114 @@
drop database if exists expr_db;
create database expr_db;
use expr_db;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
create table t2(c1 int, c2 int, c3 varchar(32), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t3(c3 int primary key, c4 int)
create index idx1 on t1(c2) LOCAL
create table test(c1 int , c2 int, c3 varchar(50), c4 varchar(50), c5 int , c6 double, c7 int, primary key(c1, c2, c3))
create index test_indx on test(c4, c5)
create table non_reserved_key_test(value int primary key)
create table test2(c1 int primary key, c2 varchar(30), c3 timestamp(6) default now(6))
create table t4(c1 int primary key, c2 int not null, c3 int default 1, c4 int not null default 2)
create table ta(c1 int primary key, c2 int auto_increment) comment='test', auto_increment= 5
create table alter_table1(c1 int primary key, c2 varchar(11) not null default 'c2', c3 tinyint default 3, c4 char(11)) partition by hash(c1) partitions 3
create index idx_c1 on alter_table1(c1) LOCAL
create table t_auto_inc(c1 int primary key, c2 int auto_increment)
create table coll_table(c1 varchar(10) collate utf8_general_ci, c2 varchar(10) collate utf8_bin, c3 varchar(10), primary key(c1, c2));
create table ts(c1 int primary key, c2 timestamp default current_timestamp on update current_timestamp, c3 int);
set @var_name = "varchar"
set auto_increment_offset = 2
show collation like "utf%"
insert t1 values(3, default)
select -(5)
select -(1.5)
select -(1231*-23)
select -(-(-3.45*23.23))
select -(-1)
select (-1) + 1
select +1 + 1
select (-1) - 1
select (-1) / 1
select (-5) * 5
select (-1) div 1
select 5 % 2
select 1 < 2
select 1 >= 2
select 1 > 2
select 1 >= 2
select 1 != 2
select (1 < 2) or ((3 > 5) and (1 != 1))
select (1 and (1 and (1 or 0)) or (1 and (0 and 1)) and (1 or 0))
select (1 and (1 and (1 and 0)))
select 1 or (1 and 0)
select 1 and (1 and 0)
select 1 or (1 and 0) or (1 or 2)
select not(not(1>2))
select c1,c2,sum(c1 + c2) as c4 from t2 group by c1
select c1,c2,c3 from t2 order by c1 desc limit 3,3
select * from t2 where not(c1 > 1 and c2 > 1)
select * from t2 where (c1 > 1 and c2 > 1) and c3 >1
select * from t2 where (c1 > 1 or c2 > 1) and c3 >1
select * from t2 where c1 > 1 or (c1 > 1 and c2 > 1)
select * from t1 where (c1 > 1 and c2 > 1) or (c1 > 1 and c2 > 1)
select c1, c2 from t1 where c1 <= all(select c2 from t1)
select c1, c2 from t1 where c1 <= any(select c2 from t1)
select c1, c2 from t2 where c1 <= some(select c2 from t2)
select count(*) from t2 where t2.c2 in (select c1 from t2)
select count(*) from t2 where t2.c1 not in (select c1 from t2)
select count(*) from t2 where exists (select c1 from t2)
select c1,c2 from t2 where c2!=100
select c1,c2 from t2 where c2 = -(100%3)
select c1,c2 from t2 where c3 = NULL
select c1,c2 from t2 where c1 between 100 and 200
select c1,c2 from t2 where c2 <> 100
select c1,c2 from t2 where c2 <> 100 or c1 = 100
select c1,c2 from t2 where c2 != 100 or c1 = 100 and c3 = "aa"
select c1,c2 from t2 where c1 in(10,100)
select c1,c2 from t2 where c2 not in (10,100)
select * from t2 where c3 regexp '^a'
select * from t2 where c3 not regexp 'm'
select c1 from t2 where c3 regexp '1000|2000'
select * from t2 where c3 like '%m%'
select * from t2 where c3 not like '_'
select * from t2 where c3 not like "ss"
select * from t2 where c3 not like 2
select * from t2 where c3 like "//" ESCAPE "/"
select * from t2 where c3 like '//' escape 2
select c1,c2 from t2 where c1 between 1 and 10
select c1,c2 from t2 where c1 not between 1 and 10
select c1,c2 from t2 where c3 not between "aaa" and "bbb"
select CASE c3 WHEN 'name1' THEN 'name2' WHEN 'name2' THEN 'name3' ELSE 'name4' END as c3 from t2;
select * from t2 order by c1
select avg(c1) as avg_c1 from t2 where c2 > 10
select avg(distinct c1) as ds from t2 where c3 = "aa"
select count(*) from (select c1 from t2) as cc where cc.c1 = 1
select count(c1) from t2 where c3 = "aa"
select max(c1) from t2 where c1 not in (select c2 from t2)
select min(c1) from t2 where c1 not in (select c2 from t2)
select sum(c1) as sum_c1 from t2 where c1 > 10
### select sum(c1*c2) as total from t2 where c2 < (select 10+10) ###
select count(*) as num, min(c1) as c1_min, max(c1) as max_c1, avg(c1) as c1_avg from t2 where c3 = "aa"
select concat (c3, '(', c2 ,')') as ncc from t2 order by c1
update t2 set c3 = "aaa" where c1 > all(select c1 from t1)
select c1 as cc1 from t2 where c1 > (select c2 as cc2 from t2)
select * from (select c2 , case c3 when 'aa' then 'bb' when 'cc' then 'dd' else 'ee' end cc3 from t2) as tt where tt.cc3 > 10
### select c1 from t1 where c1 not in(select c1 from t2 where c2 not in (select c2 from t2)) ###
select c1 from t1 where c2 not in (select c2 as cc2 from t2)
select * from t2 where (c1, c2, c3) in ((0, 1, 2), (3, 4, 5))
###select * from t2 where (c1, c2, c3) in ((0, 1, 2), (3, 5))###
select * from t2 where c1 in (1, 2, c2)
select * from t2 where c1 in (select count(*) from t1)
drop database expr_db;

View File

@ -0,0 +1,59 @@
drop database if exists index_db;
create database index_db;
use index_db;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
create table test(c1 int , c2 int, c3 varchar(50), c4 varchar(50), c5 int , c6 double, c7 int, primary key(c1, c2, c3))
create index test_indx on test(c4, c5)
drop table if exists index_t1;
#create table index_t1(c1 int primary key, c2 int, c3 int, c4 varchar(50)) partition by hash(c2 + 1) partitions 3;
create table index_t1(c1 int primary key, c2 int, c3 int, c4 varchar(50));
create index index_ia1 on index_t1(c2, c3) LOCAL;
create unique index index_ia2 on index_t1(c2, c3) LOCAL;
create index index_ia3 on index_t1(c2, c3) GLOBAL;
create unique index index_ia4 on index_t1(c2, c3) GLOBAL;
create index index_ib1 on index_t1(c2, c3);
create unique index index_ib2 on index_t1(c2, c3);
create index index_i1 on index_t1(c2, c3) BLOCK_SIZE=16384;
create unique index index_i2 on index_t1(c2, c3) comment 'unique index';
create index index_i3 on index_t1(c2 asc, c3 desc);
create index index_i4 on index_t1(c2, c3) comment 'kk contains c2/c3' BLOCK_SIZE=16384;
create index index_i5 on index_t1(c2, c3) storing(c4);
create index index_i6 on index_t1(c2, c3) storing(c4) comment 'kk contains c2/c3' BLOCK_SIZE=16384 LOCAL;
create index index_i7 on index_t1(C2, C3) storing(C4);
drop index index_ia1 on index_t1;
drop index index_ia2 on index_t1;
drop index index_ia3 on index_t1;
drop index index_ia4 on index_t1;
drop index index_ib1 on index_t1;
drop index index_ib2 on index_t1;
drop index index_i1 on index_t1;
drop index index_i2 on index_t1;
drop index index_i3 on index_t1;
drop index index_i4 on index_t1;
drop index index_i5 on index_t1;
drop index index_i6 on index_t1;
drop index index_i7 on index_t1;
#create index on non-exist column
--error 5217
#create index idx1 on t1 (list);
#prefix key
#--error 5190
#create index test_idx on test (c3(60));
#--error 5190
#create index test_idx2 on test (c1(10), c3);
#--error 4007
#create index test_idx3 on test (c1, c3(20));
--error 5191
create index test_idx3 on test (c1, c3(0));
--error 5191
create index test_idx3 on test (xx(0));
#using hash/btree(only syntax support)
create index test_idx4 using btree on test(c1) using hash;
create unique index test_uidx4 using btree on test(c1) using hash;
drop database index_db;

View File

@ -0,0 +1,124 @@
drop database if exists insert_db;
create database insert_db;
use insert_db;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
create table t2(c1 int, c2 int, c3 varchar(32), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t3(c3 int primary key, c4 int)
create index idx1 on t1(c2) LOCAL
create table test(c1 int , c2 int, c3 varchar(50), c4 varchar(50), c5 int , c6 double, c7 int, primary key(c1, c2, c3))
create index test_indx on test(c4, c5)
create table non_reserved_key_test(value int primary key)
create table test2(c1 int primary key, c2 varchar(30), c3 timestamp(6) default now(6))
create table t4(c1 int primary key, c2 int not null, c3 int default 1, c4 int not null default 2)
create table ta(c1 int primary key, c2 int auto_increment) comment='test', auto_increment= 5
create table alter_table1(c1 int primary key, c2 varchar(11) not null default 'c2', c3 tinyint default 3, c4 char(11)) partition by hash(c1) partitions 3
create index idx_c1 on alter_table1(c1) LOCAL
create table t_auto_inc(c1 int primary key, c2 int auto_increment)
create table coll_table(c1 varchar(10) collate utf8_general_ci, c2 varchar(10) collate utf8_bin, c3 varchar(10), primary key(c1, c2));
create table ts(c1 int primary key, c2 timestamp default current_timestamp on update current_timestamp, c3 int);
create table tt1(c1 int primary key auto_increment, c2 int);
create table tm(c1 int primary key, c2 char(100) default 'fffyyy', c3 int);
create table ttt(c1 int, c2 int);
create table bt(c1 binary(4), c2 binary(5), c3 binary(6));
### common
#### value or values
insert into t1 values(1, 2)
insert into t1 value(1, 2)
--error 4007
REPLACE IGNORE INTO t1 VALUE (1, 1);
#### not configure the column list
insert into t2 values(1, 1, 'test')
####default value with timestamp
insert into test2(c1,c2) values(1,'test')
#### configure the column list
insert into t1(c1,c2) values(1, 2)
insert into t2(c1, c2, c3) values(1, 1, 'test')
insert into t2 partition(p0) (c2,c3) values (1,'test')
#### multiple values
insert into t1(c1) values(1), (2)
insert into t2(c1, c2, c3) values(1, 1, 'test'), (2, 2, 'hello'), (3, 3, 'world')
#### subquery
#column count not match
--error 5175
insert into t2 select * from t1
--error 5175
insert into t2(c1) select c1, c2 from t1
insert into t2 (c2, c3) select c1, c2 from t1
insert into t2 (c2,c3) select * from t1
#no primary key table
insert into ttt select c1, c2 from t1;
insert into ttt select * from ttt;
#### function or expression
insert into t2 values (1+1, 'new'||'name', 45)
#insert into t1 values (DEFAULT, 1); //not support default
#### partition
#insert into t1 partition (p1) values (1,1) //not support
#### question mark
insert into t1 values (1,1)
#### replace
replace into t1 values (1,2)
replace into t2 (c1,c2,c3) values (1,2,'test')
#### duplicate key update
insert into t1 values (1,2) on duplicate key update c2 = c2+1
insert into t2 values (3,4,'test') on duplicate key update t2.c2 = t2.c2 + 1
insert into test (c1,c2,c3,c4) values (1,2,'test','test') on duplicate key update c5 = c2+c1
insert into test (c1,c2,c3,c4) values (1,2,'test','test') on duplicate key update c5 = c2
insert into test (c1,c2,c3,c4) values (1,2,'test','test') on duplicate key update c1 = c2
#### default + not null
insert into t4(c1, c2) values(1,1), (2,2)
insert into t4(c1, c2, c3) values(1,1,1), (2,2,2), (3,3,3)
insert into t4 values(1,2,3,4)
### autoincrement
insert into ta(c1,c2) values (1,0),(2,0)
insert into ta(c1,c2) values (3,NULL), (4, NULL)
insert into ta(c1) values (5),(6)
insert into ta set c1 = 1, c2 = c1 + 1;
insert into ta set c2 = c1, c1 = c2 + 1;
insert into ta values(1, c1 + 1);
insert into ta(c2,c1) values(NULL, c2+1);
insert into ta select * from t3;
insert into ta select * from t3 on duplicate key update c1 = c1 + 2, c2 = values(c2);
### primary key is null
##insert into test(c1) values(1);
###binary
insert into bt(c1, c2) values(1,2);
insert into bt (c1,c2)values(2, c1 + 1);
insert into bt set c1 = 2, c2 = c1 + 1;
insert into bt set c1 = 2, c2 = c1 + 1, c3 = c1 + 2;
insert into bt select c1,c2,c3 from test;
insert into bt select c1,c2,c3 from test on duplicate key update c1 = c1 + 1, c2 = values(c2);
### default
insert into test2(c1,c2, c3) values(1,'test', default);
insert into t4 (c1,c2,c3) values(11, 1, default), (13,1, default);
insert into t4 (c1,c2,c3) values(11, 2, default), (13,3, default) on duplicate key update c2 = 5, c3=4;
insert into t_auto_inc values (1, default), (2, default);
insert into t4 values(1, 3, default, 4);
insert into t1 values (1,2) on duplicate key update c1=values(c2);
insert into t1 values (1,2),(3,4) on duplicate key update c1=values(c2)+values(c1), c2= values(c1)+values(c1);
insert into tt1 ()values(),();
insert into tt1 values(),();
insert into test set c1=1, c2=c1+1, c3=c2+c1;
insert into t1 set c1 = 1 + c1, c2 = 1;
insert into tm values(1, substr(c1,1,3), c3);
create table test3(c1 int primary key, c2 int, c3 int auto_increment unique key);
insert into test3 set c1 = 135, c3 = c2 + 1
insert into t3 values(1, values(c3))
insert into t3 values(values(c3), values(c4))
drop database insert_db;

View File

@ -0,0 +1,25 @@
create database join_on
use join_on;
create table t1 (a int , b int);
create table t2 (c int , d int);
create table t3 (e int , b int);
select * from t1 left join (t2 left join t3 on c+1=e) on t1.b=t3.b;
select * from t1 left join (t2 left join t3 on d+1=e) on t1.b=t3.b;
select * from t1 left join (t2 left join t3 on d+1=b) on t1.b=t3.b;
select * from t1 left join (t2 left join t3 on c+1=b) on t1.b=t3.b;
create table t_1 (a1 int, a2 int);
create table t_2 (a1 int, b int);
create table t_3 (c1 int, c2 int);
create table t_4 (c2 int);
insert into t_1 values (1,1);
insert into t_2 values (1,1);
insert into t_3 values (1,1);
insert into t_4 values (1);
select * from t_3 join (t_1 join t_2 using (a1)) on b=c1 join t_4 using (c2);
# duplicated join using
select * from t1 join t3 using(b, b, b);
drop database join_on

View File

@ -0,0 +1,49 @@
drop database if exists merge_db;
create database merge_db;
use merge_db;
#################### schema ####################
create table sourceTable(id int primary key, sales int);
create table sourceTable_2(id2 int primary key, sales2 int);
create table targetTable(id int primary key, sales int);
################## test for target relation and source relation ##################
merge into targetTable using sourceTable on (targetTable.id = sourceTable.id) when matched then update set targetTable.sales = sourceTable.sales;
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when matched then update set t1.sales = t2.sales;
################## test for match conditoin ##################
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id and t1.id != t2.sales) when matched then update set t1.sales = t2.sales;
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id or t1.id != abs(t2.sales)) when matched then update set t1.sales = t2.sales;
merge into targetTable using sourceTable_2 on (id = id2 or id != abs(sales2)) when matched then update set sales = sales2;
################## test for update clause ##################
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id and t1.id != t2.sales) when matched then update set t1.sales = t2.sales;
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id and t1.id != t2.sales) when matched then update set t1.sales = t2.sales where t1.sales > 1;
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id and t1.id != t2.sales) when matched then update set t1.sales = t2.sales where t1.sales > 88 delete where t1.id < 99;
################## test for insert clause ##################
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when not matched then insert(t1.id, t1.sales) values(t2.id, t2.sales) where t2.id > 0;
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when not matched then insert(t1.id, t1.sales) values(t2.id, t2.sales);
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when matched then update set t1.sales = t2.sales where t1.id = 999 delete where t1.sales =888 when not matched then insert(t1.id, t1.sales) values(t2.id, t2.sales) where t2.id = 777;
################## test for column_conv ##################
### test for const value ###
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when not matched then insert(t1.id, t1.sales) values(99, 88);
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id and t1.id != t2.sales) when matched then update set t1.sales = 100;
### test for default value ###
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when not matched then insert(t1.id) values(99);
### test for empty insert columns ###
merge into targetTable t1 using sourceTable t2 on (t1.id = t2.id) when not matched then insert (t1.id, t1.sales) values(99, 88);
################## test for rowkey ##################
create table target1(id int, c2 int, c3 int, primary key(id, c2));
create table target2(id int, c2 int);
merge into target1 using sourceTable on (target1.id = sourceTable.id) when matched then update set target1.c2 = sourceTable.sales;
merge into target2 using sourceTable on (target2.id = sourceTable.id) when matched then update set target2.c2 = sourceTable.sales;
################## test for subquery ##################
merge into targetTable using (select * from target1 ) sourceTable on (targetTable.id = sourceTable.id) when matched then update set targetTable.sales = sourceTable.c3;
merge into targetTable t1 using (select * from sourceTable) t2 on (t1.id = t2.id) when matched then update set t1.sales = t2.sales where t1.id = 999 delete where t1.sales =888 when not matched then insert(t1.id, t1.sales) values(t2.id, t2.sales) where t2.id = 777;

View File

@ -0,0 +1,15 @@
select * from t3 where c3='2';
select * from t3 where c3>'2';
select * from t3 where c3<'2';
select * from t3 where c3>='2';
select * from t3 where c3<='2';
select * from t3 where c3!='2';
select * from t3 where c3<=>'2';
select * from t3 where c3 is null;
select * from t3 where c3 is false;
select * from t3 where c3 is true;
select * from t3 where c3+'2'>'1';
select * from t3 where c3-'2'>'1';
select * from t3 where c3*'2'>'1';
select * from t3 where c3/'2'>'1';
select * from t3 where length(concat(c3, '2'))>'1';

View File

@ -0,0 +1,35 @@
drop database if exists aggr_db;
create database aggr_db;
use aggr_db;
create table t1(a int, b int);
create table t2(a int, b int);
create table t3(a int, b int);
select (select count(t2.a) from t2) from t1;
select a, (select count(t2.a) from t2) from t1 group by b;
select count((select count(t2.a) from t2)) from t1;
--error 5176
select count((select count(t1.a) from t2)) from t1;
--error count(t1.a+(select count(t1.a) from t2)) from t1;
select a as c, b from t1 having b>(select count(t2.a+c) from t2);
select a as c, b from t1 having b>(select t1.a as d from t2 having count(d)>0);
select a as c, b from t1 having b>(select t1.a as d from t2 having count(c)>0);
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(t1.a) from t3));
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(1+t1.a) from t3));
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(t1.a+c) from t3));
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(c) from t3));
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(t1.a+c) from t3));
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(t1.a+c) from t3));
select a from t1 having a=(select 1+t1.a as c from t2 order by(select count(t1.a+t1.a) from t3));
select a from t1 having a=(select 1+t2.a as c from t2 order by(select count(t1.a+c) from t3));
--error 5176
select a from t1 having a=(select 1+t1.a as c from t2 having count(t1.a+(select count(c) from t3))>0);
select a from t1 having a=(select 1+t1.a as c from t2 having count(t1.a+(select 1+t1.a as cc from t3 having count(cc)>0))>0);
select a from t1 where exists(select max(t1.a) from t2);
SELECT t1.a FROM t1 GROUP BY t1.a HAVING t1.a < ALL(SELECT t2.a FROM t2 GROUP BY t2.a HAVING EXISTS(SELECT t3.a FROM t3 GROUP BY t3.a HAVING SUM(t1.a+t2.a) < t3.a/4));
select (select count(t1.b) from t2 union select 1 from t2 where 12 < 3) from t1 group by t1.a;
select a from t1 having count(*) > (select 1);
select * from t1 join t2 on t1.a=(select count(t2.a));
select * from t1 join (t2, t3) on t1.a=(select count(t2.a));
select (select count((select t1.a from t2)) from t2) from t1;

View File

@ -0,0 +1,11 @@
drop database if exists question_mark_db;
create database question_mark_db;
use question_mark_db;
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
select * from t1 where c1=0
select * from t1 where c1=1 and c2=1
drop database question_mark_db;

View File

@ -0,0 +1,25 @@
drop database if exists range_partition;
create database range_partition;
use range_partition;
create table t1(c1 int, c2 int) partition by range columns(c1) (partition p0 values less than(20), partition p1 values less than(30), partition p2 values less than maxvalue);
create table t2(c1 int, c2 int) partition by hash(c1) subpartition by range columns(c2) subpartition template (subpartition p0 values less than(20), subpartition p1 values less than(30)) partitions 4;
create table t3(c1 date, c2 int) partition by range columns(c1) (partition p0 values less than('1990-01-01'), partition p1 values less than('19910101'));
--error 5178
create table t4(c1 year, c2 int) partition by range columns(c1) (partition p0 values less than('1990'), partition p1 values less than(1997));
--error 5178
create table t5(c1 time, c2 int) partition by range columns(c1) (partition p0 values less than('10:10:10'), partition p1 values less than(101010));
create table t6(c1 datetime, c2 int) partition by range columns(c1) (partition p0 values less than('1990-01-01'), partition p1 values less than('19910101'));
--error 5178
create table t7(c1 timestamp, c2 int) partition by range columns(c1) (partition p0 values less than('1990-01-01 10:10:10'), partition p1 values less than(19910101101010));
#test error
--error 5178
create table t8(c1 float, c2 int) partition by range columns(c1) (partition p0 values less than(20), partition p1 values less than(30), partition p2 values less than maxvalue);
--error 5275
create table t9(c1 varchar(30), c2 int) partition by range columns(c1) (partition p0 values less than(20), partition p1 values less than(30), partition p2 values less than maxvalue);
--error 5275
create table t10(c1 int, c2 int) partition by range columns(c1) (partition p0 values less than(1.20),partition p1 values less than(30));
--error 5280
create table t11(c1 int, c2 int) partition by range columns(c1) (partition p0 values less than(10), partition p0 values less than(300));
drop database range_partition;

View File

@ -0,0 +1,7 @@
purge table t1;
purge database db1;
purge schema db1;
purge tenant tenant1;

View File

@ -0,0 +1,11 @@
drop database if exists rename_db;
drop database if exists rename_to;
create database rename_db;
create database rename_to;
use rename_db;
create table t1(c1 int primary key,c2 int);
create table t2(c1 int primary key,c2 varchar(30));
rename table t1 to test,t2 to test2;
#rename table rename_db.t1 to rename_to.test;
rename table t1 to test,t2 to t1,test to t2;

View File

@ -0,0 +1,13 @@
#drop database if exists returning_db;
#create database returning_db;
#use returning_db;
#
#create table t1(c1 int primary key, c2 int, c3 int);
#insert into t1 values(1, 2, 3), (2, 3, 4) returning c1, c2, c3;
#insert into t1 values(3, 3, 3) returning c1, c2, c3;
#replace into t1 values(3, 10, 11) returning c1 + 1, c2 + 1, c3 + 1;
#delete from t1 where c1 = 1 or c1 = 10 returning c1 + c2 + c3;
#update t1 set c2 = 200 where c1 = 3 returning c1 * 2, c2 + c3;
#
#drop table t1;
#drop database returning_db;

View File

@ -0,0 +1,687 @@
drop database if exists select_db;
create database select_db;
use select_db;
#schema
create table emp(emp_id int, emp_name varchar(20), mgr_id int)
create table t1(c1 int primary key, c2 int) partition by hash(c1 + 1) partitions 3
create table t2(c1 int, c2 int, c3 varchar(32), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t3(c3 int primary key, c4 int)
create index idx1 on t1(c2) LOCAL
create table test(c1 int , c2 int, c3 varchar(50), c4 varchar(50), c5 int , c6 double, c7 int, primary key(c1, c2, c3))
create index test_indx on test(c4, c5)
create table non_reserved_key_test(value int primary key)
create table test2(c1 int primary key, c2 varchar(30), c3 timestamp(6) default now(6))
create table t4(c1 int primary key, c2 int not null, c3 int default 1, c4 int not null default 2)
create table ta(c1 int primary key, c2 int auto_increment) comment='test', auto_increment= 5
create table alter_table1(c1 int primary key, c2 varchar(11) not null default 'c2', c3 tinyint default 3, c4 char(11)) partition by hash(c1) partitions 3
create index idx_c1 on alter_table1(c1) LOCAL
create table t_auto_inc(c1 int primary key, c2 int auto_increment)
create table coll_table(c1 varchar(10) collate utf8_general_ci, c2 varchar(10) collate utf8_bin, c3 varchar(10), primary key(c1, c2));
create table ts(c1 int primary key, c2 timestamp default current_timestamp on update current_timestamp, c3 int);
CREATE TABLE yu1(c1 char(20), c2 bigint, pk bigint primary key);
CREATE TABLE yu2(c1 char(20), pk bigint primary key, c2 char(20)) partition by key();
create table emp1(`level` int);
### common ###
select c1, sum(c2) from t1 where c1 > 0 and c2 + c1 = 100 group by c2 order by c1 desc limit 0, 1
select sum(c1) + sum(c3) from t2 group by c2 having sum(c3) > 1
select t1.c1, t2.c1 from t1 left join t2 on t1.c1 = t2.c2 and t1.c1 > 10 limit 10 offset 10
### all distinct ###
select all c1 from t1
select all * from t1
select distinct c1 from t1
select distinct * from t1
### select ###
#### table not exist
select 1 + 1;
select 1 + 1 from dual;
select @@sql_mode
select coalesce(NULL,NULL,3,4,5)
select case 'b' when 'a' then 1 when 'b' then 2 end
select case when 1>0 then 'true' else 'false' end
#### * star
select * from t1
select *, t1.* from t1
select t1.*, t2.* from t1,t2
select table1.* from t1 table1
select rongxuan.t1.* from rongxuan.t1
#### duplicate column name
select c1, c1 from t1
#### table name or alias
select t1.c1, t2.c1 from t1, t2
#select c1, t1.c1, table1.c1 from t1 table1 //not support
select table1.c1, table2.c1 from t1 table1, t2 table2
#### database name
select rongxuan.t1.c1 from rongxuan.t1
#### as
select c1 column1 from t1
select c1 as column1 from t1
#### column name or alias
select c1 as c2, c2 as c1 from t1
select t1.c1 as column1, t2.c1 column2 from t1, t2
#### function or expression
select count(distinct t1.c1), count(distinct t1.c2) from t1 order by c1, c2
#select -(c1 + 1 - 1.2 + 0), concat(t1.c2, 'test'), 'test', 'test', not (true or false), NULL from t1
select usec_to_time(c1) as modify_time_us from t1;
#### question mark
select 1 from t1
select 1 as c1 from t1
### from ###
#### as
select * from t1 table1
select * from t1 as table1
#### multiple table
#select t1.*, t2.* from t1, t2
#select t1.*, t2.* from t1 table1, t2 table2
#select table1.*, table2.*, c4, c5 from t1 table1, (select * from t2) table2, t1 inner join test on t1.c1 = test.c1
#### join
select * from t1 join t2 on t1.c1 = t2.c1
select * from t1 right join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 left outer join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 left join t2 using (c1)
#select t1.*, t2.* from t1 left outer join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 left join t2 using (c1)
select t1.c1, tt.c2 from t1 join (select t1.c1, t2.c2 from t1 join t2 on t1.c1 = t2.c1) tt on t1.c1 = tt.c1
select t1.c1, tt.c2 from (select t1.c1, t2.c2 from t1 join t2 on t1.c1 = t2.c1) tt join t1 on t1.c1 = tt.c1
select t1.c1,t2.c2,test.c3 from t1 join t2 on t1.c1 =t2.c1 join test on t2.c1 = test.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 right outer join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 right join t2 using (c1)
#select t1.*, t2.* from t1 right outer join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 right join t2 using (c1)
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 full join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 inner join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 full join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 inner join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 join t2 using (c2)
#select t1.*, t2.* from t1 join t2 using (c1,c2)
#using
select * from t1 join t2 using (c1)
select t1.*, * from t1 join t2 using (c2)
select * from t1 right join t2 using (c1)
select * from t1 join t2 using (c2,c1)
#natural join natural join
#select * from t1 nautral join t2 //not support
#straight join
#select * from t1 straight_join t2 //not support
#### subquery
select c1, c2 from (select c1, c2 from t1) t1
select column1, table1.column2 from (select c1 column1, c2 column2 from t1) table1
select t1.c1, t1.c2+1 from (select * from t1) t1
select * from (select * from t1) table1
#### index hint
select * from t1 use index (idx1)
select * from t1 ignore index (idx1)
select * from t1 force index (idx1)
#### partition list
select * from t1 partition (p1)
### where ###
#### expression or function
select t1.c1 from t1, t2 where t1.c1 = t2.c1
select * from t1, t2 where 1+1=2 and t1.c1=t2.c1+1;
select c1 from t2 where (c1 + 1) between 1 and 10 and c3 between 'A' and 'Z'
select * from t2 where c1 * 2 + 3 < c2 and c3 < 'XXXX' and c2 is not null
select * from t1 where c1 = now()
select * from t1 where c1 = 'test'
select * from t1 where (c1<-100 or c1 between -50 and 50 or c1 between -999 and 0 or c1>100) and (c1<-9 or c1>9) and c2 between -99 and 99
select * from t2 where c1 = 1 and c2 = 2 and c3 like '%test%' and c1 between 1 and 10
select c1, c2 from t1 where (c1, c2) in ((1, 2))
#select * from t1 where exists(select * from t2 where c1 = 1)
select * from t1 where not (c1 > 1 and c2 < 10)
select * from t1 where not (c1 > 1 or c2 < 10)
select * from t1 where not (not (c1 > 1))
select * from t1 where not (not (c1 > 1) and c2 < 10)
select * from t1 where c1 > 1 and (c2 < 10 and c1 <10)
select * from t1 where c1 > 1 or (c2 < 10 or c1 <10)
select * from t1 where (c1 > 1 and c2 > 1) or (c1 > 1 and c2 < 10)
select * from t1 where (c1 > 1 or c2 > 1) and (c1 > 1 or c2 < 10)
select t1.c1 from t1,t2,test where t1.c1=test.c1 and t1.c2=t2.c2 and t2.c3=test.c3;
select t1.c1 from t1,t2,test where t1.c1=t2.c1 and t1.c1+t2.c1=test.c1;
select t1.c1 from t1,t2,test, t1 tt where t1.c1=test.c1 and t1.c2=tt.c2 and t1.c1+t2.c1=tt.c1;
####calculate and const
#select c1 from t1 where c2 = 1 + 1 + c1
select c1 from t1 where c2 = 1+1
#### subquery
#select c1 from t1 where c1 in (select c2 from t2)
#select c1 from t1 where (select c2 from t2) in (1,2)
#select c1 from t1 where c1 exists (select c2 from t2 where t2 = 1)
#select * from t1 where (c1,c2) in ((1,2), (select c1,c3 from t2))
#### column name or alias
select c1 from t1 where c1 = 1
select c1 column1 from t1 where c1 > 2
#select c1, c2 column2 from t1 where c1 = 1 and column2 = 1
#### table name or alias
select c1, c2 from t1 table1 where table1.c2 = 1
#select c1, c2 from t1 table1 where t1.c1 = 1 and table1.c2 = 1 //not support
#### question mark
select c1, c2 from t1 where 1 >1
select * from t1 where c1 = 1
#### equal set
select c1 from t1 where c2 = 1
select c1 from t1 where 1 = c2
select c1 from t1 where c1 = 1 and c1 =2
#select c1 column1 from t1 where c1 = 1 and column1 = 5 //alias name should not in where clause
select c1 from test where c1 = c2 and c1 = 5 and c7 = c5
###group by ###
#### position
select * from t2 group by 1
#### column name or alias
select c1 from t1 group by c1
select c1, c2 column2 from t1 group by column2
#### table name or alias
#select * from t1 table1 group by t1.c1 //not support
select * from t1 table1 group by table1.c1
#### column not in select
select c1 from t1 group by c2
#### expression or function
select c1, sum(c2) from t1 group by c1+2
#### question mark this is syntax error
#select * from t1 group by 1
### order by ###
#### asc, desc
select * from t2 order by c1, c2 desc, c3 asc
#### position
select * from t2 order by 1, 2 desc, 3 asc
(select c1 from t1) except (select c2 from t2) order by 1;
#select item is not ref column
select c1+1 from t1 order by 1
#### column name or alias
select c1, c2 column2 from t1 order by c1, column2
--error 5207
select c1, c2 as c1 from t1 order by c1
#### table name or alias
select c1, c2 from t1 table1 order by table1.c2
#select c1, c2 from t1 table1 order by t1.c1, table1.c2 //not support
#### column not in select
select c1 from t1 order by c2
#### column in select item
#select t1.c1, c1 from t1 order by t1.c1
#### expression or function
select c1, sum(c2) from t1 order by sum(c2)
### having###
#### column or column alias
select * from t1 having c1 > 0
select * from t1 having sum(c1) > 0
select c1, c2 column2 from t1 having sum(c1) > 1 and sum(column2) > 1
#select c1, c2 column2 from t1 having column2 > 1 @ TODO
####having column must exist in select items or in group items
select c1 from t1 group by c2 having c2 > 0
#### table name or table alias
#the scope is T_AGG_SCOPE,not HAVING_SCOPE
#select c1, c2 from t1 table1 having sum(t1.c2) < 1
select c1, c2 from t1 table1 having sum(table1.c2) < 1
select c1 from t1 having t1.c1 > 1
select c1 from t1 having c1 > 1
#### column not in select items
select c1 from t1 having sum(c2)>1
#select t1.c1 from t1 having sum(t1.c1) > 1
#### function or expression
select c1, sum(c2) column2 from t1 having sum(c1+1)>1
#### question mark
select * from t1 having sum(1) > 1
### hint ###
#### read consistency
select /*+ READ_CONSISTENCY(WEAK) */ * from t1
select /*+ READ_CONSISTENCY(STRONG) */ * from t1
select /*+ READ_CONSISTENCY(FROZEN) FROZEN_VERSION(1) */ * from t1
#not use
#select /*+ CLIENT_VERSION */ * from t1
#select /*+ MYSQL_DRIVER */ * from t1
select /*+ TOPK(10 2) */ * from t1
select /*+ HOTSPOT*/ * from t1
select /*+ LOG_LEVEL('INFO') */ * from t1
select /*+ USE_HASH(t1)*/ * from t1
select /*+ USE_PLAN_CACHE(default)*/ * from t1
select /*+ USE_PLAN_CACHE(exact)*/ * from t1
#### query timout
select /*+ QUERY_TIMEOUT(1000) */ * from t1
#### use nl
select /*+ USE_NL(t1) */ * from t1 join t2 on t1.c1 = t2.c1
#### index
select /*+ INDEX(t1 INVALID_INDEX) */ c1 from t1;
#### leading
select /*+ leading(t2 t1 test)*/ * from t1, t2, test where t1.c1=t2.c1 and test.c1 = t2.c1;
#### merge
select /*+ use_merge(t2)*/ * from t1, t2, test where t1.c1=t2.c1 and test.c1 = t2.c1;
#### orderd
#111
select /*+ ordered, use_merge(t2), use_nl(test)*/ * from t1, t2, test where t1.c1=t2.c1 and test.c1 = t2.c1;
#### full
select /*+ full(t1) */ c1, c2 from t1 where c1 = 2 or c2 =5;
### for update ###
select * from t1 for update
select * from t1 for update wait 2
select * from t1 for update wait 1
select * from t1 for update nowait
select * from t1 for update wait 1.0
### limit ###
#### const
select c1, c2 from t1 limit 2, 10
select c1, c2 from t1 limit 10
select c1, c2 from t1 limit 2 offset 10
(select c1 from t1 limit 10) limit 20
#### question mark
select * from t1 limit 1, 1
select * from t1 limit 1
select 1 in (c1) , c1 in (c2), 1 in (c1,c2) from t1;
### set ###
#### all distinct
select c1,c2 from t1 union all select c1,c2 from t2
select c1,c2 from t1 union distinct select c1,c2 from t2
select c1,c2 from t1 union select c1,c2 from t2
select * from t1 union select * from t1
select * from t1 union select * from t1 union select * from t1
select * from t1 union all select * from t1
#select c1, c2 from t1 union all select * from t1 order by t1.c1
#(select * from t1 union select * from t1) t2 union select * from t1 order by t2.c1
(select c1 from t1) except (select c2 from t2) order by c1;
(select c1 from t1) intersect (select c2 from t2) order by c1 limit 100;
(select c1 from t1) union (select c2 from t1) union (select c2 from t2);
(select c1 from t1) union (select c2 from t1) union (select c2 from t2) order by c1 limit 100;
(select c1 from t1) union (select c2 from t1) intersect (select c2 from t2) order by c1 limit 100;
(select c5, c7 from test) union ( select t1.c1, t2.c2 from t1 join t2 on t1.c1 = t2.c1)
#(select c5, c7 from test) union ( select c1, c2 from t1 join t2 on t1.c1 = t2.c1) //error,ambiguous
## different column between left and right substmt
--error 5007
select c1 from t1 union select c1,c2 from t1;
### select into ###
### when just for test
### select c1 from t1 when ROW_COUNT(update t2 set c1 = 1) @ TODO
select t1.c1, t2.c2, t2.c3 from t1,t2 where t1.c1 = t2.c1 order by t1.c2;
### sys fun
select current_timestamp()
##TODO uncomment this when supported
##select current_times()
##select current_date()
## ``
select abs(1.8) as `a`;
select abs(1.8) as "a";
select abs(1.8) as 'a';
select abs(1.8) `a`;
select abs(1.8) "a";
select abs(1.8) 'a';
select c1 as "a" from t1;
select c1 as `a` from t1;
select c1 as 'a' from t1;
### collation
## join with no join_condition
select c1, c2, c1 > c2 from coll_table where c1 < c2 collate utf8_general_ci;
select 1 collate utf8_general_ci < _utf8 'abcd' collate utf8_general_ci;
select * from t1 join t2
select * from t1 inner join t2
select * from t1 cross join t2
select * from t1 join t2 join t3
## case alias in group and having clause
select X.c1 from t1 AS X group by X.c2 having (X.c1 = 1);
(SELECT * FROM yu1) UNION ALL (SELECT * FROM yu2);
## for coverage
select * from (select * from t1) t join t2 using(c1) join t4 using(c1)
select * from (select * from t1) t join t2 using(c1) left join t4 using(c1)
select * from (select * from t1) t join t2 using(c1) right join t4 using(c1)
# @TODO: table_id will be changed, coment out!
#select * from __idx_1099511631103_idx1
--error 5019
select * from t_not_exist
## case insensitive
--error 5207
select c1 a, C2 A from t1 order by a
select * from (t1);
select * from (t1,t2);
select * from (t1,(t2));
select * from (t3,((t1,t2)));
select * from t1 join t2 join t3;
select * from (t1 join t2) join t3;
select * from (t1 join t2) join (select * from t3) a;
select * from ((t1 join t2) join (select * from t3) a);
#select * from (t1,t2) join (t3,t4);
#select * from (t1 join t2) join (t3,t4);
select * from t1 join t2 on t1.c1=t2.c1, t3 join t4 on t3.c3=t4.c3;
select * from t1 join t2 using(c1), t3 join t4 using(c3);
select '';
select ' ';
select '\n';
select '\t';
select ' a';
select '\t a';
select '\n a';
select ' aa' 'bb';
select 'aa' ` a`;
select '111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122';
select ' 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111122';
select '\n\t11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111a22';
select 'abc' '\n\t11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111a22';
select 'abc' as '\n\t11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111a22';
select 'abc' as ` 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111a22`;
SELECT t1.c1 FROM t2 LEFT JOIN t1 ON t2.c2 = t1.c1 ORDER BY c1;
select default(c1) from t2;
select default(c3) from test2;
--error 5217
select 1 as a from t1,t2 having c1=1;
--error 5207
select t1.c1,t2.c1 from t1,t2 having c1=1;
--error 5207
select t1.c1,t2.c1 from t1,t2 order by c1;
--error 5207
select t1.c1,t2.c1 from t1,t2 group by t1.c1,t2.c1 having c1 =1;
select 1 from t1,t2 group by t1.c1,t2.c1 having t1.c1 =1;
select c1 from t1 as x group by x.c1,c1 having c1 =1;
select c1 from t1 as x group by x.c1,c1 having x.c1 =1;
--error 5217
select c1 from t1 having xxx.c1 =1;
drop database select_db;
## test comment
/* 0a026f4414465990777471049d5c12/0// */ select 'abc';
select 'abc' /* 0a026f4414465990777471049d5c12/0// */;
select /* 0a026f4414465990777471049d5c12/0// */ 'abc';
##test validation of column alias
select 'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv1111111111111111111111111111256';
select 'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv1111111111111111111111111111256aaa';
select 1 'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv1111111111111111111111111111256';
select 1 'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv1111111111111111111111111111256aaa';
select (select 'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv11111111111111111256');
select (select 'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv11111111111111111256aaa');
select concat('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','bbbbbbbbbbbbbbbbbbbbbbcdefghijklmnlzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz');
select 1+'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv1111111111111111111111111111256aaa';
select c1 +'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv11111111111111111111111256' from t1;
select c1 +'vvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvvvvvvvvvvvv2222222222333333333344444444445555555555666666666612345vvvvvvvvvv11111111111111111111111256a' from t1;
select c3 from t3 where c3>'1';
##################### test for hierarchical query ############################
#select emp_id, mgr_id, emp_name from emp connect by nocycle prior emp_id = mgr_id;
### normal test ###
#select emp_id, mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#select emp_id, mgr_id, emp_name from emp connect by prior emp_id = mgr_id and prior emp_id = emp_name;
#select emp_id, mgr_id, emp_name from emp connect by prior emp_id = mgr_id or prior emp_id = emp_name;
#select emp_id, mgr_id, emp_name from emp connect by prior emp_id = mgr_id and emp_id > 10;
#--error 5313
#select emp_id, mgr_id, emp_name from emp connect by nocycle prior (select min(c1) from t1) = mgr_id;
### select emp_id, emp_name, mgr_id from emp connect by prior emp_id = (select min(c1) from t1 where c1 > emp_id);
#
#
#select emp_id, emp_name, mgr_id from emp start with emp_id = 1 connect by prior emp_id = mgr_id;
#select emp_id, mgr_id, emp_name from emp start with (select min(c1) from t1) = 1 connect by prior emp_id = mgr_id;
#select emp_id, emp_name, mgr_id from emp start with emp_id = 1 and mgr_id > 1 connect by nocycle prior emp_id = mgr_id;
#select emp_id, emp_name, mgr_id from emp start with emp_id = 1 or mgr_id > 1 connect by nocycle prior emp_id = mgr_id;
#
#### alias name ###
#--error 5217
#select emp_id as ee, emp_name, mgr_id from emp start with ee = 1 connect by prior emp_id = mgr_id;
#--error 5217
#select emp_id as ee, emp_name, mgr_id from emp start with ee = 1 connect by prior ee = mgr_id;
#
#### alias name ###
#--error 5176
#select emp_id, emp_name, mgr_id from emp start with max(emp_id) = 1 connect by prior ee = mgr_id;
#--error 5313
#select emp_id, emp_name, mgr_id from emp start with emp_id = 1 connect by prior max(emp_id) = mgr_id;
#--error 5176
#select emp_id, emp_name, mgr_id from emp start with emp_id = 1 connect by prior emp_id = max(mgr_id);
#
#### test for pseudo column ###
#select level, emp_id from emp connect by prior emp_id = mgr_id;
#select level, emp_id from emp where level < 1 connect by prior emp_id = mgr_id;
#select max(level), emp_id from emp where level < 1 connect by prior emp_id = mgr_id;
#select connect_by_iscycle, emp_id from emp connect by nocycle prior emp_id = mgr_id;
#select connect_by_iscycle, emp_id from emp where connect_by_iscycle < 1 connect by nocycle prior emp_id = mgr_id;
#select max(connect_by_iscycle), emp_id from emp where level < 1 connect by nocycle prior emp_id = mgr_id;
#select connect_by_isleaf, emp_id from emp connect by prior emp_id = mgr_id;
#select connect_by_isleaf, emp_id from emp where connect_by_isleaf < 1 connect by prior emp_id = mgr_id;
#select max(connect_by_isleaf), emp_id from emp where connect_by_isleaf < 1 connect by prior emp_id = mgr_id;
#
#
#--error 5312
#select level from emp;
#--error 5312
#select connect_by_iscycle from emp;
#--error 5312
#select connect_by_isleaf from emp;
#--error 5312
#update t1 set c1 = 1 where level = 1;
#--error 5312
#update t1 set c1 = 1 where connect_by_isleaf = 1;
#
#--error 5313
#set @c1 = connect_by_isleaf;
#--error 5313
#set @c1 = level + 1;
#--error 5313
#set @c1 = connect_by_iscycle;
#
#--error 5312
#select emp_id from emp where level > 1;
#--error 5312
#select emp_id from emp where connect_by_isleaf > 1;
#--error 5312
#select emp_id from emp where connect_by_iscycle > 1;
#select `level` from emp1;
#
#--error 5313
#select emp_id from emp connect by level = 1;
#--error 5313
#select emp_id from emp start with level = 1 connect by prior emp_id = mgr_id;
#--error 5313
#select t1.c1 from t1 join t2 on t1.c1 = t2.c2 and level = 1 connect by prior t1.c1 = t2.c1;
#--error 5313
#select emp_id from emp connect by prior level = emp_id;
#--error 5313
#select emp_id from emp start with level = 0 connect by prior emp_id = mgr_id;
#
#--error 5313
#select emp_id from emp connect by connect_by_isleaf = 1;
#--error 5313
#select emp_id from emp start with connect_by_isleaf = 1 connect by prior emp_id = mgr_id;
#--error 5313
#select t1.c1 from t1 join t2 on t1.c1 = t2.c2 and connect_by_isleaf = 1 connect by prior t1.c1 = t2.c1;
#--error 5313
#select emp_id from emp connect by prior connect_by_isleaf = emp_id;
#--error 5313
#select emp_id from emp start with connect_by_isleaf = 0 connect by prior emp_id = mgr_id;
#
#--error 5313
#select emp_id from emp connect by connect_by_iscycle = 1;
#--error 5313
#select emp_id from emp start with connect_by_iscycle = 1 connect by prior emp_id = mgr_id;
#--error 5313
#select t1.c1 from t1 join t2 on t1.c1 = t2.c2 and connect_by_iscycle = 1 connect by prior t1.c1 = t2.c1;
#--error 5313
#select emp_id from emp connect by prior connect_by_iscycle = emp_id;
#--error 5313
#select emp_id from emp start with connect_by_iscycle = 0 connect by prior emp_id = mgr_id;
#
#--error 5314
#select connect_by_iscycle, emp_id from emp connect by prior emp_id = mgr_id;
#--error 5314
#select connect_by_iscycle, emp_id from emp where connect_by_iscycle < 1 connect by prior emp_id = mgr_id;
#--error 5314
#select max(connect_by_iscycle), emp_id from emp where level < 1 connect by prior emp_id = mgr_id;
#
#### test for prior expr ###
#
#--error 5313
#select prior (prior emp_id), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select prior (prior emp_id + 1), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select prior (level), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select prior (connect_by_iscycle), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select prior (connect_by_isleaf), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select prior (max(empr_id)), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select prior (select 1 from t1), mgr_id, emp_name from emp connect by prior emp_id = mgr_id;
#--error 5313
#select emp_id, mgr_id from emp start with prior emp_id = 1 connect by prior emp_id = mgr_id;
#--error 5313
#select t1.c1 from t1 join t2 on prior t1.c1 = t2.c2 connect by prior t1.c1 = t2.c1;
#
#--error 5312
#update t1 set c1 = 1 where prior c1 = 1;
#--error 5312
#set @c1 = prior 1;
#
#### test for connect_by_root expr ###
#select connect_by_root (emp_id) from emp connect by prior emp_id = mgr_id;
#select emp_id + connect_by_root (emp_id) from emp connect by prior emp_id = mgr_id;
#--error 5313
#select emp_id from emp connect by prior emp_id = mgr_id order siblings by connect_by_root (emp_id);
#
#### test for sys_connect_by_path expr ###
#select sys_connect_by_path(emp_id, 1) from emp connect by prior emp_id = mgr_id;
#select sys_connect_by_path(2, 1) from emp connect by prior emp_id = mgr_id;
#select sys_connect_by_path(emp_id + 1, 1) from emp connect by prior emp_id = mgr_id;
#--error 5313
#select emp_id from emp connect by prior emp_id = mgr_id order siblings by sys_connect_by_path(emp_id, 'a');
#--error 5313
#select emp_id from emp start with sys_connect_by_path (emp_id, 'a') > 1 connect by prior emp_id = mgr_id;
#--error 5313
#select emp_id from emp connect by prior emp_id = sys_connect_by_path(emp_id, 'a');
# #test '(+)' symbol
# select * from t1 right join t2 on t1.c1 = t2.c1;
# select * from t1 ,t2 where t1.c1(+) = t2.c1;
#
# select * from t1 left join ( t2 left join t3 on t2.c1 = t3.c3) on t1.c1 = t2.c1;
# select * from t1, t2, t3 where t1.c1 = t2.c1(+) and t2.c1 = t3.c3(+);
#
# select * from t1 left join ( t2 left join t3 on t2.c1 = t3.c3) on t1.c1 = t2.c1, t4 left join ta on t4.c1 = ta.c1;
# select * from ( t3 right join t2 on t2.c1 = t3.c3) right join t1 on t1.c1 = t2.c1, ta right join t4 on t4.c1 = ta.c1;
# select * from t1, t2, t3, t4, ta where t1.c1 = t2.c1(+) and t2.c1 = t3.c3(+) and t4.c1 = ta.c1(+);
#
# select * from t1, t2, t3 where t1.c1(+) = t2.c1 and t2.c1(+) = t3.c3;
# select * from t1 right join (t2 right join t3 on t2.c1 = t3.c3) on t1.c1 = t2.c1;
#
# select * from t1, t2, t3 where t1.c1(+) = t3.c3 and t2.c1 = t3.c3(+);
# select * from t1 right join (t2 right join t3 on t2.c1 = t3.c3) on t1.c1 = t3.c3;
select grouping(c1),grouping(c2),c1,c2 from t1 group by c1,c2 with rollup;
--error 4002
select grouping(c1),grouping(c2),c1 from t1 group by c1 with rollup;
--error 4002
select grouping(c1),grouping(c2),c1 from t1 group by c1;
--error 4002
select grouping(c1),c1 from t1 group by c1;
## test qp_distribute hint
select /*+ pq_distribute(t2 hash hash) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2, hash hash) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2, hash, hash) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(@sel$2 t2 hash, hash) */ * from (select t1.c1 from t1, t2 where t1.c1 = t2.c1) a, t3 where a.c1 = t3.c3;
select /*+ pq_distribute(t2 BROADCAST, NONE) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2 NONE, BROADCAST) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2 PARTITION, NONE) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2 NONE, PARTITION) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2 NONE, NONE) */ * from t1, t2 where t1.c1 = t2.c1;
# invalid hint
select /*+ pq_distribute(t2 NONE, HASH) */ * from t1, t2 where t1.c1 = t2.c1;
select /*+ pq_distribute(t2 PARTITION, BROADCAST) */ * from t1, t2 where t1.c1 = t2.c1;

View File

@ -0,0 +1,75 @@
# simple case
--error 5217
select 1 as a, (select a) as b;
--error 5217
select 1 as a, (select a+a) as b;
--error 5217
select 1 as a, 2 as b, (select a) as c;
--error 5217
select 1 as a, 2 as b, (select a+a) as c;
--error 5217
select 1 as a, 2 as b, (select a+b) as c;
# same alias case
--error 5217
select 1 as a, 2 as a, (select a) as c;
--error 5217
select 1 as a, 2 as a, (select a+a) as c;
# subquery case
--error 5217
SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
SELECT (select max(t1.c1) from t1) as field from t1 group by field;
--error 5217
SELECT 1 FROM (SELECT c1 FROM t1) b HAVING (SELECT b.c1)=1;
SELECT c1 as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
--error 5217
SELECT c1 as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING t1.a=1);
--error 5217
SELECT (SELECT 1) a, (select A);
--error 5217
SELECT 1 as a,(SELECT a+a) b,(SELECT b);
select 1 in (1, (1));
select 1 in (1, (select 1));
select 1 in ((select 1), (select 1));
select 1 in ((select 1), (select 1), (select 1));
select 1 in (1, (select 1), (select c1 from t1));
select MAX(c1) c from t1 having (select c) > 0;
--error 5225
select MAX(c1) c from t1 group by (select c);
select MAX(c1) c from t1 order by (select c);
--error 5217
select MAX(c1) c, (select c1 from t1 having c > 0) from t1;
--error 5217
select max(c1) b , (select b) from t1;
select max(c1) b from t1 having b > 0;
select max(c1) b from t1 order by b;
--error 5206
select max(c1) b from t1 group by b;
--error 5217
SELECT MAX(c2) c, (SELECT c1 FROM t1 WHERE c2 = c) FROM t1 HAVING c2 = 10;
--error 5207
select c1, c2 as c1 from t1 group by c1;
--error 5207
select c1 as c1, c2 as c1 from t1 group by c1;
--error 5207
select c1, c2 as c1 from t1 order by c1;
--error 5207
select c1 as c1, c2 as c1 from t1 order by c1;
--error 5207
select c1, c2 as c1 from t1 having c1 > 0;
--error 5207
select c1 as c1, c2 as c1 from t1 having c1 > 0;
select c1, c2 as c1 from t1 having t1.c1 > 2;
--error 5217
select c1 as cc, c2 from t1 having t1.cc > 2;
--error 5217
select c1 from t1 group by t2.c1;

View File

@ -0,0 +1,412 @@
drop database if exists enum_db;
create database enum_db;
use enum_db;
#schema
create table t1(c1 int primary key, c2 set('a', 'b', 'c')) partition by hash(c1 + 1) partitions 3
create table t2(c1 int, c2 int, c3 set('a', 'b', 'c'), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t22(c1 int, c2 int, c3 set('a', 'b', 'c'), primary key(c2, c3)) partition by key(c2, c3) partitions 3
create table t3(c3 int primary key, c4 set('a', 'b', 'c'))
create table t4(c1 int primary key, c3 set('a', 'b', 'c'))
create table coll_table(c1 varchar(10) collate utf8_general_ci, c2 set('a', 'b', 'c'), c3 varchar(10), primary key(c1, c2));
### common ###
select c1, sum(c2) from t1 where c1 > 0 and c2 + c1 = 100 group by c2 order by c1 desc limit 0, 1
select sum(c1) + sum(c3) from t2 group by c2 having sum(c3) > 1
select t1.c1, t2.c1 from t1 left join t2 on t1.c1 = t2.c2 and t1.c1 > 10 limit 10 offset 10
### all distinct ###
select all c1 from t1
select all * from t1
select distinct c1 from t1
select distinct * from t1
#### * star
select * from t1
select *, t1.* from t1
select t1.*, t2.* from t1,t2
select table1.* from t1 table1
#### duplicate column name
select c1, c1 from t1
#### table name or alias
select t1.c1, t2.c1 from t1, t2
#select c1, t1.c1, table1.c1 from t1 table1 //not support
select table1.c1, table2.c1 from t1 table1, t2 table2
#### database name
select rongxuan.t1.c1 from rongxuan.t1
#### as
select c1 column1 from t1
select c1 as column1 from t1
#### column name or alias
select c1 as c2, c2 as c1 from t1
select t1.c1 as column1, t2.c1 column2 from t1, t2
#### function or expression
select count(distinct t1.c1), count(distinct t1.c2) from t1 order by c1, c2
#select -(c1 + 1 - 1.2 + 0), concat(t1.c2, 'test'), 'test', 'test', not (true or false), NULL from t1
select usec_to_time(c1) as modify_time_us from t1;
#### question mark
select 1 from t1
select 1 as c1 from t1
### from ###
#### as
select * from t1 table1
select * from t1 as table1
#### join
select * from t1 join t2 on t1.c1 = t2.c1
select * from t1 right join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 left outer join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 left join t2 using (c1)
#select t1.*, t2.* from t1 left outer join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 left join t2 using (c1)
select t1.c1, tt.c2 from t1 join (select t1.c1, t2.c2 from t1 join t2 on t1.c1 = t2.c1) tt on t1.c1 = tt.c1
select t1.c1, tt.c2 from (select t1.c1, t2.c2 from t1 join t2 on t1.c1 = t2.c1) tt join t1 on t1.c1 = tt.c1
select t1.c1,t2.c2,t4.c3 from t1 join t2 on t1.c1 =t2.c1 join t4 on t2.c1 = t4.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 right outer join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 right join t2 using (c1)
#select t1.*, t2.* from t1 right outer join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 right join t2 using (c1)
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 full join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 inner join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 full join t2 on t1.c1 = t2.c1
#select t1.*, t2.* from t1 inner join t2 on t1.c1 = t2.c1
select t1.c1, t1.c2, t2.c2, t2.c3 from t1 join t2 using (c2)
#select t1.*, t2.* from t1 join t2 using (c1,c2)
#using
select * from t1 join t2 using (c1)
select t1.*, * from t1 join t2 using (c2)
select * from t1 right join t2 using (c1)
select * from t1 join t2 using (c2,c1)
#natural join natural join
#select * from t1 nautral join t2 //not support
#straight join
#select * from t1 straight_join t2 //not support
#### subquery
select c1, c2 from (select c1, c2 from t1) t1
select column1, table1.column2 from (select c1 column1, c2 column2 from t1) table1
select t1.c1, t1.c2+1 from (select * from t1) t1
select * from (select * from t1) table1
#### index hint
select * from t1 use index (idx1)
select * from t1 ignore index (idx1)
select * from t1 force index (idx1)
#### partition list
select * from t1 partition (p1)
### where ###
#### expression or function
select t1.c1 from t1, t2 where t1.c1 = t2.c1
select * from t1, t2 where 1+1=2 and t1.c1=t2.c1+1;
select c1 from t2 where (c1 + 1) between 1 and 10 and c3 between 'A' and 'Z'
select * from t2 where c1 * 2 + 3 < c2 and c3 < 'XXXX' and c2 is not null
select * from t1 where c1 = now()
select * from t1 where c1 = 'test'
select * from t1 where (c1<-100 or c1 between -50 and 50 or c1 between -999 and 0 or c1>100) and (c1<-9 or c1>9) and c2 between -99 and 99
select * from t2 where c1 = 1 and c2 = 2 and c3 like '%test%' and c1 between 1 and 10
select c1, c2 from t1 where (c1, c2) in ((1, 2))
#select * from t1 where exists(select * from t2 where c1 = 1)
select * from t1 where not (c1 > 1 and c2 < 10)
select * from t1 where not (c1 > 1 or c2 < 10)
select * from t1 where not (not (c1 > 1))
select * from t1 where not (not (c1 > 1) and c2 < 10)
select * from t1 where c1 > 1 and (c2 < 10 and c1 <10)
select * from t1 where c1 > 1 or (c2 < 10 or c1 <10)
select * from t1 where (c1 > 1 and c2 > 1) or (c1 > 1 and c2 < 10)
select * from t1 where (c1 > 1 or c2 > 1) and (c1 > 1 or c2 < 10)
select t1.c1 from t1,t2,t4 where t1.c1=t4.c1 and t1.c2=t2.c2 and t2.c3=t4.c3;
select t1.c1 from t1,t2,t4 where t1.c1=t2.c1 and t1.c1+t2.c1=t4.c1;
select t1.c1 from t1,t2,t4, t1 tt where t1.c1=t4.c1 and t1.c2=tt.c2 and t1.c1+t2.c1=tt.c1;
####calculate and const
#select c1 from t1 where c2 = 1 + 1 + c1
select c1 from t1 where c2 = 1+1
#### subquery
#select c1 from t1 where c1 in (select c2 from t2)
#select c1 from t1 where (select c2 from t2) in (1,2)
#select c1 from t1 where c1 exists (select c2 from t2 where t2 = 1)
#select * from t1 where (c1,c2) in ((1,2), (select c1,c3 from t2))
#### column name or alias
select c1 from t1 where c1 = 1
select c1 column1 from t1 where c1 > 2
#select c1, c2 column2 from t1 where c1 = 1 and column2 = 1
#### table name or alias
select c1, c2 from t1 table1 where table1.c2 = 1
#select c1, c2 from t1 table1 where t1.c1 = 1 and table1.c2 = 1 //not support
#### question mark
select c1, c2 from t1 where 1 >1
select * from t1 where c1 = 1
#### equal set
select c1 from t1 where c2 = 1
select c1 from t1 where 1 = c2
select c1 from t1 where c1 = 1 and c1 =2
#select c1 column1 from t1 where c1 = 1 and column1 = 5 //alias name should not in where clause
###group by ###
#### position
select * from t2 group by 1
#### column name or alias
select c1 from t1 group by c1
select c1, c2 column2 from t1 group by column2
#### table name or alias
#select * from t1 table1 group by t1.c1 //not support
select * from t1 table1 group by table1.c1
#### column not in select
select c1 from t1 group by c2
#### expression or function
select c1, sum(c2) from t1 group by c1+2
#### question mark this is syntax error
#select * from t1 group by 1
### order by ###
#### asc, desc
select * from t2 order by c1, c2 desc, c3 asc
#### position
select * from t2 order by 1, 2 desc, 3 asc
(select c1 from t1) except (select c2 from t2) order by 1;
#select item is not ref column
select c1+1 from t1 order by 1
#### column name or alias
select c1, c2 column2 from t1 order by c1, column2
--error 5207
select c1, c2 as c1 from t1 order by c1
#### table name or alias
select c1, c2 from t1 table1 order by table1.c2
#select c1, c2 from t1 table1 order by t1.c1, table1.c2 //not support
#### column not in select
select c1 from t1 order by c2
#### column in select item
#select t1.c1, c1 from t1 order by t1.c1
#### expression or function
select c1, sum(c2) from t1 order by sum(c2)
### having###
#### column or column alias
select * from t1 having c1 > 0
select * from t1 having sum(c1) > 0
select c1, c2 column2 from t1 having sum(c1) > 1 and sum(column2) > 1
#select c1, c2 column2 from t1 having column2 > 1 @ TODO
####having column must exist in select items or in group items
select c1 from t1 group by c2 having c2 > 0
#### table name or table alias
#the scope is T_AGG_SCOPE,not HAVING_SCOPE
#select c1, c2 from t1 table1 having sum(t1.c2) < 1
select c1, c2 from t1 table1 having sum(table1.c2) < 1
select c1 from t1 having t1.c1 > 1
select c1 from t1 having c1 > 1
#### column not in select items
select c1 from t1 having sum(c2)>1
#select t1.c1 from t1 having sum(t1.c1) > 1
#### function or expression
select c1, sum(c2) column2 from t1 having sum(c1+1)>1
#### question mark
select * from t1 having sum(1) > 1
### hint ###
#### read consistency
select /*+ READ_CONSISTENCY(WEAK) */ * from t1
select /*+ READ_CONSISTENCY(STRONG) */ * from t1
select /*+ READ_CONSISTENCY(FROZEN) FROZEN_VERSION(1) */ * from t1
#not use
#select /*+ CLIENT_VERSION */ * from t1
#select /*+ MYSQL_DRIVER */ * from t1
select /*+ TOPK(10 2) */ * from t1
select /*+ HOTSPOT*/ * from t1
select /*+ LOG_LEVEL('INFO') */ * from t1
select /*+ USE_HASH(t1)*/ * from t1
select /*+ USE_PLAN_CACHE(default)*/ * from t1
select /*+ USE_PLAN_CACHE(exact)*/ * from t1
#### query timout
select /*+ QUERY_TIMEOUT(1000) */ * from t1
#### use nl
select /*+ USE_NL(t1) */ * from t1 join t2 on t1.c1 = t2.c1
#### index
select /*+ INDEX(t1 INVALID_INDEX) */ c1 from t1;
#### full
select /*+ full(t1) */ c1, c2 from t1 where c1 = 2 or c2 =5;
### for update ###
select * from t1 for update
select * from t1 for update wait 2
select * from t1 for update wait 1
select * from t1 for update nowait
select * from t1 for update wait 1.0
### limit ###
#### const
select c1, c2 from t1 limit 2, 10
select c1, c2 from t1 limit 10
select c1, c2 from t1 limit 2 offset 10
(select c1 from t1 limit 10) limit 20
#### question mark
select * from t1 limit 1, 1
select * from t1 limit 1
select 1 in (c1) , c1 in (c2), 1 in (c1,c2) from t1;
### set ###
#### all distinct
select c1,c2 from t1 union all select c1,c2 from t2
select c1,c2 from t1 union distinct select c1,c2 from t2
select c1,c2 from t1 union select c1,c2 from t2
select * from t1 union select * from t1
select * from t1 union select * from t1 union select * from t1
select * from t1 union all select * from t1
#select c1, c2 from t1 union all select * from t1 order by t1.c1
#(select * from t1 union select * from t1) t2 union select * from t1 order by t2.c1
(select c1 from t1) except (select c2 from t2) order by c1;
(select c1 from t1) intersect (select c2 from t2) order by c1 limit 100;
(select c1 from t1) union (select c2 from t1) union (select c2 from t2);
(select c1 from t1) union (select c2 from t1) union (select c2 from t2) order by c1 limit 100;
(select c1 from t1) union (select c2 from t1) intersect (select c2 from t2) order by c1 limit 100;
(select c4, c3 from t3) union ( select t1.c1, t2.c3 from t1 join t2 on t1.c1 = t2.c1)
#(select c5, c7 from test) union ( select c1, c2 from t1 join t2 on t1.c1 = t2.c1) //error,ambiguous
## different column between left and right substmt
--error 5007
select c1 from t1 union select c1,c2 from t1;
### select into ###
### when just for test
### select c1 from t1 when ROW_COUNT(update t2 set c1 = 1) @ TODO
select t1.c1, t2.c2, t2.c3 from t1,t2 where t1.c1 = t2.c1 order by t1.c2;
### sys fun
select current_timestamp()
##TODO uncomment this when supported
##select current_times()
##select current_date()
## ``
select c1 as "a" from t1;
select c1 as `a` from t1;
select c1 as 'a' from t1;
### collation
## join with no join_condition
select c1, c2, c1 > c2 from coll_table where c1 < c2 collate utf8_general_ci;
select 1 collate utf8_general_ci < _utf8 'abcd' collate utf8_general_ci;
select * from t1 join t2
select * from t1 inner join t2
select * from t1 cross join t2
select * from t1 join t2 join t3
## case alias in group and having clause
select X.c1 from t1 AS X group by X.c2 having (X.c1 = 1);
(SELECT * FROM t1) UNION ALL (SELECT c1,c2 FROM t2);
## for coverage
select * from (select * from t1) t join t2 using(c1) join t4 using(c1)
select * from (select * from t1) t join t2 using(c1) left join t4 using(c1)
select * from (select * from t1) t join t2 using(c1) right join t4 using(c1)
# @TODO: table_id will be changed, coment out!
#select * from __idx_1099511631103_idx1
--error 5019
select * from t_not_exist
## case insensitive
--error 5207
select c1 a, C2 A from t1 order by a
select * from (t1);
select * from (t1,t2);
select * from (t1,(t2));
select * from (t3,((t1,t2)));
select * from t1 join t2 join t3;
select * from (t1 join t2) join t3;
###YYYYselect * from (t1 join t2) join (select * from t3) a;
####YYYYselect * from ((t1 join t2) join (select * from t3) a);
#select * from (t1,t2) join (t3,t4);
#select * from (t1 join t2) join (t3,t4);
select * from t1 join t2 on t1.c1=t2.c1, t3 join t4 on t3.c3=t4.c3;
select * from t1 join t2 using(c1), t3 join t4 using(c3);
SELECT t1.c1 FROM t2 LEFT JOIN t1 ON t2.c2 = t1.c1 ORDER BY c1;
select default(c1) from t2;
--error 5217
select 1 as a from t1,t2 having c1=1;
--error 5207
select t1.c1,t2.c1 from t1,t2 having c1=1;
--error 5207
select t1.c1,t2.c1 from t1,t2 order by c1;
--error 5207
select t1.c1,t2.c1 from t1,t2 group by t1.c1,t2.c1 having c1 =1;
select 1 from t1,t2 group by t1.c1,t2.c1 having t1.c1 =1;
select c1 from t1 as x group by x.c1,c1 having c1 =1;
select c1 from t1 as x group by x.c1,c1 having x.c1 =1;
--error 5217
select c1 from t1 having xxx.c1 =1;
drop database enum_db;
select c3 from t3 where c3>'1';
## add for enum
select * from (select t1.c2, t2.c3 from t1, t2) as a;
select (1, '2') in (select c1,c2 from t1 union select c2,c3 from t2);
select * from (select c1,c2 from t1 union select c2,c3 from t2) as a;
select c2,c3 from t2 union select c2,c3 from t2 union select c1,c2 from t1;
select (select c2 from t1) > 1 from t1;
select * from t2 where (1) in (c2, (select c2 from t1));

Some files were not shown because too many files have changed in this diff Show More