From 83a9b4af97fd1c631d24b734b275982561069bda Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 23 Apr 2014 16:34:50 +0000 Subject: [PATCH] improve SQL style: avoid "SELECT *", be explicit in what columns we want; suggested by espie@. --- mandocdb.c | 5 +++-- mansearch.c | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mandocdb.c b/mandocdb.c index 0fc16443..78ce1217 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.141 2014/04/20 16:46:04 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.142 2014/04/23 16:34:50 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -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 fb2de009..eec5ff13 100644 --- a/mansearch.c +++ b/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.34 2014/04/20 16:46:05 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.35 2014/04/23 16:34:50 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -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) { -- 2.47.1