diff options
| author | Egor Tensin <Egor.Tensin@gmail.com> | 2023-07-09 15:53:11 +0200 |
|---|---|---|
| committer | Egor Tensin <Egor.Tensin@gmail.com> | 2023-07-09 17:37:44 +0200 |
| commit | 0600cacfadf00e916340f2394f1d3bfc173a3d0b (patch) | |
| tree | 4b1900b096de3d2b3ad49094e86adc310ec79dac /src/storage_sqlite.c | |
| parent | test: attempt to fix random port selection again (diff) | |
| download | cimple-0600cacfadf00e916340f2394f1d3bfc173a3d0b.tar.gz cimple-0600cacfadf00e916340f2394f1d3bfc173a3d0b.zip | |
store process output in SQLite
Diffstat (limited to '')
| -rw-r--r-- | src/storage_sqlite.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/storage_sqlite.c b/src/storage_sqlite.c index 2ac8b30..981a5dd 100644 --- a/src/storage_sqlite.c +++ b/src/storage_sqlite.c @@ -7,6 +7,7 @@ #include "storage_sqlite.h" #include "log.h" +#include "process.h" #include "run_queue.h" #include "sql/sqlite_sql.h" #include "sqlite.h" @@ -207,7 +208,7 @@ static int storage_sqlite_prepare_statements(struct storage_sqlite *storage) static const char *const fmt_run_insert = "INSERT INTO cimple_runs(status, ec, output, repo_id, rev) VALUES (?, -1, x'', ?, ?) RETURNING id;"; static const char *const fmt_run_finished = - "UPDATE cimple_runs SET status = ?, ec = ? WHERE id = ?;"; + "UPDATE cimple_runs SET status = ?, ec = ?, output = ? WHERE id = ?;"; int ret = 0; @@ -395,7 +396,8 @@ int storage_sqlite_run_create(struct storage *storage, const char *repo_url, con return ret; } -int storage_sqlite_run_finished(struct storage *storage, int run_id, int ec) +int storage_sqlite_run_finished(struct storage *storage, int run_id, + const struct proc_output *output) { struct prepared_stmt *stmt = &storage->sqlite->stmt_run_finished; int ret = 0; @@ -406,10 +408,13 @@ int storage_sqlite_run_finished(struct storage *storage, int run_id, int ec) ret = sqlite_bind_int(stmt->impl, 1, RUN_STATUS_FINISHED); if (ret < 0) goto reset; - ret = sqlite_bind_int(stmt->impl, 2, ec); + ret = sqlite_bind_int(stmt->impl, 2, output->ec); if (ret < 0) goto reset; - ret = sqlite_bind_int(stmt->impl, 3, run_id); + ret = sqlite_bind_blob(stmt->impl, 3, output->data, output->data_size); + if (ret < 0) + goto reset; + ret = sqlite_bind_int(stmt->impl, 4, run_id); if (ret < 0) goto reset; ret = sqlite_step(stmt->impl); |
