| tenant-type | | slug | error-sql-option-obclient |
When executing scripts batches of statements via OBClient (for example, using the -e option, input redirection, or executing multiple statements with source), it can sometimes be difficult to immediately identify which specific SQL statements caused the failure based solely on the error messages returned by the database. The --error-sql option appends the SQL text surrounding the fault point to the error output, making it easier to troubleshoot by comparing it with the script.
This parameter is supported for both MySQL-compatible mode and Oracle-compatible mode tenants in OceanBase Database.
Parameter description
Syntax |
Description |
|---|---|
--error-sql=xxx |
Enable context output. It is conventionally represented asxxxAs a placeholder literal, it indicates "Enable this capability". After enabling, the first 5 lines of the relevant SQL will be displayed by default near the error message (consistent with common release notes; if different from your on-site version, the actual client shall prevail). |
--error-sql=top0 |
When enabled, it tries to output the most complete relevant SQL statements possible before the error occurs. |
--error-sql=topN |
When enabled, the system outputs the N most recent SQL statements before the error occurred. (NA positive integer, for example,top3(That is, the first three rows). |
Usage example
Replace the address, port, username, and database name in the connection string with your environment's values:
obclient -h127.0.0.1 -P2881 -uroot@mysql -Dtest --error-sql=xxx
obclient -h127.0.0.1 -P2881 -uroot@mysql -Dtest --error-sql=top0
obclient -h127.0.0.1 -P2881 -uroot@mysql -Dtest --error-sql=top3
Note
Whether "lines" in the output correspond to physical lines of the script or are split by statements depends on the client implementation and version. After upgrading OBClient, we recommend testing your script in a pre-release environment with the same script as used online to confirm whether the rollback granularity still meets your troubleshooting habits.
