Tiny Tweak: mysql_errno
While we were batting forth ideas about the SIGNAL statement (MySQL 7.0, we appreciate your patience), the question arose: what do we call the thingabummie number that MySQL uses for errors and warnings? You know, this thing …
mysql> crete table t;
ERROR 1064 (42000): You have an error in your SQL syntax; …
What do we call that ‘1064′? An old-timer might say SQLCODE but actually the SQL standard committee decided a decade ago to dump SQLCODE in favour of SQLSTATE, which is a string rather than a number. Besides, MySQL’s number doesn’t follow the old standard conventions for SQLCODE.
There were 7 choices for the term for the numeric return, that we’ll use eventually in SIGNAL / RESIGNAL / GET DIAGNOSTICS syntax and descriptions.
1. SQLCODE.
SQLCODE does not appear in the standard, but it is the DB2 term
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzala/rzalaco.htm
and DB2 specifically has DB2_RETURNED_SQLCODE in GET DIAGNOSTICS
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_signalstatement4externalsqlpl.htm
(DB2 also has “error code” but that’s for a different thing.)
Oracle uses SQLCODE (as well as SQLERRM) for its exception handlers
http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10807/13_elems049.htm
2. NativeError, “Native Error”, or NATIVE_ERROR.
The term NativeError is standard, but only for 9075-3 SQL/CLI.
It’s in SQLError() and SQLGetDiagRec().
It’s also called “ODBC Native Error”, and I suppose our connector people would recognize it.
3. “Error Message Number”.
I believe this term makes sense when there is a one-to-one relation for all messages and numbers, but with SIGNAL that won’t be the case.
4. “mysql_error_code”
This is a term that now appears in the manual page for DECLARE … CONDITION. That’s a change. When I wrote the original description I said “mysql-specific error code”.
5. “error_code” / “error code”
6. “errno”
7. “error_number” / “error number”
The MySQL Reference Manual varies. I found four different terms
(”error code”, “error number”, “error message number”, “mysql_errno”)
on the same manual page
http://dev.mysql.com/doc/refman/6.0/en/mysql-errno.html.
There’s no clear favourite.
Google search results within site:dev.mysql.com/doc: "error code" or "error codes" 1030 "mysql_errno" i.e. the API function name 817 "errno" 236 "error number" or "error numbers" 215 "mysql_error_code" 8 "error message number" or "error message numbers" 2 "nativeerror" or "native error" or "native errors" 1 "sqlcode" 0
Exactness is misleading, because terms are not always used in the sense that we’re discussing.
So we’re playing around with terminology voting now. The take-home for our end users should be: (a) gee, things must have reached an advanced stage if they’re putting in tacks rather than nails now, (b) it’s nice to know that all these things are the same.

Leave a Reply