MySQL Cookbook, 1st Edition - Errata

This document lists the known errors for the book:

MySQL Cookbook, 1st Edition
Paul DuBois
O'Reilly & Associates
2002
ISBN 0-596-00145-2
[book information]
Number of items: 34
Date of most recently reported item: 2006-02-11

Sort by: [page number] [most recent errata first]
Date 2003-02-03
Page xxv, middle of page
Reported by Andrew Loughe
Description

Missing word. The sentence that says "...where filename is the name of the containing the CREATE TABLE statement" should say "...where filename is the name of the file containing the CREATE TABLE statement".


Date 2002-12-09
Page 61
Reported by Marc Weidner
Description In the first example under "Additional connection parameters", the unix_sock parameter should be unix_socket.

Date 2002-11-24
Page 69, last paragraph, third line
Reported by uffe larsson
Description Typo. "if you omit" should be "If you omit".

Date 2002-11-24
Page 115, first line
Reported by uffe larsson
Description The reference to Recipe 2.8 in the first sentence is incorrect. It should refer to Recipe 2.7.

Date 2005-12-20
Page 129
Description Under "Quoting and Placeholder Support," there is a cross-reference to Recipe 2.8. It should say 2.7 instead.

Date 2003-01-13
Page 174, bottom ofpage
Reported by ko
Description

The query at the bottom of the page says:

mysql> SELECT name, DATE_FORMAT(birth,'%m-%e') AS birthday
    -> FROM profile ORDER BY birthday LIMIT 1;

Because DATE_FORMAT() returns a string, the sort order is ASCII. To make sure that all values have the same number of digits (so that the ASCII sort order corresponds the the numeric order), the formatting specifier should use %d (which always produces two digits), not %e (which produces only a single digit for day values less than 10).


Date 2006-02-04
Page 255, paragraph preceding 5.17 title
Description "the resulting value like in the allowable range" should be "the resulting value lie in the allowable range".

Date 2003-03-13
Page 257
Description Extraneous word. The second paragraph that begins "For values that occur prior outside the range..." should say "For values that occur outside the range..."

Date 2006-02-04
Page 281, second to last display
Description "INTERVAL 6 MONTH" should be "INTERVAL 6 YEAR" to match the preceding display.

Date 2002-12-19
Page 353, 5th-6th lines from bottom of page
Description

This clause:

...the only values you can select are the grouped columns or the summary values calculated from them.

Should be:

...the only values you can select are the grouped columns or summary values calculated from the groups.


Date 2003-05-04
Page 365
Reported by Stefan Hinz
Description Typo in query column header. The first query on the p. 365 is printed as:
mysql> SELECT name, COUNT(*) AS days, SUM(miles) AS mileage
    -> FROM driver_log GROUP BY name;
+-------+------+-------------+
| name  | days | total miles |
+-------+------+-------------+
| Ben   |    3 |         362 |
| Henry |    5 |         911 |
| Suzi  |    2 |         893 |
+-------+------+-------------+
The third column header should be "mileage", not "total miles":
mysql> SELECT name, COUNT(*) AS days, SUM(miles) AS mileage
    -> FROM driver_log GROUP BY name;
+-------+------+---------+
| name  | days | mileage |
+-------+------+---------+
| Ben   |    3 |     362 |
| Henry |    5 |     911 |
| Suzi  |    2 |     893 |
+-------+------+---------+

Date 2003-05-04
Page 367
Reported by Stefan Hinz
Description Typo in query. The second query on p. 367 is printed like this:
mysql> SELECT name, SUM(miles)
    -> FROM driver_log
    -> GROUP BY name
    -> HAVING SUM(miles) = MAX(SUM(name));
ERROR 1111 at line 1: Invalid use of group function
MAX(SUM(name)) should be MAX(SUM(miles)):
mysql> SELECT name, SUM(miles)
    -> FROM driver_log
    -> GROUP BY name
    -> HAVING SUM(miles) = MAX(SUM(miles));
ERROR 1111 at line 1: Invalid use of group function

Date 2003-02-03
Page 402, bottom of page
Reported by ko
Description

Typos. Near the bottom of the page, these two lines occur:

$name = $sth->{NAMES}->[$i];

@names = @{$sth->{NAMES}};

NAMES should be NAME. The lines should read:

$name = $sth->{NAME}->[$i];

@names = @{$sth->{NAME}};

Date 2005-12-31
Page 417, second paragraph
Description "it a SQL pattern string" should be "it is a SQL pattern string".

Date 2006-01-01
Page 436, Problem
Description "You want to the MySQL server to tell you about itself" should be "You want the MySQL server to tell you about itself".

Date 2002-11-17
Page 444, third paragraph
Reported by Jesse Sheidlower
Description Typo. A comma should be a period. Change "representative techniques and utilities, You" to "representive techniques and utilities. You".

Date 2002-11-17
Page 446, middle of page
Reported by Jesse Sheidlower
Description Typo. A comma should be a period. Change "column delimiters, On" to "column delimiters. On".

Date 2003-04-25
Page 501, last paragraph
Reported by Stefan Hinz
Description The last paragraph states that the range for hour values is 0 to 24. It should say 0 to 23.

