mirror of
https://github.com/facebook/sapling.git
synced 2024-10-04 13:57:13 +03:00
commit cloud: Add mysql query for version insertion
Summary: ^ From https://www.internalfb.com/code/fbsource/[6bf6523985dc]/fbcode/scm/commitcloud/service-cpp/CommitCloudHandlers.cpp?lines=906-913 Reviewed By: markbt Differential Revision: D56801073 fbshipit-source-id: b06b48b2a3d4f7550aed10e9c49faaa96085e957
This commit is contained in:
parent
01296c3ecc
commit
610b9cd3a6
@ -33,7 +33,15 @@ mononoke_queries! {
|
||||
// it could be modified by another transaction fail the transaction in such cases
|
||||
write InsertVersion(reponame: String, workspace: String, version: u64, timestamp: Timestamp) {
|
||||
none,
|
||||
"INSERT INTO versions (`reponame`, `workspace`, `version`, `timestamp`)
|
||||
mysql("INSERT INTO versions (`reponame`, `workspace`, `version`, `timestamp`) VALUES ({reponame}, {workspace}, {version}, {timestamp}) \
|
||||
ON DUPLICATE KEY UPDATE timestamp = current_timestamp, version = \
|
||||
IF(version + 1 = VALUES(version), \
|
||||
VALUES(version), \
|
||||
/* hack: the query below always generates runtime error \
|
||||
this is a way to raise an exception (err 1242) */ \
|
||||
(SELECT table_name FROM information_schema.tables LIMIT 2) \
|
||||
)")
|
||||
sqlite("INSERT INTO versions (`reponame`, `workspace`, `version`, `timestamp`)
|
||||
VALUES ({reponame}, {workspace}, {version}, {timestamp})
|
||||
ON CONFLICT(`reponame`, `workspace`) DO UPDATE SET`timestamp` = CURRENT_TIMESTAMP,
|
||||
`version` = CASE
|
||||
@ -41,7 +49,7 @@ mononoke_queries! {
|
||||
ELSE
|
||||
/* hack: the query below always generates runtime error this is a way to raise an exception (err 1242) */
|
||||
(SELECT name FROM sqlite_master WHERE type='table' LIMIT 2)
|
||||
END"
|
||||
END")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user