Module Name:    src
Committed By:   wiz
Date:           Mon May  7 11:18:16 UTC 2012

Modified Files:
        src/usr.sbin/makemandb: DBSCHEMA apropos-utils.c apropos-utils.h
            makemandb.c

Log Message:
PR 46419 by Abhinav Upadhyay using his updated patch:
Clean up after removing man page aliases.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makemandb/DBSCHEMA
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/apropos-utils.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/apropos-utils.h
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makemandb/makemandb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makemandb/DBSCHEMA
diff -u src/usr.sbin/makemandb/DBSCHEMA:1.1 src/usr.sbin/makemandb/DBSCHEMA:1.2
--- src/usr.sbin/makemandb/DBSCHEMA:1.1	Tue Feb  7 19:13:32 2012
+++ src/usr.sbin/makemandb/DBSCHEMA	Mon May  7 11:18:16 2012
@@ -50,3 +50,4 @@ There are three tables in the database a
   3. section        The section number  
   4. machine        The machine architecture (if any) for which 
                     the page is relevant
+  5. md5_hash       MD5 Hash of the target man page.

Index: src/usr.sbin/makemandb/apropos-utils.c
diff -u src/usr.sbin/makemandb/apropos-utils.c:1.4 src/usr.sbin/makemandb/apropos-utils.c:1.5
--- src/usr.sbin/makemandb/apropos-utils.c:1.4	Sun Apr 15 15:56:52 2012
+++ src/usr.sbin/makemandb/apropos-utils.c	Mon May  7 11:18:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.c,v 1.4 2012/04/15 15:56:52 wiz Exp $	*/
+/*	$NetBSD: apropos-utils.c,v 1.5 2012/05/07 11:18:16 wiz Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com>
  * All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: apropos-utils.c,v 1.4 2012/04/15 15:56:52 wiz Exp $");
+__RCSID("$NetBSD: apropos-utils.c,v 1.5 2012/05/07 11:18:16 wiz Exp $");
 
 #include <sys/stat.h>
 
@@ -172,7 +172,7 @@ create_db(sqlite3 *db)
 			    "file UNIQUE, md5_hash UNIQUE, id  INTEGER PRIMARY KEY); "
 				//mandb_meta
 			"CREATE TABLE IF NOT EXISTS mandb_links(link, target, section, "
-			    "machine); ";	//mandb_links
+			    "machine, md5_hash); ";	//mandb_links
 
 	sqlite3_exec(db, sqlstr, NULL, NULL, &errmsg);
 	if (errmsg != NULL)
@@ -181,7 +181,9 @@ create_db(sqlite3 *db)
 	sqlstr = "CREATE INDEX IF NOT EXISTS index_mandb_links ON mandb_links "
 			"(link); "
 			"CREATE INDEX IF NOT EXISTS index_mandb_meta_dev ON mandb_meta "
-			"(device, inode)";
+			"(device, inode); "
+			"CREATE INDEX IF NOT EXISTS index_mandb_links_md5 ON mandb_links "
+			"(md5_hash);";
 	sqlite3_exec(db, sqlstr, NULL, NULL, &errmsg);
 	if (errmsg != NULL)
 		goto out;

Index: src/usr.sbin/makemandb/apropos-utils.h
diff -u src/usr.sbin/makemandb/apropos-utils.h:1.2 src/usr.sbin/makemandb/apropos-utils.h:1.3
--- src/usr.sbin/makemandb/apropos-utils.h:1.2	Tue Feb  7 19:17:16 2012
+++ src/usr.sbin/makemandb/apropos-utils.h	Mon May  7 11:18:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: apropos-utils.h,v 1.2 2012/02/07 19:17:16 joerg Exp $	*/
+/*	$NetBSD: apropos-utils.h,v 1.3 2012/05/07 11:18:16 wiz Exp $	*/
 /*-
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com>
  * All rights reserved.
@@ -43,7 +43,7 @@
 #define MANDB_WRITE SQLITE_OPEN_READWRITE
 #define MANDB_CREATE SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
 
-#define APROPOS_SCHEMA_VERSION 20120130
+#define APROPOS_SCHEMA_VERSION 20120507
 
 /*
  * Used to identify the section of a man(7) page.

Index: src/usr.sbin/makemandb/makemandb.c
diff -u src/usr.sbin/makemandb/makemandb.c:1.8 src/usr.sbin/makemandb/makemandb.c:1.9
--- src/usr.sbin/makemandb/makemandb.c:1.8	Fri May  4 23:50:26 2012
+++ src/usr.sbin/makemandb/makemandb.c	Mon May  7 11:18:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: makemandb.c,v 1.8 2012/05/04 23:50:26 wiz Exp $	*/
+/*	$NetBSD: makemandb.c,v 1.9 2012/05/07 11:18:16 wiz Exp $	*/
 /*
  * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com>
  * Copyright (c) 2011 Kristaps Dzonsons <krist...@bsd.lv>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: makemandb.c,v 1.8 2012/05/04 23:50:26 wiz Exp $");
+__RCSID("$NetBSD: makemandb.c,v 1.9 2012/05/07 11:18:16 wiz Exp $");
 
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -780,6 +780,8 @@ update_db(sqlite3 *db, struct mparse *mp
 
 	sqlstr = "DELETE FROM mandb_meta WHERE file NOT IN"
 		 " (SELECT file FROM metadb.file_cache);"
+		 "DELETE FROM mandb_links WHERE md5_hash NOT IN"
+		 " (SELECT md5_hash from mandb_meta);"
 		 "DROP TABLE metadb.file_cache;"
 		 "DELETE FROM mandb WHERE rowid NOT IN"
 		 " (SELECT id FROM mandb_meta);";
@@ -1726,9 +1728,9 @@ insert_into_db(sqlite3 *db, mandb_rec *r
 				ln[strlen(ln) - 1] = 0;
 			
 			str = sqlite3_mprintf("INSERT INTO mandb_links"
-					      " VALUES (%Q, %Q, %Q, %Q)",
+					      " VALUES (%Q, %Q, %Q, %Q, %Q)",
 					      ln, rec->name, rec->section,
-					      rec->machine);
+					      rec->machine, rec->md5_hash);
 			sqlite3_exec(db, str, NULL, NULL, &errmsg);
 			sqlite3_free(str);
 			if (errmsg != NULL) {

Reply via email to