Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pgsql VACUUM ANALYZE syntax error #504

Merged
merged 1 commit into from
Apr 10, 2014
Merged

Conversation

snowyote
Copy link
Contributor

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:

2014-03-30 00:45:18 UTC ERROR:  syntax error at or near "$1" at character 16
2014-03-30 00:45:18 UTC STATEMENT:  VACUUM ANALYZE $1

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

Unfortunately, using a bound parameter for a table name (as opposed to a value) is not supported by PostgreSQL, so "VACUUM ANALYZE :table" is a syntax error.  We have to dynamically create this query.  See this thread for details:

http://www.postgresql.org/message-id/CAFj8pRD1Y4tpAzXeQR511+q8qJ9a5n4CpF=64HrudQtWRraZiw@mail.gmail.com

Since the parameter in this query is a table name in the database, any attacker would have to have create table privileges, so I don't consider this a SQL injection risk.
SSilence added a commit that referenced this pull request Apr 10, 2014
Fix pgsql VACUUM ANALYZE syntax error
@SSilence SSilence merged commit 043cc4d into fossar:master Apr 10, 2014
@jtojnar
Copy link
Member

jtojnar commented Nov 7, 2020

Hi @snowyote. Previously, it was not clear if selfoss was licensed under GPL 3 only, or also any later version. Could you clarify whether you are fine with licensing your contributions under GPL-3-or-later?

Thanks again and sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants