[CP] to issue<53546058>:trigger always forbid pdml
This commit is contained in:
		| @ -243,6 +243,22 @@ class ObSPIService | |||||||
| public: | public: | ||||||
|   struct ObSPIPrepareResult |   struct ObSPIPrepareResult | ||||||
|   { |   { | ||||||
|  |     ObSPIPrepareResult() : | ||||||
|  |     type_(stmt::T_NONE), | ||||||
|  |     for_update_(false), | ||||||
|  |     has_hidden_rowid_(false), | ||||||
|  |     exec_params_(), | ||||||
|  |     into_exprs_(), | ||||||
|  |     ref_objects_(), | ||||||
|  |     route_sql_(), | ||||||
|  |     record_type_(nullptr), | ||||||
|  |     tg_timing_event_(), | ||||||
|  |     rowid_table_id_(OB_INVALID_ID), | ||||||
|  |     ps_sql_(), | ||||||
|  |     is_bulk_(false), | ||||||
|  |     has_dup_column_name_(false), | ||||||
|  |     has_link_table_(false) | ||||||
|  |     {} | ||||||
|     stmt::StmtType type_; //prepare的语句类型 |     stmt::StmtType type_; //prepare的语句类型 | ||||||
|     bool for_update_; |     bool for_update_; | ||||||
|     bool has_hidden_rowid_; |     bool has_hidden_rowid_; | ||||||
|  | |||||||
| @ -426,7 +426,7 @@ int ObOptimizer::check_pdml_supported_feature(const ObDelUpdStmt &pdml_stmt, | |||||||
|     ctx_.add_plan_note(PDML_DISABLED_BY_INSERT_UP); |     ctx_.add_plan_note(PDML_DISABLED_BY_INSERT_UP); | ||||||
|   } else if (ctx_.has_dblink()) { |   } else if (ctx_.has_dblink()) { | ||||||
|     is_use_pdml = false; |     is_use_pdml = false; | ||||||
|   } else if (!ctx_.has_trigger() && ctx_.contain_user_nested_sql()) { |   } else if (ctx_.contain_user_nested_sql()) { | ||||||
|     //user nested sql can't use PDML plan, force to use DAS plan |     //user nested sql can't use PDML plan, force to use DAS plan | ||||||
|     //if online ddl has pl udf, only this way, allow it use PDML plan |     //if online ddl has pl udf, only this way, allow it use PDML plan | ||||||
|     //such as: |     //such as: | ||||||
| @ -435,11 +435,6 @@ int ObOptimizer::check_pdml_supported_feature(const ObDelUpdStmt &pdml_stmt, | |||||||
|     //create index with PL UDF allow to use PDML plan during build index table |     //create index with PL UDF allow to use PDML plan during build index table | ||||||
|     is_use_pdml = false; |     is_use_pdml = false; | ||||||
|     ctx_.add_plan_note(PDML_DISABLED_BY_NESTED_SQL); |     ctx_.add_plan_note(PDML_DISABLED_BY_NESTED_SQL); | ||||||
|   } else if (!ctx_.is_online_ddl() && ctx_.has_trigger() && !ctx_.is_allow_parallel_trigger()) { |  | ||||||
|     // if sql linked trigger, and trigger do not access package var, sequence, sql stmt etc.., |  | ||||||
|     // allow it use PDML plan |  | ||||||
|     is_use_pdml = false; |  | ||||||
|     ctx_.add_plan_note(PDML_DISABLED_BY_NESTED_SQL); |  | ||||||
|   } else if (stmt::T_DELETE == pdml_stmt.get_stmt_type()) { |   } else if (stmt::T_DELETE == pdml_stmt.get_stmt_type()) { | ||||||
|     // |     // | ||||||
|     // if no trigger, no foreign key, delete can do pdml, even if with local unique index |     // if no trigger, no foreign key, delete can do pdml, even if with local unique index | ||||||
| @ -745,7 +740,6 @@ int ObOptimizer::check_whether_contain_nested_sql(const ObDMLStmt &stmt) | |||||||
|       const ObTableSchema *table_schema = nullptr; |       const ObTableSchema *table_schema = nullptr; | ||||||
|       ObSQLSessionInfo *session = ctx_.get_session_info(); |       ObSQLSessionInfo *session = ctx_.get_session_info(); | ||||||
|       bool trigger_exists = false; |       bool trigger_exists = false; | ||||||
|       bool is_forbid_parallel = false; |  | ||||||
|       if (OB_ISNULL(table_info) || OB_ISNULL(schema_guard) || OB_ISNULL(session)) { |       if (OB_ISNULL(table_info) || OB_ISNULL(schema_guard) || OB_ISNULL(session)) { | ||||||
|         ret = OB_ERR_UNEXPECTED; |         ret = OB_ERR_UNEXPECTED; | ||||||
|         LOG_WARN("sql schema guard is nullptr", K(ret), K(table_info), K(schema_guard), K(session)); |         LOG_WARN("sql schema guard is nullptr", K(ret), K(table_info), K(schema_guard), K(session)); | ||||||
| @ -764,13 +758,6 @@ int ObOptimizer::check_whether_contain_nested_sql(const ObDMLStmt &stmt) | |||||||
|           ctx_.set_has_trigger(true); |           ctx_.set_has_trigger(true); | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|       if (OB_SUCC(ret) && trigger_exists) { |  | ||||||
|         if (OB_FAIL(table_schema->is_allow_parallel_of_trigger(*schema_guard, is_forbid_parallel))) { |  | ||||||
|           LOG_WARN("check allow parallel failed", K(ret)); |  | ||||||
|         } else if (!is_forbid_parallel) { |  | ||||||
|           ctx_.set_allow_parallel_trigger(true); |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   return ret; |   return ret; | ||||||
|  | |||||||
| @ -573,8 +573,6 @@ ObOptimizerContext(ObSQLSessionInfo *session_info, | |||||||
|   bool has_trigger() const { return has_trigger_; } |   bool has_trigger() const { return has_trigger_; } | ||||||
|   void set_has_pl_udf(bool v) { has_pl_udf_ = v; } |   void set_has_pl_udf(bool v) { has_pl_udf_ = v; } | ||||||
|   bool has_pl_udf() const { return has_pl_udf_; } |   bool has_pl_udf() const { return has_pl_udf_; } | ||||||
|   void set_allow_parallel_trigger(bool v) { is_allow_parallel_trigger_ = v; } |  | ||||||
|   bool is_allow_parallel_trigger() const { return is_allow_parallel_trigger_; } |  | ||||||
|   void set_has_cursor_expression(bool v) { has_cursor_expression_ = v; } |   void set_has_cursor_expression(bool v) { has_cursor_expression_ = v; } | ||||||
|   bool has_cursor_expression() const { return has_cursor_expression_; } |   bool has_cursor_expression() const { return has_cursor_expression_; } | ||||||
|   void set_has_dblink(bool v) { has_dblink_ = v; } |   void set_has_dblink(bool v) { has_dblink_ = v; } | ||||||
| @ -671,7 +669,6 @@ private: | |||||||
|       int8_t has_pl_udf_                       : 1; //this sql has pl user defined function |       int8_t has_pl_udf_                       : 1; //this sql has pl user defined function | ||||||
|       int8_t has_subquery_in_function_table_   : 1; //this stmt has function table |       int8_t has_subquery_in_function_table_   : 1; //this stmt has function table | ||||||
|       int8_t has_dblink_                       : 1; //this stmt has dblink table |       int8_t has_dblink_                       : 1; //this stmt has dblink table | ||||||
|       int8_t is_allow_parallel_trigger_        : 1; //this sql linked trigger can parallel execute |  | ||||||
|       int8_t has_cursor_expression_            : 1; //this sql has cursor expression |       int8_t has_cursor_expression_            : 1; //this sql has cursor expression | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
|  | |||||||
| @ -6909,7 +6909,8 @@ int ObResolverUtils::set_parallel_info(sql::ObSQLSessionInfo &session_info, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (OB_SUCC(ret) && OB_NOT_NULL(routine_info)) { |     if (OB_SUCC(ret) && OB_NOT_NULL(routine_info)) { | ||||||
|       if (routine_info->is_modifies_sql_data() || |       if (!routine_info->is_valid() || | ||||||
|  |           routine_info->is_modifies_sql_data() || | ||||||
|           routine_info->is_wps() || |           routine_info->is_wps() || | ||||||
|           routine_info->is_rps() || |           routine_info->is_rps() || | ||||||
|           routine_info->is_has_sequence() || |           routine_info->is_has_sequence() || | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 obdev
					obdev