Skip to content

Commit

Permalink
mxq_daemon: Don't use NULL for CURRENT_TIMESTAMP()
Browse files Browse the repository at this point in the history
daemon_start and daemon_stop are defined as

    TIMESTAMP NOT NULL DEFAULT 0

If elder mysql versions, these fields could be set to NULL to get the
current timestamp into it. mysql 8 does not allow that and throws

    2019-10-22 10:55:50 +0200 mxqd[9827]: mxqd mx_mysql.c:413:mx__mysql_stmt_execute(): WARNING: MySQL mysql_stmt_execute(): ERROR 1048 (23000): Column 'daemon_start' cannot be null

So use CURRENT_TIMESTAMP explicitly.
  • Loading branch information
donald committed Jan 24, 2020
1 parent ec49090 commit 87f24ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions mxq_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int mxq_daemon_register(struct mx_mysql *mysql, struct mxq_daemon *daemon)
" daemon_threads_running = 0,"
" daemon_memory_used = 0,"
" mtime = NULL,"
" daemon_start = NULL,"
" daemon_start = CURRENT_TIMESTAMP(),"
" daemon_stop = 0"
);
if (!stmt) {
Expand Down Expand Up @@ -196,7 +196,7 @@ int mxq_daemon_shutdown(struct mx_mysql *mysql, struct mxq_daemon *daemon)
" mxq_daemon"
" SET"
" mtime = NULL,"
" daemon_stop = NULL,"
" daemon_stop = CURRENT_TIMESTAMP(),"
" status = " status_str(MXQ_DAEMON_STATUS_EXITED)
" WHERE daemon_id = ?";

Expand Down Expand Up @@ -232,7 +232,7 @@ int mxq_daemon_mark_crashed(struct mx_mysql *mysql, struct mxq_daemon *daemon)
query = "UPDATE"
" mxq_daemon"
" SET"
" daemon_stop = NULL,"
" daemon_stop = CURRENT_TIMESTAMP(),"
" status = " status_str(MXQ_DAEMON_STATUS_CRASHED)
" WHERE status NOT IN ("
status_str(MXQ_DAEMON_STATUS_EXITED) ","
Expand Down
2 changes: 1 addition & 1 deletion mxq_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ int mxq_set_job_status_exited(struct mx_mysql *mysql, struct mxq_job *job)
" stats_nvcsw = ?,"
" stats_nivcsw = ?,"
" job_status = ?,"
" date_end = NULL"
" date_end = CURRENT_TIMESTAMP()"
" WHERE job_status IN ("
status_str(MXQ_JOB_STATUS_LOADED) ","
status_str(MXQ_JOB_STATUS_RUNNING) ")"
Expand Down

0 comments on commit 87f24ef

Please sign in to comment.