MySQL

The world's most popular open source database

Contact a MySQL Representative


  • MySQL.com
  • Developer Zone
  • Partners & Solutions
  • Customer Login
  • DevZone
  • Downloads
  • Documentation
  • Articles
  • Forums
  • Bugs
  • Forge
  • Blogs
 
  • Pages

    • About
    • Find and store the error return value in procedures or functions
  • Archives

    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
  • Categories

    • MySQL 5.1 Features (3)
    • MySQL 5.4 New Features (2)
    • MySQL 6.0 New Features (5)
    • MySQL 6.x New Features (5)
    • News (8)
    • Personal Opinion (4)
    • Tiny Tweaks (10)
    • Uncategorized (19)



New Features In MySQL 6.x

« Tiny Tweak: SELECT with some sort of delay
Personal Opinion: Half-baked = false analogy »

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.

This entry was posted on Monday, May 19th, 2008 at 12:53 am and is filed under Tiny Tweaks. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

New Features In MySQL 6.x is proudly powered by WordPress MU running on Blogs.mysql.com.
Entries (RSS) and Comments (RSS).