Sometimes a small bug-fix can lead to an avalanche of Pull Requests

Sep 18, 2018 · 3 min read

TL;DR — mauricio/postgresql-async fixed a bug couple of years ago. It turns out that this bugfix caused a major performance regression, but it was never reverted. Now that we forked the lib to jasync-sql we decided to revert that fix.

It looks like an innocent bug —

“Error using NUMERIC columns with PreparedStatements in PostgreSQL”

With this fix:

But… Here come the problems…

It turns out that this fix was introducing large performance problems, and a lot of reverts were never merged:

So how do we proceed with that?

First, I reverted the fix in jasync-sql, seems like people were using the old behavior for many versions until 0.2.18 without issues.

There is also a mention that this edge case is not a best practice anyway: “The effect of reverting this change means that you cannot create a prepared statement using say integer types and then start passing doubles to it. Which would be a pretty dubious practice to do anyway!” (see here).

I think there can be found another solution, though I am not 100% sure yet. Maybe this one can solve it:

But I will have to check with tests to validate that.