Skip to content

Commit e9bf748

Browse files
author
Jonas Oreland
committed
ndb - merge 71 to 72
2 parents 2f8d34c + e87de9c commit e9bf748

36 files changed

+1692
-297
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--ndb-log-transaction-id
1+
--ndb-log-transaction-id --log-bin-use-v1-row-events=false

mysql-test/suite/ndb_rpl/t/ndb_rpl_conflict_epoch_trans.cnf

+4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
# Potential infinite loops are broken by both servers
1212
# on each cluster having the same server-id
1313

14+
[cluster_config.slave]
15+
mysqld=,
16+
1417
[mysqld]
1518
log-slave-updates
1619
ndb-log-apply-status
1720
ndb-log-transaction-id
21+
log-bin-use-v1-row-events=false
1822

1923
[mysqld.1.1]
2024
server-id= 1

storage/ndb/clusterj/clusterj-api/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<parent>
2121
<groupId>com.mysql.clusterj</groupId>
2222
<artifactId>clusterj-aggregate</artifactId>
23-
<version>7.1.16-SNAPSHOT</version>
23+
<version>7.1.17-SNAPSHOT</version>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>
2626
<groupId>com.mysql.clusterj</groupId>
2727
<artifactId>clusterj-api</artifactId>
2828
<packaging>bundle</packaging>
29-
<version>7.1.16-SNAPSHOT</version>
29+
<version>7.1.17-SNAPSHOT</version>
3030
<name>ClusterJ API</name>
3131
<description>The API for ClusterJ</description>
3232
<build>

storage/ndb/clusterj/clusterj-bindings/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<parent>
2121
<groupId>com.mysql.clusterj</groupId>
2222
<artifactId>clusterj-aggregate</artifactId>
23-
<version>7.1.16-SNAPSHOT</version>
23+
<version>7.1.17-SNAPSHOT</version>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>
2626
<groupId>com.mysql.clusterj</groupId>
2727
<artifactId>clusterj-bindings</artifactId>
2828
<packaging>bundle</packaging>
29-
<version>7.1.16-SNAPSHOT</version>
29+
<version>7.1.17-SNAPSHOT</version>
3030
<name>ClusterJ Bindings</name>
3131
<description>The ndb-bindings implementation of ClusterJ storage spi</description>
3232
<build>

storage/ndb/clusterj/clusterj-core/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<parent>
2121
<groupId>com.mysql.clusterj</groupId>
2222
<artifactId>clusterj-aggregate</artifactId>
23-
<version>7.1.16-SNAPSHOT</version>
23+
<version>7.1.17-SNAPSHOT</version>
2424
</parent>
2525
<modelVersion>4.0.0</modelVersion>
2626
<groupId>com.mysql.clusterj</groupId>
2727
<artifactId>clusterj-core</artifactId>
2828
<packaging>bundle</packaging>
29-
<version>7.1.16-SNAPSHOT</version>
29+
<version>7.1.17-SNAPSHOT</version>
3030
<name>ClusterJ Core</name>
3131
<description>The core implementation of ClusterJ</description>
3232
<build>

storage/ndb/clusterj/clusterj-jdbc/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
<parent>
2020
<groupId>com.mysql.clusterj</groupId>
2121
<artifactId>clusterj-aggregate</artifactId>
22-
<version>7.1.16-SNAPSHOT</version>
22+
<version>7.1.17-SNAPSHOT</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525
<groupId>clusterj</groupId>
2626
<artifactId>clusterj-jdbc</artifactId>
2727
<name>ClusterJ JDBC Plugin</name>
28-
<version>7.1.16-SNAPSHOT</version>
28+
<version>7.1.17-SNAPSHOT</version>
2929
<dependencies>
3030
<dependency>
3131
<groupId>junit</groupId>

storage/ndb/clusterj/clusterj-jdbc/src/main/java/com/mysql/clusterj/jdbc/InterceptorImpl.java

+41-9
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
package com.mysql.clusterj.jdbc;
1919

20+
import com.mysql.clusterj.ClusterJFatalInternalException;
2021
import com.mysql.clusterj.ClusterJHelper;
2122
import com.mysql.clusterj.ClusterJUserException;
23+
import com.mysql.clusterj.LockMode;
2224
import com.mysql.clusterj.SessionFactory;
2325
import com.mysql.clusterj.core.query.QueryDomainTypeImpl;
2426
import com.mysql.clusterj.core.spi.SessionSPI;
@@ -28,7 +30,10 @@
2830
import com.mysql.clusterj.core.util.LoggerFactoryService;
2931
import com.mysql.jdbc.Connection;
3032
import com.mysql.jdbc.ResultSetInternalMethods;
33+
import com.mysql.jdbc.ServerPreparedStatement;
3134
import com.mysql.jdbc.Statement;
35+
import com.mysql.jdbc.ServerPreparedStatement.BatchedBindValues;
36+
import com.mysql.jdbc.ServerPreparedStatement.BindValue;
3237
import com.mysql.clusterj.jdbc.antlr.ANTLRNoCaseStringStream;
3338
import com.mysql.clusterj.jdbc.antlr.MySQL51Parser;
3439
import com.mysql.clusterj.jdbc.antlr.MySQL51Lexer;
@@ -40,6 +45,8 @@
4045
import com.mysql.clusterj.query.Predicate;
4146

