File tree 2 files changed +30
-2
lines changed
wrapper/src/main/java/software/amazon/jdbc/dialect
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ public class GlobalAuroraMysqlDialect extends AuroraMysqlDialect {
32
32
"SELECT 1 AS tmp FROM information_schema.tables WHERE"
33
33
+ " upper(table_schema) = 'INFORMATION_SCHEMA' AND upper(table_name) = 'AURORA_GLOBAL_DB_STATUS'" ;
34
34
35
+ protected final String globalDbStatusQuery =
36
+ "SELECT count(1) FROM information_schema.aurora_global_db_status" ;
37
+
35
38
protected final String globalDbInstanceStatusTableExistQuery =
36
39
"SELECT 1 AS tmp FROM information_schema.tables WHERE"
37
40
+ " upper(table_schema) = 'INFORMATION_SCHEMA' AND upper(table_name) = 'AURORA_GLOBAL_DB_INSTANCE_STATUS'" ;
@@ -59,7 +62,18 @@ public boolean isDialect(final Connection connection) {
59
62
stmt = connection .createStatement ();
60
63
rs = stmt .executeQuery (this .globalDbInstanceStatusTableExistQuery );
61
64
62
- return rs .next ();
65
+ if (rs .next ()) {
66
+ rs .close ();
67
+ stmt .close ();
68
+
69
+ stmt = connection .createStatement ();
70
+ rs = stmt .executeQuery (this .globalDbStatusQuery );
71
+
72
+ if (rs .next ()) {
73
+ int awsRegionCount = rs .getInt (1 );
74
+ return awsRegionCount > 1 ;
75
+ }
76
+ }
63
77
}
64
78
return false ;
65
79
} catch (final SQLException ex ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ public class GlobalAuroraPgDialect extends AuroraPgDialect {
42
42
+ "VISIBILITY_LAG_IN_MSEC, AWS_REGION "
43
43
+ "FROM aurora_global_db_instance_status()" ;
44
44
45
+ protected final String globalDbStatusQuery =
46
+ "SELECT count(1) FROM aurora_global_db_status()" ;
47
+
45
48
protected final String regionByNodeIdQuery =
46
49
"SELECT AWS_REGION FROM aurora_global_db_instance_status() WHERE SERVER_ID = ?" ;
47
50
@@ -72,7 +75,18 @@ public boolean isDialect(final Connection connection) {
72
75
stmt = connection .createStatement ();
73
76
rs = stmt .executeQuery (this .globalDbInstanceStatusFuncExistQuery );
74
77
75
- return rs .next ();
78
+ if (rs .next ()) {
79
+ rs .close ();
80
+ stmt .close ();
81
+
82
+ stmt = connection .createStatement ();
83
+ rs = stmt .executeQuery (this .globalDbStatusQuery );
84
+
85
+ if (rs .next ()) {
86
+ int awsRegionCount = rs .getInt (1 );
87
+ return awsRegionCount > 1 ;
88
+ }
89
+ }
76
90
}
77
91
return false ;
78
92
} catch (final SQLException ex ) {
You can’t perform that action at this time.
0 commit comments