Skip to content

Commit

Permalink
[CONJ-834] use of BULK is conditionned to server 10.2.7+ version, not…
Browse files Browse the repository at this point in the history
… capability

use of BULK is conditionned to server 10.2.7+ version, not MARIADB_CLIENT_STMT_BULK_OPERATIONS capability.
This can cause issues when using with proxy like maxscale.
  • Loading branch information
rusher committed Oct 18, 2020
1 parent 1646a5f commit 5c9d7fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Expand Up @@ -89,4 +89,10 @@ public class MariaDbServerCapabilities {
1L << 32; /* Client support progress indicator (since 10.2) */
public static final long MARIADB_CLIENT_COM_MULTI =
1L << 33; /* bundle command during connection */

/* support of array binding */
public static final long MARIADB_CLIENT_STMT_BULK_OPERATIONS = 1L << 34;

/* support of extended metadata (e.g. type/format information) */
public static final long MARIADB_CLIENT_EXTENDED_METADATA = 1L << 35;
}
Expand Up @@ -293,6 +293,13 @@ private static long initializeClientCapabilities(
capabilities |= MariaDbServerCapabilities.CLIENT_DEPRECATE_EOF;
}

if (options.useBulkStmts) {
if ((serverCapabilities & MariaDbServerCapabilities.MARIADB_CLIENT_STMT_BULK_OPERATIONS)
!= 0) {
capabilities |= MariaDbServerCapabilities.MARIADB_CLIENT_STMT_BULK_OPERATIONS;
}
}

if (options.useCompression) {
if ((serverCapabilities & MariaDbServerCapabilities.COMPRESS) == 0) {
// ensure that server has compress capacity - MaxScale doesn't
Expand Down
Expand Up @@ -407,7 +407,6 @@ public boolean executeBatchClient(
&& !hasLongData
&& prepareResult.isQueryMultipleRewritable() // INSERT FROM SELECT not allowed
&& results.getAutoGeneratedKeys() == Statement.NO_GENERATED_KEYS
&& versionGreaterOrEqual(10, 2, 7)
&& executeBulkBatch(results, prepareResult.getSql(), null, parametersList)) {
return true;
}
Expand All @@ -422,7 +421,6 @@ && executeBulkBatch(results, prepareResult.getSql(), null, parametersList)) {
if (options.useBulkStmts
&& !hasLongData
&& results.getAutoGeneratedKeys() == Statement.NO_GENERATED_KEYS
&& versionGreaterOrEqual(10, 2, 7)
&& executeBulkBatch(results, prepareResult.getSql(), null, parametersList)) {
return true;
}
Expand Down Expand Up @@ -455,11 +453,13 @@ private boolean executeBulkBatch(

// **************************************************************************************
// Ensure BULK can be use :
// - server version >= 10.2.7
// - server support bulk
// - no stream
// - parameter type doesn't change
// - avoid INSERT FROM SELECT
// **************************************************************************************
if ((serverCapabilities & MariaDbServerCapabilities.MARIADB_CLIENT_STMT_BULK_OPERATIONS) == 0)
return false;

// ensure that there is no long data and type doesn't change
ParameterHolder[] initParameters = parametersList.get(0);
Expand Down Expand Up @@ -1009,7 +1009,6 @@ public boolean executeBatchServer(
if (options.useBulkStmts
&& !hasLongData
&& results.getAutoGeneratedKeys() == Statement.NO_GENERATED_KEYS
&& versionGreaterOrEqual(10, 2, 7)
&& executeBulkBatch(results, sql, serverPrepareResult, parametersList)) {
return true;
}
Expand Down

0 comments on commit 5c9d7fe

Please sign in to comment.