Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15479727
D9234.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9234.diff
View Options
diff --git a/resources/sql/autopatches/20140521.factlint.1.sql b/resources/sql/autopatches/20140521.factlint.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140521.factlint.1.sql
@@ -0,0 +1,4 @@
+ALTER TABLE {$NAMESPACE}_fact.fact_aggregate
+ ADD COLUMN `stringAHash` VARCHAR(64) COLLATE utf8_bin NOT NULL,
+ DROP KEY `factType`,
+ ADD UNIQUE KEY factType (`factType`, `objectPHID`, `stringAHash`);
diff --git a/src/applications/fact/daemon/PhabricatorFactDaemon.php b/src/applications/fact/daemon/PhabricatorFactDaemon.php
--- a/src/applications/fact/daemon/PhabricatorFactDaemon.php
+++ b/src/applications/fact/daemon/PhabricatorFactDaemon.php
@@ -204,18 +204,19 @@
foreach ($facts as $fact) {
$sql[] = qsprintf(
$conn,
- '(%s, %s, %s, %d)',
+ '(%s, %s, %s, %s, %d)',
$fact->getFactType(),
$fact->getObjectPHID(),
$fact->getStringA(),
+ md5($fact->getStringA()),
$fact->getValueX());
}
foreach (array_chunk($sql, 256) as $chunk) {
queryfx(
$conn,
- 'INSERT INTO %T (factType, objectPHID, stringA, valueX) VALUES %Q
- ON DUPLICATE KEY UPDATE valueX = VALUES(valueX)',
+ 'INSERT INTO %T (factType, objectPHID, stringA, stringAHash, valueX)
+ VALUES %Q ON DUPLICATE KEY UPDATE valueX = VALUES(valueX)',
$table_name,
implode(', ', $chunk));
}
diff --git a/src/applications/fact/storage/PhabricatorFactAggregate.php b/src/applications/fact/storage/PhabricatorFactAggregate.php
--- a/src/applications/fact/storage/PhabricatorFactAggregate.php
+++ b/src/applications/fact/storage/PhabricatorFactAggregate.php
@@ -5,6 +5,7 @@
protected $factType;
protected $objectPHID;
protected $stringA;
+ protected $stringAHash;
protected $valueX;
public function getConfiguration() {
@@ -23,4 +24,14 @@
) + parent::getConfiguration();
}
+ /*
+ * Ensure that the hash in the database gets updated. We
+ * can't use the full length stringA field as part of the
+ * unique key because the maximum unique key is 787 bytes.
+ */
+ public function setStringA($value) {
+ $this->setStringAHash(md5($value));
+ return parent::setStringA($value);
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 9, 9:04 AM (4 d, 14 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7717600
Default Alt Text
D9234.diff (2 KB)
Attached To
Mode
D9234: Update unique key for Fact aggregates to include a hash of stringA
Attached
Detach File
Event Timeline
Log In to Comment