fix(seekdb): DIMA-2026051300116077401#896
Open
ep-12221 wants to merge 1 commit into
Open
Conversation
…st of deferred errors during PL parsing, when a non-existent object is referenced in a trigger/SP body, the formatted user message (e.g., "Unknown table 't.notable'") originally written to the thread-local warning buffer by `ob_select_resolver.cpp` via `LOG_USER_ERROR(OB_ERR_BAD_TABLE, table_name.length, table_name.ptr)` was being discarded at the end of parsing. At runtime, the PL_SIGNAL stub would only regenerate the bare template "Unknown table", losing the object name. Fix: 1. In `ObPLResolver::resolve`, when entering the deferred-error branch, capture the formatted message from the warning buffer that matches the current errno and store it in the new `ObPLSignalStmt::user_msg_` (held by the PL function allocator). 2. In `ObPLCodeGenerateVisitor::visit(ObPLSignalStmt)`, before generating the exception, for signals that have a `user_msg_`, generate a call to the new SPI `spi_pl_set_user_error_msg` to write the message back to the warning buffer. The error code uses `ob_error_code_` (the internal OB errno) so that the comparison `wb->get_err_code == err` at `ObMPPacketSender::send_error_packet` succeeds and reads this formatted message. 3. Add the implementation for `spi_pl_set_user_error_msg` in `ob_spi.cpp` / `ob_spi.h` and register the LLVM symbol in `ObPL::init`. Scope of impact: Only affects scenarios under the deferred-error branch (OB_ERR_FUNCTION_UNKNOWN / OB_ERR_SP_WRONG_ARG_NUM / OB_ERR_SP_DOES_NOT_EXIST / OB_ERR_GET_STACKED_DIAGNOSTICS / OB_ERR_RESIGNAL_WITHOUT_ACTIVE_HANDLER / OB_ERR_BAD_TABLE) where there is a user message in the warning buffer during the parsing phase. When `user_msg_` is empty, all paths remain consistent with the pre-change behavior. The regular user SIGNAL/RESIGNAL path is unchanged. DIMA: 2026051300116077401 Co-Authored-By: Claude Opus 4 <[REDACTED_EMAIL]>
Contributor
Author
|
The mapping Dima issue is: [macOS] [introduced after 20260331] [mysqltest] Trigger referencing non-existent table 't.notable' reports an error inconsistent with Linux seekdb. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task Description
Fix an issue where the detailed error message (including the object name) is lost when a DML statement referencing a non-existent object (e.g.,
SELECT t.notable.*) is executed inside a trigger or stored procedure body, resulting in a generic "Unknown table" error.Solution Description
Root Cause: The regression was introduced by commit
676b4e2dc86(2026-05-06), which addedOB_ERR_BAD_TABLEto the deferred-error list inObPLResolver::resolve. In the deferred-error branch, the failed statement is replaced with aPL_SIGNALstub, which only saves theerror_code_,ob_error_code_, andsql_state_, but does not save the formatted user message already present in the thread-localObWarningBuffer. Consequently, at runtime, only the generic template fromob_errpkt_strerror("Unknown table") is used, losing the specific object name.Fix Details:
src/pl/ob_pl_resolver.cpp: When entering the deferred-error branch, before destroying the failed statement, ifwb->get_err_code == save_ret, copywb->get_err_msginto the PL parsing allocator and store it in a newObPLSignalStmt::user_msg_field.src/pl/ob_pl_stmt.h: Added acommon::ObString user_msg_field and correspondingget_user_msg/set_user_msg/has_user_msgmethods to theObPLSignalStmtclass.src/sql/ob_spi.{h,cpp}: AddedObSPIService::spi_pl_set_user_error_msg(ctx, err_code, sql_state, msg, msg_len)to write the message (truncated toObWarningBuffer::WarningItem::STR_LEN) back to the current thread-local warning buffer.src/pl/ob_pl_code_generator.{h,cpp}: Registered the LLVM function ininit_spi_service. Invisit(ObPLSignalStmt), for signals wherehas_user_msgis true, generate a call to the new SPI function beforegenerate_exception. Theerr_codeparameter usess.get_ob_error_code(the OB internal errno, e.g., -5201) to align with the check insend_error_packet.src/pl/ob_pl.cpp: Registered the symbolspi_pl_set_user_error_msgviaWRAP_SPI_CALLfor LLVM JIT linking.Behavior Comparison (macOS, mysql-mode):
ERROR 42S02: Unknown tableERROR 42S02: Unknown table 't.notable'(Matches Linux behavior and the expected result intools/deploy/mysql_test/test_suite/ddl/r/mysql/drop.result:104)Scope of Impact:
OB_ERR_FUNCTION_UNKNOWN,OB_ERR_SP_WRONG_ARG_NUM,OB_ERR_SP_DOES_NOT_EXIST,OB_ERR_GET_STACKED_DIAGNOSTICS,OB_ERR_RESIGNAL_WITHOUT_ACTIVE_HANDLER,OB_ERR_BAD_TABLE) when a matching user message exists in the warning buffer.user_msg_is empty, all code paths behave identically to before the fix.SIGNAL/RESIGNALpaths (with explicitMESSAGE_TEXT) are unaffected.Passed Regressions
Local Validation Environment: macOS arm64,
build_release/src/observer/seekdb, port 12881.ddl.drop:mysql8_t_1/signal.testandmysql8_t_1/signal_demo1.testbefore and after the patch showed diffs only in timestamps, confirming existing failures are unrelated and no new mismatches were introduced.mysql8_t_1/signal_code.test: exit=0 (ok).DEBUG: captured saved_user_msg for deferred SIGNAL(save_ret=-5201, saved_user_msg=Unknown table 't.notable')– Confirmed successful capture from warning buffer.DEBUG: spi_pl_set_user_error_msg called(err_code=-5201, msg_len=25, ObString(msg_len, msg)=Unknown table 't.notable')– Confirmed LLVM JIT call to SPI with OB internal errno parameter.Commit:
e4be58867b8pushed toissue/2026051300116077401, awaiting orchestrator execution ofob flow checkin / merge-review / core-test.Upgrade Compatibility
Other Information
DIMA: 2026051300116077401
Release Note
Fixed an issue where executing a DML statement referencing a non-existent object inside a trigger or stored procedure body resulted in a generic error message (e.g., "Unknown table") instead of the specific message containing the object name (e.g., "Unknown table 't.notable'").