MySQL Forums
Forum List  »  Docs

GET DIAGNOSTICS CONDITION 1 returns erroneous info - Big Issue
Posted by: William Donaldson
Date: November 04, 2024 03:54AM

I've used Oracle databases since 1998 and recently started big project with MySQL database. When I began migrating database schemas and learning MySQL I was used:

DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1 e1 = MYSQL_ERRNO, e2 = MESSAGE_TEXT, e3 = RETURNED_SQLSTATE, e4 = SCHEMA_NAME, e5 = CATALOG_NAME;
SELECT e1, e2, e3, e4, e5;
END;

To understand issues I was having. Now much more advanced in MySQL knowledge I realize there is a "BIG ISSUE" with data returned. Verbiage is being added to the MESSAGE_TEXT variable when an error is unknown to MySQL.

I have a Stored Function which checks for conditions before running import process. I am pasting a snippet of One of the conditions:

IF importFileName IS NULL THEN
-- This is an error. Import File must be in table when import processing.
SET processFile = 0;
SIGNAL SQLSTATE
'45000'
SET
MESSAGE_TEXT = `Import File is not found in import_file table. An error has happened.`,
MYSQL_ERRNO = ER_SIGNAL_EXCEPTION;
This is simple and raises an error in the store procedure's - DECLARE EXIT HANDLER FOR SQLEXCEPTION

Here is the BIG ISSUE. Below is the error message returned from the code above.

'Unknown column ''Import File is not found in import_file table. An error has happened.'' in ''field list'''

No where in my code to I ever say 'Unknown column' or ' in 'field list''

MySQL inserted that verbiage into my error message. It does not matter what value I place in SQLSTATE or MYSQL_ERRNO before issuing SIGNAL. MySQL is still replacing MYSQL_ERRNO with 1054 and wraps MESSAGE_TEXT with verbiage 'Unknow column' and ' in 'field list'' on each side.

When I was learning MySQL that inserted message and FALSE MYSQL_ERRNO value had me spend HOURS and HOURS looking for a problem that did not exist. It almost had me talk the client out of using MySQL for the project.

I don't know who is responsible for this HUGE ISSUE but they should be FIRED!

Options: ReplyQuote


Subject
Views
Written By
Posted
GET DIAGNOSTICS CONDITION 1 returns erroneous info - Big Issue
93
November 04, 2024 03:54AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.