forked from Github/emacs
Make Fsqlite_select error data better
* src/sqlite.c (Fsqlite_select): Add more the more specific error text to the error data (bug#58363).
This commit is contained in:
parent
0ce91ed8b4
commit
b5dc0513d5
1 changed files with 11 additions and 7 deletions
18
src/sqlite.c
18
src/sqlite.c
|
|
@ -521,9 +521,8 @@ which means that we return a set object that can be queried with
|
|||
xsignal1 (Qerror, build_string ("VALUES must be a list or a vector"));
|
||||
|
||||
sqlite3 *sdb = XSQLITE (db)->db;
|
||||
Lisp_Object retval = Qnil;
|
||||
const char *errmsg = NULL;
|
||||
Lisp_Object encoded = encode_string (query);
|
||||
Lisp_Object retval = Qnil, errmsg = Qnil,
|
||||
encoded = encode_string (query);
|
||||
|
||||
sqlite3_stmt *stmt = NULL;
|
||||
int ret = sqlite3_prepare_v2 (sdb, SSDATA (encoded), SBYTES (encoded),
|
||||
|
|
@ -532,7 +531,12 @@ which means that we return a set object that can be queried with
|
|||
{
|
||||
if (stmt)
|
||||
sqlite3_finalize (stmt);
|
||||
errmsg = sqlite3_errstr (ret);
|
||||
errmsg = build_string (sqlite3_errstr (ret));
|
||||
/* More details about what went wrong. */
|
||||
const char *sql_error = sqlite3_errmsg (sdb);
|
||||
if (sql_error)
|
||||
errmsg = CALLN (Fformat, build_string ("%s (%s)"),
|
||||
errmsg, build_string (sql_error));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +547,7 @@ which means that we return a set object that can be queried with
|
|||
if (err != NULL)
|
||||
{
|
||||
sqlite3_finalize (stmt);
|
||||
errmsg = err;
|
||||
errmsg = build_string (err);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
|
@ -567,8 +571,8 @@ which means that we return a set object that can be queried with
|
|||
sqlite3_finalize (stmt);
|
||||
|
||||
exit:
|
||||
if (errmsg != NULL)
|
||||
xsignal1 (Qerror, build_string (errmsg));
|
||||
if (! NILP (errmsg))
|
||||
xsignal1 (Qerror, errmsg);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue