init push
This commit is contained in:
		
							
								
								
									
										47
									
								
								src/sql/resolver/tcl/ob_end_trans_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								src/sql/resolver/tcl/ob_end_trans_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | ||||
| /** | ||||
|  * 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_RESV | ||||
|  | ||||
| #include "ob_end_trans_resolver.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| using namespace common; | ||||
| namespace sql { | ||||
|  | ||||
| ObEndTransResolver::ObEndTransResolver(ObResolverParams& params) : ObTCLResolver(params) | ||||
| {} | ||||
|  | ||||
| ObEndTransResolver::~ObEndTransResolver() | ||||
| {} | ||||
|  | ||||
| int ObEndTransResolver::resolve(const ParseNode& parse_node) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   ObEndTransStmt* end_stmt = NULL; | ||||
|   if (OB_LIKELY((T_COMMIT == parse_node.type_ || T_ROLLBACK == parse_node.type_) && parse_node.num_child_ == 0)) { | ||||
|     if (OB_UNLIKELY(NULL == (end_stmt = create_stmt<ObEndTransStmt>()))) { | ||||
|       ret = OB_SQL_RESOLVER_NO_MEMORY; | ||||
|       LOG_WARN("failed to create select stmt"); | ||||
|     } else { | ||||
|       stmt_ = end_stmt; | ||||
|       end_stmt->set_is_rollback(T_ROLLBACK == parse_node.type_); | ||||
|     } | ||||
|   } else { | ||||
|     ret = OB_ERR_UNEXPECTED; | ||||
|     LOG_ERROR("unexpected parse node", K(parse_node.type_), K(parse_node.num_child_)); | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
							
								
								
									
										37
									
								
								src/sql/resolver/tcl/ob_end_trans_resolver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/sql/resolver/tcl/ob_end_trans_resolver.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef OCEANBASE_SQL_RESOLVER_TCL_END_TRANS_RESOLVER_ | ||||
| #define OCEANBASE_SQL_RESOLVER_TCL_END_TRANS_RESOLVER_ | ||||
|  | ||||
| #include "sql/resolver/ob_stmt_resolver.h" | ||||
| #include "sql/resolver/tcl/ob_tcl_resolver.h" | ||||
| #include "sql/resolver/tcl/ob_end_trans_stmt.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| class ObEndTransResolver : public ObTCLResolver { | ||||
|   public: | ||||
|   explicit ObEndTransResolver(ObResolverParams& params); | ||||
|   virtual ~ObEndTransResolver(); | ||||
|  | ||||
|   virtual int resolve(const ParseNode& parse_node); | ||||
|  | ||||
|   private: | ||||
|   /* functions */ | ||||
|   /* variables */ | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObEndTransResolver); | ||||
| }; | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
| #endif /* OCEANBASE_SQL_RESOLVER_TCL_END_TRANS_RESOLVER_ */ | ||||
| //// end of header file | ||||
							
								
								
									
										58
									
								
								src/sql/resolver/tcl/ob_end_trans_stmt.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								src/sql/resolver/tcl/ob_end_trans_stmt.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef _OB_END_TRANS_STMT_H | ||||
