From: schwarze Date: Wed, 23 Apr 2014 16:33:37 +0000 (+0000) Subject: improve SQL style: avoid "SELECT *", be explicit in what columns we want; X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fd4216ccebcd41c2db6c4755836c1cd62a44738f;p=openbsd improve SQL style: avoid "SELECT *", be explicit in what columns we want; suggested by espie@. --- 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) {