[to #46691522]fix bug verify trigger update columns
This commit is contained in:
		| @ -1802,7 +1802,11 @@ int ObDmlCgService::need_fire_update_event(const ObTableSchema &table_schema, | |||||||
|       OV (column_node->str_value_ != NULL && column_node->str_len_ > 0); |       OV (column_node->str_value_ != NULL && column_node->str_len_ > 0); | ||||||
|       OX (column_name.assign_ptr(column_node->str_value_, static_cast<int32_t>(column_node->str_len_))); |       OX (column_name.assign_ptr(column_node->str_value_, static_cast<int32_t>(column_node->str_len_))); | ||||||
|       OX (column_schema = table_schema.get_column_schema(column_name)); |       OX (column_schema = table_schema.get_column_schema(column_name)); | ||||||
|       OV (column_schema != NULL); |       if (OB_SUCC(ret) && OB_ISNULL(column_schema)) { | ||||||
|  |         ret = OB_ERR_KEY_COLUMN_DOES_NOT_EXITS; | ||||||
|  |         LOG_WARN("column not exist", K(ret), K(i), K(column_name)); | ||||||
|  |         LOG_USER_ERROR(OB_ERR_KEY_COLUMN_DOES_NOT_EXITS, column_name.length(), column_name.ptr()); | ||||||
|  |       } | ||||||
|       for (int64_t j = 0; OB_SUCC(ret) && j < base_column_ids.count(); j++) { |       for (int64_t j = 0; OB_SUCC(ret) && j < base_column_ids.count(); j++) { | ||||||
|         if (column_schema->get_column_id() == base_column_ids.at(j)) { |         if (column_schema->get_column_id() == base_column_ids.at(j)) { | ||||||
|           OX (need_fire = !assignments.at(j).is_implicit_); |           OX (need_fire = !assignments.at(j).is_implicit_); | ||||||
|  | |||||||
| @ -547,10 +547,10 @@ int ObTriggerResolver::resolve_dml_event_option(const ParseNode &parse_node, | |||||||
|       LOG_USER_ERROR(OB_NOT_SUPPORTED, "nested table cluase"); |       LOG_USER_ERROR(OB_NOT_SUPPORTED, "nested table cluase"); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   OZ (resolve_dml_event_list(*parse_node.children_[0], trigger_arg)); |  | ||||||
|   OZ (resolve_schema_name(*parse_node.children_[2], |   OZ (resolve_schema_name(*parse_node.children_[2], | ||||||
|                           trigger_arg.base_object_database_, trigger_arg.base_object_name_)); |                           trigger_arg.base_object_database_, trigger_arg.base_object_name_)); | ||||||
|   OZ (resolve_base_object(trigger_arg, NULL == parse_node.children_[2]->children_[0])); |   OZ (resolve_base_object(trigger_arg, NULL == parse_node.children_[2]->children_[0])); | ||||||
|  |   OZ (resolve_dml_event_list(*parse_node.children_[0], trigger_arg)); | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -686,6 +686,23 @@ int ObTriggerResolver::resolve_dml_event_list(const ParseNode &parse_node, | |||||||
|       LOG_WARN("parse_node type is invalid", K(ret), K(event_node->type_)); |       LOG_WARN("parse_node type is invalid", K(ret), K(event_node->type_)); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |   if (OB_SUCC(ret)) { | ||||||
|  |     const ObTableSchema *table_schema = NULL; | ||||||
|  |     ObSchemaGetterGuard *schema_guard = schema_checker_->get_schema_guard(); | ||||||
|  |     OZ (schema_guard->get_table_schema(trigger_arg.trigger_info_.get_tenant_id(), | ||||||
|  |                                        trigger_arg.base_object_database_, | ||||||
|  |                                        trigger_arg.base_object_name_, | ||||||
|  |                                       false/*is_index*/, table_schema)); | ||||||
|  |     CK (OB_NOT_NULL(table_schema)); | ||||||
|  |     for (int64_t i = 0; OB_SUCC(ret) && i < col_array.count(); i++) { | ||||||
|  |       const ObColumnSchemaV2 *col_schema = table_schema->get_column_schema(col_array.at(i)); | ||||||
|  |       if (OB_ISNULL(col_schema)) { | ||||||
|  |         ret = OB_ERR_KEY_COLUMN_DOES_NOT_EXITS; | ||||||
|  |         LOG_WARN("column not exist", K(ret), K(col_array.at(i))); | ||||||
|  |         LOG_USER_ERROR(OB_ERR_KEY_COLUMN_DOES_NOT_EXITS, col_array.at(i).length(), col_array.at(i).ptr()); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|   return ret; |   return ret; | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -1038,6 +1055,35 @@ int ObTriggerResolver::analyze_trigger(ObSchemaGetterGuard &schema_guard, | |||||||
|       ObString source; |       ObString source; | ||||||
|       ObPLCompiler compiler(allocator, *session_info, schema_guard, package_guard, *sql_proxy); |       ObPLCompiler compiler(allocator, *session_info, schema_guard, package_guard, *sql_proxy); | ||||||
|       const ObPackageInfo &package_spec_info = trigger_info.get_package_spec_info(); |       const ObPackageInfo &package_spec_info = trigger_info.get_package_spec_info(); | ||||||
|  |       if (!trigger_info.get_update_columns().empty()) { | ||||||
|  |         ObPLParser parser(allocator, session_info->get_local_collation_connection()); | ||||||
|  |         ObStmtNodeTree *column_list = NULL; | ||||||
|  |         ParseResult parse_result; | ||||||
|  |         OZ (parser.parse(trigger_info.get_update_columns(), trigger_info.get_update_columns(), parse_result, true)); | ||||||
|  |         CK (OB_NOT_NULL(parse_result.result_tree_) && 1 == parse_result.result_tree_->num_child_); | ||||||
|  |         CK (OB_NOT_NULL(column_list = parse_result.result_tree_->children_[0])); | ||||||
|  |         CK (column_list->type_ == T_TG_COLUMN_LIST); | ||||||
|  |         if (OB_SUCC(ret)) { | ||||||
|  |           const ObTableSchema *table_schema = NULL; | ||||||
|  |           OZ (schema_guard.get_table_schema(trigger_info.get_tenant_id(), | ||||||
|  |                                             trigger_info.get_base_object_id(), | ||||||
|  |                                             table_schema)); | ||||||
|  |           CK (OB_NOT_NULL(table_schema)); | ||||||
|  |           for (int64_t i = 0; OB_SUCC(ret) && i < column_list->num_child_; i++) { | ||||||
|  |             const ParseNode *column_node = column_list->children_[i]; | ||||||
|  |             const ObColumnSchemaV2 *column_schema = NULL; | ||||||
|  |             OV (column_node != NULL); | ||||||
|  |             OV (column_node->type_ == T_IDENT, OB_ERR_UNEXPECTED, column_node->type_); | ||||||
|  |             OV (column_node->str_value_ != NULL && column_node->str_len_ > 0); | ||||||
|  |             OX (column_schema = table_schema->get_column_schema(column_node->str_value_)); | ||||||
|  |             if (OB_SUCC(ret) && OB_ISNULL(column_schema)) { | ||||||
|  |               ret = OB_ERR_KEY_COLUMN_DOES_NOT_EXITS; | ||||||
|  |               LOG_WARN("column not exist", K(ret), K(trigger_info.get_update_columns()), K(i)); | ||||||
|  |               LOG_USER_ERROR(OB_ERR_KEY_COLUMN_DOES_NOT_EXITS, (int32_t)column_node->str_len_, column_node->str_value_); | ||||||
|  |             } | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } | ||||||
|       OZ (package_spec_ast.init(db_name, |       OZ (package_spec_ast.init(db_name, | ||||||
|                                 package_spec_info.get_package_name(), |                                 package_spec_info.get_package_name(), | ||||||
|                                 PL_PACKAGE_SPEC, |                                 PL_PACKAGE_SPEC, | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 seuwebber
					seuwebber