Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb Add the result from sqlite3_errmsg() to s...



details:   https://anonhg.NetBSD.org/src/rev/a205e6adf90d
branches:  trunk
changeset: 778651:a205e6adf90d
user:      apb <apb%NetBSD.org@localhost>
date:      Sat Apr 07 10:44:58 2012 +0000

description:
Add the result from sqlite3_errmsg() to some error messages.
Now we can get "apropos: Unable to query schema version: database is locked"
instead of just "apropos: Unable to query schema version".

diffstat:

 usr.sbin/makemandb/apropos-utils.c |  20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diffs (67 lines):

diff -r c9c9348bebde -r a205e6adf90d usr.sbin/makemandb/apropos-utils.c
--- a/usr.sbin/makemandb/apropos-utils.c        Sat Apr 07 10:43:38 2012 +0000
+++ b/usr.sbin/makemandb/apropos-utils.c        Sat Apr 07 10:44:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos-utils.c,v 1.2 2012/02/07 19:17:16 joerg Exp $  */
+/*     $NetBSD: apropos-utils.c,v 1.3 2012/04/07 10:44:58 apb Exp $    */
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay%gmail.com@localhost>
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos-utils.c,v 1.2 2012/02/07 19:17:16 joerg Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.3 2012/04/07 10:44:58 apb Exp $");
 
 #include <sys/stat.h>
 
@@ -312,12 +312,14 @@
 
        rc = sqlite3_prepare_v2(db, "PRAGMA user_version", -1, &stmt, NULL);
        if (rc != SQLITE_OK) {
-               warnx("Unable to query schema version");
+               warnx("Unable to query schema version: %s",
+                   sqlite3_errmsg(db));
                goto error;
        }
        if (sqlite3_step(stmt) != SQLITE_ROW) {
                sqlite3_finalize(stmt);
-               warnx("Unable to query schema version");
+               warnx("Unable to query schema version: %s",
+                   sqlite3_errmsg(db));
                goto error;
        }
        if (sqlite3_column_int(stmt, 0) != APROPOS_SCHEMA_VERSION) {
@@ -333,14 +335,16 @@
        /* Register the zip and unzip functions for FTS compression */
        rc = sqlite3_create_function(db, "zip", 1, SQLITE_ANY, NULL, zip, NULL, NULL);
        if (rc != SQLITE_OK) {
-               warnx("Unable to register function: compress");
+               warnx("Unable to register function: compress: %s",
+                   sqlite3_errmsg(db));
                goto error;
        }
 
        rc = sqlite3_create_function(db, "unzip", 1, SQLITE_ANY, NULL, 
                                  unzip, NULL, NULL);
        if (rc != SQLITE_OK) {
-               warnx("Unable to register function: uncompress");
+               warnx("Unable to register function: uncompress: %s",
+                   sqlite3_errmsg(db));
                goto error;
        }
        return db;
@@ -457,9 +461,11 @@
        rc = sqlite3_create_function(db, "rank_func", 1, SQLITE_ANY, (void *)&idf, 
                                     rank_func, NULL, NULL);
        if (rc != SQLITE_OK) {
+               warnx("Unable to register the ranking function: %s",
+                   sqlite3_errmsg(db));
                sqlite3_close(db);
                sqlite3_shutdown();
-               errx(EXIT_FAILURE, "Unable to register the ranking function");
+               exit(EXIT_FAILURE);
        }
        
        /* We want to build a query of the form: "select x,y,z from mandb where



Home | Main Index | Thread Index | Old Index