| #define _OB_END_TRANS_STMT_H | ||||
| #include "sql/resolver/tcl/ob_tcl_stmt.h" | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| class ObEndTransStmt : public ObTCLStmt { | ||||
|   public: | ||||
|   ObEndTransStmt() : ObTCLStmt(stmt::T_END_TRANS), is_rollback_(false) | ||||
|   {} | ||||
|   virtual ~ObEndTransStmt() | ||||
|   {} | ||||
|   virtual void print(FILE* fp, int32_t level, int32_t index); | ||||
|  | ||||
|   void set_is_rollback(bool val) | ||||
|   { | ||||
|     is_rollback_ = val; | ||||
|   } | ||||
|   bool get_is_rollback() const | ||||
|   { | ||||
|     return is_rollback_; | ||||
|   } | ||||
|  | ||||
|   private: | ||||
|   // types and constants | ||||
|   // function members | ||||
|   private: | ||||
|   // data members | ||||
|   bool is_rollback_; | ||||
|  | ||||
|   private: | ||||
|   // disallow copy | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObEndTransStmt); | ||||
| }; | ||||
| inline void ObEndTransStmt::print(FILE* fp, int32_t level, int32_t index) | ||||
| { | ||||
|   print_indentation(fp, level); | ||||
|   fprintf(fp, "<ObEndTransStmt id=%d>\n", index); | ||||
|   print_indentation(fp, level + 1); | ||||
|   fprintf(fp, "IsRollback := %c\n", is_rollback_ ? 'Y' : 'N'); | ||||
|   print_indentation(fp, level); | ||||
|   fprintf(fp, "</ObEndTransStmt>\n"); | ||||
| } | ||||
| }  // end namespace sql | ||||
| }  // end namespace oceanbase | ||||
|  | ||||
| #endif /* _OB_END_TRANS_STMT_H */ | ||||
							
								
								
									
										56
									
								
								src/sql/resolver/tcl/ob_savepoint_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/sql/resolver/tcl/ob_savepoint_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| /** | ||||
|  * 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_RESV | ||||
| #include "ob_savepoint_resolver.h" | ||||
| #include "ob_savepoint_stmt.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| using namespace common; | ||||
|  | ||||
| int ObSavePointResolver::resolve(const ParseNode& parse_tree) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   ObSavePointStmt* stmt = NULL; | ||||
|   if (OB_FAIL(create_savepoint_stmt(parse_tree.type_, stmt)) || OB_ISNULL(stmt)) { | ||||
|     LOG_WARN("failed to create savepoint stmt", K(ret)); | ||||
|   } else if (OB_FAIL(stmt->set_sp_name(parse_tree.str_value_, parse_tree.str_len_))) { | ||||
|     LOG_WARN("failed to set savepoint name", K(ret)); | ||||
|   } else { | ||||
|     stmt_ = stmt; | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| int ObSavePointResolver::create_savepoint_stmt(ObItemType stmt_type, ObSavePointStmt*& stmt) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   switch (stmt_type) { | ||||
|     case T_CREATE_SAVEPOINT: | ||||
|       stmt = create_stmt<ObCreateSavePointStmt>(); | ||||
|       break; | ||||
|     case T_ROLLBACK_SAVEPOINT: | ||||
|       stmt = create_stmt<ObRollbackSavePointStmt>(); | ||||
|       break; | ||||
|     case T_RELEASE_SAVEPOINT: | ||||
|       stmt = create_stmt<ObReleaseSavePointStmt>(); | ||||
|       break; | ||||
|     default: | ||||
|       ret = OB_INVALID_ARGUMENT; | ||||
|       LOG_WARN("invalid stmt type", K(ret), K(stmt_type)); | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
							
								
								
									
										38
									
								
								src/sql/resolver/tcl/ob_savepoint_resolver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/sql/resolver/tcl/ob_savepoint_resolver.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef OCEANBASE_SQL_RESOLVER_TCL_OB_SAVEPOINT_RESOLVER_ | ||||
| #define OCEANBASE_SQL_RESOLVER_TCL_OB_SAVEPOINT_RESOLVER_ | ||||
|  | ||||
| #include "sql/resolver/ob_stmt_resolver.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
|  | ||||
| class ObSavePointStmt; | ||||
| class ObSavePointResolver : public ObStmtResolver { | ||||
|   public: | ||||
|   explicit ObSavePointResolver(ObResolverParams& params) : ObStmtResolver(params) | ||||
|   {} | ||||
|   virtual ~ObSavePointResolver() | ||||
|   {} | ||||
|   virtual int resolve(const ParseNode& parse_tree); | ||||
|   int create_savepoint_stmt(ObItemType stmt_type, ObSavePointStmt*& stmt); | ||||
|  | ||||
|   private: | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObSavePointResolver); | ||||
| }; | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
|  | ||||
| #endif  // OCEANBASE_SQL_RESOLVER_TCL_OB_SAVEPOINT_RESOLVER_ | ||||
							
								
								
									
										33
									
								
								src/sql/resolver/tcl/ob_savepoint_stmt.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/sql/resolver/tcl/ob_savepoint_stmt.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| /** | ||||
|  * 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_RESV | ||||
| #include "ob_savepoint_stmt.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| using namespace common; | ||||
|  | ||||
| int ObSavePointStmt::set_sp_name(const char* str_value, int64_t str_len) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   if (OB_ISNULL(str_value) || str_len <= 0) { | ||||
|     ret = OB_INVALID_ARGUMENT; | ||||
|     LOG_WARN("invalid savepoint name", K(ret), KP(str_value), K(str_len)); | ||||
|   } else { | ||||
|     sp_name_.assign_ptr(str_value, static_cast<int32_t>(str_len)); | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
							
								
								
									
										74
									
								
								src/sql/resolver/tcl/ob_savepoint_stmt.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								src/sql/resolver/tcl/ob_savepoint_stmt.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,74 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef OCEANBASE_SQL_RESOLVER_TCL_OB_SAVEPOINT_STMT_ | ||||
| #define OCEANBASE_SQL_RESOLVER_TCL_OB_SAVEPOINT_STMT_ | ||||
|  | ||||
| #include "sql/resolver/tcl/ob_tcl_stmt.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
|  | ||||
| class ObSavePointStmt : public ObTCLStmt { | ||||
|   public: | ||||
|   explicit ObSavePointStmt(stmt::StmtType type) : ObTCLStmt(type), sp_name_() | ||||
|   {} | ||||
|   virtual ~ObSavePointStmt() | ||||
|   {} | ||||
|   int set_sp_name(const char* str_value, int64_t str_len); | ||||
|   inline const common::ObString& get_sp_name() const | ||||
|   { | ||||
|     return sp_name_; | ||||
|   } | ||||
|  | ||||
|   private: | ||||
|   common::ObString sp_name_; | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObSavePointStmt); | ||||
| }; | ||||
|  | ||||
| class ObCreateSavePointStmt : public ObSavePointStmt { | ||||
|   public: | ||||
|   explicit ObCreateSavePointStmt() : ObSavePointStmt(stmt::T_CREATE_SAVEPOINT) | ||||
|   {} | ||||
|   virtual ~ObCreateSavePointStmt() | ||||
|   {} | ||||
|  | ||||
|   private: | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObCreateSavePointStmt); | ||||
| }; | ||||
|  | ||||
| class ObRollbackSavePointStmt : public ObSavePointStmt { | ||||
|   public: | ||||
|   explicit ObRollbackSavePointStmt() : ObSavePointStmt(stmt::T_ROLLBACK_SAVEPOINT) | ||||
|   {} | ||||
|   virtual ~ObRollbackSavePointStmt() | ||||
|   {} | ||||
|  | ||||
|   private: | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObRollbackSavePointStmt); | ||||
| }; | ||||
|  | ||||
| class ObReleaseSavePointStmt : public ObSavePointStmt { | ||||
|   public: | ||||
|   explicit ObReleaseSavePointStmt() : ObSavePointStmt(stmt::T_RELEASE_SAVEPOINT) | ||||
|   {} | ||||
|   virtual ~ObReleaseSavePointStmt() | ||||
|   {} | ||||
|  | ||||
|   private: | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObReleaseSavePointStmt); | ||||
| }; | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
|  | ||||
| #endif  // OCEANBASE_SQL_RESOLVER_TCL_OB_SAVEPOINT_STMT_ | ||||
							
								
								
									
										72
									
								
								src/sql/resolver/tcl/ob_start_trans_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								src/sql/resolver/tcl/ob_start_trans_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,72 @@ | ||||
| /** | ||||
|  * 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_RESV | ||||
|  | ||||
| #include "ob_start_trans_resolver.h" | ||||
| #include "sql/session/ob_sql_session_info.h" | ||||
| #include "sql/ob_trans_character.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| using namespace common; | ||||
| using namespace share; | ||||
| namespace sql { | ||||
|  | ||||
| ObStartTransResolver::ObStartTransResolver(ObResolverParams& params) : ObTCLResolver(params) | ||||
| {} | ||||
|  | ||||
| ObStartTransResolver::~ObStartTransResolver() | ||||
| {} | ||||
|  | ||||
| int ObStartTransResolver::resolve(const ParseNode& parse_node) | ||||
| { | ||||
|   int ret = OB_SUCCESS; | ||||
|   ObStartTransStmt* start_stmt = NULL; | ||||
|   if (OB_UNLIKELY(T_BEGIN != parse_node.type_ || 1 != parse_node.num_child_)) { | ||||
|     ret = OB_ERR_UNEXPECTED; | ||||
|     LOG_ERROR("unexpected val", K(parse_node.type_), K(parse_node.num_child_), K(ret)); | ||||
|   } else if (OB_UNLIKELY(NULL == (start_stmt = create_stmt<ObStartTransStmt>()))) { | ||||
|     ret = OB_SQL_RESOLVER_NO_MEMORY; | ||||
|     LOG_WARN("failed to create select stmt", K(ret)); | ||||
|   } else { | ||||
|     stmt_ = start_stmt; | ||||
|     const uint64_t tenant_id = session_info_->get_effective_tenant_id(); | ||||
|     const share::schema::ObSysVariableSchema* sys_variable = NULL; | ||||
|     if (OB_FAIL(schema_checker_->get_sys_variable_schema(tenant_id, sys_variable))) { | ||||
|       LOG_WARN("fail to get sys variable schema", K(tenant_id), K(ret)); | ||||
|     } else if (OB_ISNULL(sys_variable)) { | ||||
|       ret = OB_ERR_UNEXPECTED; | ||||
|       LOG_WARN("sys variable should not be null", K(tenant_id), K(ret)); | ||||
|     } else if (OB_UNLIKELY(!session_info_->has_user_super_privilege() && sys_variable->is_read_only() && | ||||
|                            IS_READ_WRITE(parse_node.children_[0]->value_))) { | ||||
|       ret = OB_ERR_OPTION_PREVENTS_STATEMENT; | ||||
|  | ||||
|       LOG_WARN("the server is running with read_only, cannot execute stmt"); | ||||
|     } else { | ||||
|       bool tx_read_only = params_.session_info_->get_tx_read_only(); | ||||
|       if (IS_READ_ONLY(parse_node.children_[0]->value_)) { | ||||
|         start_stmt->set_read_only(true); | ||||
|       } else if (IS_READ_WRITE(parse_node.children_[0]->value_)) { | ||||
|         start_stmt->set_read_only(false); | ||||
|       } else { | ||||
|         start_stmt->set_read_only(tx_read_only); | ||||
|       } | ||||
|       if (IS_WITH_SNAPSHOT(parse_node.children_[0]->value_)) { | ||||
|         start_stmt->set_with_consistent_snapshot(true); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   return ret; | ||||
| } | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
							
								
								
									
										37
									
								
								src/sql/resolver/tcl/ob_start_trans_resolver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/sql/resolver/tcl/ob_start_trans_resolver.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef OCEANBASE_RESOLVER_TCL_START_TRANS_RESOLVER_ | ||||
| #define OCEANBASE_RESOLVER_TCL_START_TRANS_RESOLVER_ | ||||
|  | ||||
| #include "sql/resolver/ob_stmt_resolver.h" | ||||
| #include "sql/resolver/tcl/ob_tcl_resolver.h" | ||||
| #include "sql/resolver/tcl/ob_start_trans_stmt.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| class ObStartTransResolver : public ObTCLResolver { | ||||
|   public: | ||||
|   explicit ObStartTransResolver(ObResolverParams& params); | ||||
|   virtual ~ObStartTransResolver(); | ||||
|  | ||||
|   virtual int resolve(const ParseNode& parse_node); | ||||
|  | ||||
|   private: | ||||
|   /* functions */ | ||||
|   /* variables */ | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObStartTransResolver); | ||||
| }; | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
| #endif /* OCEANBASE_RESOLVER_TCL_START_TRANS_RESOLVER_ */ | ||||
| //// end of header file | ||||
							
								
								
									
										79
									
								
								src/sql/resolver/tcl/ob_start_trans_stmt.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										79
									
								
								src/sql/resolver/tcl/ob_start_trans_stmt.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,79 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef _OB_START_TRANS_STMT_H | ||||
