From 3be781a150d283ef21fc799447e3aaa53897eb92 Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 16 Apr 2014 21:35:48 +0000 Subject: [PATCH] Rename the mpages.id column to mpages.pageid. There is no good reason to call this kid by a different name here than in all other tables. Easier to polish this now than after enabling. --- usr.bin/mandoc/mandocdb.c | 24 ++++++++++++------------ usr.bin/mandoc/mansearch.c | 36 ++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 2e1a10b1b54..0f5d9c42769 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.93 2014/04/16 18:59:38 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.94 2014/04/16 21:35:48 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -92,7 +92,7 @@ struct inodev { struct mpage { struct inodev inodev; /* used for hashing routine */ - int64_t recno; /* id in mpages SQL table */ + int64_t pageid; /* pageid in mpages SQL table */ enum form form; /* format from file content */ char *sec; /* section from file content */ char *arch; /* architecture from file content */ @@ -1091,7 +1091,7 @@ mpages_merge(struct mchars *mc, struct mparse *mp) * to the target. */ - if (mpage_dest->recno) + if (mpage_dest->pageid) dbadd_mlink(mlink); if (NULL == mlink->next) @@ -1884,7 +1884,7 @@ dbadd_mlink(const struct mlink *mlink) SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->dsec); SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->arch); SQL_BIND_TEXT(stmts[STMT_INSERT_LINK], i, mlink->name); - SQL_BIND_INT64(stmts[STMT_INSERT_LINK], i, mlink->mpage->recno); + SQL_BIND_INT64(stmts[STMT_INSERT_LINK], i, mlink->mpage->pageid); SQL_STEP(stmts[STMT_INSERT_LINK]); sqlite3_reset(stmts[STMT_INSERT_LINK]); } @@ -1936,7 +1936,7 @@ dbadd(struct mpage *mpage, struct mchars *mc) SQL_BIND_TEXT(stmts[STMT_INSERT_PAGE], i, mpage->desc); SQL_BIND_INT(stmts[STMT_INSERT_PAGE], i, FORM_SRC == mpage->form); SQL_STEP(stmts[STMT_INSERT_PAGE]); - mpage->recno = sqlite3_last_insert_rowid(db); + mpage->pageid = sqlite3_last_insert_rowid(db); sqlite3_reset(stmts[STMT_INSERT_PAGE]); while (NULL != mlink) { @@ -1953,7 +1953,7 @@ dbadd(struct mpage *mpage, struct mchars *mc) i = 1; SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, key->mask); SQL_BIND_TEXT(stmts[STMT_INSERT_NAME], i, key->rendered); - SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, mpage->recno); + SQL_BIND_INT64(stmts[STMT_INSERT_NAME], i, mpage->pageid); SQL_STEP(stmts[STMT_INSERT_NAME]); sqlite3_reset(stmts[STMT_INSERT_NAME]); if (key->rendered != key->key) @@ -1968,7 +1968,7 @@ dbadd(struct mpage *mpage, struct mchars *mc) i = 1; SQL_BIND_INT64(stmts[STMT_INSERT_KEY], i, key->mask); SQL_BIND_TEXT(stmts[STMT_INSERT_KEY], i, key->rendered); - SQL_BIND_INT64(stmts[STMT_INSERT_KEY], i, mpage->recno); + SQL_BIND_INT64(stmts[STMT_INSERT_KEY], i, mpage->pageid); SQL_STEP(stmts[STMT_INSERT_KEY]); sqlite3_reset(stmts[STMT_INSERT_KEY]); if (key->rendered != key->key) @@ -2164,14 +2164,14 @@ create_tables: sql = "CREATE TABLE \"mpages\" (\n" " \"desc\" TEXT NOT NULL,\n" " \"form\" INTEGER NOT NULL,\n" - " \"id\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL\n" + " \"pageid\" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL\n" ");\n" "\n" "CREATE TABLE \"mlinks\" (\n" " \"sec\" TEXT NOT NULL,\n" " \"arch\" TEXT NOT NULL,\n" " \"name\" TEXT NOT NULL,\n" - " \"pageid\" INTEGER NOT NULL REFERENCES mpages(id) " + " \"pageid\" INTEGER NOT NULL REFERENCES mpages(pageid) " "ON DELETE CASCADE\n" ");\n" "CREATE INDEX mlinks_pageid_idx ON mlinks (pageid);\n" @@ -2179,14 +2179,14 @@ create_tables: "CREATE TABLE \"names\" (\n" " \"bits\" INTEGER NOT NULL,\n" " \"name\" TEXT NOT NULL,\n" - " \"pageid\" INTEGER NOT NULL REFERENCES mpages(id) " + " \"pageid\" INTEGER NOT NULL REFERENCES mpages(pageid) " "ON DELETE CASCADE\n" ");\n" "\n" "CREATE TABLE \"keys\" (\n" " \"bits\" INTEGER NOT NULL,\n" " \"key\" TEXT NOT NULL,\n" - " \"pageid\" INTEGER NOT NULL REFERENCES mpages(id) " + " \"pageid\" INTEGER NOT NULL REFERENCES mpages(pageid) " "ON DELETE CASCADE\n" ");\n" "CREATE INDEX keys_pageid_idx ON keys (pageid);\n"; @@ -2199,7 +2199,7 @@ create_tables: prepare_statements: SQL_EXEC("PRAGMA foreign_keys = ON"); - sql = "DELETE FROM mpages WHERE id IN " + sql = "DELETE FROM mpages WHERE pageid IN " "(SELECT pageid FROM mlinks WHERE " "sec=? AND arch=? AND name=?)"; sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_DELETE_PAGE], NULL); diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index 5447bf35ef4..7b0a287c47a 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.21 2014/04/16 00:33:24 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.22 2014/04/16 21:35:48 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -66,7 +66,7 @@ struct expr { }; struct match { - uint64_t id; /* identifier in database */ + uint64_t pageid; /* identifier in database */ char *desc; /* manual page description */ int form; /* 0 == catpage */ }; @@ -148,7 +148,7 @@ mansearch(const struct mansearch *search, struct manpage **res, size_t *sz) { int fd, rc, c, indexbit; - int64_t id; + int64_t pageid; uint64_t outbit, iterbit; char buf[PATH_MAX]; char *sql; @@ -167,7 +167,7 @@ mansearch(const struct mansearch *search, info.halloc = hash_halloc; info.alloc = hash_alloc; info.hfree = hash_free; - info.key_offset = offsetof(struct match, id); + info.key_offset = offsetof(struct match, pageid); *sz = cur = maxres = 0; sql = NULL; @@ -279,16 +279,16 @@ mansearch(const struct mansearch *search, * distribution of buckets in the table. */ while (SQLITE_ROW == (c = sqlite3_step(s))) { - id = sqlite3_column_int64(s, 2); + pageid = sqlite3_column_int64(s, 2); idx = ohash_lookup_memory - (&htab, (char *)&id, - sizeof(uint64_t), (uint32_t)id); + (&htab, (char *)&pageid, + sizeof(uint64_t), (uint32_t)pageid); if (NULL != ohash_find(&htab, idx)) continue; mp = mandoc_calloc(1, sizeof(struct match)); - mp->id = id; + mp->pageid = pageid; mp->form = sqlite3_column_int(s, 1); if (TYPE_Nd == outbit) mp->desc = mandoc_strdup( @@ -324,11 +324,11 @@ mansearch(const struct mansearch *search, } mpage = *res + cur; mpage->form = mp->form; - buildnames(mpage, db, s, mp->id, + buildnames(mpage, db, s, mp->pageid, paths->paths[i], mp->form); mpage->output = TYPE_Nd & outbit ? mp->desc : outbit ? - buildoutput(db, s2, mp->id, outbit) : NULL; + buildoutput(db, s2, mp->pageid, outbit) : NULL; free(mp); cur++; @@ -354,7 +354,7 @@ out: static void buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s, - uint64_t id, const char *path, int form) + uint64_t pageid, const char *path, int form) { char *newnames, *prevsec, *prevarch; const char *oldnames, *sep1, *name, *sec, *sep2, *arch, *fsec; @@ -365,7 +365,7 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s, mpage->names = NULL; prevsec = prevarch = NULL; i = 1; - SQL_BIND_INT64(db, s, i, id); + SQL_BIND_INT64(db, s, i, pageid); while (SQLITE_ROW == (c = sqlite3_step(s))) { /* Decide whether we already have some names. */ @@ -447,7 +447,7 @@ buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s, } static char * -buildoutput(sqlite3 *db, sqlite3_stmt *s, uint64_t id, uint64_t outbit) +buildoutput(sqlite3 *db, sqlite3_stmt *s, uint64_t pageid, uint64_t outbit) { char *output, *newoutput; const char *oldoutput, *sep1, *data; @@ -456,7 +456,7 @@ buildoutput(sqlite3 *db, sqlite3_stmt *s, uint64_t id, uint64_t outbit) output = NULL; i = 1; - SQL_BIND_INT64(db, s, i, id); + SQL_BIND_INT64(db, s, i, pageid); SQL_BIND_INT64(db, s, i, outbit); while (SQLITE_ROW == (c = sqlite3_step(s))) { if (NULL == output) { @@ -551,14 +551,14 @@ sql_statement(const struct expr *e) : "desc MATCH ?") : TYPE_Nm == e->bits ? (NULL == e->substr - ? "id IN (SELECT pageid FROM names " + ? "pageid IN (SELECT pageid FROM names " "WHERE name REGEXP ?)" - : "id IN (SELECT pageid FROM names " + : "pageid IN (SELECT pageid FROM names " "WHERE name MATCH ?)") : (NULL == e->substr - ? "id IN (SELECT pageid FROM keys " + ? "pageid IN (SELECT pageid FROM keys " "WHERE key REGEXP ? AND bits & ?)" - : "id IN (SELECT pageid FROM keys " + : "pageid IN (SELECT pageid FROM keys " "WHERE key MATCH ? AND bits & ?)"), 1); if (e->close) sql_append(&sql, &sz, ")", e->close); -- 2.20.1