Ticket #384 (fixed bug)
ReplaceQueries don't work properly with PostgreSQL
- Created: 2011-03-31 14:59:59
- Reported by: Reines
- Assigned to: Franz
- Milestone: 2.0-alpha1
- Component: database
- Priority: normal
PostgreSQL doesn't have an equivalent of REPLACE INTO. At the moment the query we have will only perform an insert if there isn't a matching row - but this isn't quite the same as it doesn't update any existing rows.
The consensus seems to be we need to use either multiple queries or a PL/pgSQL function - either way it is going to be messy.
Reines 2011-03-31 15:01:42
- Summary changed from ReplaceQueries don't work right with PostgreSQL to ReplaceQueries don't work properly with PostgreSQL.
Franz 2011-10-31 15:48:35
- Owner set to Franz.
Franz 2011-11-03 14:35:17
I found this answer on StackOverflow, which seems to be exactly what we want.
Unfortunately that means we will run two queries, but there is no other way. Also, we can pass them to the database in just one go, which means we'll get rid of the slowest part anyway, so things should be fine.
Franz 2011-11-03 23:20:27
Ok, I more or less fixed this now.
One problem remains, and that is concurrency: The current approach can lead to race conditions (though probably not in the use cases in FluxBB). There are ways to prevent this - is it worth it?
Franz 2011-11-07 13:56:40
- Status changed from open to fixed.
Well, I'll mark this as done.
At some point, we will probably have to revisit the concurrency issue.
daris 2011-11-07 18:03:58
It's not working as expected, see this:
Franz 2011-11-09 22:42:57
This was fixed by now.