Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit 2726401

Browse files
author
Chris Board
committed
Fixed couple of issues with latest version of MySQL 8
- Fixed issue that ztsd compression was not supported (the compression flag being disabled by the client was ignored due to a new server flag) - Fixed issue when sending query triggered Malformed packet response due to server flag default value being changed so client wasn't disabling.
1 parent 4967024 commit 2726401

File tree

14 files changed

+88
-50
lines changed

14 files changed

+88
-50
lines changed

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

AndroidMySQLConnector/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ else
2020
}
2121

2222
archivesBaseName="AndroidMySQLConnector"
23-
version '0.48'
23+
version '0.49'
2424
group 'com.BoardiesITSolutions'
2525

2626

@@ -30,8 +30,6 @@ android {
3030
//applicationId "com.BoardiesITSolutions.AndroidMySQLConnector"
3131
minSdkVersion 19
3232
targetSdkVersion 30
33-
versionCode 37
34-
versionName "0.48"
3533
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3634
}
3735
buildTypes {
@@ -81,6 +79,7 @@ android {
8179
url "https://maven.google.com"
8280
}
8381
}
82+
namespace 'com.BoardiesITSolutions.AndroidMySQLConnector'
8483
}
8584

8685
def getArtifactFullPath() {

AndroidMySQLConnector/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.BoardiesITSolutions.AndroidMySQLConnector">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

43
<application
54
android:allowBackup="true"

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/Connection.java

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,37 @@ public class Connection
7070
public static final int CLIENT_MULTI_SET = 0x00010000;
7171
public static final int CLIENT_SSL = 0x00000800;
7272
public static final int CLIENT_LONG_PASSWORD = 0x00000001;
73-
public static final int CLIENT_MULTI_STATEMENTS = 0x00010000;
73+
//public static final int CLIENT_MULTI_STATEMENTS = 0x00010000;
7474
public static final int CLIENT_SECURE_CONNECTION = 0x00008000;
7575
public static final int CLIENT_CONNECT_ATTRS = 0x00100000;
7676
public static final int CLIENT_CONNECT_WITH_DB = 0x00000008;
7777
public static final int CLIENT_PROTOCOL_41 = 0x00000200;
7878
public static final int CLIENT_COMPRESS = 0x00000020;
79+
80+
public static final int CLIENT_MULTI_STATEMENTS = 1 << 16;
81+
public static final int MULTI_RESULTS = 1 << 17;
82+
public static final int CLIENT_MULTI_RESULTS = 1 << 17;
7983
public static final int CLIENT_NO_SCHEMA = 0x00000010;
8084
public static final int CLIENT_IGNORE_SIGPIPE = 0x00001000;
8185
public static final int CLIENT_INTERACTIVE = 0x00000400;
8286
public static final int CLIENT_ODBC = 0x00000040;
8387
public static final int CLIENT_IGNORE_SPACE = 0x00000100;
8488
public static final int CLIENT_PS_MULTI_RESULTS = 0x00040000;
85-
public static final int CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS = 0x00400000;
86-
public static final int CLIENT_SESSION_TRACK = 0x00800000;
87-
88-
89-
public static final int MULTI_RESULTS = 1 << 17;
89+
public static final int CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS = 1 << 22;
90+
public static final int CLIENT_SESSION_TRACK = 1 << 23;
9091
public static final int DEPRECATE_EOF = 1 << 24;
9192
public static final int CLIENT_OPTIONAL_RESULTSET_METADATA = 1 << 25;
93+
public static final int CLIENT_ZSTD_COMPRESSION_ALGORITHM = 1 << 26;
94+
public static final int CLIENT_QUERY_ATTRIBUTES = 1 << 27;
95+
public static final int MULTI_FACTOR_AUTHENTICATION = 1 << 28;
96+
97+
98+
99+
100+
101+
102+
/** ADDED OPTION */
103+
92104

93105
//Character Sets
94106
private final int LATIN1_SWEDISH_CI = 0x08;
@@ -416,16 +428,66 @@ private void processWelcomePacket() throws MySQLConnException, IOException {
416428
clientCapabilities &= ~CLIENT_COMPRESS;
417429
}
418430

431+
if ((Connection.this.serverCapabilities & CLIENT_ZSTD_COMPRESSION_ALGORITHM) == CLIENT_ZSTD_COMPRESSION_ALGORITHM)
432+
{
433+
Log.d("Connection", "Disabling ztsd compression");
434+
clientCapabilities &= ~CLIENT_ZSTD_COMPRESSION_ALGORITHM;
435+
}
436+
437+
if ((Connection.this.serverCapabilities & CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS) == CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)
438+
{
439+
Log.d("Connection", "Disabling CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS");
440+
clientCapabilities &= ~CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS;
441+
}
442+
443+
if ((Connection.this.serverCapabilities & CLIENT_LONG_PASSWORD) == CLIENT_LONG_PASSWORD)
444+
{
445+
Log.d("Connection", "Disabling CLIENT_LONG_PASSWORD");
446+
clientCapabilities &= ~CLIENT_LONG_PASSWORD;
447+
}
448+
449+
if ((Connection.this.serverCapabilities & CLIENT_MULTI_STATEMENTS) == CLIENT_MULTI_STATEMENTS)
450+
{
451+
Log.d("Connection", "Disabling CLIENT_MULTI_STATEMENTS");
452+
clientCapabilities &= ~CLIENT_MULTI_STATEMENTS;
453+
}
454+
if ((Connection.this.serverCapabilities & MULTI_FACTOR_AUTHENTICATION) == MULTI_FACTOR_AUTHENTICATION)
455+
{
456+
Log.d("Connection", "Disabling MULTI_FACTOR_AUTHENTICATION");
457+
clientCapabilities &= ~MULTI_FACTOR_AUTHENTICATION;
458+
}
459+
460+
if ((Connection.this.serverCapabilities & CLIENT_MULTI_RESULTS) == CLIENT_MULTI_RESULTS)
461+
{
462+
Log.d("Connection", "Disabling CLIENT_MULTI_RESULTS");
463+
clientCapabilities &= ~CLIENT_MULTI_RESULTS;
464+
}
465+
466+
if ((Connection.this.serverCapabilities & CLIENT_SESSION_TRACK) == CLIENT_SESSION_TRACK)
467+
{
468+
Log.d("Connection", "Disabling CLIENT_SESSION_TRACK");
469+
clientCapabilities &= ~CLIENT_SESSION_TRACK;
470+
}
471+
472+
if ((Connection.this.serverCapabilities & CLIENT_QUERY_ATTRIBUTES) == CLIENT_QUERY_ATTRIBUTES)
473+
{
474+
Log.d("Connection", "Disabling CLIENT_QUERY_ATTRIBUTES");
475+
clientCapabilities &= ~CLIENT_QUERY_ATTRIBUTES;
476+
}
477+
478+
if ((Connection.this.serverCapabilities & DEPRECATE_EOF) == DEPRECATE_EOF)
479+
{
480+
Log.d("MainActivity", "Disabled DEPRECATE_EOF");
481+
clientCapabilities &= ~DEPRECATE_EOF;
482+
}
483+
419484
//If MySQL 8 turn off can accept expired password
420485
if (this.getMajorVersion() >= 8)
421486
{
422487
clientCapabilities &= ~CLIENT_OPTIONAL_RESULTSET_METADATA;
423488
clientCapabilities &= ~CLIENT_SSL;
424-
425489
}
426490

427-
clientCapabilities &= ~DEPRECATE_EOF;
428-
clientCapabilities &= ~MULTI_RESULTS;
429491

430492
//Check if the server is set to don't allow database.table, if so unset it so we can
431493
//Having this enabled means SHOW TABLES and SHOW DATABASES can't be executed as it will only

AndroidMySQLConnector/src/main/java/com/BoardiesITSolutions/AndroidMySQLConnector/PacketManager/COM_QueryResponse.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,29 @@ private void processPacketData()
4848
for (int currentColumnCount = 0; currentColumnCount < numberOfFields; currentColumnCount++)
4949
{
5050
this.mysqlConn.getMysqlIO().shiftCurrentBytePosition(4);
51-
5251
int catalogLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
5352
String catalog = this.mysqlConn.getMysqlIO().extractData(false, catalogLength);
54-
5553
int databaseLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
5654
String database = this.mysqlConn.getMysqlIO().extractData(false, databaseLength);
5755

5856
int tableLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
5957
String table = this.mysqlConn.getMysqlIO().extractData(false, tableLength);
60-
6158
int origTableLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
6259
String origTable = this.mysqlConn.getMysqlIO().extractData(false, origTableLength);
63-
6460
int columnNameLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
6561
String columnName = this.mysqlConn.getMysqlIO().extractData(false, columnNameLength);
66-
6762
int origColumnNameLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
6863
String origColumnName = this.mysqlConn.getMysqlIO().extractData(false, origColumnNameLength);
69-
7064
int nextLength = (byte)this.mysqlConn.getMysqlIO().getLenEncodedInt();
71-
7265
int characterSet = this.mysqlConn.getMysqlIO().fromByteArray((byte[])this.mysqlConn.getMysqlIO().extractData(2));
73-
7466
int columnLength = this.mysqlConn.getMysqlIO().fromByteArray((byte[])this.mysqlConn.getMysqlIO().extractData(4));
75-
7667
int columnType = (byte)this.mysqlConn.getMysqlIO().extractData(1) & 0xff;
77-
7868
int flags = this.mysqlConn.getMysqlIO().fromByteArray((byte[])this.mysqlConn.getMysqlIO().extractData(2));
79-
8069
int decimals = (byte)this.mysqlConn.getMysqlIO().extractData(1);
8170

82-
8371
//2 Byte NULL fillers so shift on another 2
8472
this.mysqlConn.getMysqlIO().shiftCurrentBytePosition(2);
8573
//break;
86-
8774
this.columnDefinitions.add(new ColumnDefinition(catalog, database, table, columnName, characterSet,
8875
columnType, flags, decimals));
8976
}
@@ -92,6 +79,7 @@ private void processPacketData()
9279
//it in case we need it - don't think we do though!
9380
if (this.mysqlConn.isConnectedVersionLessThan(5,5,60) && !this.mysqlConn.isMariaDB())
9481
{
82+
Log.d("COMQueryResponse", "Reading extra un-used data");
9583
int packetLength = this.mysqlConn.getMysqlIO().fromByteArray((byte[]) this.mysqlConn.getMysqlIO().extractData(3));
9684
int packetNumber = (byte) this.mysqlConn.getMysqlIO().extractData(1);
9785
int eofMarker = (byte) this.mysqlConn.getMysqlIO().extractData(1);

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
google()
1717
}
1818
dependencies {
19-
classpath 'com.android.tools.build:gradle:4.1.3'
19+
classpath 'com.android.tools.build:gradle:4.2.2'
2020
if (!publishToMavenLocal) {
2121
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
2222
}

0 commit comments

Comments
 (0)