Skip to content

Commit ade4a41

Browse files
committed
Fix for Bug#23204652, Bug#71929 (18346501) and Bug#103612 (32902019).
Fix for Bug#23204652, CURSOR POSITIONING API'S DOESNOT CHECK THE VALIDITY OF RESULTSET. Fix for Bug#71929 (18346501), Prefixing query with double comments cancels query DML validation. Fix for Bug#103612 (32902019), Incorrectly identified WITH...SELECT as unsafe for read-only connections.
1 parent 509f184 commit ade4a41

19 files changed

+2007
-998
lines changed

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
Version 8.0.27
55

6+
- Fix for Bug#103612 (32902019), Incorrectly identified WITH...SELECT as unsafe for read-only connections.
7+
8+
- Fix for Bug#71929 (18346501), Prefixing query with double comments cancels query DML validation.
9+
10+
- Fix for Bug#23204652, CURSOR POSITIONING API'S DOESNOT CHECK THE VALIDITY OF RESULTSET.
11+
612
- Fix for Bug#28725534, MULTI HOST CONNECTION WOULD BLOCK IN CONNECTION POOLING.
713

814
- Fix for Bug#95139 (29807572), CACHESERVERCONFIGURATION APPEARS TO THWART CHARSET DETECTION.

src/build/java/instrumentation/TranslateExceptions.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -292,7 +292,7 @@ public static void main(String[] args) throws Exception {
292292
/*
293293
* java.sql.PreparedStatement extends java.sql.Statement (java.sql.Statement extends java.sql.Wrapper)
294294
*/
295-
// com.mysql.cj.jdbc.PreparedStatement extends com.mysql.cj.jdbc.StatementImpl implements java.sql.PreparedStatement
295+
// com.mysql.cj.jdbc.ClientPreparedStatement extends com.mysql.cj.jdbc.StatementImpl implements java.sql.PreparedStatement
296296
clazz = pool.get(ClientPreparedStatement.class.getName());
297297
instrumentJdbcMethods(clazz, java.sql.PreparedStatement.class, false, EXCEPTION_INTERCEPTOR_GETTER);
298298
instrumentJdbcMethods(clazz, JdbcStatement.class, true, EXCEPTION_INTERCEPTOR_GETTER);
@@ -318,7 +318,6 @@ public static void main(String[] args) throws Exception {
318318
catchRuntimeException(clazz, clazz.getDeclaredMethod("getParameterBindings", new CtClass[] {}), EXCEPTION_INTERCEPTOR_GETTER);
319319
catchRuntimeException(clazz, clazz.getDeclaredMethod("initializeFromParseInfo", new CtClass[] {}), EXCEPTION_INTERCEPTOR_GETTER);
320320
catchRuntimeException(clazz, clazz.getDeclaredMethod("isNull", new CtClass[] { CtClass.intType }), EXCEPTION_INTERCEPTOR_GETTER);
321-
catchRuntimeException(clazz, clazz.getDeclaredMethod("isSelectQuery", new CtClass[] {}), EXCEPTION_INTERCEPTOR_GETTER);
322321
catchRuntimeException(clazz, clazz.getDeclaredMethod("prepareBatchedInsertSQL", new CtClass[] { ctJdbcConnection, CtClass.intType }),
323322
EXCEPTION_INTERCEPTOR_GETTER);
324323
catchRuntimeException(clazz,
@@ -328,7 +327,7 @@ public static void main(String[] args) throws Exception {
328327
clazz.writeFile(args[0]);
329328

330329
/*
331-
* com.mysql.cj.jdbc.ServerPreparedStatement extends PreparedStatement
330+
* com.mysql.cj.jdbc.ServerPreparedStatement extends ClientPreparedStatement
332331
*/
333332
clazz = pool.get(ServerPreparedStatement.class.getName());
334333
instrumentJdbcMethods(clazz, java.sql.PreparedStatement.class, false, EXCEPTION_INTERCEPTOR_GETTER);

src/main/core-api/java/com/mysql/cj/ParseInfo.java

Lines changed: 285 additions & 212 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License, version 2.0, as published by the
6+
* Free Software Foundation.
7+
*
8+
* This program is also distributed with certain software (including but not
9+
* limited to OpenSSL) that is licensed under separate terms, as designated in a
10+
* particular file or component or in included license documentation. The
11+
* authors of MySQL hereby grant you an additional permission to link the
12+
* program and your derivative works with the separately licensed software that
13+
* they have included with MySQL.
14+
*
15+
* Without limiting anything contained in the foregoing, this file, which is
16+
* part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
17+
* version 1.0, a copy of which can be found at
18+
* http://oss.oracle.com/licenses/universal-foss-exception.
19+
*
20+
* This program is distributed in the hope that it will be useful, but WITHOUT
21+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
23+
* for more details.
24+
*
25+
* You should have received a copy of the GNU General Public License along with
26+
* this program; if not, write to the Free Software Foundation, Inc.,
27+
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
*/
29+
30+
package com.mysql.cj;
31+
32+
/**
33+
* The possible return types from executing queries.
34+
*/
35+
public enum QueryReturnType {
36+
PRODUCES_RESULT_SET, MAY_PRODUCE_RESULT_SET, DOES_NOT_PRODUCE_RESULT_SET, NONE;
37+
}

src/main/core-api/java/com/mysql/cj/conf/ConnectionUrlParser.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -49,6 +49,7 @@
4949
import com.mysql.cj.exceptions.ExceptionFactory;
5050
import com.mysql.cj.exceptions.UnsupportedConnectionStringException;
5151
import com.mysql.cj.exceptions.WrongArgumentException;
52+
import com.mysql.cj.util.SearchMode;
5253
import com.mysql.cj.util.StringUtils;
5354

5455
/**
@@ -178,7 +179,7 @@ private void parseAuthoritySection() {
178179
}
179180

180181
List<String> authoritySegments = StringUtils.split(this.authority, HOSTS_SEPARATOR, HOSTS_LIST_OPENING_MARKERS, HOSTS_LIST_CLOSING_MARKERS, true,
181-
StringUtils.SEARCH_MODE__MRK_WS);
182+
SearchMode.__MRK_WS);
182183
for (String hi : authoritySegments) {
183184
parseAuthoritySegment(hi);
184185
}
@@ -354,7 +355,7 @@ private List<HostInfo> buildHostInfoResortingToSubHostsListParser(String user, S
354355
if (matcher.matches()) {
355356
String hosts = matcher.group("hosts");
356357
List<String> hostsList = StringUtils.split(hosts, HOSTS_SEPARATOR, HOSTS_LIST_OPENING_MARKERS, HOSTS_LIST_CLOSING_MARKERS, true,
357-
StringUtils.SEARCH_MODE__MRK_WS);
358+
SearchMode.__MRK_WS);
358359
// One single element could, in fact, be an IPv6 stripped from its delimiters.
359360
boolean maybeIPv6 = hostsList.size() == 1 && hostsList.get(0).matches("(?i)^[\\dabcdef:]+$");
360361
List<HostInfo> hostInfoList = new ArrayList<>();
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
*
4+
* This program is free software; you can redistribute it and/or modify it under
5+
* the terms of the GNU General Public License, version 2.0, as published by the
6+
* Free Software Foundation.
7+
*
8+
* This program is also distributed with certain software (including but not
9+
* limited to OpenSSL) that is licensed under separate terms, as designated in a
10+
* particular file or component or in included license documentation. The
11+
* authors of MySQL hereby grant you an additional permission to link the
12+
* program and your derivative works with the separately licensed software that
13+
* they have included with MySQL.
14+
*
15+
* Without limiting anything contained in the foregoing, this file, which is
16+
* part of MySQL Connector/J, is also subject to the Universal FOSS Exception,
17+
* version 1.0, a copy of which can be found at
18+
* http://oss.oracle.com/licenses/universal-foss-exception.
19+
*
20+
* This program is distributed in the hope that it will be useful, but WITHOUT
21+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
23+
* for more details.
24+
*
25+
* You should have received a copy of the GNU General Public License along with
26+
* this program; if not, write to the Free Software Foundation, Inc.,
27+
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
*/
29+
30+
package com.mysql.cj.util;
31+
32+
import java.util.Collections;
33+
import java.util.EnumSet;
34+
import java.util.Set;
35+
36+
/**
37+
* Search mode flags enumeration. Primarily used by {@link StringInspector}.
38+
*/
39+
public enum SearchMode {
40+
/**
41+
* Allow backslash escapes.
42+
*/
43+
ALLOW_BACKSLASH_ESCAPE,
44+
/**
45+
* Skip between markers (quoted text, quoted identifiers, text between parentheses).
46+
*/
47+
SKIP_BETWEEN_MARKERS,
48+
/**
49+
* Skip between block comments ("/* text... *\/") but not between hint blocks.
50+
*/
51+
SKIP_BLOCK_COMMENTS,
52+
/**
53+
* Skip line comments ("-- text...", "# text...").
54+
*/
55+
SKIP_LINE_COMMENTS,
56+
/**
57+
* Skip MySQL specific markers ("/*![12345]" and "*\/") but not their contents.
58+
*/
59+
SKIP_MYSQL_MARKERS,
60+
/**
61+
* Skip hint blocks ("/*+ text... *\/").
62+
*/
63+
SKIP_HINT_BLOCKS,
64+
/**
65+
* Skip white space.
66+
*/
67+
SKIP_WHITE_SPACE,
68+
/**
69+
* Dummy search mode. Does nothing.
70+
*/
71+
VOID;
72+
73+
/*
74+
* Convenience EnumSets for several SearchMode combinations
75+
*/
76+
77+
/**
78+
* Full search mode: allow backslash escape, skip between markers, skip block comments, skip line comments, skip MySQL markers, skip hint blocks and skip
79+
* white space.
80+
* This is technically equivalent to __BSE_MRK_COM_MYM_HNT_WS.
81+
*/
82+
public static final Set<SearchMode> __FULL = Collections.unmodifiableSet(EnumSet.allOf(SearchMode.class));
83+
84+
/**
85+
* Search mode: allow backslash escape, skip between markers, skip block comments, skip line comments, skip MySQL markers, skip hint blocks and skip
86+
* white space.
87+
*/
88+
public static final Set<SearchMode> __BSE_MRK_COM_MYM_HNT_WS = Collections.unmodifiableSet(EnumSet.of(ALLOW_BACKSLASH_ESCAPE, SKIP_BETWEEN_MARKERS,
89+
SKIP_BLOCK_COMMENTS, SKIP_LINE_COMMENTS, SKIP_MYSQL_MARKERS, SKIP_HINT_BLOCKS, SKIP_WHITE_SPACE));
90+
91+
/**
92+
* Search mode: skip between markers, skip block comments, skip line comments, skip MySQL markers, skip hint blocks and skip white space.
93+
*/
94+
public static final Set<SearchMode> __MRK_COM_MYM_HNT_WS = Collections
95+
.unmodifiableSet(EnumSet.of(SKIP_BETWEEN_MARKERS, SKIP_BLOCK_COMMENTS, SKIP_LINE_COMMENTS, SKIP_MYSQL_MARKERS, SKIP_HINT_BLOCKS, SKIP_WHITE_SPACE));
96+
97+
/**
98+
* Search mode: allow backslash escape, skip block comments, skip line comments, skip MySQL markers, skip hint blocks and skip white space.
99+
*/
100+
public static final Set<SearchMode> __BSE_COM_MYM_HNT_WS = Collections.unmodifiableSet(
101+
EnumSet.of(ALLOW_BACKSLASH_ESCAPE, SKIP_BLOCK_COMMENTS, SKIP_LINE_COMMENTS, SKIP_MYSQL_MARKERS, SKIP_HINT_BLOCKS, SKIP_WHITE_SPACE));
102+
103+
/**
104+
* Search mode: skip block comments, skip line comments, skip MySQL markers, skip hint blocks and skip white space.
105+
*/
106+
public static final Set<SearchMode> __COM_MYM_HNT_WS = Collections
107+
.unmodifiableSet(EnumSet.of(SKIP_BLOCK_COMMENTS, SKIP_LINE_COMMENTS, SKIP_MYSQL_MARKERS, SKIP_HINT_BLOCKS, SKIP_WHITE_SPACE));
108+
109+
/**
110+
* Search mode: allow backslash escape, skip between markers and skip white space.
111+
*/
112+
public static final Set<SearchMode> __BSE_MRK_WS = Collections.unmodifiableSet(EnumSet.of(ALLOW_BACKSLASH_ESCAPE, SKIP_BETWEEN_MARKERS, SKIP_WHITE_SPACE));
113+
114+
/**
115+
* Search mode: skip between markers and skip white space.
116+
*/
117+
public static final Set<SearchMode> __MRK_WS = Collections.unmodifiableSet(EnumSet.of(SKIP_BETWEEN_MARKERS, SKIP_WHITE_SPACE));
118+
119+
/**
120+
* Empty search mode.
121+
* There must be at least one element so that the Set may be later duplicated if needed.
122+
*/
123+
public static final Set<SearchMode> __NONE = Collections.unmodifiableSet(EnumSet.of(VOID));
124+
}

0 commit comments

Comments
 (0)