From ac7a5fea6e471805663886c925831beed3d5ea67 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Fri, 6 Sep 2024 15:57:38 +1000 Subject: [PATCH 01/14] Added support for MariaDb extend type info --- .../io/asyncer/r2dbc/mysql/Capability.java | 15 +++++++++- .../r2dbc/mysql/MySqlColumnDescriptor.java | 8 +++-- .../r2dbc/mysql/MySqlTypeMetadata.java | 26 +++++++++++++--- .../mysql/api/MySqlNativeTypeMetadata.java | 7 +++++ .../r2dbc/mysql/constant/MySqlType.java | 2 +- .../server/DefinitionMetadataMessage.java | 30 ++++++++++++++----- .../r2dbc/mysql/MySqlRowDescriptorTest.java | 2 +- .../r2dbc/mysql/MySqlTypeMetadataTest.java | 23 +++++++++++--- 8 files changed, 91 insertions(+), 22 deletions(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java index 26299a08b..66560c3da 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java @@ -169,7 +169,11 @@ public final class Capability { // private static final long MARIADB_CLIENT_PROGRESS = 1L << 32; // private static final long MARIADB_CLIENT_COM_MULTI = 1L << 33; // private static final long MARIADB_CLIENT_STMT_BULK_OPERATIONS = 1L << 34; -// private static final long MARIADB_CLIENT_EXTENDED_TYPE_INFO = 1L << 35; + + /** + * Receive extended column type information from MariaDB to find out more specific details about column type. + */ + private static final long MARIADB_CLIENT_EXTENDED_TYPE_INFO = 1L << 35; // private static final long MARIADB_CLIENT_CACHE_METADATA = 1L << 36; private static final long ALL_SUPPORTED = CLIENT_MYSQL | FOUND_ROWS | LONG_FLAG | CONNECT_WITH_DB | @@ -309,6 +313,15 @@ public boolean isZlibCompression() { public boolean isZstdCompression() { return (bitmap & ZSTD_COMPRESS) != 0; } + + /** + * Checks if MariaDB extended type info enabled. + * + * @return if MariaDB extended type info enabled. + */ + public boolean isExtendedTypeInfo() { + return (bitmap & MARIADB_CLIENT_EXTENDED_TYPE_INFO) != 0; + } /** * Extends MariaDB capabilities. diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlColumnDescriptor.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlColumnDescriptor.java index 8f8d2e9e0..4817518ad 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlColumnDescriptor.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlColumnDescriptor.java @@ -23,6 +23,8 @@ import io.asyncer.r2dbc.mysql.constant.MySqlType; import io.asyncer.r2dbc.mysql.message.server.DefinitionMetadataMessage; import io.r2dbc.spi.Nullability; + +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; import static io.asyncer.r2dbc.mysql.internal.util.AssertUtils.require; @@ -53,13 +55,13 @@ final class MySqlColumnDescriptor implements MySqlColumnMetadata { @VisibleForTesting MySqlColumnDescriptor(int index, short typeId, String name, int definitions, - long size, int decimals, int collationId) { + long size, int decimals, int collationId, @Nullable String extendedTypeInfo) { require(index >= 0, "index must not be a negative integer"); require(size >= 0, "size must not be a negative integer"); require(decimals >= 0, "decimals must not be a negative integer"); requireNonNull(name, "name must not be null"); - MySqlTypeMetadata typeMetadata = new MySqlTypeMetadata(typeId, definitions, collationId); + MySqlTypeMetadata typeMetadata = new MySqlTypeMetadata(typeId, definitions, collationId, extendedTypeInfo); this.index = index; this.typeMetadata = typeMetadata; @@ -74,7 +76,7 @@ final class MySqlColumnDescriptor implements MySqlColumnMetadata { static MySqlColumnDescriptor create(int index, DefinitionMetadataMessage message) { int definitions = message.getDefinitions(); return new MySqlColumnDescriptor(index, message.getTypeId(), message.getColumn(), definitions, - message.getSize(), message.getDecimals(), message.getCollationId()); + message.getSize(), message.getDecimals(), message.getCollationId(), message.getExtendedTypeInfo()); } int getIndex() { diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java index 9217367fa..9d5d4de1e 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java @@ -16,6 +16,10 @@ package io.asyncer.r2dbc.mysql; +import java.util.Objects; + +import org.jetbrains.annotations.Nullable; + import io.asyncer.r2dbc.mysql.api.MySqlNativeTypeMetadata; import io.asyncer.r2dbc.mysql.collation.CharCollation; @@ -64,11 +68,18 @@ final class MySqlTypeMetadata implements MySqlNativeTypeMetadata { * collationId > 0 when protocol version == 4.1, 0 otherwise. */ private final int collationId; + + /** + * The MariaDB extended type info field that provides more specific details about column type. + */ + @Nullable + private final String extendedTypeInfo; - MySqlTypeMetadata(int typeId, int definitions, int collationId) { + MySqlTypeMetadata(int typeId, int definitions, int collationId, @Nullable String extendedTypeInfo) { this.typeId = typeId; this.definitions = (short) (definitions & ALL_USED); this.collationId = collationId; + this.extendedTypeInfo = extendedTypeInfo; } @Override @@ -105,6 +116,11 @@ public boolean isEnum() { public boolean isSet() { return (definitions & SET) != 0; } + + @Override + public boolean isMariaDbJson() { + return extendedTypeInfo.equals("json"); + } @Override public boolean equals(Object o) { @@ -117,20 +133,22 @@ public boolean equals(Object o) { MySqlTypeMetadata that = (MySqlTypeMetadata) o; - return typeId == that.typeId && definitions == that.definitions && collationId == that.collationId; + return typeId == that.typeId && definitions == that.definitions && collationId == that.collationId && + Objects.equals(extendedTypeInfo, that.extendedTypeInfo); } @Override public int hashCode() { int result = 31 * typeId + (int) definitions; - return 31 * result + collationId; + return 31 * result + collationId + extendedTypeInfo.hashCode(); } @Override public String toString() { return "MySqlTypeMetadata{typeId=" + typeId + ", definitions=0x" + Integer.toHexString(definitions) + - ", collationId=" + collationId + + ", collationId=" + collationId + + ", extendedTypeInfo=" + extendedTypeInfo + '}'; } } diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java index adb9533a3..f739a5911 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java @@ -71,4 +71,11 @@ public interface MySqlNativeTypeMetadata { * @return if value is a set */ boolean isSet(); + + /** + * Checks if value is JSON for MariaDb. + * + * @return if value is a JSON for MariaDb + */ + boolean isMariaDbJson(); } diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/constant/MySqlType.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/constant/MySqlType.java index 2485d897b..36017786a 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/constant/MySqlType.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/constant/MySqlType.java @@ -712,7 +712,7 @@ public static MySqlType of(MySqlNativeTypeMetadata metadata) { case ID_VARCHAR: case ID_VAR_STRING: case ID_STRING: - return metadata.isBinary() ? VARBINARY : VARCHAR; + return metadata.isBinary() ? VARBINARY : (metadata.isMariaDbJson() ? JSON : VARCHAR); case ID_BIT: return BIT; case ID_JSON: diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index b4a9d9fdd..36c03d761 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -45,6 +45,9 @@ public final class DefinitionMetadataMessage implements ServerMessage { @Nullable private final String originColumn; + + @Nullable + private final String extendedTypeInfo; private final int collationId; @@ -57,7 +60,7 @@ public final class DefinitionMetadataMessage implements ServerMessage { private final short decimals; private DefinitionMetadataMessage(@Nullable String database, String table, @Nullable String originTable, - String column, @Nullable String originColumn, int collationId, long size, short typeId, + String column, @Nullable String originColumn, @Nullable String extendedTypeInfo, int collationId, long size, short typeId, int definitions, short decimals) { require(size >= 0, "size must not be a negative integer"); @@ -66,6 +69,7 @@ private DefinitionMetadataMessage(@Nullable String database, String table, @Null this.originTable = originTable; this.column = requireNonNull(column, "column must not be null"); this.originColumn = originColumn; + this.extendedTypeInfo = extendedTypeInfo; this.collationId = collationId; this.size = size; this.typeId = typeId; @@ -96,6 +100,10 @@ public int getDefinitions() { public short getDecimals() { return decimals; } + + public String getExtendedTypeInfo() { + return extendedTypeInfo; + } @Override public boolean equals(Object o) { @@ -115,21 +123,22 @@ public boolean equals(Object o) { table.equals(that.table) && Objects.equals(originTable, that.originTable) && column.equals(that.column) && - Objects.equals(originColumn, that.originColumn); + Objects.equals(originColumn, that.originColumn) && + Objects.equals(extendedTypeInfo, that.extendedTypeInfo); } @Override public int hashCode() { return Objects.hash(database, table, originTable, column, originColumn, collationId, size, typeId, - definitions, decimals); + definitions, decimals, extendedTypeInfo); } @Override public String toString() { return "DefinitionMetadataMessage{database='" + database + "', table='" + table + "' (origin:'" + - originTable + "'), column='" + column + "' (origin:'" + originColumn + "'), collationId=" + - collationId + ", size=" + size + ", type=" + typeId + ", definitions=" + definitions + - ", decimals=" + decimals + '}'; + originTable + "'), column='" + column + "' (origin:'" + originColumn + "'), extendedTypeInfo=" + + extendedTypeInfo + ", collationId=" +collationId + ", size=" + size + ", type=" + typeId + + ", definitions=" + definitions + ", decimals=" + decimals + '}'; } static DefinitionMetadataMessage decode(ByteBuf buf, ConnectionContext context) { @@ -156,7 +165,7 @@ private static DefinitionMetadataMessage decode320(ByteBuf buf, ConnectionContex int definitions = buf.readUnsignedShortLE(); short decimals = buf.readUnsignedByte(); - return new DefinitionMetadataMessage(null, table, null, column, null, 0, size, typeId, + return new DefinitionMetadataMessage(null, table, null, column, null, null, 0, size, typeId, definitions, decimals); } @@ -170,6 +179,11 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String originTable = readVarIntSizedString(buf, charset); String column = readVarIntSizedString(buf, charset); String originColumn = readVarIntSizedString(buf, charset); + + String extendTypeInfo = null; + if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { + extendTypeInfo = readVarIntSizedString(buf, charset); + } // Skip constant 0x0c encoded by var integer VarIntUtils.readVarInt(buf); @@ -179,7 +193,7 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext short typeId = buf.readUnsignedByte(); int definitions = buf.readUnsignedShortLE(); - return new DefinitionMetadataMessage(database, table, originTable, column, originColumn, collationId, + return new DefinitionMetadataMessage(database, table, originTable, column, originColumn, extendTypeInfo, collationId, size, typeId, definitions, buf.readUnsignedByte()); } diff --git a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlRowDescriptorTest.java b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlRowDescriptorTest.java index aceff07ad..31e602d83 100644 --- a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlRowDescriptorTest.java +++ b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlRowDescriptorTest.java @@ -56,7 +56,7 @@ private static MySqlRowDescriptor create(final String... names) { MySqlColumnDescriptor[] metadata = new MySqlColumnDescriptor[names.length]; for (int i = 0; i < names.length; ++i) { metadata[i] = - new MySqlColumnDescriptor(i, (short) 0, names[i], 0, 0, 0, 1); + new MySqlColumnDescriptor(i, (short) 0, names[i], 0, 0, 0, 1, null); } return new MySqlRowDescriptor(metadata); } diff --git a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadataTest.java b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadataTest.java index 0edff7805..23a831103 100644 --- a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadataTest.java +++ b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadataTest.java @@ -17,6 +17,8 @@ package io.asyncer.r2dbc.mysql; import io.asyncer.r2dbc.mysql.collation.CharCollation; +import io.asyncer.r2dbc.mysql.constant.MySqlType; + import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -28,7 +30,7 @@ class MySqlTypeMetadataTest { @Test void allSet() { - MySqlTypeMetadata metadata = new MySqlTypeMetadata(0, -1, 0); + MySqlTypeMetadata metadata = new MySqlTypeMetadata(0, -1, 0, null); assertThat(metadata.isBinary()).isTrue(); assertThat(metadata.isSet()).isTrue(); @@ -39,7 +41,7 @@ void allSet() { @Test void noSet() { - MySqlTypeMetadata metadata = new MySqlTypeMetadata(0, 0, 0); + MySqlTypeMetadata metadata = new MySqlTypeMetadata(0, 0, 0, null); assertThat(metadata.isBinary()).isFalse(); assertThat(metadata.isSet()).isFalse(); @@ -50,11 +52,24 @@ void noSet() { @Test void isBinaryUsesCollationId() { - MySqlTypeMetadata metadata = new MySqlTypeMetadata(0, -1, CharCollation.BINARY_ID); + MySqlTypeMetadata metadata = new MySqlTypeMetadata(0, -1, CharCollation.BINARY_ID, null); assertThat(metadata.isBinary()).isTrue(); - metadata = new MySqlTypeMetadata(0, -1, 33); + metadata = new MySqlTypeMetadata(0, -1, 33, null); assertThat(metadata.isBinary()).isFalse(); } + + @Test + void mariaDbJsonReturnsCorrectMySqlType() { + MySqlTypeMetadata metadata = new MySqlTypeMetadata(254, 0, 0, "json"); + + assertThat(metadata.isMariaDbJson()).isTrue(); + assertThat(MySqlType.of(metadata)).isEqualTo(MySqlType.JSON); + + metadata = new MySqlTypeMetadata(254, 0 ,0 , null); + + assertThat(metadata.isMariaDbJson()).isFalse(); + assertThat(MySqlType.of(metadata)).isEqualTo(MySqlType.VARCHAR); + } } From cc72c61dd870c240e21737d0f4fbf9e9b18cad68 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Thu, 26 Sep 2024 16:46:51 +1000 Subject: [PATCH 02/14] MariaDb extended type info changes --- .../io/asyncer/r2dbc/mysql/Capability.java | 19 ++++++++--- .../r2dbc/mysql/MySqlTypeMetadata.java | 19 ++++++----- .../mysql/api/MySqlNativeTypeMetadata.java | 4 +-- .../server/DefinitionMetadataMessage.java | 25 +++++++------- .../mysql/MariaDbIntegrationTestSupport.java | 34 +++++++++++++++++++ 5 files changed, 74 insertions(+), 27 deletions(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java index 66560c3da..dba877183 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java @@ -169,7 +169,7 @@ public final class Capability { // private static final long MARIADB_CLIENT_PROGRESS = 1L << 32; // private static final long MARIADB_CLIENT_COM_MULTI = 1L << 33; // private static final long MARIADB_CLIENT_STMT_BULK_OPERATIONS = 1L << 34; - + /** * Receive extended column type information from MariaDB to find out more specific details about column type. */ @@ -181,11 +181,22 @@ public final class Capability { TRANSACTIONS | SECURE_SALT | MULTI_STATEMENTS | MULTI_RESULTS | PS_MULTI_RESULTS | PLUGIN_AUTH | CONNECT_ATTRS | VAR_INT_SIZED_AUTH | SESSION_TRACK | DEPRECATE_EOF | ZSTD_COMPRESS; + private static final long ALL_SUPPORTED_MARIADB = FOUND_ROWS | LONG_FLAG | CONNECT_WITH_DB | + NO_SCHEMA | COMPRESS | LOCAL_FILES | IGNORE_SPACE | PROTOCOL_41 | INTERACTIVE | SSL | + TRANSACTIONS | SECURE_SALT | MULTI_STATEMENTS | MULTI_RESULTS | PS_MULTI_RESULTS | PLUGIN_AUTH | + CONNECT_ATTRS | VAR_INT_SIZED_AUTH | SESSION_TRACK | DEPRECATE_EOF | ZSTD_COMPRESS | + MARIADB_CLIENT_EXTENDED_TYPE_INFO; + /** * The default capabilities for a MySQL connection. It contains all client supported capabilities. */ public static final Capability DEFAULT = new Capability(ALL_SUPPORTED); + /** + * The default capabilities for a MariaDB connection. It contains all client supported capabilities. + */ + public static final Capability DEFAULT_MARIADB = new Capability(ALL_SUPPORTED_MARIADB); + private final long bitmap; /** @@ -313,14 +324,14 @@ public boolean isZlibCompression() { public boolean isZstdCompression() { return (bitmap & ZSTD_COMPRESS) != 0; } - + /** * Checks if MariaDB extended type info enabled. - * + * * @return if MariaDB extended type info enabled. */ public boolean isExtendedTypeInfo() { - return (bitmap & MARIADB_CLIENT_EXTENDED_TYPE_INFO) != 0; + return (bitmap & MARIADB_CLIENT_EXTENDED_TYPE_INFO) != 0; } /** diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java index 9d5d4de1e..126ad55be 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlTypeMetadata.java @@ -68,7 +68,7 @@ final class MySqlTypeMetadata implements MySqlNativeTypeMetadata { * collationId > 0 when protocol version == 4.1, 0 otherwise. */ private final int collationId; - + /** * The MariaDB extended type info field that provides more specific details about column type. */ @@ -116,10 +116,10 @@ public boolean isEnum() { public boolean isSet() { return (definitions & SET) != 0; } - + @Override public boolean isMariaDbJson() { - return extendedTypeInfo.equals("json"); + return (extendedTypeInfo == null ? false : extendedTypeInfo.equals("json")); } @Override @@ -133,22 +133,23 @@ public boolean equals(Object o) { MySqlTypeMetadata that = (MySqlTypeMetadata) o; - return typeId == that.typeId && definitions == that.definitions && collationId == that.collationId && - Objects.equals(extendedTypeInfo, that.extendedTypeInfo); + return typeId == that.typeId && definitions == that.definitions && collationId == that.collationId && + Objects.equals(extendedTypeInfo, that.extendedTypeInfo); } @Override public int hashCode() { int result = 31 * typeId + (int) definitions; - return 31 * result + collationId + extendedTypeInfo.hashCode(); + result = 31 * result + collationId; + return 31 * result + (extendedTypeInfo == null ? 0 : extendedTypeInfo.hashCode()); } @Override public String toString() { return "MySqlTypeMetadata{typeId=" + typeId + ", definitions=0x" + Integer.toHexString(definitions) + - ", collationId=" + collationId + - ", extendedTypeInfo=" + extendedTypeInfo + - '}'; + ", collationId=" + collationId + + ", extendedTypeInfo='" + extendedTypeInfo + + "'}"; } } diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java index f739a5911..c5e63e72b 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/api/MySqlNativeTypeMetadata.java @@ -71,10 +71,10 @@ public interface MySqlNativeTypeMetadata { * @return if value is a set */ boolean isSet(); - + /** * Checks if value is JSON for MariaDb. - * + * * @return if value is a JSON for MariaDb */ boolean isMariaDbJson(); diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index 36c03d761..65f80149d 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -45,7 +45,7 @@ public final class DefinitionMetadataMessage implements ServerMessage { @Nullable private final String originColumn; - + @Nullable private final String extendedTypeInfo; @@ -60,8 +60,8 @@ public final class DefinitionMetadataMessage implements ServerMessage { private final short decimals; private DefinitionMetadataMessage(@Nullable String database, String table, @Nullable String originTable, - String column, @Nullable String originColumn, @Nullable String extendedTypeInfo, int collationId, long size, short typeId, - int definitions, short decimals) { + String column, @Nullable String originColumn, @Nullable String extendedTypeInfo, int collationId, + long size, short typeId, int definitions, short decimals) { require(size >= 0, "size must not be a negative integer"); this.database = database; @@ -100,9 +100,10 @@ public int getDefinitions() { public short getDecimals() { return decimals; } - + + @Nullable public String getExtendedTypeInfo() { - return extendedTypeInfo; + return extendedTypeInfo; } @Override @@ -136,9 +137,9 @@ public int hashCode() { @Override public String toString() { return "DefinitionMetadataMessage{database='" + database + "', table='" + table + "' (origin:'" + - originTable + "'), column='" + column + "' (origin:'" + originColumn + "'), extendedTypeInfo=" + - extendedTypeInfo + ", collationId=" +collationId + ", size=" + size + ", type=" + typeId + - ", definitions=" + definitions + ", decimals=" + decimals + '}'; + originTable + "'), column='" + column + "' (origin:'" + originColumn + "'), extendedTypeInfo='" + + extendedTypeInfo + "', collationId=" + collationId + ", size=" + size + ", type=" + typeId + + ", definitions=" + definitions + ", decimals=" + decimals + '}'; } static DefinitionMetadataMessage decode(ByteBuf buf, ConnectionContext context) { @@ -179,10 +180,10 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String originTable = readVarIntSizedString(buf, charset); String column = readVarIntSizedString(buf, charset); String originColumn = readVarIntSizedString(buf, charset); - + String extendTypeInfo = null; if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { - extendTypeInfo = readVarIntSizedString(buf, charset); + extendTypeInfo = readVarIntSizedString(buf, charset); } // Skip constant 0x0c encoded by var integer @@ -193,8 +194,8 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext short typeId = buf.readUnsignedByte(); int definitions = buf.readUnsignedShortLE(); - return new DefinitionMetadataMessage(database, table, originTable, column, originColumn, extendTypeInfo, collationId, - size, typeId, definitions, buf.readUnsignedByte()); + return new DefinitionMetadataMessage(database, table, originTable, column, originColumn, + extendTypeInfo, collationId, size, typeId, definitions, buf.readUnsignedByte()); } private static String readVarIntSizedString(ByteBuf buf, Charset charset) { diff --git a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java index 00d192de3..50155494c 100644 --- a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java +++ b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java @@ -16,8 +16,14 @@ package io.asyncer.r2dbc.mysql; +import io.asyncer.r2dbc.mysql.api.MySqlColumnMetadata; import io.asyncer.r2dbc.mysql.api.MySqlConnection; +import io.asyncer.r2dbc.mysql.api.MySqlRow; +import io.asyncer.r2dbc.mysql.api.MySqlRowMetadata; import io.r2dbc.spi.Readable; +import io.r2dbc.spi.Row; +import io.r2dbc.spi.RowMetadata; + import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; @@ -141,6 +147,22 @@ void returningGetRowUpdated() { .doOnNext(it -> assertThat(it).isEqualTo(2))); } + @Test + void returningExtendedTypeInfoJson() { + complete(conn -> changeCapability(conn).createStatement("CREATE TEMPORARY TABLE test(" + + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value JSON NOT NULL)") + .execute() + .flatMap(IntegrationTestSupport::extractRowsUpdated) + .thenMany(conn.createStatement("INSERT INTO test(value) VALUES (?)") + .bind(0, "'{\"abc\": 123}'") + .returnGeneratedValues() + .execute()) + .flatMap(result -> result.map(DataEntity::readExtendedTypeInfoResult)) + .collectList() + .doOnNext(list -> assertThat(list.get(0)).isEqualTo(true)) + ); + } + private static Mono assertWithSelectAll(MySqlConnection conn, Mono> returning) { return returning.zipWhen(list -> conn.createStatement("SELECT * FROM test WHERE id IN (?,?,?,?,?)") .bind(0, list.get(0).getId()) @@ -171,6 +193,12 @@ private static Mono assertWithoutCreatedAt(MySqlConnection conn, Mono Date: Tue, 1 Oct 2024 13:21:56 +1000 Subject: [PATCH 03/14] Altered DefinitionMetadataMessage --- .../r2dbc/mysql/message/server/DefinitionMetadataMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index 65f80149d..fa8c4c160 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -183,6 +183,7 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String extendTypeInfo = null; if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { + buf.readUnsignedByte(); extendTypeInfo = readVarIntSizedString(buf, charset); } From 14fedd30648a78ba3682e3ee8789436b28986985 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Tue, 1 Oct 2024 13:31:02 +1000 Subject: [PATCH 04/14] Added enabledif to integration test --- .../io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java index 50155494c..94130bfa3 100644 --- a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java +++ b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java @@ -25,6 +25,8 @@ import io.r2dbc.spi.RowMetadata; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIf; + import reactor.core.publisher.Mono; import java.time.Instant; @@ -148,6 +150,7 @@ void returningGetRowUpdated() { } @Test + @EnabledIf("envIsMariaDb10_5_1") void returningExtendedTypeInfoJson() { complete(conn -> changeCapability(conn).createStatement("CREATE TEMPORARY TABLE test(" + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value JSON NOT NULL)") From 518c1c5801516a4a6d8495290f8752710d7c39c2 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Wed, 2 Oct 2024 16:14:21 +1000 Subject: [PATCH 05/14] Testing decode --- .../r2dbc/mysql/message/server/DefinitionMetadataMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index fa8c4c160..8d3ca89e1 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -175,6 +175,7 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext CharCollation collation = context.getClientCollation(); Charset charset = collation.getCharset(); + System.out.println("Buffer val: " + buf.toString(charset)); String database = readVarIntSizedString(buf, charset); String table = readVarIntSizedString(buf, charset); String originTable = readVarIntSizedString(buf, charset); From 088f8f66bfca1d2141f2a563aa686c5393953c52 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Wed, 2 Oct 2024 16:23:03 +1000 Subject: [PATCH 06/14] Testing decode --- .../r2dbc/mysql/message/server/DefinitionMetadataMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index 8d3ca89e1..6ed604a8d 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -175,7 +175,7 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext CharCollation collation = context.getClientCollation(); Charset charset = collation.getCharset(); - System.out.println("Buffer val: " + buf.toString(charset)); + System.out.println("Buffer val: " + buf); String database = readVarIntSizedString(buf, charset); String table = readVarIntSizedString(buf, charset); String originTable = readVarIntSizedString(buf, charset); From 567dc8d92736a32eaed56963fbd5cc3aa53b12ad Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Wed, 2 Oct 2024 16:53:43 +1000 Subject: [PATCH 07/14] Changed decode41 --- .../message/server/DefinitionMetadataMessage.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index 6ed604a8d..dac73898a 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -175,7 +175,6 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext CharCollation collation = context.getClientCollation(); Charset charset = collation.getCharset(); - System.out.println("Buffer val: " + buf); String database = readVarIntSizedString(buf, charset); String table = readVarIntSizedString(buf, charset); String originTable = readVarIntSizedString(buf, charset); @@ -184,8 +183,13 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String extendTypeInfo = null; if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { - buf.readUnsignedByte(); - extendTypeInfo = readVarIntSizedString(buf, charset); + buf.markReaderIndex(); + short extendedTypeInfoDataType = buf.readUnsignedByte(); + if (extendedTypeInfoDataType == 0 || extendedTypeInfoDataType == 1) { + extendTypeInfo = readVarIntSizedString(buf, charset); + } else { + buf.resetReaderIndex(); + } } // Skip constant 0x0c encoded by var integer From 4ff52dcfbf61349bd69795ec36b85cda135d12da Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Wed, 2 Oct 2024 17:13:30 +1000 Subject: [PATCH 08/14] Changed integration test --- .../io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java index 94130bfa3..65864b354 100644 --- a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java +++ b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java @@ -157,7 +157,7 @@ void returningExtendedTypeInfoJson() { .execute() .flatMap(IntegrationTestSupport::extractRowsUpdated) .thenMany(conn.createStatement("INSERT INTO test(value) VALUES (?)") - .bind(0, "'{\"abc\": 123}'") + .bind(0, "{\"abc\": 123}") .returnGeneratedValues() .execute()) .flatMap(result -> result.map(DataEntity::readExtendedTypeInfoResult)) From b05d64c0e79cef146aafd395f00d38f3861fe9c9 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Wed, 9 Oct 2024 18:44:18 +1100 Subject: [PATCH 09/14] Fixed integration test --- .../java/io/asyncer/r2dbc/mysql/Capability.java | 11 ----------- .../message/server/DefinitionMetadataMessage.java | 9 ++------- .../mysql/MariaDbIntegrationTestSupport.java | 15 +++++++++------ 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java index dba877183..aa8a435e9 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java @@ -181,22 +181,11 @@ public final class Capability { TRANSACTIONS | SECURE_SALT | MULTI_STATEMENTS | MULTI_RESULTS | PS_MULTI_RESULTS | PLUGIN_AUTH | CONNECT_ATTRS | VAR_INT_SIZED_AUTH | SESSION_TRACK | DEPRECATE_EOF | ZSTD_COMPRESS; - private static final long ALL_SUPPORTED_MARIADB = FOUND_ROWS | LONG_FLAG | CONNECT_WITH_DB | - NO_SCHEMA | COMPRESS | LOCAL_FILES | IGNORE_SPACE | PROTOCOL_41 | INTERACTIVE | SSL | - TRANSACTIONS | SECURE_SALT | MULTI_STATEMENTS | MULTI_RESULTS | PS_MULTI_RESULTS | PLUGIN_AUTH | - CONNECT_ATTRS | VAR_INT_SIZED_AUTH | SESSION_TRACK | DEPRECATE_EOF | ZSTD_COMPRESS | - MARIADB_CLIENT_EXTENDED_TYPE_INFO; - /** * The default capabilities for a MySQL connection. It contains all client supported capabilities. */ public static final Capability DEFAULT = new Capability(ALL_SUPPORTED); - /** - * The default capabilities for a MariaDB connection. It contains all client supported capabilities. - */ - public static final Capability DEFAULT_MARIADB = new Capability(ALL_SUPPORTED_MARIADB); - private final long bitmap; /** diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index dac73898a..fa8c4c160 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -183,13 +183,8 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String extendTypeInfo = null; if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { - buf.markReaderIndex(); - short extendedTypeInfoDataType = buf.readUnsignedByte(); - if (extendedTypeInfoDataType == 0 || extendedTypeInfoDataType == 1) { - extendTypeInfo = readVarIntSizedString(buf, charset); - } else { - buf.resetReaderIndex(); - } + buf.readUnsignedByte(); + extendTypeInfo = readVarIntSizedString(buf, charset); } // Skip constant 0x0c encoded by var integer diff --git a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java index 65864b354..33bab9acf 100644 --- a/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java +++ b/r2dbc-mysql/src/test/java/io/asyncer/r2dbc/mysql/MariaDbIntegrationTestSupport.java @@ -152,7 +152,7 @@ void returningGetRowUpdated() { @Test @EnabledIf("envIsMariaDb10_5_1") void returningExtendedTypeInfoJson() { - complete(conn -> changeCapability(conn).createStatement("CREATE TEMPORARY TABLE test(" + + complete(conn -> conn.createStatement("CREATE TEMPORARY TABLE test(" + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, value JSON NOT NULL)") .execute() .flatMap(IntegrationTestSupport::extractRowsUpdated) @@ -162,7 +162,7 @@ void returningExtendedTypeInfoJson() { .execute()) .flatMap(result -> result.map(DataEntity::readExtendedTypeInfoResult)) .collectList() - .doOnNext(list -> assertThat(list.get(0)).isEqualTo(true)) + .doOnNext(list -> assertIfExtendedTypeInfoEnabled(conn, list)) ); } @@ -196,10 +196,13 @@ private static Mono assertWithoutCreatedAt(MySqlConnection conn, Mono list) { + boolean enabled = ((MySqlSimpleConnection)conn).context().getCapability().isExtendedTypeInfo(); + if (enabled) { + assertThat(list.get(0)).isEqualTo(true); + } else { + assertThat(list.get(0)).isEqualTo(false); + } } private static final class DataEntity { From 6211e5726d458d468579220d12753373a87f8c1b Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Mon, 14 Oct 2024 13:43:15 +1100 Subject: [PATCH 10/14] Testing capability --- .../src/main/java/io/asyncer/r2dbc/mysql/Capability.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java index aa8a435e9..646f866d0 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/Capability.java @@ -179,7 +179,8 @@ public final class Capability { private static final long ALL_SUPPORTED = CLIENT_MYSQL | FOUND_ROWS | LONG_FLAG | CONNECT_WITH_DB | NO_SCHEMA | COMPRESS | LOCAL_FILES | IGNORE_SPACE | PROTOCOL_41 | INTERACTIVE | SSL | TRANSACTIONS | SECURE_SALT | MULTI_STATEMENTS | MULTI_RESULTS | PS_MULTI_RESULTS | - PLUGIN_AUTH | CONNECT_ATTRS | VAR_INT_SIZED_AUTH | SESSION_TRACK | DEPRECATE_EOF | ZSTD_COMPRESS; + PLUGIN_AUTH | CONNECT_ATTRS | VAR_INT_SIZED_AUTH | SESSION_TRACK | DEPRECATE_EOF | ZSTD_COMPRESS | + MARIADB_CLIENT_EXTENDED_TYPE_INFO; /** * The default capabilities for a MySQL connection. It contains all client supported capabilities. From a5750a92da5eedf025f087ee7d6a6469ce26b8eb Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Tue, 15 Oct 2024 13:13:20 +1100 Subject: [PATCH 11/14] Added 11.5.2 to ci-mariadb-integration --- .github/workflows/ci-mariadb-intergration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mariadb-intergration-tests.yml b/.github/workflows/ci-mariadb-intergration-tests.yml index d20bba01a..be9a11bf2 100644 --- a/.github/workflows/ci-mariadb-intergration-tests.yml +++ b/.github/workflows/ci-mariadb-intergration-tests.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - mariadb-version: [ 10.0, 10.1, 10.2.15, 10.2, 10.3.7, 10.3, 10.5.1, 10.5, 10.6, 10.11] + mariadb-version: [ 10.0, 10.1, 10.2.15, 10.2, 10.3.7, 10.3, 10.5.1, 10.5, 10.6, 10.11, 11.5.2] name: Integration test with MariaDB ${{ matrix.mariadb-version }} steps: - uses: actions/checkout@v3 From c7bece45d908b03b77a6948194e6c0510525c4b9 Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Tue, 15 Oct 2024 13:32:34 +1100 Subject: [PATCH 12/14] Only testing 11.5.2 --- .github/workflows/ci-mariadb-intergration-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-mariadb-intergration-tests.yml b/.github/workflows/ci-mariadb-intergration-tests.yml index be9a11bf2..56bde7659 100644 --- a/.github/workflows/ci-mariadb-intergration-tests.yml +++ b/.github/workflows/ci-mariadb-intergration-tests.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - mariadb-version: [ 10.0, 10.1, 10.2.15, 10.2, 10.3.7, 10.3, 10.5.1, 10.5, 10.6, 10.11, 11.5.2] + mariadb-version: [ 11.5.2 ] name: Integration test with MariaDB ${{ matrix.mariadb-version }} steps: - uses: actions/checkout@v3 From 1d91f3e7be2a1eef39ba868fe01816cdf2f6cd4b Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Tue, 15 Oct 2024 14:30:25 +1100 Subject: [PATCH 13/14] Changed decode41 and reset ci-mariadb-integration --- .github/workflows/ci-mariadb-intergration-tests.yml | 2 +- .../mysql/message/server/DefinitionMetadataMessage.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-mariadb-intergration-tests.yml b/.github/workflows/ci-mariadb-intergration-tests.yml index 56bde7659..44e68ab52 100644 --- a/.github/workflows/ci-mariadb-intergration-tests.yml +++ b/.github/workflows/ci-mariadb-intergration-tests.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - mariadb-version: [ 11.5.2 ] + mariadb-version: [ 10.0, 10.1, 10.2.15, 10.2, 10.3.7, 10.3, 10.5.1, 10.5, 10.6, 10.11 ] name: Integration test with MariaDB ${{ matrix.mariadb-version }} steps: - uses: actions/checkout@v3 diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index fa8c4c160..dac73898a 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -183,8 +183,13 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String extendTypeInfo = null; if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { - buf.readUnsignedByte(); - extendTypeInfo = readVarIntSizedString(buf, charset); + buf.markReaderIndex(); + short extendedTypeInfoDataType = buf.readUnsignedByte(); + if (extendedTypeInfoDataType == 0 || extendedTypeInfoDataType == 1) { + extendTypeInfo = readVarIntSizedString(buf, charset); + } else { + buf.resetReaderIndex(); + } } // Skip constant 0x0c encoded by var integer From 42da732e35e7f6d8f7187a1f25960eb11adc224b Mon Sep 17 00:00:00 2001 From: Ram Sin Date: Thu, 17 Oct 2024 12:05:57 +1100 Subject: [PATCH 14/14] Reset decode41 --- .../mysql/message/server/DefinitionMetadataMessage.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java index dac73898a..fa8c4c160 100644 --- a/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java +++ b/r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/message/server/DefinitionMetadataMessage.java @@ -183,13 +183,8 @@ private static DefinitionMetadataMessage decode41(ByteBuf buf, ConnectionContext String extendTypeInfo = null; if (context.getCapability().isMariaDb() && context.getCapability().isExtendedTypeInfo()) { - buf.markReaderIndex(); - short extendedTypeInfoDataType = buf.readUnsignedByte(); - if (extendedTypeInfoDataType == 0 || extendedTypeInfoDataType == 1) { - extendTypeInfo = readVarIntSizedString(buf, charset); - } else { - buf.resetReaderIndex(); - } + buf.readUnsignedByte(); + extendTypeInfo = readVarIntSizedString(buf, charset); } // Skip constant 0x0c encoded by var integer