lua-resty-mysql
lua-resty-mysql copied to clipboard
The document of *query* is misleading
bytes, err = db:send_query(query)
res, err, errcode, sqlstate = db:read_result()
res, err, errcode, sqlstate = db:read_result(nrows)
res, err, errcode, sqlstate = db:query(query)
res, err, errcode, sqlstate = db:query(query, nrows)
db:query() may return 2 values, if we access the 3rd return value, we may get nil, but we expect errcode.
@FrancisHe The errcode is the error code returned by the MySQL server, so when there is a lower level failure on the wire (like timeout or connection aborts), then there surely is no error code returned. There's no guarantee that an error code is always returned upon any kind of failures.
@agentzh I mean that it's better to point that there query() may return only 2 values(not always 4) in the document. The document of read_result() is much better:
Note that, the errcode and sqlstate might be nil if MySQL does not return them.