ovh / osarchiver

OpenStack databases archiver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SUBDATE syntax error with the where clause from example config

dmsimard opened this issue Β· comments

Hi and thanks for osarchiver πŸŽ‰

Writing this down in case someone else bumps into this.

The example config has the following line:
where=${deleted_column} <= SUBDATE({now}, INTERVAL ${retention})

However this yields a syntax error:

2020-06-01 20:27:29,725 DEBUG: Executing SQL command: 'SELECT * FROM `nova`.`agent_builds` WHERE id > '0' AND deleted_at <= SUBDATE(2020-06-01 20:27:29, INTERVAL 1 MONTH) LIMIT 1000'
2020-06-01 20:27:29,725 ERROR: SQL error: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '20:27:29, INTERVAL 1 MONTH) LIMIT 1000' at line 1")

From the mariadb docs for subdate, the syntax requires the date to be inbetween single quotes: https://mariadb.com/kb/en/subdate/

So the correct line would actually be:
where=${deleted_column} <= SUBDATE('{now}', INTERVAL ${retention})

Hello @dmsimard,

Thanks for pointing me this case. I will update the example config file accordingly.