Fix pgsql VACUUM ANALYZE syntax error #504
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi there - first off, thanks for SelfOSS! Still getting used to it but it's really nice to have a self-hosted RSS solution.
I noticed an error every five minutes or so in my postgres logs that I tracked down to daos/pgsql/Database.php. It's a syntax error in the VACUUM ANALYZE statement:
It turns out that pgsql doesn't let you use bound parameters to represent table names - the commit message explains it in greater detail.
An alternative implementation might be to just execute a list of VACUUM ANALYZE statements for the known set of tables (items, sources, version, tags); but I wasn't sure if you were dynamically getting the list of tables to help with maintenance. Another simpler alternative would be an unqualified VACUUM ANALYZE, which would just vacuum all the tables the db user has access to.
I'm not a Postgres expert so I opted for the solution that fixed the error while changing behavior as little as possible - if you'd like me to investigate any of the alternatives, let me know and I'll give it a shot.
Thanks!
-Ben