forked from lix-project/hydra
Pass null values to libpqxx properly
This commit is contained in:
parent
dc446c3980
commit
604fdb908f
|
@ -137,11 +137,10 @@ State::~State()
|
||||||
void State::markActiveBuildStepsAsAborted(pqxx::connection & conn, time_t stopTime)
|
void State::markActiveBuildStepsAsAborted(pqxx::connection & conn, time_t stopTime)
|
||||||
{
|
{
|
||||||
pqxx::work txn(conn);
|
pqxx::work txn(conn);
|
||||||
auto stm = txn.parameterized
|
txn.parameterized
|
||||||
("update BuildSteps set busy = 0, status = $1, stopTime = $2 where busy = 1")
|
("update BuildSteps set busy = 0, status = $1, stopTime = $2 where busy = 1")
|
||||||
((int) bssAborted);
|
((int) bssAborted)
|
||||||
if (stopTime) stm(stopTime); else stm();
|
(stopTime, stopTime != 0).exec();
|
||||||
stm.exec();
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,14 +151,13 @@ int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build,
|
||||||
auto res = txn.parameterized("select max(stepnr) from BuildSteps where build = $1")(build->id).exec();
|
auto res = txn.parameterized("select max(stepnr) from BuildSteps where build = $1")(build->id).exec();
|
||||||
int stepNr = res[0][0].is_null() ? 1 : res[0][0].as<int>() + 1;
|
int stepNr = res[0][0].is_null() ? 1 : res[0][0].as<int>() + 1;
|
||||||
|
|
||||||
auto stm = txn.parameterized
|
txn.parameterized
|
||||||
("insert into BuildSteps (build, stepnr, type, drvPath, busy, startTime, system, status, propagatedFrom, errorMsg, stopTime) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)")
|
("insert into BuildSteps (build, stepnr, type, drvPath, busy, startTime, system, status, propagatedFrom, errorMsg, stopTime) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)")
|
||||||
(build->id)(stepNr)(0)(step->drvPath)(status == bssBusy ? 1 : 0)(startTime)(step->drv.platform);
|
(build->id)(stepNr)(0)(step->drvPath)(status == bssBusy ? 1 : 0)(startTime)(step->drv.platform)
|
||||||
if (status == bssBusy) stm(); else stm((int) status);
|
((int) status, status != bssBusy)
|
||||||
if (propagatedFrom) stm(propagatedFrom); else stm();
|
(propagatedFrom, propagatedFrom != 0)
|
||||||
if (errorMsg != "") stm(errorMsg); else stm();
|
(errorMsg, errorMsg != "")
|
||||||
if (status == bssBusy) stm(); else stm(startTime);
|
(startTime, status != bssBusy).exec();
|
||||||
stm.exec();
|
|
||||||
|
|
||||||
for (auto & output : step->drv.outputs)
|
for (auto & output : step->drv.outputs)
|
||||||
txn.parameterized
|
txn.parameterized
|
||||||
|
@ -173,13 +171,12 @@ int State::createBuildStep(pqxx::work & txn, time_t startTime, Build::ptr build,
|
||||||
void State::finishBuildStep(pqxx::work & txn, time_t stopTime, BuildID buildId, int stepNr,
|
void State::finishBuildStep(pqxx::work & txn, time_t stopTime, BuildID buildId, int stepNr,
|
||||||
BuildStepStatus status, const std::string & errorMsg, BuildID propagatedFrom)
|
BuildStepStatus status, const std::string & errorMsg, BuildID propagatedFrom)
|
||||||
{
|
{
|
||||||
auto stm = txn.parameterized
|
txn.parameterized
|
||||||
("update BuildSteps set busy = 0, status = $1, propagatedFrom = $4, errorMsg = $5, stopTime = $6 where build = $2 and stepnr = $3")
|
("update BuildSteps set busy = 0, status = $1, propagatedFrom = $4, errorMsg = $5, stopTime = $6 where build = $2 and stepnr = $3")
|
||||||
((int) status)(buildId)(stepNr);
|
((int) status)(buildId)(stepNr)
|
||||||
if (propagatedFrom) stm(propagatedFrom); else stm();
|
(propagatedFrom, propagatedFrom != 0)
|
||||||
if (errorMsg != "") stm(errorMsg); else stm();
|
(errorMsg, errorMsg != "")
|
||||||
if (stopTime) stm(stopTime); else stm();
|
(stopTime, stopTime != 0).exec();
|
||||||
stm.exec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -456,30 +453,28 @@ void State::doBuildStep(Step::ptr step)
|
||||||
void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
void State::markSucceededBuild(pqxx::work & txn, Build::ptr build,
|
||||||
const BuildResult & res, bool isCachedBuild, time_t startTime, time_t stopTime)
|
const BuildResult & res, bool isCachedBuild, time_t startTime, time_t stopTime)
|
||||||
{
|
{
|
||||||
auto stm = txn.parameterized
|
txn.parameterized
|
||||||
("update Builds set finished = 1, buildStatus = $2, startTime = $3, stopTime = $4, size = $5, closureSize = $6, releaseName = $7, isCachedBuild = $8 where id = $1")
|
("update Builds set finished = 1, buildStatus = $2, startTime = $3, stopTime = $4, size = $5, closureSize = $6, releaseName = $7, isCachedBuild = $8 where id = $1")
|
||||||
(build->id)
|
(build->id)
|
||||||
((int) bsSuccess)
|
((int) bsSuccess)
|
||||||
(startTime)
|
(startTime)
|
||||||
(stopTime)
|
(stopTime)
|
||||||
(res.size)
|
(res.size)
|
||||||
(res.closureSize);
|
(res.closureSize)
|
||||||
if (res.releaseName != "") stm(res.releaseName); else stm();
|
(res.releaseName, res.releaseName != "")
|
||||||
stm(isCachedBuild ? 1 : 0);
|
(isCachedBuild ? 1 : 0).exec();
|
||||||
stm.exec();
|
|
||||||
|
|
||||||
unsigned int productNr = 1;
|
unsigned int productNr = 1;
|
||||||
for (auto & product : res.products) {
|
for (auto & product : res.products) {
|
||||||
auto stm = txn.parameterized
|
txn.parameterized
|
||||||
("insert into BuildProducts (build, productnr, type, subtype, fileSize, sha1hash, sha256hash, path, name, defaultPath) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)")
|
("insert into BuildProducts (build, productnr, type, subtype, fileSize, sha1hash, sha256hash, path, name, defaultPath) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)")
|
||||||
(build->id)
|
(build->id)
|
||||||
(productNr++)
|
(productNr++)
|
||||||
(product.type)
|
(product.type)
|
||||||
(product.subtype);
|
(product.subtype)
|
||||||
if (product.isRegular) stm(product.fileSize); else stm();
|
(product.fileSize, product.isRegular)
|
||||||
if (product.isRegular) stm(printHash(product.sha1hash)); else stm();
|
(printHash(product.sha1hash), product.isRegular)
|
||||||
if (product.isRegular) stm(printHash(product.sha256hash)); else stm();
|
(printHash(product.sha256hash), product.isRegular)
|
||||||
stm
|
|
||||||
(product.path)
|
(product.path)
|
||||||
(product.name)
|
(product.name)
|
||||||
(product.defaultPath).exec();
|
(product.defaultPath).exec();
|
||||||
|
|
Loading…
Reference in a new issue