Skip to content

Navigation Menu

Sign in
Sign up

Add MySQL support to River - #1227

Draft
brandur wants to merge 1 commit into
master from
brandur-river-mysql
Draft

Add MySQL support to River #1227
brandur wants to merge 1 commit into
master from
brandur-river-mysql

Conversation

@brandur

@brandur brandur commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Here, add a new driver rivermysql that brings MySQL support to River.

Similar to SQLite, it's unfortunately not quite as good as the Postgres
driver, but it does the job. MySQL has more facilities than SQLite, but
it's still missing some major niceties like RETURNING, which for many
queries requires us to write an implementation using two operations --
one that performs the action, and then another that loads back the
result using returned IDs. It also doesn't have listen/notify.

Luckily, like SQLite, any of this nastiness stays cordoned to the
driver layer and doesn't leak into the mainline River code. We've got
good driver testing and basic tests on clients for each driver in place
so we get reasonable assurance that everything works.

In the before times, I would've been fairly concerned at the additional
maintenance burden that supporting another database would bring, but
with the rise of LLMs I think it's more plausible that we can bring
something like this in without much trouble. Incredibly, I was able to
get almost all of this implemented in just one evening whereby my SQLite
driver took me multiple months.

I don't want to bring MySQL in as a hard dependency, so I've made the
MySQL tests disabled by default. Use RIVER_MYSQL_TESTS_ENABLED=true to
activate them. Only one CI matrix case runs MySQL tests so that we don't
have to repeat them to exhaustion on every version of Go and Postgres.

See also:
#158

brandur force-pushed the brandur-river-mysql branch 4 times, most recently from 0f7a847 to ec9be04 Compare April 24, 2026 06:05
brandur force-pushed the brandur-river-mysql branch 2 times, most recently from 29d0c9e to ff70405 Compare June 11, 2026 19:56

brandur commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased this one so it has a new Listener similar to the one added for SQLite in #1275. MySQL's is a bit more difficult because unlike SQLite, out of order transactions are possible so we can't just track lastID, but Codex found a nice trick involving FOR UPDATE that we can use, and was able to verify it works via test case.

Comment thread rivershared/sqlctemplate/sqlc_template.go Dismissed
Here, add a new driver `rivermysql` that brings MySQL support to River.
Similar to SQLite, it's unfortunately not quite as good as the Postgres
driver, but it does the job. MySQL has more facilities than SQLite, but
it's still missing some major niceties like `RETURNING`, which for many
queries requires us to write an implementation using two operations --
one that performs the action, and then another that loads back the
result using returned IDs. It also doesn't have listen/notify.
Luckily, _like_ SQLite, any of this nastiness stays cordoned to the
driver layer and doesn't leak into the mainline River code. We've got
good driver testing and basic tests on clients for each driver in place
so we get reasonable assurance that everything works.
In the before times, I would've been fairly concerned at the additional
maintenance burden that supporting another database would bring, but
with the rise of LLMs I think it's more plausible that we can bring
something like this in without much trouble. Incredibly, I was able to
get almost all of this implemented in just one evening whereby my SQLite
driver took me multiple months.
I don't want to bring MySQL in as a hard dependency, so I've made the
MySQL tests disabled by default. Use `RIVER_MYSQL_TESTS_ENABLED=true` to
activate them. Only one CI matrix case runs MySQL tests so that we don't
have to repeat them to exhaustion on every version of Go and Postgres.
See also:
#158 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@github-advanced-security github-advanced-security[bot] github-advanced-security[bot] left review comments
Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /