From fd4216ccebcd41c2db6c4755836c1cd62a44738f Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 23 Apr 2014 16:33:37 +0000 Subject: [PATCH] improve SQL style: avoid "SELECT *", be explicit in what columns we want; suggested by espie@. --- usr.bin/mandoc/mandocdb.c | 5 +++-- usr.bin/mandoc/mansearch.c | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 4a75494348c..ee75af0e0b8 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.98 2014/04/20 16:44:44 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.99 2014/04/23 16:33:37 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -1279,7 +1279,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/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index 9141c4c691d..cf2299dd0ad 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.24 2014/04/20 16:44:44 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.25 2014/04/23 16:33:37 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -302,14 +302,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)); @@ -534,7 +535,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.20.1