Date 2003-04-25
Page 502, is_ampm_time() function
Reported by Stefan Hinz
Description The is_ampm_time() function erroneously will convert the 12-hour time of 12:00:00 PM to the 24-hour time of 24:00:00. PM times with an hour value of 12 should not have the hour changed. In the function body, modify this line:
$hour += 12 if defined ($4) && uc ($4) eq "PM";
To this:
$hour += 12 if defined ($4) && uc ($4) eq "PM" && $hour != 12;

Date 2002-12-02
Page 517, option description items
Reported by Jesse Sheidlower
Description The syntax for the fifth option for guess_table.pl is described as --tbl_name=tbl_name. The correct syntax is --table=tbl_name.

Date 2002-11-26
Page 530, first bullet, second sentence
Reported by Jesse Sheidlower
Description Typo. "The script rewrites dates the contents" should be "The script rewrites the contents".

Date 2006-02-11
Page 543, first bullet
Description The bullet item indicates that an AUTO_INCREMENT column must be indexed with either a PRIMARY KEY or a UNIQUE index. The requirement actually is only that the column be indexed. The index need not enforce uniqueness.

Date 2003-04-29
Page 548, first bullet
Reported by Stefan Hinz
Description The first bullet states:
"With ISAM and BDB tables, the next sequence number always is the smallest positive integer not currently present in the column."
That is not quite correct; it should say this instead:
"With ISAM and BDB tables, the next sequence number always is the maximum integer currently present in the column plus one."

Date 2003-09-23
Page 687, second listing
Description Double typo. The example that shows how to calculate the terms for correlation should say "Y sum of squares" rather than "Y sum of square", both in the query and in its output.

Date 2003-01-23
Page 794, near bottom of page
Reported by David
Description

Typos. The code display near the bottom of the page is missing some closing double quotes. The code reads:

<a href="#1>Chapter 1</a>
<a href="#2>Chapter 2</a>
<a href="#3>Chapter 3</a>

It should read:

<a href="#1">Chapter 1</a>
<a href="#2">Chapter 2</a>
<a href="#3">Chapter 3</a>

Date 2005-12-27
Page 796
Description In the final line on the page, "artist ID" should be "chapter number".

Date 2005-12-27
Page 797
Description At the top of the page, "valid artist ID" should be "valid chapter number".

Date 2005-12-27
Page 798
Description About three-fourths of the way down the page, "use static bold text if entry is for current artist" should be "use static bold text if entry is for current chapter".

Date 2002-11-22
Page 801, last bullet item, last sentence
Reported by Jesse Sheidlower
Description Typo. "fix-length types" should be "fixed-length types".

Date 2002-11-22
Page 802, store_image.pl listing
Reported by Jesse Sheidlower
Description Typo. In the introductory comment "store in that image table", should be "store in the image table".

Date 2002-11-22
Page 809, program listing
Description Typo. The banner.py descriptive comment "server randomly chosen banner ad" should be "serve randomly chosen banner ad".

Date 2006-02-04
Page 835, first listing
Description The SELECT statement looks like this:
  SELECT
    DATE_SUB(CURDATE(),INTERVAL 5 DAY),
    DATE_SUB(CURDATE(),INTERVAL 4 DAY),
    DATE_SUB(CURDATE(),INTERVAL 3 DAY),
    DATE_SUB(CURDATE(),INTERVAL 2 DAY),
    DATE_SUB(CURDATE(),INTERVAL 1 DAY),
    CURDATE()
There is a line missing for the date 6 days before the current date. The statement should look like this:
  SELECT
    DATE_SUB(CURDATE(),INTERVAL 6 DAY),
    DATE_SUB(CURDATE(),INTERVAL 5 DAY),
    DATE_SUB(CURDATE(),INTERVAL 4 DAY),
    DATE_SUB(CURDATE(),INTERVAL 3 DAY),
    DATE_SUB(CURDATE(),INTERVAL 2 DAY),
    DATE_SUB(CURDATE(),INTERVAL 1 DAY),
    CURDATE()

Date 2002-11-07
Page 873, first paragraph
Reported by Jesse Sheidlower
Description Typo. In the second sentence, "how many row" should be "how many rows".

Date 2003-04-29
Page 919-920
Description Some changes to Tomcat session support are necessary for Tomcat 4.1 compared to 4.0, because the session-storage table needs an application name column. On page 919, the tomcat_session table is shown like this:
CREATE TABLE tomcat_session
(
    id              CHAR(32) NOT NULL,
    data            BLOB,
    valid_session   CHAR(1) NOT NULL,
    max_inactive    INT NOT NULL,
    last_access     BIGINT NOT NULL,
    PRIMARY KEY (id)
);
Use this structure instead:
CREATE TABLE tomcat_session
(
    id              VARCHAR(32) NOT NULL,
    app             VARCHAR(255),
    data            MEDIUMBLOB,
    valid_session   CHAR(1) NOT NULL,
    max_inactive    INT NOT NULL,
    last_access     BIGINT NOT NULL,
    PRIMARY KEY (id),
    INDEX (app)
);
Also, on p. 920, add a sessionAppCol attribute to the <Store> element, for example, after the sessionIdCol attribute:
...
sessionIdCol="id"
sessionAppCol="app"
...

This document is maintained by Paul DuBois. Please report any errors you find in the book that are not already listed here.