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
Murmur postgresql support #2541
Conversation
…t4-sql-psql' package in Debian) is required. To enable this feature, use the 'dbDriver=QPSQL' option in your 'mumble-server.ini'.
… current version of mumur. Change users table to have new column format. Change slog table to have a default value of "now()" for column msgtime as other databases use triggers to add this value. Revert database logging statement so that the timestamp is assigned by triggers or column default values.
Used place holder marks for PostgreSQL UPSERT values instead of positional binding since the statements require the values twice (once for the INSERT, and once for the UPDATE should the insert fail). The values to use for the ON CONFLICT DO UPDATE part of the UPSERT have been prefixed with u_ . This commit reverts to using REPLACE INTO for non-PostgreSQL databases and uses the same code for them as the upstream master mumble-voip/mumble. Previously this branch used the same code for all databases. This commit uses if statements to treat PostgreSQL differently from other databases where it needs to use UPSERT instead of REPLACE INTO.
Logic was removed due to issues raised in comment mumble-voip#2383 (comment) .
I made a mess of my old branch and the rebasing onto all the new commits seemed to make the commit sequence look weird. To fix that I made a new branch and manually did all the edits and commits in sequence. Hopefully all's well with this one. I think I've addressed most of the issues raised about the last pull request. The only things I'm not sure about are the lines I've closed #2383 as this is the new improved version. I noticed that most of the tables created by murmur in PostgreSQL don't actually have primary keys. It seems a bit odd. I was surprised that the UPSERT was working without the PKEYs being present, and that I didn't need to add a bunch of alter table statements in different places to add unique constraints to trigger the conflicts so that the UPSERT would update instead of insert duplicates like:
Seems the indexes served that purpose however as I didn't need to add the above bits to get it to work. |
Thanks a bunch for doing this. I haven't looked closely yet... Just a few drive-by comments.
I'd prefer
Hmmm. Seems odd. |
Yup == not != , copy and paste error in the comment :) Regarding the PKEYs on the tables, these tables have them:
And these do not:
Attached is a zip file containing text files with SQL commands which would result in same tables that murmur makes in PostgreSQL (I copied them from the table SQL pane in pgAdmin3) Edit: It seems the job of the PKey is kinda being done with unique indexes in those tables. |
Are there any more changes that need to be made? After this next week I'm not sure when I'll get the time to look at this again. |
Patch looks pretty good. @LuAPi It seems to me that as of the current PR, ::query() is now equivalent to ::exec(). |
@LuAPi BTW, did you mean this week? Or the upcoming week? I can make the change with query() -> exec() if we agree that it's OK. No problem. |
If you're suggesting replacing instances of SQLQUERY(x) with SQLDO(x) then that won't work. In PostgreSQL PREPARE may only appear before
https://www.postgresql.org/docs/9.5/static/sql-prepare.html I suppose it might be clearer if exec was renamed prepAndExec or something, and then query was renamed to exec. I meant this week, really just the next 5 days actually. |
My apologies. I missed the prepare difference between the two when I looked through. |
Thanks once again for making this mergable! :-) |
No problem. Thanks for the feedback with things to change. I just hope that there isn't something I missed when testing it that breaks something. |
This is the new and improved version of #2383 and addresses issue #2187
This pull request uses the UPSERT functionality of PostgreSQL. If QPSQL is chosen as the database engine in mumble-server.ini then the version of PostgreSQL used needs to be 9.5 or higher.
Key changes this pull request makes:
Example settings for mumble-server.ini to use PostgerSQL:
database=localdb
dbDriver=QPSQL
dbUsername=murmur
dbPassword=murmurpass
dbHost=localhost
dbPort=5432
dbPrefix=murmur_
These settings will cause murmur to try and connect to a PostgreSQL database called "localdb" on the server with the address "localhost" and port 5432.
It will connect using the username "murmur" and the password "murmurpass". All the tables and sequences automatically created used will have the prefix "murmur_".
If there is a schema with the same name as the user name then the murmur tables and sequences will be created in that schema (this is the default PostgreSQL behavior).