Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make some changes in the database schema:

1. Add columns for storing md5 checksum and machine architecture in
 the mandb table.
2. Update the DBSCHEMA file to reflect these changes and also remove
the UNIQUE constraint from the link column in mandb_links table,
which was wrong.
3. Add code in makemandb.c to store these two columns in mandb.
4. Give a weight of 0.0 to the md5_hash column in the ranking algorithm
as it should not affect the search results and weight of 1.0 to the
machine column.
Fixes #64
  • Loading branch information...
commit 2dd48dc2a7a442d31b0e68c324735446bab3a203 1 parent 526f96d
@abhinav-upadhyay authored
Showing with 32 additions and 8 deletions.
  1. +5 −2 DBSCHEMA
  2. +8 −5 apropos-utils.c
  3. +19 −1 makemandb.c
View
7 DBSCHEMA
@@ -15,9 +15,12 @@ There are three tables in the database at present:
6. return_vals RETURN VALUES section
7. env ENVIRONMENT section
8. files FILES section
- 9. exit_status EXIT STATUS section
+ 9. exit_status EXIT STATUS section
10. diagnostics DIAGNOSTICS section
11. errors ERRORS section
+ 12. md5_hash md5 hash of the man page
+ 13. machine The machine architecture (if any) for which this page is
+ relevant.
(2) mandb_meta:
This table contains md5 hashes of all the indexed man
@@ -42,7 +45,7 @@ There are three tables in the database at present:
from the multiple .Nm entries in the page.
Column Name Description
- 1. link The name of the hard/soft link (UNIQUE index)
+ 1. link The name of the hard/soft link (index)
2. target Name of the target page to which it points
3. section The section number
4. machine The machine architecture (if any) for which
View
13 apropos-utils.c
@@ -66,7 +66,9 @@ static const double col_weights[] = {
0.01, //FILES
0.001, //EXIT STATUS
2.00, //DIAGNOSTICS
- 0.05 //ERRORS
+ 0.05, //ERRORS
+ 0.00, //md5_hash
+ 1.00 //machine
};
/*
@@ -144,10 +146,11 @@ create_db(sqlite3 *db)
sqlstr = "CREATE VIRTUAL TABLE mandb USING fts4(section, name, "
"name_desc, desc, lib, return_vals, env, files, "
- "exit_status, diagnostics, errors, compress=zip, "
- "uncompress=unzip, tokenize=porter); " //mandb table
- "CREATE TABLE IF NOT EXISTS mandb_meta(device, inode, mtime, file UNIQUE, "
- "md5_hash UNIQUE, id INTEGER PRIMARY KEY); " //mandb_meta
+ "exit_status, diagnostics, errors, md5_hash, machine, "
+ "tokenize=porter); " //mandb
+ "CREATE TABLE IF NOT EXISTS mandb_meta(device, inode, mtime, "
+ "file UNIQUE, md5_hash UNIQUE, id INTEGER PRIMARY KEY); "
+ //mandb_meta
"CREATE TABLE IF NOT EXISTS mandb_links(link, target, section, "
"machine); "; //mandb_links
View
20 makemandb.c
@@ -1353,7 +1353,7 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
/*------------------------ Populate the mandb table---------------------------*/
sqlstr = "INSERT INTO mandb VALUES (:section, :name, :name_desc, :desc, "
":lib, :return_vals, :env, :files, :exit_status, "
- ":diagnostics, :errors)";
+ ":diagnostics, :errors, :md5_hash, :machine)";
rc = sqlite3_prepare_v2(db, sqlstr, -1, &stmt, NULL);
if (rc != SQLITE_OK) {
@@ -1460,6 +1460,24 @@ insert_into_db(sqlite3 *db, mandb_rec *rec)
cleanup(rec);
return -1;
}
+
+ idx = sqlite3_bind_parameter_index(stmt, ":md5_hash");
+ rc = sqlite3_bind_text(stmt, idx, rec->md5_hash, -1, NULL);
+ if (rc != SQLITE_OK) {
+ warnx("%s", sqlite3_errmsg(db));
+ sqlite3_finalize(stmt);
+ cleanup(rec);
+ return -1;
+ }
+
+ idx = sqlite3_bind_parameter_index(stmt, ":machine");
+ rc = sqlite3_bind_text(stmt, idx, rec->machine, -1, NULL);
+ if (rc != SQLITE_OK) {
+ warnx("%s", sqlite3_errmsg(db));
+ sqlite3_finalize(stmt);
+ cleanup(rec);
+ return -1;
+ }
rc = sqlite3_step(stmt);
if (rc != SQLITE_DONE) {
Please sign in to comment.
Something went wrong with that request. Please try again.