GeezerVison is showing github.com — Merge branch 'master' into master · jasync-sql/jasync-sql@c8313ef
File treeExpand file treeCollapse file tree Open diff view settings main/java/com/github/jasync/sql/db/mysql test/java/com/github/jasync/sql/db/mysql
r2dbc-mysql/src/main/java
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: CHANGELOG.md +6Lines changed: 6 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | * Switch to Java Date/Time API from Joda Time [#233](https://github.com/jasync-sql/jasync-sql/pull/233) | 6 | 6 | * For postgresql, add support for threeten.PeriodDuration for interval data type. [#233](https://github.com/jasync-sql/jasync-sql/pull/233) | 7 | 7 |
| | 8 | +## 1.2.3 | | 9 | + | | 10 | +* Enable CLIENT_FOUND_ROWS in r2dbc-mysql in favor of spring-data-r2dbc [#240](https://github.com/jasync-sql/jasync-sql/pull/240). | | 11 | +* Fix SSL Connection to MySQL [#237](https://github.com/jasync-sql/jasync-sql/pull/237). | | 12 | +* Add explicit dependency on kotlin-reflect. | | 13 | + | 8 | 14 | ## 1.2.1 | 9 | 15 |
| 10 | 16 | * Deploy directly to maven central [#232](https://github.com/jasync-sql/jasync-sql/pull/232). | |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/MySQLConnection.kt +11-4Lines changed: 11 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,8 +15,8 @@ import com.github.jasync.sql.db.mysql.codec.MySQLConnectionHandler | 15 | 15 | import com.github.jasync.sql.db.mysql.codec.MySQLHandlerDelegate | 16 | 16 | import com.github.jasync.sql.db.mysql.exceptions.MySQLException | 17 | 17 | import com.github.jasync.sql.db.mysql.message.client.AuthenticationSwitchResponse | | 18 | +import com.github.jasync.sql.db.mysql.message.client.CapabilityRequestMessage | 18 | 19 | import com.github.jasync.sql.db.mysql.message.client.HandshakeResponseMessage | 19 | | -import com.github.jasync.sql.db.mysql.message.client.SSLRequestMessage | 20 | 20 | import com.github.jasync.sql.db.mysql.message.server.AuthenticationSwitchRequest | 21 | 21 | import com.github.jasync.sql.db.mysql.message.server.EOFMessage | 22 | 22 | import com.github.jasync.sql.db.mysql.message.server.ErrorMessage | @@ -61,6 +61,7 @@ class MySQLConnection @JvmOverloads constructor( | 61 | 61 | @Suppress("unused") | 62 | 62 | val MicrosecondsVersion = Version(5, 6, 0) | 63 | 63 | private val regexForCallInQueryStart = Regex("\\s*call\\s+.*", RegexOption.IGNORE_CASE) | | 64 | + const val CLIENT_FOUND_ROWS_PROP_NAME = "jasync.mysql.CLIENT_FOUND_ROWS" | 64 | 65 | } | 65 | 66 |
| 66 | 67 | init { | @@ -262,8 +263,14 @@ class MySQLConnection @JvmOverloads constructor( | 262 | 263 | } | 263 | 264 | } | 264 | 265 |
| 265 | | - val sslRequest = SSLRequestMessage(setOfNotNull( | | 266 | + val clientFoundRows = System.getProperty(CLIENT_FOUND_ROWS_PROP_NAME) != null | | 267 | + if (clientFoundRows) { | | 268 | + logger.debug { "CLIENT_FOUND_ROWS capability set" } | | 269 | + } | | 270 | + | | 271 | + val capabilities = CapabilityRequestMessage(setOfNotNull( | 266 | 272 | CapabilityFlag.CLIENT_PLUGIN_AUTH, | | 273 | + CapabilityFlag.CLIENT_FOUND_ROWS.takeIf { clientFoundRows }, | 267 | 274 | CapabilityFlag.CLIENT_PROTOCOL_41, | 268 | 275 | CapabilityFlag.CLIENT_TRANSACTIONS, | 269 | 276 | CapabilityFlag.CLIENT_MULTI_RESULTS, | @@ -274,7 +281,7 @@ class MySQLConnection @JvmOverloads constructor( | 274 | 281 | )) | 275 | 282 |
| 276 | 283 | val handshakeResponse = HandshakeResponseMessage( | 277 | | - sslRequest, | | 284 | + capabilities, | 278 | 285 | configuration.username, | 279 | 286 | configuration.charset, | 280 | 287 | message.seed, | @@ -289,7 +296,7 @@ class MySQLConnection @JvmOverloads constructor( | 289 | 296 | return | 290 | 297 | } | 291 | 298 |
| 292 | | - val channelFuture = connectionHandler.write(sslRequest) | | 299 | + val channelFuture = connectionHandler.write(capabilities) | 293 | 300 | channelFuture.addListener { sslRequestFuture -> | 294 | 301 | // connectionHandler.write will handle errors (logging, failing promise, etc) in this case. | 295 | 302 | if (!sslRequestFuture.isSuccess) return@addListener | |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLConnectionHandler.kt +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,13 +5,13 @@ import com.github.jasync.sql.db.exceptions.DatabaseException | 5 | 5 | import com.github.jasync.sql.db.general.MutableResultSet | 6 | 6 | import com.github.jasync.sql.db.mysql.binary.BinaryRowDecoder | 7 | 7 | import com.github.jasync.sql.db.mysql.message.client.AuthenticationSwitchResponse | | 8 | +import com.github.jasync.sql.db.mysql.message.client.CapabilityRequestMessage | 8 | 9 | import com.github.jasync.sql.db.mysql.message.client.CloseStatementMessage | 9 | 10 | import com.github.jasync.sql.db.mysql.message.client.HandshakeResponseMessage | 10 | 11 | import com.github.jasync.sql.db.mysql.message.client.PreparedStatementExecuteMessage | 11 | 12 | import com.github.jasync.sql.db.mysql.message.client.PreparedStatementPrepareMessage | 12 | 13 | import com.github.jasync.sql.db.mysql.message.client.QueryMessage | 13 | 14 | import com.github.jasync.sql.db.mysql.message.client.QuitMessage | 14 | | -import com.github.jasync.sql.db.mysql.message.client.SSLRequestMessage | 15 | 15 | import com.github.jasync.sql.db.mysql.message.client.SendLongDataMessage | 16 | 16 | import com.github.jasync.sql.db.mysql.message.server.AuthenticationSwitchRequest | 17 | 17 | import com.github.jasync.sql.db.mysql.message.server.BinaryRowMessage | @@ -273,7 +273,7 @@ class MySQLConnectionHandler( | 273 | 273 | } | 274 | 274 | } | 275 | 275 |
| 276 | | - fun write(message: SSLRequestMessage): ChannelFuture = writeAndHandleError(message) | | 276 | + fun write(message: CapabilityRequestMessage): ChannelFuture = writeAndHandleError(message) | 277 | 277 |
| 278 | 278 | fun write(message: HandshakeResponseMessage): ChannelFuture { | 279 | 279 | decoder.hasDoneHandshake = true | |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ package com.github.jasync.sql.db.mysql.codec | 3 | 3 | import com.github.jasync.sql.db.exceptions.BufferNotFullyConsumedException | 4 | 4 | import com.github.jasync.sql.db.exceptions.NegativeMessageSizeException | 5 | 5 | import com.github.jasync.sql.db.exceptions.ParserNotAvailableException | | 6 | +import com.github.jasync.sql.db.mysql.decoder.AuthenticationSwitchRequestDecoder | 6 | 7 | import com.github.jasync.sql.db.mysql.decoder.ColumnDefinitionDecoder | 7 | 8 | import com.github.jasync.sql.db.mysql.decoder.ColumnProcessingFinishedDecoder | 8 | 9 | import com.github.jasync.sql.db.mysql.decoder.EOFMessageDecoder | @@ -39,6 +40,7 @@ class MySQLFrameDecoder(val charset: Charset, private val connectionId: String) | 39 | 40 | private val errorDecoder = ErrorDecoder(charset) | 40 | 41 | private val okDecoder = OkDecoder(charset) | 41 | 42 | private val columnDecoder = ColumnDefinitionDecoder(charset, DecoderRegistry(charset)) | | 43 | + private val authenticationSwitchRequestDecoder = AuthenticationSwitchRequestDecoder(charset) | 42 | 44 | private val rowDecoder = ResultSetRowDecoder() | 43 | 45 | private val preparedStatementPrepareDecoder = PreparedStatementPrepareResponseDecoder() | 44 | 46 |
| @@ -128,6 +130,8 @@ class MySQLFrameDecoder(val charset: Charset, private val connectionId: String) | 128 | 130 | if (this.processingColumns) { | 129 | 131 | this.processingColumns = false | 130 | 132 | ColumnProcessingFinishedDecoder | | 133 | + } else if (!isValidEOF(slice)) { | | 134 | + authenticationSwitchRequestDecoder | 131 | 135 | } else { | 132 | 136 | this.clear() | 133 | 137 | EOFMessageDecoder | @@ -169,6 +173,11 @@ class MySQLFrameDecoder(val charset: Charset, private val connectionId: String) | 169 | 173 | doDecoding(decoder, slice, out) | 170 | 174 | } | 171 | 175 |
| | 176 | + private fun isValidEOF(slice: ByteBuf): Boolean { | | 177 | + // see https://dev.mysql.com/doc/internals/en/packet-EOF_Packet.html | | 178 | + return slice.readableBytes() == 4 | | 179 | + } | | 180 | + | 172 | 181 | private fun doDecoding(decoder: MessageDecoder?, slice: ByteBuf, out: MutableList<Any>) { | 173 | 182 | if (decoder == null) { | 174 | 183 | slice.readerIndex(slice.readerIndex() - 1) | |
Collapse file Copy file name to clipboard +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +package com.github.jasync.sql.db.mysql.decoder | | 2 | + | | 3 | +import com.github.jasync.sql.db.mysql.message.server.AuthenticationSwitchRequest | | 4 | +import com.github.jasync.sql.db.mysql.message.server.ServerMessage | | 5 | +import com.github.jasync.sql.db.util.readCString | | 6 | +import io.netty.buffer.ByteBuf | | 7 | +import io.netty.buffer.ByteBufUtil | | 8 | +import java.nio.charset.Charset | | 9 | + | | 10 | +class AuthenticationSwitchRequestDecoder(val charset: Charset) : MessageDecoder { | | 11 | + override fun decode(buffer: ByteBuf): ServerMessage { | | 12 | + val method = buffer.readCString(charset) | | 13 | + val bytes: Int = buffer.readableBytes() | | 14 | + val terminal = 0.toByte() | | 15 | + val salt = if (bytes > 0 && buffer.getByte(buffer.writerIndex() - 1) == terminal) ByteBufUtil.getBytes( | | 16 | + buffer, | | 17 | + buffer.readerIndex(), | | 18 | + bytes - 1 | | 19 | + ) else ByteBufUtil.getBytes(buffer) | | 20 | + return AuthenticationSwitchRequest(method, salt) | | 21 | + } | | 22 | +} |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/AuthenticationSwitchResponseEncoder.kt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,7 +21,7 @@ class AuthenticationSwitchResponseEncoder(val charset: Charset) : MessageEncoder | 21 | 21 | val buffer = ByteBufferUtils.packetBuffer() | 22 | 22 |
| 23 | 23 | val bytes = | 24 | | - authenticator.generateAuthentication(charset, switch.password, switch.request.seed.toByteArray(charset)) | | 24 | + authenticator.generateAuthentication(charset, switch.password, switch.request.seed) | 25 | 25 | buffer.writeBytes(bytes) | 26 | 26 |
| 27 | 27 | return buffer | |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/SSLRequestEncoder.kt +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package com.github.jasync.sql.db.mysql.encoder | 2 | 2 |
| | 3 | +import com.github.jasync.sql.db.mysql.message.client.CapabilityRequestMessage | 3 | 4 | import com.github.jasync.sql.db.mysql.message.client.ClientMessage | 4 | | -import com.github.jasync.sql.db.mysql.message.client.SSLRequestMessage | 5 | 5 | import com.github.jasync.sql.db.mysql.util.CharsetMapper | 6 | 6 | import com.github.jasync.sql.db.util.ByteBufferUtils | 7 | 7 | import io.netty.buffer.ByteBuf | @@ -15,7 +15,7 @@ class SSLRequestEncoder(private val charset: Charset, private val charsetMapper: | 15 | 15 | } | 16 | 16 |
| 17 | 17 | override fun encode(message: ClientMessage): ByteBuf { | 18 | | - require(message is SSLRequestMessage) | | 18 | + require(message is CapabilityRequestMessage) | 19 | 19 | var clientCapabilities = 0 | 20 | 20 |
| 21 | 21 | for (flag in message.flags) { | |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/CapabilityRequestMessage.kt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,4 +2,4 @@ package com.github.jasync.sql.db.mysql.message.client | 2 | 2 |
| 3 | 3 | import com.github.jasync.sql.db.mysql.util.CapabilityFlag | 4 | 4 |
| 5 | | -data class SSLRequestMessage(val flags: Set<CapabilityFlag>) : ClientMessage(SslRequest) | | 5 | +data class CapabilityRequestMessage(val flags: Set<CapabilityFlag>) : ClientMessage(SslRequest) |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/HandshakeResponseMessage.kt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,7 @@ package com.github.jasync.sql.db.mysql.message.client | 3 | 3 | import java.nio.charset.Charset | 4 | 4 |
| 5 | 5 | data class HandshakeResponseMessage( | 6 | | - val header: SSLRequestMessage, | | 6 | + val header: CapabilityRequestMessage, | 7 | 7 | val username: String, | 8 | 8 | val charset: Charset, | 9 | 9 | @Suppress("ArrayInDataClass") | |
Collapse file Copy file name to clipboardExpand all lines: mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthenticationSwitchRequest.kt +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,5 +2,5 @@ package com.github.jasync.sql.db.mysql.message.server | 2 | 2 |
| 3 | 3 | data class AuthenticationSwitchRequest( | 4 | 4 | val method: String, | 5 | | - val seed: String | | 5 | + val seed: ByteArray | 6 | 6 | ) : ServerMessage(ServerMessage.EOF) |
|