diff --git a/lib/go/camli/mysqlindexer/dbschema.go b/lib/go/camli/mysqlindexer/dbschema.go index 5cb6f9163..a1156b1d6 100644 --- a/lib/go/camli/mysqlindexer/dbschema.go +++ b/lib/go/camli/mysqlindexer/dbschema.go @@ -18,7 +18,7 @@ package mysqlindexer import () -const requiredSchemaVersion = 12 +const requiredSchemaVersion = 14 func SchemaVersion() int { return requiredSchemaVersion @@ -94,6 +94,21 @@ blobref VARCHAR(128) NOT NULL, PRIMARY KEY (blobref), keyid VARCHAR(128) NOT NULL, INDEX (keyid) +)`, + + + // Bi-direction index of camliPath claims + `CREATE TABLE path ( +claimref VARCHAR(128) NOT NULL, +PRIMARY KEY (claimref), +claimdate VARCHAR(40) NOT NULL, +keyid VARCHAR(128) NOT NULL, +baseref VARCHAR(128) NOT NULL, +suffix VARCHAR(255) NOT NULL, +targetref VARCHAR(128) NOT NULL, +INDEX (keyid), +INDEX (targetref, keyid), +INDEX (baseref, keyid) )`, } } diff --git a/lib/go/camli/mysqlindexer/receive.go b/lib/go/camli/mysqlindexer/receive.go index 7c50d8ae7..aa71af2a5 100644 --- a/lib/go/camli/mysqlindexer/receive.go +++ b/lib/go/camli/mysqlindexer/receive.go @@ -225,6 +225,19 @@ func (mi *Indexer) populateClaim(client *mysql.Client, blobRef *blobref.BlobRef, return } } + if strings.HasPrefix(camli.Attribute, "camliPath:") { + // TODO: deal with set-attribute vs. del-attribute + // properly? I think we get it for free when + // del-attribute has no Value, but we need to deal + // with the case where they explicitly delete the + // current value. + suffix := camli.Attribute[len("camliPath:"):] + if err = execSQL(client, "INSERT IGNORE INTO path (claimref, claimdate, keyid, baseref, suffix, targetref) "+ + "VALUES (?, ?, ?, ?, ?, ?)", + blobRef.String(), camli.ClaimDate, verifiedKeyId, camli.Permanode, suffix, camli.Value); err != nil { + return + } + } } // And update the lastmod on the permanode row.