source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: improve SQL style: avoid "SELECT *", be explicit in what columns
Date: Wed, 23 Apr 2014 12:34:50 -0400 (EDT)	[thread overview]
Message-ID: <201404231634.s3NGYoYR005196@krisdoz.my.domain> (raw)

Log Message:
-----------
improve SQL style: avoid "SELECT *", be explicit in what columns we want;
suggested by espie@.

Modified Files:
--------------
    mdocml:
        mandocdb.c
        mansearch.c

Revision Data
-------------
Index: mansearch.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lmansearch.c -Lmansearch.c -u -p -r1.34 -r1.35
--- mansearch.c
+++ 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) {
Index: mandocdb.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandocdb.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -Lmandocdb.c -Lmandocdb.c -u -p -r1.141 -r1.142
--- mandocdb.c
+++ 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);
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

                 reply	other threads:[~2014-04-23 16:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201404231634.s3NGYoYR005196@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).