| #define _OB_START_TRANS_STMT_H | ||||
| #include "sql/resolver/tcl/ob_tcl_stmt.h" | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| class ObStartTransStmt : public ObTCLStmt { | ||||
|   public: | ||||
|   ObStartTransStmt(); | ||||
|   virtual ~ObStartTransStmt(); | ||||
|   virtual void print(FILE* fp, int32_t level, int32_t index); | ||||
|   void set_read_only(bool val); | ||||
|   bool get_read_only() const; | ||||
|   void set_with_consistent_snapshot(bool val); | ||||
|   bool get_with_consistent_snapshot() const; | ||||
|   virtual bool cause_implicit_commit() const | ||||
|   { | ||||
|     return true; | ||||
|   } | ||||
|   TO_STRING_KV(N_STMT_TYPE, ((int)stmt_type_), K_(read_only), K_(with_consistent_snapshot)); | ||||
|  | ||||
|   private: | ||||
|   // types and constants | ||||
|   private: | ||||
|   // disallow copy | ||||
|   ObStartTransStmt(const ObStartTransStmt& other); | ||||
|   ObStartTransStmt& operator=(const ObStartTransStmt& other); | ||||
|   // function members | ||||
|   private: | ||||
|   // data members | ||||
|   bool with_consistent_snapshot_; | ||||
|   bool read_only_; | ||||
| }; | ||||
|  | ||||
| inline ObStartTransStmt::ObStartTransStmt() | ||||
|     : ObTCLStmt(stmt::T_START_TRANS), with_consistent_snapshot_(false), read_only_(false) | ||||
| {} | ||||
| inline ObStartTransStmt::~ObStartTransStmt() | ||||
| {} | ||||
| inline void ObStartTransStmt::set_read_only(bool val) | ||||
| { | ||||
|   read_only_ = val; | ||||
| } | ||||
| inline bool ObStartTransStmt::get_read_only() const | ||||
| { | ||||
|   return read_only_; | ||||
| } | ||||
| inline void ObStartTransStmt::set_with_consistent_snapshot(bool val) | ||||
| { | ||||
|   with_consistent_snapshot_ = val; | ||||
| } | ||||
| inline bool ObStartTransStmt::get_with_consistent_snapshot() const | ||||
| { | ||||
|   return with_consistent_snapshot_; | ||||
| } | ||||
| inline void ObStartTransStmt::print(FILE* fp, int32_t level, int32_t index) | ||||
| { | ||||
|   print_indentation(fp, level); | ||||
|   fprintf(fp, "<ObStartTransStmt id=%d>\n", index); | ||||
|   print_indentation(fp, level + 1); | ||||
|   fprintf(fp, "WithConsistentSnapshot := %c\n", with_consistent_snapshot_ ? 'Y' : 'N'); | ||||
|   print_indentation(fp, level); | ||||
|   fprintf(fp, "</ObStartTransStmt>\n"); | ||||
| } | ||||
| }  // end namespace sql | ||||
| }  // end namespace oceanbase | ||||
|  | ||||
| #endif  // _OB_START_TRANS_STMT_H | ||||
							
								
								
									
										46
									
								
								src/sql/resolver/tcl/ob_tcl_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								src/sql/resolver/tcl/ob_tcl_resolver.cpp
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| /** | ||||
|  * 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/resolver/tcl/ob_tcl_resolver.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| using namespace common; | ||||
| using namespace share::schema; | ||||
| namespace sql { | ||||
|  | ||||
| ObTCLResolver::ObTCLResolver(ObResolverParams& params) : ObStmtResolver(params) | ||||
| {} | ||||
|  | ||||
| ObTCLResolver::~ObTCLResolver() | ||||
| {} | ||||
|  | ||||
| int ObTCLResolver::resolve_special_expr(ObRawExpr*& expr, ObStmtScope scope) | ||||
| { | ||||
|   UNUSED(expr); | ||||
|   UNUSED(scope); | ||||
|   return OB_SUCCESS; | ||||
| } | ||||
| int ObTCLResolver::resolve_sub_query_info(const ObIArray<ObSubQueryInfo>& subquery_info, const ObStmtScope upper_scope) | ||||
| { | ||||
|   UNUSED(subquery_info); | ||||
|   UNUSED(upper_scope); | ||||
|   return OB_SUCCESS; | ||||
| } | ||||
| int ObTCLResolver::resolve_columns(ObRawExpr*& expr, ObArray<ObQualifiedName>& columns) | ||||
| { | ||||
|   UNUSED(expr); | ||||
|   UNUSED(columns); | ||||
|   return OB_SUCCESS; | ||||
| } | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
							
								
								
									
										40
									
								
								src/sql/resolver/tcl/ob_tcl_resolver.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/sql/resolver/tcl/ob_tcl_resolver.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef OCEANBASE_SQL_TCL_RESOLVER_ | ||||
| #define OCEANBASE_SQL_TCL_RESOLVER_ | ||||
|  | ||||
| #include "sql/resolver/ob_stmt_resolver.h" | ||||
|  | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
|  | ||||
| class ObTCLResolver : public ObStmtResolver { | ||||
|   public: | ||||
|   explicit ObTCLResolver(ObResolverParams& params); | ||||
|   virtual ~ObTCLResolver(); | ||||
|  | ||||
|   virtual int resolve_special_expr(ObRawExpr*& expr, ObStmtScope scope); | ||||
|   virtual int resolve_sub_query_info( | ||||
|       const common::ObIArray<ObSubQueryInfo>& subquery_info, const ObStmtScope upper_scope); | ||||
|   virtual int resolve_columns(ObRawExpr*& expr, common::ObArray<ObQualifiedName>& columns); | ||||
|  | ||||
|   private: | ||||
|   /* functions */ | ||||
|   /* variables */ | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObTCLResolver); | ||||
| }; | ||||
|  | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
| #endif /* OCEANBASE_SQL_TCL_RESOLVER_ */ | ||||
| //// end of header file | ||||
							
								
								
									
										38
									
								
								src/sql/resolver/tcl/ob_tcl_stmt.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/sql/resolver/tcl/ob_tcl_stmt.h
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| /** | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| #ifndef OCEANBASE_SRC_SQL_RESOLVER_TCL_OB_TCL_STMT_H_ | ||||
| #define OCEANBASE_SRC_SQL_RESOLVER_TCL_OB_TCL_STMT_H_ 1 | ||||
| #include "share/ob_rpc_struct.h" | ||||
| #include "sql/resolver/ob_stmt.h" | ||||
| #include "sql/resolver/ob_cmd.h" | ||||
| namespace oceanbase { | ||||
| namespace sql { | ||||
| class ObTCLStmt : public ObStmt, public ObICmd { | ||||
|   public: | ||||
|   ObTCLStmt(common::ObIAllocator* name_pool, stmt::StmtType type) : ObStmt(name_pool, type) | ||||
|   {} | ||||
|   explicit ObTCLStmt(stmt::StmtType type) : ObStmt(type) | ||||
|   {} | ||||
|   virtual ~ObTCLStmt() | ||||
|   {} | ||||
|   virtual int get_cmd_type() const | ||||
|   { | ||||
|     return get_stmt_type(); | ||||
|   } | ||||
|  | ||||
|   private: | ||||
|   DISALLOW_COPY_AND_ASSIGN(ObTCLStmt); | ||||
| }; | ||||
| }  // namespace sql | ||||
| }  // namespace oceanbase | ||||
| #endif /* OCEANBASE_SRC_SQL_RESOLVER_TCL_OB_TCL_STMT_H_ */ | ||||
		Reference in New Issue
	
	Block a user
	 oceanbase-admin
					oceanbase-admin