summaryrefslogtreecommitdiff
path: root/src/sqlite.c
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-10-09 16:17:22 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-10-09 16:17:22 +0200
commitb5dc0513d53cf0e520c8e9c4ca197cb7ccdf2b23 (patch)
treea3e6212633cf1a2c1c4510a20e8b71b0fdaa3985 /src/sqlite.c
parent0ce91ed8b478364a69502751d86bf5c5568a429c (diff)
downloademacs-b5dc0513d53cf0e520c8e9c4ca197cb7ccdf2b23.tar.gz
Make Fsqlite_select error data better
* src/sqlite.c (Fsqlite_select): Add more the more specific error text to the error data (bug#58363).
Diffstat (limited to 'src/sqlite.c')
-rw-r--r--src/sqlite.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/sqlite.c b/src/sqlite.c
index a46acf8523a..ababa73b99f 100644
--- a/src/sqlite.c
+++ b/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;
}