|
@@ -15,6 +15,10 @@ import (
|
15
|
15
|
)
|
16
|
16
|
|
17
|
17
|
const (
|
|
18
|
+ // maximum length in bytes of any message target (nickname or channel name) in its
|
|
19
|
+ // canonicalized (i.e., casefolded) state:
|
|
20
|
+ MaxTargetLength = 64
|
|
21
|
+
|
18
|
22
|
// latest schema of the db
|
19
|
23
|
latestDbSchema = "1"
|
20
|
24
|
keySchemaVersion = "db.version"
|
|
@@ -120,27 +124,27 @@ func (mysql *MySQL) createTables() (err error) {
|
120
|
124
|
return err
|
121
|
125
|
}
|
122
|
126
|
|
123
|
|
- _, err = mysql.db.Exec(`CREATE TABLE sequence (
|
|
127
|
+ _, err = mysql.db.Exec(fmt.Sprintf(`CREATE TABLE sequence (
|
124
|
128
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
125
|
|
- target VARBINARY(64) NOT NULL,
|
|
129
|
+ target VARBINARY(%[1]d) NOT NULL,
|
126
|
130
|
nanotime BIGINT UNSIGNED NOT NULL,
|
127
|
131
|
history_id BIGINT NOT NULL,
|
128
|
132
|
KEY (target, nanotime),
|
129
|
133
|
KEY (history_id)
|
130
|
|
- ) CHARSET=ascii COLLATE=ascii_bin;`)
|
|
134
|
+ ) CHARSET=ascii COLLATE=ascii_bin;`, MaxTargetLength))
|
131
|
135
|
if err != nil {
|
132
|
136
|
return err
|
133
|
137
|
}
|
134
|
138
|
|
135
|
|
- _, err = mysql.db.Exec(`CREATE TABLE conversations (
|
|
139
|
+ _, err = mysql.db.Exec(fmt.Sprintf(`CREATE TABLE conversations (
|
136
|
140
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
137
|
|
- lower_target VARBINARY(64) NOT NULL,
|
138
|
|
- upper_target VARBINARY(64) NOT NULL,
|
|
141
|
+ lower_target VARBINARY(%[1]d) NOT NULL,
|
|
142
|
+ upper_target VARBINARY(%[1]d) NOT NULL,
|
139
|
143
|
nanotime BIGINT UNSIGNED NOT NULL,
|
140
|
144
|
history_id BIGINT NOT NULL,
|
141
|
145
|
KEY (lower_target, upper_target, nanotime),
|
142
|
146
|
KEY (history_id)
|
143
|
|
- ) CHARSET=ascii COLLATE=ascii_bin;`)
|
|
147
|
+ ) CHARSET=ascii COLLATE=ascii_bin;`, MaxTargetLength))
|
144
|
148
|
if err != nil {
|
145
|
149
|
return err
|
146
|
150
|
}
|