-
Notifications
You must be signed in to change notification settings - Fork 33
PostgreSQL backend for Ocsipersist #99
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
Conversation
Can finally start implementing functions now, mostly copy from the sqlite3 backend probably.
0bf3664 to
8e5e467
Compare
e8b0e2b to
c962748
Compare
c962748 to
23b1bf7
Compare
| let open_store store = use_pool @@ fun db -> | ||
| create_table db store >> Lwt.return store | ||
|
|
||
| let make_persistent_lazy_lwt ~store ~name ~default = use_pool @@ fun db -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is racy. Another thread could insert into the table after the select and before we perform the insert ourself.
I think, the best we can do is to repeat the two following commands until one of them succeed (that is, until it returns a non-empty list).
SELECT value FROM %s WHERE key = $1;
INSERT INTO %s VALUES ($1, $2) ON CONFLICT (key) DO NOTHING RETURNING 0;
For compatibility with PostgreSQL < 9.5, we can probably replace the second command with the following one and catch the duplicate-key error:
INSERT INTO %s VALUES ($1, $2);
21e3795 to
8064c11
Compare
92f2e4a to
b0f08ea
Compare
7d39b76 to
1823669
Compare
| and depends on {{{ sqlite3.cma }}}). | ||
| {{{ ocsipersist-dbm.cma }}} (uses the DBM database); | ||
| {{{ ocsipersist-sqlite.cma }}} (uses the SQLite database | ||
| and depends on {{{ sqlite3.cma }}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't be better to point to the opam package name ... ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
No description provided.