So... It is kind of important that the sample function bodies in hook documentation follow the Drupal coding standards. I noticed a couple of things in hook_taxonomy_vocabulary_insert() (they apply to other functions in the patch too):
- Normally we use single quotes instead of double quotes for strings (unless the string itself contains apostrophes/single quotes).
- We don't normally split watchdog() calls into multiple lines.

Elsewhere in the patch, I noticed:
- The word "translator" is misspelled several times.
- The term delete hook body is not valid (it references vocabulary not terms). Also the vocabulary create hook body references term not vocabulary.
- I think each sample function body could be improved by starting it with a code comment explaining what the sample body does. For instance "// A term has changed, so notify translators." etc.
- I like some of the examples, but I'm not too excited about:
-- The "paper trail" examples. Can we come up with something better?
-- The vocabulary load one that multiplies all the weights by 10 (what for?)
-- The ones that set a value for "foo", without explaining what it would do... and will that even work? Where is this "foo" field/property defined?

@cam8001: Those cases are fine. vid is a machine name, not an int, it's a config entity. And the objects are by reference, that's how load hooks work. The only thing that I'm not sure about is if we invoke load hooks for config entities at all. If not then we should simply delete that hook documentation.

tid/id() are correct. $record is a database result row, which is a stdClass without methods. $term is a Term object with an id() method. That $record is currently using ->id() was a search & replace bug when terms were converted.

And our current standard is AFAIK still to use db_query() unless there is a reason to use db_select(), e.g. some dynamic parts. As I said above, that line should probably not be touched at all, but I have no strong opinion on that, so back to you for now :)

Well, how come most of the example hook function bodies use db_select() and this one uses db_query()? If this logic applies to one example, it should apply to all. Can't we keep them consistent?

I also personally find db_select() a lot easier to read/parse than a bare SQL query with placeholders, so my preference would be to use db_select() in the examples for clarity, even if our coding standards recommend db_query().

Anyway... Let's either use a db_query() for both vocabulary and term load examples, or use db_select for both. You are right that our documentation says to use db_query() if performance is an issue:https://drupal.org/node/310075

But the queries in the examples for vocabulary load and term load are nearly identical. One is using db_query, and the other is using db_select. They can't both be the right thing to do. Let's make them the same.

Um... in the term_update and vocabulary_update hooks, shouldn't we be updating a record rather than inserting a new one? It seems like the tid/vid is probably the primary key, so we'd either need to delete the previous record before inserting, or use db_update() rather than db_insert()?

We did that in the 8.x patch too... guess we need to go back and fix it there?