summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-23 16:34:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-23 16:34:50 +0000
commita7b25cfc2df349d5af8d9f64b781ef9aa16b83e3 (patch)
tree773a732384e7649c5d78a2954378dee87058ddf7
parent842d2c18036af60bbed3a3624ecf8fe100d9d443 (diff)
downloadmandoc-a7b25cfc2df349d5af8d9f64b781ef9aa16b83e3.tar.gz
improve SQL style: avoid "SELECT *", be explicit in what columns we want;
suggested by espie@.
-rw-r--r--mandocdb.c3
-rw-r--r--mansearch.c10
2 files changed, 8 insertions, 5 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 4025cb5b..9d7534af 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1287,7 +1287,8 @@ names_check(void)
"AND mlinks.name == names.name"
")"
") JOIN ("
- "SELECT * FROM mlinks GROUP BY pageid"
+ "SELECT sec, arch, name, pageid FROM mlinks "
+ "GROUP BY pageid"
") USING (pageid);",
-1, &stmt, NULL);
diff --git a/mansearch.c b/mansearch.c
index cbf2cec8..f7c99394 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -310,14 +310,15 @@ mansearch(const struct mansearch *search,
sqlite3_finalize(s);
c = sqlite3_prepare_v2(db,
- "SELECT * FROM mlinks WHERE pageid=?"
- " ORDER BY sec, arch, name",
+ "SELECT sec, arch, name, pageid FROM mlinks "
+ "WHERE pageid=? ORDER BY sec, arch, name",
-1, &s, NULL);
if (SQLITE_OK != c)
fprintf(stderr, "%s\n", sqlite3_errmsg(db));
c = sqlite3_prepare_v2(db,
- "SELECT * FROM keys WHERE pageid=? AND bits & ?",
+ "SELECT bits, key, pageid FROM keys "
+ "WHERE pageid=? AND bits & ?",
-1, &s2, NULL);
if (SQLITE_OK != c)
fprintf(stderr, "%s\n", sqlite3_errmsg(db));
@@ -542,7 +543,8 @@ sql_statement(const struct expr *e)
size_t sz;
int needop;
- sql = mandoc_strdup("SELECT * FROM mpages WHERE ");
+ sql = mandoc_strdup(
+ "SELECT desc, form, pageid FROM mpages WHERE ");
sz = strlen(sql);
for (needop = 0; NULL != e; e = e->next) {