4247
import com.mysql.clusterj.jdbc.SQLExecutor.Executor;
48+
49+
import java.io.InputStream;
4350
import java.sql.SQLException;
4451
import java.sql.Savepoint;
4552
import java.util.ArrayList;
@@ -244,29 +251,45 @@ public ResultSetInternalMethods postProcess(String sql, Statement statement,
244251
public ResultSetInternalMethods preProcess(String sql, Statement statement,
245252
Connection connection) throws SQLException {
246253
assertReady();
254+
if (logger.isDebugEnabled() && statement != null)
255+
logger.debug(statement.getClass().getName() + ": " + sql);
247256
if (statement instanceof com.mysql.jdbc.PreparedStatement) {
248257
com.mysql.jdbc.PreparedStatement preparedStatement =
249258
(com.mysql.jdbc.PreparedStatement)statement;
250259
// key must be interned because we are using IdentityHashMap
251-
String preparedSql = preparedStatement.getPreparedSql().intern();
260+
// TODO: in case of DELETE, the SQL has already been rewritten at this point,
261+
// and the original SQL is gone
262+
// so the key in the table is the rewritten DELETE SQL -- not what we want at all
263+
String nonRewrittenSql = preparedStatement.getNonRewrittenSql();
264+
String internedSql = nonRewrittenSql.intern();
265+
252266
// see if we have a parsed version of this query
253267
Executor sQLExecutor = null;
254268
synchronized(parsedSqlMap) {
255-
sQLExecutor = parsedSqlMap.get(preparedSql);
269+
sQLExecutor = parsedSqlMap.get(internedSql);
256270
}
257271
// if no cached SQLExecutor, create it, which might take some time
258272
if (sQLExecutor == null) {
259-
sQLExecutor = createSQLExecutor(preparedSql);
273+
sQLExecutor = createSQLExecutor(internedSql);
260274
if (sQLExecutor != null) {
261275
// multiple thread might have created a SQLExecutor but it's ok
262276
synchronized(parsedSqlMap) {
263-
parsedSqlMap.put(preparedSql, sQLExecutor);
277+
parsedSqlMap.put(internedSql, sQLExecutor);
264278
}
265279
}
266280
}
267-
return sQLExecutor.execute(this, preparedStatement.getParameterBindings());
281+
try {
282+
return sQLExecutor.execute(this, preparedStatement);
283+
} catch (Throwable t) {
284+
t.printStackTrace();
285+
return null;
286+
}
287+
} else {
288+
if (logger.isDebugEnabled() && statement != null)
289+
logger.debug(statement.getClass().getName() + " is not instanceof com.mysql.jdbc.PreparedStatement");
290+
// not a prepared statement; won't execute this
291+
return null;
268292
}
269-
return null;
270293
}
271294

272295
/**
@@ -323,6 +346,14 @@ private Executor createSQLExecutor(String preparedSql) {
323346
result = new SQLExecutor.Noop();
324347
break;
325348
}
349+
boolean forUpdate = null != (CommonTree)root.getFirstChildWithType(MySQL51Parser.FOR);
350+
boolean lockShared = null != (CommonTree)root.getFirstChildWithType(MySQL51Parser.LOCK);
351+
LockMode lockMode = LockMode.READ_COMMITTED;
352+
if (forUpdate) {
353+
lockMode = LockMode.EXCLUSIVE;
354+
} else if (lockShared) {
355+
lockMode = LockMode.SHARED;
356+
}
326357
getSession();
327358
dictionary = session.getDictionary();
328359
domainTypeHandler = getDomainTypeHandler(tableName, dictionary);
@@ -343,14 +374,15 @@ private Executor createSQLExecutor(String preparedSql) {
343374
queryDomainType = (QueryDomainTypeImpl<?>) session.createQueryDomainType(domainTypeHandler);
344375
if (whereNode == null) {
345376
// no where clause (select all rows)
346-
result = new SQLExecutor.Select(domainTypeHandler, columnNames, queryDomainType);
377+
result = new SQLExecutor.Select(domainTypeHandler, columnNames, queryDomainType, lockMode);
347378
} else {
348379
// create a predicate from the tree
349380
Predicate predicate = whereNode.getPredicate(queryDomainType);
350381
if (predicate != null) {
351382
// where clause that can be executed by clusterj
352383
queryDomainType.where(predicate);
353-
result = new SQLExecutor.Select(domainTypeHandler, columnNames, queryDomainType);
384+
int numberOfParameters = whereNode.getNumberOfParameters();
385+
result = new SQLExecutor.Select(domainTypeHandler, columnNames, queryDomainType, lockMode, numberOfParameters);
354386
whereType = "clusterj";
355387
} else {
356388
// where clause that cannot be executed by clusterj
@@ -461,7 +493,7 @@ private CommonTree parse(String preparedSql) {
461493
lexer.setErrorListener(new QueuingErrorListener(lexer));
462494
tokens.getTokens();
463495
if (lexer.getErrorListener().hasErrors()) {
464-
logger.warn(local.message("ERR_Lexing_SQ",preparedSql));
496+
logger.warn(local.message("ERR_Lexing_SQL",preparedSql));
465497
return result;
466498
}
467499
PlaceholderNode.resetId();

0 commit comments

Comments
 (0)