|
26 | 26 | #include "sql/engine/expr/ob_expr_pl_integer_checker.h" |
27 | 27 | #include "sql/engine/expr/ob_expr_lob_utils.h" |
28 | 28 | #include "pl/ob_pl_package.h" |
| 29 | +#include "share/schema/ob_trigger_info.h" |
29 | 30 | #include "sql/engine/expr/ob_expr_obj_access.h" |
30 | 31 | #include "pl/ob_pl_exception_handling.h" |
31 | 32 | #include "sql/dblink/ob_tm_service.h" |
@@ -2081,7 +2082,16 @@ int ObSPIService::spi_parse_prepare(common::ObIAllocator &allocator, |
2081 | 2082 | } else if (OB_FAIL(ob_write_string(allocator, ObString(parse_result.no_param_sql_len_, parse_result.no_param_sql_), prepare_result.route_sql_))) { |
2082 | 2083 | LOG_WARN("failed to write string", K(sql), K(ret)); |
2083 | 2084 | } else { |
2084 | | - PLPrepareCtx pl_prepare_ctx(session, NULL, false, false, false); |
| 2085 | + // Pass secondary_namespace for trigger packages so that SQL in trigger body |
| 2086 | + // is fully resolved at compile time, catching references to dropped columns |
| 2087 | + // early instead of crashing at runtime. For non-trigger PL, keep using simple |
| 2088 | + // PS protocol (NULL) to allow deferred resolution of dynamic SQL constructs. |
| 2089 | + pl::ObPLBlockNS *ns_for_prepare = NULL; |
| 2090 | + if (OB_NOT_NULL(secondary_namespace) |
| 2091 | + && ObTriggerInfo::is_trigger_package_id(secondary_namespace->get_package_id())) { |
| 2092 | + ns_for_prepare = secondary_namespace; |
| 2093 | + } |
| 2094 | + PLPrepareCtx pl_prepare_ctx(session, ns_for_prepare, false, false, false); |
2085 | 2095 | SMART_VAR(PLPrepareResult, pl_prepare_result) { |
2086 | 2096 | CK (OB_NOT_NULL(GCTX.sql_engine_)); |
2087 | 2097 | OZ (pl_prepare_result.init(session)); |
|
0 commit comments