asyncer-io / r2dbc-mysql

Reactive Relational Database Connectivity for MySQL. The official successor to mirromutth/r2dbc-mysql(dev.miku:r2dbc-mysql).
https://r2dbc.io
Apache License 2.0
206 stars 21 forks source link

Support for r2dbc-spi's Optional Interface 'LifeCycle' #64

Closed jchrys closed 10 months ago

jchrys commented 1 year ago

While implementing r2dbc-spi, the interface 'LifeCycle' is optional and not mandated by the specification. However, we believe it is important to provide support for this interface as it can benefit minority use cases. You can refer to this link for more information: https://r2dbc.io/spec/1.0.0.RELEASE/spec/html/#lifecycle.

svats0001 commented 1 year ago

Hi @jchrys,

Do these interfaces need to be implemented anywhere or do they just need to be created? I think MySqlConnection has to implement Lifecycle. I don't think Wrapped needs to be implemented anywhere, it's up to the end user. Closeable might have to be implemented by MySqlConnectionFactory etc.

jchrys commented 1 year ago

You're absolutely right. There is no need to implement the Wrapped interface for MySqlConnection and MySqlConnectionFactory, as they are not wrappers. If, however, we come across a class that wraps an r2dbc-spi implementation, it would be advisable to implement Wrapped in that case.

mirromutth commented 10 months ago

The MySqlConnection should to do nothing in postAllocate, only contains one job in preRelease, which is to rollback if it is in a transaction.

Which means postAllocate will return an empty Mono, and preRelease will be an alias as rollbackTransaction.

mirromutth commented 10 months ago

Hmmm, I noticed that the COM_RESET_CONNECTION command, which should be more suitable as preRelease, it resets almost all state, including temporary tables, transactions, etc.

mirromutth commented 10 months ago

Forget it, it turns out that COM_RESET_CONNECTION is not a good solution.

This command not being supported in 5.6.x and below, it will also cause all prepared statements to be cleared.

jchrys commented 10 months ago

171 #175