publishing work: index path mounts

Change-Id: I9e6f273289f136fbbfa8565c24be250e28ae1a6e
This commit is contained in:
Brad Fitzpatrick 2011-06-24 18:50:00 -07:00
parent 05c45e6989
commit b2edc4a5f9
2 changed files with 29 additions and 1 deletions

View File

@ -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)
)`,
}
}

View File

@ -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.